pimappservices/calendar/tsrc/tcal_entryattributes.cpp
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "caltestlib.h"
       
    17 #include <calentry.h>
       
    18 #include <calentryview.h>
       
    19 #include <calalarm.h>
       
    20 #include <calcategory.h>
       
    21 #include <calinstance.h>
       
    22 #include <calinstanceview.h>
       
    23 #include <calrrule.h>
       
    24 #include <caliterator.h>
       
    25 #include <tz.h>
       
    26 #include <vtzrules.h>
       
    27 #include <e32test.h>
       
    28 #include <s32file.h>
       
    29 
       
    30 static RTest test(_L("tcal_entryattributes"));
       
    31 
       
    32 _LIT8(KGUID1, "A_Global_UID1");
       
    33 _LIT8(KGUID2, "A_Global_UID2");
       
    34 _LIT8(KGUID3, "A_Global_UID3");
       
    35 _LIT8(KGUID4, "A_Global_UID4");
       
    36 _LIT8(KGUID5, "A_Global_UID5");
       
    37 _LIT(KCalName, "TestCalendar");
       
    38 
       
    39 _LIT(KSummary1, "dummy summary text");
       
    40 _LIT(KDescription1, "dummy description text");
       
    41 
       
    42 class CEntryAttributesTestManager : public CBase
       
    43 	{
       
    44 public:
       
    45 	static CEntryAttributesTestManager* NewLC();
       
    46 	~CEntryAttributesTestManager();
       
    47 
       
    48 	void CreateEntriesL(TBool aFloating = EFalse);
       
    49 	void TestFetchAndDeleteNonExistentEntryL();
       
    50 	void TestLiteEntriesL();
       
    51 	void TestLastChangedDateL();
       
    52 	void TestLastChangedDateWithStoreL();
       
    53 	void StoreLastChangedDatesL();
       
    54 	void CheckForValuesL(TBool aFlip);
       
    55 	void UpdateEntriesL();
       
    56 	void TestCopySummaryAndDescriptionL();
       
    57 	void TestAlarmedCompletedTodoL();
       
    58 	void FindSummaryL();
       
    59 	void TestEndTimeBeforeStartTimeL();
       
    60 	void TestEndTimeNullL();
       
    61 	void TestEndTimeForeverL();
       
    62 	void TestAlarmedTodoWithoutDueDateL();
       
    63 	void TestGEOAttributesL();
       
    64 	void TestGEOValueSetAndGetL();
       
    65 	void TestGEOEntrySetAndGetL();
       
    66 	void TestGEOVerifySetAndGetL(const TReal& aSetLat, const TReal& aSetLong, const TReal& aExpLat, const TReal& aExpLong, CCalGeoValue& aCalGeoValue) const;
       
    67 	void TestGEOInternalizeAndExternalizeL();
       
    68 	void TestGEOCompareAndCopyFromL();
       
    69 	void UpdateEntryHaveRdateOnlyL();
       
    70 	void TestStartDateTestL();
       
    71 	void TestStoreEntryWithTzL();
       
    72 	void TestRdateL();
       
    73 	void TestDeleteInstancesL(TInt aLoop=0);
       
    74 	void GetInstanceCrossDstL();
       
    75 	void FindInstancesL(TInt aExpectedNumInstances);
       
    76 	// from former tcal_CopyEntryImpl
       
    77 	
       
    78 	void CreateEntriesForCopyL();
       
    79 	void CreateEventForCopyPasteL();
       
    80 	
       
    81 	// for DEF080249: Addition of additional child entry with repeat rule should fail
       
    82 	void AddTwoRepeatingChildL();
       
    83 	
       
    84 	void StoreAndExportL();
       
    85 
       
    86 private:
       
    87 
       
    88 	CEntryAttributesTestManager();
       
    89 	void TestEndTimeNullL(CCalEntry::TType aType);
       
    90 
       
    91 	// no copy constructor and assignment operator
       
    92 	CEntryAttributesTestManager(CEntryAttributesTestManager& );
       
    93 	CEntryAttributesTestManager& operator = (const CEntryAttributesTestManager& );
       
    94 
       
    95 	void ConstructL();
       
    96 	void TestCalEntryL(CCalEntry* aEntry, TBool aFloating = EFalse);
       
    97 	void TestThisLiteEntryL(CCalEntry* aEntry);
       
    98 	
       
    99 	// from former tcal_CopyEntryImpl
       
   100 	
       
   101 	void CopyEventForCopyPasteL(const CCalEntry& aEntry);
       
   102 	void CopyEntryL(const CCalEntry& aEntry);
       
   103 
       
   104 
       
   105 private:
       
   106 	CCalTestLibrary* iTestLib;
       
   107 	CArrayFix<TTime>* iDateArray;
       
   108 	};
       
   109 
       
   110 
       
   111 // Constructor/Destructor
       
   112 
       
   113 CEntryAttributesTestManager* CEntryAttributesTestManager::NewLC()
       
   114 	{
       
   115 	CEntryAttributesTestManager* self = new (ELeave) CEntryAttributesTestManager();
       
   116 	
       
   117 	CleanupStack::PushL(self);
       
   118 	self->ConstructL();
       
   119 	
       
   120 	return (self);
       
   121 	}
       
   122 
       
   123 CEntryAttributesTestManager::CEntryAttributesTestManager()
       
   124 	{
       
   125 	}
       
   126 
       
   127 void CEntryAttributesTestManager::ConstructL()
       
   128 	{
       
   129 	iDateArray = new(ELeave) CArrayFixFlat<TTime>(5);
       
   130 	
       
   131 	iTestLib = CCalTestLibrary::NewL(EFalse);
       
   132 	
       
   133 	iTestLib->ReplaceFileL(KCalName());
       
   134 	iTestLib->OpenFileL(KCalName());
       
   135 	}
       
   136 
       
   137 	
       
   138 CEntryAttributesTestManager::~CEntryAttributesTestManager()
       
   139 	{
       
   140 	TRAP_IGNORE(iTestLib->DeleteFileL(KCalName));
       
   141 	delete iDateArray;
       
   142 	delete iTestLib;
       
   143 	}
       
   144 
       
   145 
       
   146 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
       
   147  * Test cases forming the Entry Attributes test suite
       
   148  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
       
   149 void CEntryAttributesTestManager::TestDeleteInstancesL(TInt aLoop)
       
   150 	{
       
   151 	test.Printf(_L("Test TestDeleteInstancesL started\n"));
       
   152 
       
   153 	
       
   154 	_LIT8(KRnzLine1, "BEGIN:VCALENDAR\r\n"
       
   155 					 "VERSION:1.0\r\n"
       
   156 					 "TZ:+00\r\n"
       
   157 					 "DAYLIGHT:TRUE;+01;20010325T010000Z;20011028T010000Z;;\r\n"
       
   158 					 "DAYLIGHT:TRUE;+01;20070325T010000Z;20071028T010000Z;;\r\n"
       
   159 					 "DAYLIGHT:TRUE;+01;20080330T010000Z;20081026T010000Z;;\r\n"
       
   160 					 "DAYLIGHT:TRUE;+01;20090329T010000Z;20091025T010000Z;;\r\n"
       
   161 					 "DAYLIGHT:TRUE;+01;20100328T010000Z;20101031T010000Z;;\r\n"
       
   162 					 "DAYLIGHT:TRUE;+01;20110327T010000Z;20111030T010000Z;;\r\n"
       
   163 					 "BEGIN:VEVENT\r\n"
       
   164 					 "UID:5\r\n"
       
   165 					 "DUE:19990416T230000Z\r\n"
       
   166 					 "DTSTART:20010925T170000Z\r\n"
       
   167 					 "DTEND:20010925T170000Z\r\n"
       
   168 					 "X-EPOCAGENDAENTRYTYPE:ANNIVERSARY\r\n"
       
   169 					 "CLASS:PUBLIC\r\n"
       
   170 					 "SEQUENCE:0\r\n"
       
   171 					 "X-METHOD:ADD\r\n"
       
   172 					 "RRULE:YM1 9 #2\r\n"
       
   173 					 "END:VEVENT\r\n"
       
   174 					 "END:VCALENDAR\r\n");	
       
   175 	
       
   176 	RPointerArray<CCalEntry> importedEntryArr;
       
   177 	CleanupResetAndDestroyPushL(importedEntryArr);
       
   178 
       
   179 	iTestLib->ImportL(KRnzLine1, importedEntryArr);
       
   180 	test.Printf(_L("File imported\n"));
       
   181 	
       
   182 	// store in the cal file
       
   183 	TInt success = 0;
       
   184 	iTestLib->SynCGetEntryViewL().StoreL(importedEntryArr, success);
       
   185 	test(success == 1);
       
   186 	
       
   187 	CleanupStack::PopAndDestroy(&importedEntryArr);
       
   188 	
       
   189 	
       
   190 	// fetch instances
       
   191 	TTime		startDate(TDateTime(2000, EJanuary, 0, 12, 0, 0, 0));
       
   192 	TCalTime	start;
       
   193 	start.SetTimeUtcL(startDate);
       
   194 		
       
   195 	TTime		endDate(TDateTime(2098, EJanuary, 0, 12, 0, 0, 0));
       
   196 	TCalTime	end;
       
   197 	end.SetTimeUtcL(endDate);
       
   198 
       
   199 	CalCommon::TCalTimeRange	timeRange(start, end);
       
   200 	CalCommon::TCalViewFilter	filter=CalCommon::EIncludeAll;
       
   201 	RPointerArray<CCalInstance> fetchedInstanceArr;
       
   202 	CleanupClosePushL(fetchedInstanceArr);	
       
   203 	iTestLib->SynCGetInstanceViewL().FindInstanceL(fetchedInstanceArr, filter, timeRange);
       
   204 	TInt countInstances=fetchedInstanceArr.Count();
       
   205 	
       
   206 	// try to delete one-by-one
       
   207 
       
   208 	if( aLoop==0 )
       
   209 		{
       
   210 		// one way to do it
       
   211 		for(TInt i=countInstances-1;i>=0;i--)
       
   212 			{
       
   213 			iTestLib->SynCGetInstanceViewL().DeleteL(fetchedInstanceArr[i], CalCommon::EThisAndFuture); 
       
   214 			}
       
   215 		test.Printf(_L("TestDeleteInstances1 Finished\n"));
       
   216 		}
       
   217 	else
       
   218 		{
       
   219 		// another way to delete instaces
       
   220 		for(TInt i=0;i<countInstances; i++)
       
   221 			{
       
   222 			iTestLib->SynCGetInstanceViewL().DeleteL(fetchedInstanceArr[i], CalCommon::EThisAndPrior); 
       
   223 			}
       
   224 		// cleanup
       
   225 		test.Printf(_L("TestDeleteInstances2 Finished\n"));
       
   226 		}
       
   227 	CleanupStack::PopAndDestroy(&fetchedInstanceArr);
       
   228 }
       
   229 	
       
   230 /* Set and get each property on a CCalEntry and check the two match. */ 	
       
   231 
       
   232 
       
   233 void CEntryAttributesTestManager::TestCalEntryL(CCalEntry* aEntry, TBool aFloating)
       
   234 	{
       
   235 	TTime time1;
       
   236 	time1.HomeTime();
       
   237 	TTime time2(time1);
       
   238 	time2 += TTimeIntervalHours(2);
       
   239 	time2 += TTimeIntervalYears(1);
       
   240 	
       
   241 	TCalTime calTime1;
       
   242 	TCalTime calTime2;
       
   243 
       
   244 	if (aFloating)
       
   245 		{
       
   246 		calTime1.SetTimeLocalFloatingL(time1);
       
   247 		calTime2.SetTimeLocalFloatingL(time2);
       
   248 		}
       
   249 	else
       
   250 		{
       
   251 		calTime1.SetTimeUtcL(time1);
       
   252 		calTime2.SetTimeUtcL(time2);		
       
   253 		}
       
   254 	
       
   255 	aEntry->SetStartAndEndTimeL(calTime1, calTime2);
       
   256 
       
   257 	test.Next(_L("Start date"));
       
   258 
       
   259 	if (aEntry->EntryTypeL() == CCalEntry::ETodo)
       
   260 		{
       
   261 		if (aFloating)
       
   262 			{
       
   263 			test(aEntry->StartTimeL().TimeLocalL().DaysFrom(time1).Int() == 0);
       
   264 			}
       
   265 		else
       
   266 			{
       
   267 			test(aEntry->StartTimeL().TimeUtcL().DaysFrom(time1).Int() == 0);
       
   268 			}
       
   269 		}
       
   270 	else
       
   271 		{
       
   272 		if (aFloating)
       
   273 			{
       
   274 			test(aEntry->StartTimeL().TimeLocalL() == time1);
       
   275 			}
       
   276 		else
       
   277 			{
       
   278 			test(aEntry->StartTimeL().TimeUtcL() == time1);
       
   279 			}
       
   280 		}
       
   281 
       
   282 	if (aEntry->EntryTypeL() == CCalEntry::EReminder)
       
   283 		{
       
   284 	
       
   285 		test.Next(_L("End date"));
       
   286 
       
   287 		if (aFloating)
       
   288 			{
       
   289 			test(aEntry->EndTimeL().TimeLocalL() == Time::NullTTime());	
       
   290 			}
       
   291 		else
       
   292 			{
       
   293 			test(aEntry->EndTimeL().TimeUtcL() == Time::NullTTime());
       
   294 			}
       
   295 		}
       
   296 	else 
       
   297 		{
       
   298 
       
   299 		test.Next(_L("End date"));
       
   300 
       
   301 		if (aFloating)
       
   302 			{
       
   303 			test(aEntry->EndTimeL().TimeLocalL() == time2);
       
   304 			}
       
   305 		else
       
   306 			{
       
   307 			test(aEntry->EndTimeL().TimeUtcL() == time2);
       
   308 			}
       
   309 		}
       
   310 
       
   311 	if (aFloating)
       
   312 		{
       
   313 
       
   314 		test.Next(_L("time mode"));
       
   315 
       
   316 		test(aEntry->StartTimeL().TimeMode() == TCalTime::EFloating);
       
   317 
       
   318 		if (aEntry->EntryTypeL() != CCalEntry::EReminder)
       
   319 			{
       
   320 			test(aEntry->EndTimeL().TimeMode() == TCalTime::EFloating);
       
   321 			}
       
   322 		}
       
   323 
       
   324 
       
   325 	test.Next(_L("alarm setting"));
       
   326 
       
   327 	CCalAlarm* alarm = aEntry->AlarmL();
       
   328 	test(alarm == NULL);
       
   329 	TTime time4(time1);
       
   330 	time4 += TTimeIntervalHours(5);
       
   331 	
       
   332 	alarm = CCalAlarm::NewL();
       
   333 	
       
   334 	const TInt KAlarmOffset(600);
       
   335 	alarm->SetTimeOffset(KAlarmOffset);
       
   336 	alarm->SetAlarmSoundNameL(KNullDesC());
       
   337 	aEntry->SetAlarmL(alarm);
       
   338 	delete alarm;
       
   339 	alarm = NULL;
       
   340 	TTimeIntervalHours hours2(0);
       
   341 	alarm = aEntry->AlarmL();
       
   342 	test(alarm->TimeOffset().Int() == KAlarmOffset);
       
   343 	test(alarm->AlarmSoundNameL().Length() == 0);
       
   344 	alarm->SetAlarmSoundNameL(_L("dummy"));
       
   345 	test(alarm->AlarmSoundNameL().Compare(_L("dummy")) == 0);
       
   346 	delete alarm;
       
   347 	alarm = NULL;
       
   348 	aEntry->SetAlarmL(NULL);
       
   349 	test(aEntry->AlarmL() == NULL);
       
   350 	
       
   351 	const TInt KHugeAlarmOffset(600000);
       
   352 	alarm = CCalAlarm::NewL();
       
   353 	alarm->SetTimeOffset(KHugeAlarmOffset);
       
   354 	aEntry->SetAlarmL(alarm);
       
   355 	delete alarm;
       
   356 	alarm = NULL;
       
   357 	alarm = aEntry->AlarmL();
       
   358 	test(alarm->TimeOffset().Int() == KHugeAlarmOffset);
       
   359 	delete alarm;
       
   360 	
       
   361 	TTime time5(time1);
       
   362 	time5 += TTimeIntervalHours(2);
       
   363 	time5 += TTimeIntervalDays(5);
       
   364 
       
   365 	if (aEntry->EntryTypeL() == CCalEntry::ETodo)
       
   366 		{
       
   367 
       
   368 		test.Next(_L("status"));
       
   369 
       
   370 		aEntry->SetStatusL(CCalEntry::ETodoNeedsAction);
       
   371 		test(aEntry->StatusL() == CCalEntry::ETodoNeedsAction);
       
   372 		aEntry->SetStatusL(CCalEntry::ETodoInProcess);
       
   373 		test(aEntry->StatusL() == CCalEntry::ETodoInProcess);
       
   374 
       
   375 		test.Next(_L("complete date"));
       
   376 
       
   377 		TCalTime completedCalTime;
       
   378 		completedCalTime.SetTimeUtcL(time5);
       
   379 		aEntry->SetCompletedL(ETrue, completedCalTime);
       
   380 		test(aEntry->StatusL() == CCalEntry::ETodoCompleted);
       
   381 		test(aEntry->CompletedTimeL().TimeUtcL() == time5);
       
   382 		aEntry->SetCompletedL(EFalse, completedCalTime);
       
   383 		test(aEntry->StatusL() != CCalEntry::ETodoCompleted);
       
   384 		}
       
   385 	else 
       
   386 		{
       
   387 
       
   388 		test.Next(_L("status"));
       
   389 
       
   390 		aEntry->SetStatusL(CCalEntry::EConfirmed);
       
   391 		test(aEntry->StatusL() == CCalEntry::EConfirmed);
       
   392 		aEntry->SetStatusL(CCalEntry::ETentative);
       
   393 		test(aEntry->StatusL() == CCalEntry::ETentative);
       
   394 		}
       
   395 		
       
   396 	test.Next(_L("priority"));
       
   397 
       
   398 	aEntry->SetPriorityL(5);
       
   399 	test(aEntry->PriorityL() == 5);
       
   400 	aEntry->SetPriorityL(9);
       
   401 	test(aEntry->PriorityL() == 9);
       
   402 	
       
   403 	test.Next(_L("summary"));
       
   404 
       
   405 	TBuf<32> buf1;
       
   406 	buf1.Copy(KSummary1);
       
   407 	aEntry->SetSummaryL(buf1);
       
   408 	test(aEntry->SummaryL().Compare(buf1) == 0);
       
   409 	
       
   410 	test.Next(_L("Description"));
       
   411 
       
   412 	TBuf<32> buf2;
       
   413 	buf2.Copy(KDescription1);
       
   414 	aEntry->SetDescriptionL(buf2);
       
   415 	test(aEntry->DescriptionL().Compare(buf2) == 0);
       
   416 
       
   417 	test.Next(_L("Location"));
       
   418 
       
   419 	TBuf<32> buf3;
       
   420 	buf3.Copy(_L("dummy Location text"));
       
   421 	aEntry->SetLocationL(buf3);
       
   422 	test(aEntry->LocationL().Compare(buf3) == 0);
       
   423 
       
   424 	test.Next(_L("Category"));
       
   425 
       
   426 	const RPointerArray<CCalCategory> categoryList = aEntry->CategoryListL();
       
   427 	test(categoryList.Count() == 0);
       
   428 	TBuf<32> buf4;
       
   429 	buf4.Copy(_L("dummy Category text"));
       
   430 	
       
   431 	CCalCategory* category = CCalCategory::NewL(buf4);
       
   432 	CleanupStack::PushL(category);
       
   433 	aEntry->AddCategoryL(category);
       
   434 	CleanupStack::Pop(category);
       
   435 	const RPointerArray<CCalCategory> categoryList1 = aEntry->CategoryListL();
       
   436 	test(categoryList1.Count() == 1);
       
   437 	test(categoryList1[0]->ExtendedCategoryName().Compare(buf4) == 0);
       
   438 		
       
   439 	test.Next(_L("DTSTAMP"));
       
   440 
       
   441 	TTime now;
       
   442 	now.UniversalTime();
       
   443 	TCalTime dTStampTime;
       
   444 	dTStampTime.SetTimeUtcL(now);
       
   445 	aEntry->SetDTStampL(dTStampTime);
       
   446 	test(dTStampTime.TimeUtcL() == aEntry->DTStampL().TimeUtcL());
       
   447 	
       
   448 	// copy this entry
       
   449 
       
   450 	test.Next(_L("entry copying"));
       
   451 
       
   452 	HBufC8* uid = aEntry->UidL().AllocLC();
       
   453 	CCalEntry* entryCopy = CCalEntry::NewL(aEntry->EntryTypeL(), uid, aEntry->MethodL(), 
       
   454 		aEntry->SequenceNumberL(), aEntry->RecurrenceIdL(), aEntry->RecurrenceRangeL());
       
   455 	CleanupStack::Pop(uid);
       
   456 	CleanupStack::PushL(entryCopy);
       
   457 	entryCopy->CopyFromL(*aEntry);
       
   458 	test(entryCopy->CompareL(*aEntry));
       
   459 
       
   460 	CleanupStack::PopAndDestroy(entryCopy);
       
   461 
       
   462 	test.Next(_L("last modified date"));
       
   463 
       
   464 	now.UniversalTime();
       
   465 	aEntry->SetLastModifiedDateL();
       
   466 	TTimeIntervalSeconds secs;
       
   467 	aEntry->LastModifiedDateL().TimeUtcL().SecondsFrom(now, secs);
       
   468 	test(secs.Int() < 2);
       
   469 	
       
   470 	test.Next(_L("method"));
       
   471 
       
   472 		{
       
   473 		// positive testing	
       
   474 		
       
   475 		aEntry->SetMethodL(CCalEntry::EMethodAdd);
       
   476 		test(aEntry->MethodL() == CCalEntry::EMethodAdd);
       
   477 		aEntry->SetMethodL(CCalEntry::EMethodCancel);
       
   478 		test(aEntry->MethodL() == CCalEntry::EMethodCancel);
       
   479 		aEntry->SetMethodL(CCalEntry::EMethodNone);
       
   480 		test(aEntry->MethodL() == CCalEntry::EMethodNone);	
       
   481 		aEntry->SetMethodL(CCalEntry::EMethodPublish);
       
   482 		test(aEntry->MethodL() == CCalEntry::EMethodPublish);
       
   483 		aEntry->SetMethodL(CCalEntry::EMethodRequest);
       
   484 		test(aEntry->MethodL() == CCalEntry::EMethodRequest);
       
   485 		aEntry->SetMethodL(CCalEntry::EMethodReply);
       
   486 		test(aEntry->MethodL() == CCalEntry::EMethodReply);
       
   487 		aEntry->SetMethodL(CCalEntry::EMethodRefresh);
       
   488 		test(aEntry->MethodL() == CCalEntry::EMethodRefresh);
       
   489 		aEntry->SetMethodL(CCalEntry::EMethodCounter);
       
   490 		test(aEntry->MethodL() == CCalEntry::EMethodCounter);
       
   491 		aEntry->SetMethodL(CCalEntry::EMethodDeclineCounter);
       
   492 		test(aEntry->MethodL() == CCalEntry::EMethodDeclineCounter);
       
   493 		
       
   494 		// negative testing	
       
   495 		
       
   496 		TRAPD(err1, aEntry->SetMethodL(CCalEntry::TMethod(CCalEntry::EMethodNone-1)) );
       
   497 		test(err1 == KErrArgument);
       
   498 
       
   499 		TRAPD(err2, aEntry->SetMethodL(CCalEntry::TMethod(CCalEntry::EMethodDeclineCounter+1)) );
       
   500 		test(err2 == KErrArgument);
       
   501 		}	
       
   502 
       
   503 		test.Next(_L("sequence number"));
       
   504 
       
   505 		{
       
   506 		aEntry->SetSequenceNumberL(1);
       
   507 		test(aEntry->SequenceNumberL() == 1);
       
   508 		}	
       
   509 	
       
   510 	test.Next(_L("replication status"));
       
   511 
       
   512 		{
       
   513 		// positive testing
       
   514 		
       
   515 		aEntry->SetReplicationStatusL(CCalEntry::EOpen);
       
   516 		test(aEntry->ReplicationStatusL() == CCalEntry::EOpen);
       
   517 		aEntry->SetReplicationStatusL(CCalEntry::EPrivate);
       
   518 		test(aEntry->ReplicationStatusL() == CCalEntry::EPrivate);
       
   519 		aEntry->SetReplicationStatusL(CCalEntry::ERestricted);
       
   520 		test(aEntry->ReplicationStatusL() == CCalEntry::ERestricted);
       
   521 		
       
   522 		// negative testing	
       
   523 		
       
   524 		TRAPD(err1, aEntry->SetReplicationStatusL(CCalEntry::TReplicationStatus(CCalEntry::EOpen-1)) );
       
   525 		test(err1 == KErrArgument);
       
   526 		TRAPD(err2, aEntry->SetReplicationStatusL(CCalEntry::TReplicationStatus(CCalEntry::ERestricted+1)) );
       
   527 		test(err2 == KErrArgument);
       
   528 		}
       
   529 
       
   530 		test.Next(_L("transparency"));
       
   531 
       
   532 		{
       
   533 		// positive testing	
       
   534 		
       
   535 		aEntry->SetTimeTransparencyL(CCalEntry::ETranspTentative);
       
   536 		test(aEntry->TimeTransparencyL() == CCalEntry::ETranspTentative);
       
   537 		aEntry->SetTimeTransparencyL(CCalEntry::ETranspBusy);
       
   538 		test(aEntry->TimeTransparencyL() == CCalEntry::ETranspBusy);
       
   539 		aEntry->SetTimeTransparencyL(CCalEntry::ETranspFree);
       
   540 		test(aEntry->TimeTransparencyL() == CCalEntry::ETranspFree);
       
   541 		aEntry->SetTimeTransparencyL(CCalEntry::ETranspOutOfOffice);
       
   542 		test(aEntry->TimeTransparencyL() == CCalEntry::ETranspOutOfOffice);	
       
   543 
       
   544 		// negative testing	
       
   545 
       
   546 		TRAPD(err1, aEntry->SetTimeTransparencyL(CCalEntry::TTransp(-1)) );
       
   547 		test(err1 == KErrArgument);	
       
   548 		}	
       
   549 		
       
   550 	// .. other properties?
       
   551 	}
       
   552 	
       
   553 	
       
   554 
       
   555 
       
   556 void CEntryAttributesTestManager::TestThisLiteEntryL(CCalEntry* aEntry)
       
   557 	{
       
   558 /* Get properties on a CCalEntry (set as a lite entry) then compare with getting properties from the full entry. */
       
   559 
       
   560 	test.Next(_L("Testing lite entry"));
       
   561 	
       
   562 	test.Next(_L("Start date"));
       
   563 
       
   564 	TTime time1	= aEntry->StartTimeL().TimeUtcL();
       
   565 	
       
   566 	test.Next(_L("End date"));
       
   567 
       
   568 	TTime time2 = aEntry->EndTimeL().TimeUtcL();
       
   569 		
       
   570 	test.Next(_L("priority"));
       
   571 
       
   572 	TInt priority = aEntry->PriorityL();
       
   573 
       
   574 	TTime time3;
       
   575 
       
   576 	if (aEntry->EntryTypeL() == CCalEntry::ETodo)
       
   577 		{
       
   578 
       
   579 		test.Next(_L("complete date"));
       
   580 
       
   581 		time3 = aEntry->CompletedTimeL().TimeUtcL();
       
   582 		}
       
   583 	
       
   584 	// now use full aEntry and compare results
       
   585 	aEntry->SetStatusL(aEntry->StatusL());
       
   586 	
       
   587 	test.Next(_L("Testing full aEntry"));
       
   588 	
       
   589 	test.Next(_L("Start date"));
       
   590 
       
   591 	test(time1 == aEntry->StartTimeL().TimeUtcL());
       
   592 	
       
   593 	test.Next(_L("End date"));
       
   594 
       
   595 	TDateTime dt1 = time2.DateTime();
       
   596 	TDateTime dt2 = aEntry->EndTimeL().TimeUtcL().DateTime();
       
   597 	CCalEntry::TType type = aEntry->EntryTypeL();
       
   598 	test(time2 == aEntry->EndTimeL().TimeUtcL());
       
   599 
       
   600 	test.Next(_L("priority"));
       
   601 
       
   602 	test(priority == aEntry->PriorityL());
       
   603 
       
   604 	if (aEntry->EntryTypeL() == CCalEntry::ETodo)
       
   605 		{
       
   606 
       
   607 		test.Next(_L("complete date"));
       
   608 
       
   609 		test(time3 == aEntry->CompletedTimeL().TimeUtcL());
       
   610 		}
       
   611 	
       
   612 	test(aEntry->TimeTransparencyL() == CCalEntry::ETranspOutOfOffice);
       
   613 	}
       
   614 
       
   615 void CEntryAttributesTestManager::CreateEntriesL(TBool aFloating)
       
   616 	{
       
   617 	TTime time1;
       
   618 	time1.HomeTime();
       
   619 	TTime time2(time1);
       
   620 	time2 += TTimeIntervalHours(2);
       
   621 	time2 += TTimeIntervalMonths(30);
       
   622 	RPointerArray<CCalEntry> array;
       
   623 	CleanupResetAndDestroyPushL(array);
       
   624 	HBufC8* guid = KGUID1().AllocLC();
       
   625 	CCalEntry* entry = CCalEntry::NewL(CCalEntry::ETodo, guid, CCalEntry::EMethodNone, 0);
       
   626 	CleanupStack::Pop(guid);
       
   627 	CleanupStack::PushL(entry);
       
   628 	TCalTime calTime1;
       
   629 	TCalTime calTime2;
       
   630 
       
   631 	if (aFloating)
       
   632 		{
       
   633 		calTime1.SetTimeLocalFloatingL(time1);
       
   634 		calTime2.SetTimeLocalFloatingL(time2);
       
   635 		}
       
   636 	else
       
   637 		{
       
   638 		calTime1.SetTimeUtcL(time1);
       
   639 		calTime2.SetTimeUtcL(time2);
       
   640 		}
       
   641 
       
   642 	entry->SetStartAndEndTimeL(calTime1, calTime2);
       
   643 	TestCalEntryL(entry, aFloating);
       
   644 	array.AppendL(entry);
       
   645 	CleanupStack::Pop(entry);
       
   646 	
       
   647 	TInt success(0);
       
   648 	
       
   649 	iTestLib->SynCGetEntryViewL().StoreL(array, success);
       
   650 	//Test storing an entry array twice and make sure it doesn't leave
       
   651 	test.Next(_L("Storing an entry array twice"));
       
   652 
       
   653 	iTestLib->SynCGetEntryViewL().StoreL(array, success);
       
   654 	delete entry;
       
   655 	entry = NULL;
       
   656 
       
   657 	array.Reset();
       
   658 	guid = KGUID2().AllocLC();
       
   659 	entry = CCalEntry::NewL(CCalEntry::EAppt, guid, CCalEntry::EMethodNone, 0);
       
   660 	CleanupStack::Pop(guid);
       
   661 	CleanupStack::PushL(entry);
       
   662 	entry->SetStartAndEndTimeL(calTime1, calTime2);
       
   663 	TestCalEntryL(entry, aFloating);
       
   664 	
       
   665 	array.AppendL(entry);
       
   666 	CleanupStack::Pop(entry);
       
   667 	iTestLib->SynCGetEntryViewL().StoreL(array, success);
       
   668 	delete entry;
       
   669 	entry = NULL;
       
   670 	array.Reset();
       
   671 	
       
   672 	guid = KGUID3().AllocLC();
       
   673 	entry = CCalEntry::NewL(CCalEntry::EEvent, guid, CCalEntry::EMethodNone, 0);
       
   674 	CleanupStack::Pop(guid);
       
   675 	CleanupStack::PushL(entry);
       
   676 	entry->SetStartAndEndTimeL(calTime1, calTime2);
       
   677 	TestCalEntryL(entry, aFloating);
       
   678 	
       
   679 	array.AppendL(entry);
       
   680 	CleanupStack::Pop(entry);
       
   681 	iTestLib->SynCGetEntryViewL().StoreL(array, success);
       
   682 	delete entry;
       
   683 	entry = NULL;
       
   684 	array.Reset();
       
   685 	
       
   686 	guid = KGUID4().AllocLC();
       
   687 	entry = CCalEntry::NewL(CCalEntry::EAnniv, guid, CCalEntry::EMethodNone, 0);
       
   688 	CleanupStack::Pop(guid);
       
   689 	CleanupStack::PushL(entry);
       
   690 	entry->SetStartAndEndTimeL(calTime1, calTime2);
       
   691 	TestCalEntryL(entry, aFloating);
       
   692 	
       
   693 	array.AppendL(entry);
       
   694 	CleanupStack::Pop(entry);
       
   695 	iTestLib->SynCGetEntryViewL().StoreL(array, success);
       
   696 	delete entry;
       
   697 	entry = NULL;
       
   698 	array.Reset();
       
   699 	
       
   700 	guid = KGUID5().AllocLC();
       
   701 	entry = CCalEntry::NewL(CCalEntry::EReminder, guid, CCalEntry::EMethodNone, 0);
       
   702 	CleanupStack::Pop(guid);
       
   703 	CleanupStack::PushL(entry);
       
   704 	entry->SetStartAndEndTimeL(calTime1, calTime2);
       
   705 	TestCalEntryL(entry, aFloating);
       
   706 	
       
   707 	array.AppendL(entry);
       
   708 	CleanupStack::Pop(entry);
       
   709 	iTestLib->SynCGetEntryViewL().StoreL(array, success);
       
   710 	delete entry;
       
   711 	entry = NULL;
       
   712 	array.Reset();
       
   713 	CleanupStack::Pop(&array);
       
   714 	}
       
   715 
       
   716 	
       
   717 void CEntryAttributesTestManager::TestLiteEntriesL()
       
   718 	{
       
   719 // retrieve lite entries from database and test them, including checking that full entries can be retrieved
       
   720 	RPointerArray<CCalInstance> array;
       
   721 	CleanupResetAndDestroyPushL(array);
       
   722 	
       
   723 	CalCommon::TCalViewFilter filter = CalCommon::EIncludeAll;
       
   724 	TCalTime startDate;
       
   725 	startDate.SetTimeLocalL(TDateTime(2000, EJanuary, 0, 0, 0, 0, 0));
       
   726 	TCalTime endDate;
       
   727 	endDate.SetTimeLocalL(TDateTime(2010, EJanuary, 0, 0, 0, 0, 0));
       
   728 	
       
   729 	CalCommon::TCalTimeRange timeRange(startDate, endDate);
       
   730 	iTestLib->SynCGetInstanceViewL().FindInstanceL(array, filter, timeRange);
       
   731 	TInt i = 0;
       
   732 	while (i < array.Count())
       
   733 		{
       
   734 		TestThisLiteEntryL(&array[i]->Entry());
       
   735 		i++;
       
   736 		}
       
   737 		
       
   738 	CleanupStack::PopAndDestroy(&array);
       
   739 	}
       
   740 	
       
   741 
       
   742 void CEntryAttributesTestManager::StoreLastChangedDatesL()
       
   743 	{
       
   744 	test.Next(_L("Storing LastChangedDate before Modifying entries"));
       
   745 
       
   746 	
       
   747 	CCalIter& iter = iTestLib->GetIterL();
       
   748 	
       
   749 	for( TPtrC8 Uid(iter.FirstL()); Uid != KNullDesC8(); Uid.Set(iter.NextL()) )
       
   750 		{
       
   751 		RPointerArray<CCalEntry> entryList;
       
   752 		CleanupResetAndDestroyPushL(entryList);
       
   753 		
       
   754 		iTestLib->SynCGetEntryViewL().FetchL(Uid, entryList);
       
   755 		iDateArray->AppendL(entryList[0]->LastModifiedDateL().TimeUtcL());
       
   756 		
       
   757 		CleanupStack::PopAndDestroy(&entryList); 
       
   758 		}
       
   759 	}
       
   760 
       
   761 
       
   762 void CEntryAttributesTestManager::CheckForValuesL(TBool aFlip)
       
   763 	{
       
   764 	test.Next(_L("Checking entries"));
       
   765 
       
   766 	
       
   767 	CCalIter& iter = iTestLib->GetIterL();
       
   768 	
       
   769 	TInt i = 0;
       
   770 	for( TPtrC8 Uid(iter.FirstL()); Uid != KNullDesC8(); Uid.Set(iter.NextL()), ++i )
       
   771 		{
       
   772 		RPointerArray<CCalEntry> entryList;
       
   773 		CleanupResetAndDestroyPushL(entryList);
       
   774 		
       
   775 		iTestLib->SynCGetEntryViewL().FetchL(Uid, entryList);
       
   776 
       
   777 		TDateTime dt= iDateArray->At(i).DateTime();
       
   778 		test.Printf(_L("Initial Lastmodified date is  %d/%d/%d, %d:%d:%d\n"),dt.Day()+1, dt.Month()+1, dt.Year(), dt.Hour(), dt.Minute(), dt.Second());
       
   779 		dt= entryList[0]->LastModifiedDateL().TimeUtcL().DateTime();
       
   780 
       
   781 		if(aFlip) //while fetching last changed time should not be altered.
       
   782 		{
       
   783 			test(iDateArray->At(i) == entryList[0]->LastModifiedDateL().TimeUtcL());
       
   784 			test.Printf(_L("Fetching after 1 seconds   %d/%d/%d, %d:%d:%d\n\n"),dt.Day()+1, dt.Month()+1, dt.Year(), dt.Hour(), dt.Minute(), dt.Second());
       
   785 		}	
       
   786 		else	 //while Updating last changed time should be set to current time.
       
   787 		{
       
   788 			test(!(iDateArray->At(i) == entryList[0]->LastModifiedDateL().TimeUtcL()));	
       
   789 			test.Printf(_L("After Updating   %d/%d/%d, %d:%d:%d\n\n"),dt.Day()+1, dt.Month()+1, dt.Year(), dt.Hour(), dt.Minute(), dt.Second());
       
   790 		}
       
   791 		
       
   792 		CleanupStack::PopAndDestroy(&entryList);	
       
   793 		}
       
   794 	}
       
   795 
       
   796 
       
   797 void CEntryAttributesTestManager::UpdateEntriesL()
       
   798 	{
       
   799 	test.Next(_L("Updating entries so the LastChangedDate shud change"));
       
   800 
       
   801 	
       
   802 	CCalIter& iter = iTestLib->GetIterL();
       
   803 	
       
   804 	for( TPtrC8 Uid(iter.FirstL()); Uid != KNullDesC8(); Uid.Set(iter.NextL()) )
       
   805 		{
       
   806 		RPointerArray<CCalEntry> entryList;
       
   807 		CleanupResetAndDestroyPushL(entryList);
       
   808 		iTestLib->SynCGetEntryViewL().FetchL(Uid, entryList);
       
   809 
       
   810 		TBuf<32> bufSummary;
       
   811 		bufSummary.Copy(_L("dummy summary text"));
       
   812 		entryList[0]->SetSummaryL(bufSummary);
       
   813 		TBuf<32> bufDescription;
       
   814 		bufDescription.Copy(_L("dummy description text"));
       
   815 		entryList[0]->SetDescriptionL(bufDescription);
       
   816 		TInt success=0;
       
   817 		iTestLib->SynCGetEntryViewL().UpdateL(entryList, success);
       
   818 		test(success==entryList.Count());
       
   819 		entryList.ResetAndDestroy();
       
   820 		iTestLib->SynCGetEntryViewL().FetchL(Uid, entryList);
       
   821 		test(entryList[0]->SummaryL()==bufSummary);
       
   822 		test(entryList[0]->DescriptionL()==bufDescription);
       
   823 		entryList[0]->SetSummaryL(KNullDesC);
       
   824 		entryList[0]->SetDescriptionL(KNullDesC);
       
   825 		iTestLib->SynCGetEntryViewL().UpdateL(entryList, success);
       
   826 		entryList.ResetAndDestroy();
       
   827 		iTestLib->SynCGetEntryViewL().FetchL(Uid, entryList);
       
   828 		test(entryList[0]->SummaryL()==KNullDesC);
       
   829 		test(entryList[0]->DescriptionL()==KNullDesC);
       
   830 		CleanupStack::PopAndDestroy(&entryList);	
       
   831 		}
       
   832 	}	
       
   833 	
       
   834 void CEntryAttributesTestManager::TestLastChangedDateL()
       
   835 	{
       
   836 	// check last modified date changes during an update:
       
   837 	StoreLastChangedDatesL();
       
   838 	CheckForValuesL(ETrue);
       
   839 
       
   840 	UpdateEntriesL();
       
   841 	CheckForValuesL(EFalse);	
       
   842 
       
   843 	// check last modified date changes during a StoreL on a parent (not allowed on a child)
       
   844 	TestLastChangedDateWithStoreL();
       
   845 	}
       
   846 
       
   847 void CEntryAttributesTestManager::TestLastChangedDateWithStoreL()
       
   848 	{
       
   849 	_LIT8(KGuid, "test StoreL with LastModifiedDateL");
       
   850 	HBufC8* guid = KGuid().AllocLC();
       
   851 	CCalEntry* parent = CCalEntry::NewL(CCalEntry::EAppt, guid, CCalEntry::EMethodNone, 0);
       
   852 	CleanupStack::Pop(guid);
       
   853 	CleanupStack::PushL(parent);
       
   854 	
       
   855 	TTime time = TDateTime(2006, EJanuary, 0, 9, 0, 0, 0);
       
   856 	TCalTime dummyTime;
       
   857 	dummyTime.SetTimeLocalL(time); // 0900 on 1 Jan 06
       
   858 	parent->SetStartAndEndTimeL(dummyTime, dummyTime);
       
   859 	
       
   860 	const TTime KOriginalLastModTime = parent->LastModifiedDateL().TimeLocalL();
       
   861 	
       
   862 	iTestLib->StoreEntryL(*parent);	
       
   863 	CleanupStack::PopAndDestroy(parent);
       
   864 	
       
   865 	RPointerArray<CCalEntry> entries;
       
   866 	CleanupResetAndDestroyPushL(entries);
       
   867 	iTestLib->SynCGetEntryViewL().FetchL(KGuid, entries);
       
   868 	test(entries.Count() == 1);
       
   869 	parent = entries[0];
       
   870 	test(KOriginalLastModTime == parent->LastModifiedDateL().TimeLocalL());
       
   871 	
       
   872 	// wait a second so the last modified date will be different
       
   873 	User::After(1000000);
       
   874 	// update the parent
       
   875 	_LIT(KSummary, "zxcvbnm");
       
   876 	parent->SetSummaryL(KSummary);
       
   877 	iTestLib->StoreEntryL(*parent);
       
   878 	
       
   879 	entries.ResetAndDestroy();
       
   880 	
       
   881 	// get updated parent
       
   882 	iTestLib->SynCGetEntryViewL().FetchL(KGuid, entries);
       
   883 	test(entries.Count() == 1);
       
   884 	parent = entries[0];
       
   885 	test(KOriginalLastModTime < parent->LastModifiedDateL().TimeLocalL());
       
   886 	test(parent->LastModifiedDateL().TimeLocalL() < KOriginalLastModTime + TTimeIntervalSeconds(3));
       
   887 	
       
   888 	CleanupStack::PopAndDestroy(&entries);
       
   889 	}
       
   890 	
       
   891 void CEntryAttributesTestManager::TestCopySummaryAndDescriptionL()
       
   892 	{
       
   893 	CreateEntriesL(EFalse);
       
   894 	
       
   895 	RPointerArray<CCalEntry> entryList;
       
   896 	CleanupResetAndDestroyPushL(entryList);
       
   897 	RPointerArray<CCalEntry> entriesToStore;
       
   898 	CleanupResetAndDestroyPushL(entriesToStore);
       
   899 	
       
   900 	iTestLib->SynCGetEntryViewL().FetchL(KGUID1(), entryList);
       
   901 	_LIT8(KNewGuid, "zxcvbnm");
       
   902 	HBufC8* uid = KNewGuid().AllocLC();
       
   903 	CCalEntry* newEntry = CCalEntry::NewL(CCalEntry::ETodo, uid, CCalEntry::EMethodNone, 0);
       
   904 	CleanupStack::Pop(uid);
       
   905 	CleanupStack::PushL(newEntry);
       
   906 	newEntry->CopyFromL(*entryList[0], CCalEntry::EDontCopyId);
       
   907 	
       
   908 	entriesToStore.AppendL(newEntry);
       
   909 	CleanupStack::Pop(newEntry);
       
   910 
       
   911 	TInt success(0);
       
   912 	iTestLib->SynCGetEntryViewL().StoreL(entriesToStore, success);
       
   913 	test(success == 1);
       
   914 	
       
   915 	CDesC8Array* uidArray = new (ELeave) CDesC8ArrayFlat(1);
       
   916 	CleanupStack::PushL(uidArray);
       
   917 	uidArray->AppendL(KGUID1());
       
   918 	iTestLib->SynCGetEntryViewL().DeleteL(*uidArray);
       
   919 	CleanupStack::PopAndDestroy(uidArray);
       
   920 	
       
   921 	entryList.ResetAndDestroy();
       
   922 	iTestLib->SynCGetEntryViewL().FetchL(KNewGuid(), entryList);
       
   923 	test(entryList.Count() == 1);
       
   924 	
       
   925 	test(entryList[0]->SummaryL() == KSummary1());
       
   926 	test(entryList[0]->DescriptionL() == KDescription1());
       
   927 	CleanupStack::PopAndDestroy(); // entriesToStore
       
   928 	CleanupStack::PopAndDestroy(); // entryList
       
   929 	}
       
   930 
       
   931 void CEntryAttributesTestManager::TestAlarmedCompletedTodoL()
       
   932 	{
       
   933 	_LIT8(KGuid1, "guid-1");
       
   934 	
       
   935 	_LIT(KTime1, "20030127:020000.000000");
       
   936 	_LIT(KTime2, "20040127:020000.000000");
       
   937 		
       
   938 	HBufC8* guid = KGuid1().AllocLC();
       
   939 	CCalEntry* entry = CCalEntry::NewL(CCalEntry::ETodo, guid, CCalEntry::EMethodAdd, (TUint)0);	
       
   940 	CleanupStack::Pop(guid);
       
   941 	CleanupStack::PushL(entry);
       
   942 	
       
   943 	TTime time1(KTime1());
       
   944 	TCalTime st;
       
   945 	st.SetTimeUtcL(time1);
       
   946 	entry->SetStartAndEndTimeL(st, st);
       
   947 	
       
   948 	TTime time2(KTime2());
       
   949 	TCalTime comp;
       
   950 	comp.SetTimeUtcL(time2);
       
   951 	entry->SetCompletedL(ETrue, comp);
       
   952 	
       
   953 	TTime compTime = entry->CompletedTimeL().TimeUtcL();
       
   954 	test(compTime == time2);
       
   955 	
       
   956 	CCalAlarm* alarm=CCalAlarm::NewL();
       
   957 	CleanupStack::PushL(alarm);
       
   958 	alarm->SetTimeOffset(20);
       
   959 	alarm->SetAlarmSoundNameL(_L("SHHH"));
       
   960 	entry->SetAlarmL(alarm);
       
   961 	CleanupStack::PopAndDestroy(alarm);
       
   962 	
       
   963 	CCalAlarm* alarm1 = entry->AlarmL();
       
   964 	test(alarm1 == NULL);
       
   965 			
       
   966 	iTestLib->StoreEntryL(*entry);
       
   967 	CleanupStack::PopAndDestroy(entry);
       
   968 	
       
   969 	// fetch the entry
       
   970 	RPointerArray<CCalEntry> entries;
       
   971 	CleanupResetAndDestroyPushL(entries);
       
   972 	iTestLib->SynCGetEntryViewL().FetchL(KGuid1, entries);
       
   973 	
       
   974 	entry = entries[0];
       
   975 	
       
   976 	TTime compTime2 = entry->CompletedTimeL().TimeUtcL();
       
   977 	test(compTime2 == time2);
       
   978 	
       
   979 	CCalAlarm* alarm2 = entry->AlarmL();
       
   980 	test(alarm2 == NULL);
       
   981 	CleanupStack::PopAndDestroy(&entries);
       
   982 	}
       
   983 
       
   984 // from former tcal_CopyEntryImpl
       
   985 
       
   986 void CEntryAttributesTestManager::CopyEntryL(const CCalEntry& aEntry)
       
   987 	{
       
   988 	HBufC8* guid = aEntry.UidL().AllocLC();
       
   989 	CCalEntry::TType type = aEntry.EntryTypeL();
       
   990     CCalEntry::TMethod method = aEntry.MethodL();
       
   991     TInt seqNumber = aEntry.SequenceNumberL();
       
   992     
       
   993     CCalEntry* entry = CCalEntry::NewL(type,guid,method,seqNumber);
       
   994     CleanupStack::Pop(guid);
       
   995     CleanupStack::PushL(entry);
       
   996     
       
   997 	const TDesC8& original_uid = aEntry.UidL();
       
   998 	const TDesC8& uid_before_copy = entry->UidL();
       
   999 	
       
  1000 	__ASSERT_ALWAYS(original_uid == uid_before_copy, User::Invariant());
       
  1001 	
       
  1002 	entry->CopyFromL(aEntry);
       
  1003 	
       
  1004 	const TDesC8& uid_after_copy = entry->UidL();
       
  1005 	
       
  1006 	__ASSERT_ALWAYS(original_uid == uid_after_copy, User::Invariant());
       
  1007    
       
  1008     CleanupStack::PopAndDestroy(entry);
       
  1009    	}
       
  1010    	
       
  1011 
       
  1012 void CEntryAttributesTestManager::CopyEventForCopyPasteL(const CCalEntry& aEntry)
       
  1013 	{
       
  1014     CCalEntry::TType type = aEntry.EntryTypeL();
       
  1015     CCalEntry::TMethod method = aEntry.MethodL();
       
  1016     TInt seqNumber = aEntry.SequenceNumberL();
       
  1017 	_LIT8(KGuid, "ABCDEFGHIJ");
       
  1018 	HBufC8* newUid = KGuid().AllocLC();
       
  1019     CCalEntry* entry = CCalEntry::NewL(type,newUid,method,seqNumber);
       
  1020     CleanupStack::Pop(newUid);
       
  1021     CleanupStack::PushL(entry);
       
  1022     TCalLocalUid newLocalUid(4);
       
  1023 	entry->SetLocalUidL(newLocalUid);
       
  1024 	entry->CopyFromL(aEntry ,CCalEntry::EDontCopyId);
       
  1025 	
       
  1026 	HBufC8* copyUid = entry->UidL().AllocLC();
       
  1027 
       
  1028 	const TDesC8& original_uid = aEntry.UidL();
       
  1029 	const TDesC8& uid_after_copy = entry->UidL();
       
  1030 	TCalLocalUid originalUniqueId = aEntry.LocalUidL();
       
  1031 	TCalLocalUid copiedUniqueId = entry->LocalUidL();
       
  1032 	
       
  1033 	__ASSERT_ALWAYS(originalUniqueId != copiedUniqueId, User::Invariant());
       
  1034 	__ASSERT_ALWAYS(original_uid != uid_after_copy, User::Invariant());
       
  1035    
       
  1036    	entry->CopyFromL(aEntry, CCalEntry::ECopyAll);
       
  1037 	
       
  1038 	const TDesC8& original_entry_uid = aEntry.UidL();
       
  1039 	const TDesC8& after_copy_uid = entry->UidL();
       
  1040 	copiedUniqueId = entry->LocalUidL();
       
  1041 	
       
  1042 	__ASSERT_ALWAYS(originalUniqueId == copiedUniqueId, User::Invariant());
       
  1043 	__ASSERT_ALWAYS(original_entry_uid == after_copy_uid, User::Invariant());
       
  1044    
       
  1045    	CleanupStack::PopAndDestroy(copyUid);
       
  1046    	CleanupStack::PopAndDestroy(entry);
       
  1047     }
       
  1048     
       
  1049 	
       
  1050 void CEntryAttributesTestManager::CreateEntriesForCopyL()
       
  1051 	{
       
  1052 	TTime time1;
       
  1053 	time1.HomeTime();
       
  1054 	TTime time2(time1);
       
  1055 	time2 += TTimeIntervalHours(2);
       
  1056 	time2 += TTimeIntervalMonths(30);
       
  1057 	
       
  1058 	HBufC8* guid = KGUID1().AllocLC();
       
  1059 	CCalEntry* entry = CCalEntry::NewL(CCalEntry::ETodo, guid, CCalEntry::EMethodNone, 0);
       
  1060 	CleanupStack::Pop(guid);
       
  1061 	CleanupStack::PushL(entry);
       
  1062 	
       
  1063 	TCalTime calTime1;
       
  1064 	calTime1.SetTimeUtcL(time1);
       
  1065 	TCalTime calTime2;
       
  1066 	calTime2.SetTimeUtcL(time2);
       
  1067 	entry->SetStartAndEndTimeL(calTime1, calTime2);
       
  1068 	
       
  1069 	CopyEntryL(*entry);
       
  1070 
       
  1071 	CleanupStack::PopAndDestroy(entry);
       
  1072 	}
       
  1073 	
       
  1074 
       
  1075 void CEntryAttributesTestManager::CreateEventForCopyPasteL()
       
  1076 	{
       
  1077 	TTime time1;
       
  1078 	time1.HomeTime();
       
  1079 	TTime time2(time1);
       
  1080 	time2 += TTimeIntervalHours(2);
       
  1081 	time2 += TTimeIntervalMonths(30);
       
  1082 	
       
  1083 	HBufC8* guid = KGUID1().AllocLC();
       
  1084 	CCalEntry* entry = CCalEntry::NewL(CCalEntry::EEvent, guid, CCalEntry::EMethodNone, 0);
       
  1085 	CleanupStack::Pop(guid);
       
  1086 	CleanupStack::PushL(entry);
       
  1087 	
       
  1088 	TCalTime calTime1;
       
  1089 	calTime1.SetTimeUtcL(time1);
       
  1090 	TCalTime calTime2;
       
  1091 	calTime2.SetTimeUtcL(time2);
       
  1092 	entry->SetStartAndEndTimeL(calTime1, calTime2);
       
  1093 	
       
  1094 	CopyEventForCopyPasteL(*entry);
       
  1095 	
       
  1096 	CleanupStack::PopAndDestroy(entry);
       
  1097 	}
       
  1098 
       
  1099 
       
  1100 void CEntryAttributesTestManager::FindSummaryL()
       
  1101 	{
       
  1102 	_LIT8(KGuid1, "guid-1");
       
  1103 	_LIT(KSummary1, "SAMPLE SUMMARY");
       
  1104 	_LIT(KTime1, "20020815:230000.000000");
       
  1105 	
       
  1106 	_LIT(KTimeFindSt, "20020715:230000.000000");
       
  1107 	_LIT(KTimeFindEnd, "20020915:230000.000000");
       
  1108 	
       
  1109 	HBufC8* guid8 = KGuid1().AllocLC();
       
  1110 	CCalEntry* entry = CCalEntry::NewL(CCalEntry::EReminder, guid8, CCalEntry::EMethodAdd, (TUint)0);	
       
  1111 	CleanupStack::Pop(guid8);
       
  1112 	CleanupStack::PushL(entry);
       
  1113 	TTime time(KTime1());
       
  1114 	TCalTime st;
       
  1115 	st.SetTimeUtcL(time);
       
  1116 	
       
  1117 	entry->SetStartAndEndTimeL(st, st);
       
  1118 	entry->SetSummaryL(KSummary1);
       
  1119 	
       
  1120 	TInt						entriesStored(0);
       
  1121 	RPointerArray<CCalEntry>	entriesToStore;
       
  1122 	entriesToStore.AppendL(entry);
       
  1123 	TRAPD(err, iTestLib->SynCGetEntryViewL().StoreL(entriesToStore, entriesStored));
       
  1124 	test(err == KErrNone);
       
  1125 	CleanupStack::PopAndDestroy(entry);
       
  1126 	entriesToStore.Reset();
       
  1127 	
       
  1128 	// added to test with a new session //
       
  1129 	delete iTestLib;
       
  1130 	iTestLib = NULL;
       
  1131 	iTestLib = CCalTestLibrary::NewL(EFalse);
       
  1132 	iTestLib->OpenFileL(KCalName());
       
  1133 	
       
  1134 	// testing if entry exists with new session //
       
  1135 	RPointerArray<CCalEntry>	entries;
       
  1136 	iTestLib->SynCGetEntryViewL().FetchL(KGuid1, entries);
       
  1137 	test(entries[0]->SummaryL() == KSummary1);
       
  1138 	entries.ResetAndDestroy();
       
  1139 
       
  1140 	RPointerArray<CCalInstance>	instances;
       
  1141 	
       
  1142 	CalCommon::TCalViewFilter filter = CalCommon::EIncludeAll;
       
  1143 	
       
  1144 	TTime time1(KTimeFindSt());
       
  1145 	st.SetTimeUtcL(time1);
       
  1146 	TTime time2(KTimeFindEnd());
       
  1147 	TCalTime end;
       
  1148 	end.SetTimeUtcL(time2);
       
  1149 	CalCommon::TCalTimeRange timerange(st, end);
       
  1150 	
       
  1151 	CalCommon::TCalSearchBehaviour behaviour = CalCommon::EExactTextSearch;
       
  1152 	
       
  1153 	CCalInstanceView::TCalSearchParams params(KSummary1, behaviour);
       
  1154 	
       
  1155 	iTestLib->SynCGetInstanceViewL().FindInstanceL(instances, filter, timerange, params);
       
  1156 		
       
  1157 	test.Printf(_L("Instances found with correct summary = %D\n"), instances.Count());
       
  1158 	test(instances.Count() == 1);
       
  1159 	
       
  1160 	instances.ResetAndDestroy();
       
  1161 	}
       
  1162 
       
  1163 
       
  1164 void CEntryAttributesTestManager::AddTwoRepeatingChildL()
       
  1165 	{
       
  1166 	// Add Entries for Test
       
  1167 	test.Next(_L("Add Two Repeating Children"));
       
  1168 
       
  1169 
       
  1170 	RPointerArray<CCalEntry> entriesToStore;
       
  1171 	CleanupResetAndDestroyPushL(entriesToStore);
       
  1172 
       
  1173 	_LIT8(KUid, "UID_AABB");
       
  1174 	HBufC8* guid = KUid().AllocLC();
       
  1175 	CCalEntry* entry = CCalEntry::NewL(CCalEntry::EAppt, guid, CCalEntry::EMethodNone, 0);
       
  1176 	CleanupStack::Pop(guid);
       
  1177 	CleanupStack::PushL(entry);
       
  1178 
       
  1179 	TTime startTime (TDateTime(2005, EJanuary, 7, 10, 0, 0, 0)); 
       
  1180 	TCalTime calStartTime;
       
  1181 	calStartTime.SetTimeLocalL(startTime);
       
  1182 	TTime endTime (TDateTime(2005, EJanuary, 7, 11, 0, 0, 0)); 
       
  1183 	TCalTime calEndTime;
       
  1184 	calEndTime.SetTimeLocalL(endTime);
       
  1185 	entry->SetStartAndEndTimeL(calStartTime, calEndTime);
       
  1186 
       
  1187 	TCalRRule* rpt = new (ELeave) TCalRRule(TCalRRule::EDaily);
       
  1188 	CleanupStack::PushL(rpt);
       
  1189 	TTime daily1end(TDateTime(2005, EJanuary, 20, 10, 0, 0, 0));
       
  1190 	TCalTime rptendTime;
       
  1191 	rptendTime.SetTimeLocalL(daily1end);
       
  1192 
       
  1193 	rpt->SetDtStart(calStartTime);
       
  1194 	rpt->SetUntil(rptendTime);
       
  1195 	rpt->SetInterval(1);
       
  1196 	entry->SetRRuleL(*rpt);//take a copy of the rule
       
  1197 	CleanupStack::PopAndDestroy(rpt);
       
  1198 	entriesToStore.Append(entry);
       
  1199 	CleanupStack::Pop(entry);
       
  1200 	
       
  1201 //create a child entry and store it
       
  1202 	guid = KUid().AllocLC();
       
  1203 	TTime ttime (TDateTime(2005, EJanuary, 15, 10, 0, 0, 0));
       
  1204 	TCalTime recurrenceId;
       
  1205 	recurrenceId.SetTimeUtcL(ttime);
       
  1206 	entry = CCalEntry::NewL(CCalEntry::EAppt, guid, CCalEntry::EMethodRequest, 0, recurrenceId, CalCommon::EThisAndFuture);
       
  1207 	CleanupStack::Pop(guid);
       
  1208 	CleanupStack::PushL(entry);
       
  1209 
       
  1210 	// Start date same as RecId. End time is 1 hour later.
       
  1211 	TTime newStartDate (TDateTime(2005, EJanuary, 15, 11, 0, 0, 0));
       
  1212 	TTime newEndDate (TDateTime(2005, EJanuary, 15, 12, 0, 0, 0));
       
  1213 	
       
  1214 	TCalTime newCalstartTime;
       
  1215 	newCalstartTime.SetTimeUtcL(newStartDate);
       
  1216 	
       
  1217 	TCalTime newCalendTime;
       
  1218 	newCalendTime.SetTimeUtcL(newEndDate);
       
  1219 	
       
  1220 	entry->SetStartAndEndTimeL(newCalstartTime, newCalendTime);
       
  1221 	
       
  1222 	rpt = new (ELeave) TCalRRule(TCalRRule::EDaily);
       
  1223 	CleanupStack::PushL(rpt);
       
  1224 	TTime dailyend(TDateTime(2005, EJanuary, 25, 11, 0, 0, 0));
       
  1225 	TCalTime rptChildendTime;
       
  1226 	rptChildendTime.SetTimeLocalL(dailyend);
       
  1227 
       
  1228 	rpt->SetDtStart(newCalstartTime);
       
  1229 	rpt->SetUntil(rptChildendTime);
       
  1230 	rpt->SetInterval(1);
       
  1231 	entry->SetRRuleL(*rpt);//take a copy of the rule
       
  1232 	CleanupStack::PopAndDestroy(rpt);
       
  1233 	entriesToStore.Append(entry);
       
  1234 	CleanupStack::Pop(entry);
       
  1235 	
       
  1236 	TInt entriesStored;
       
  1237 	iTestLib->SynCGetEntryViewL().StoreL(entriesToStore, entriesStored);
       
  1238 	test(entriesStored ==2);
       
  1239 	delete entriesToStore[0];
       
  1240 	entriesToStore.Reset();
       
  1241 	CleanupStack::PushL(entry);
       
  1242 	//create another child
       
  1243 	guid = KUid().AllocLC();
       
  1244 	ttime = TDateTime(2005, EJanuary, 10, 10, 0, 0, 0);
       
  1245 	TCalTime recurrenceId1;
       
  1246 	recurrenceId1.SetTimeUtcL(ttime);
       
  1247 	CCalEntry* otherChild = CCalEntry::NewL(CCalEntry::EAppt, guid, CCalEntry::EMethodRequest, 0, recurrenceId1, CalCommon::EThisAndPrior);
       
  1248 	CleanupStack::Pop(guid);
       
  1249 	CleanupStack::PushL(otherChild);
       
  1250 	otherChild->CopyFromL(*entry, CCalEntry::EDontCopyId);
       
  1251 	TCalRRule otherChildRpt;
       
  1252 	test(otherChild->GetRRuleL(otherChildRpt));
       
  1253 	otherChild->SetStartAndEndTimeL(calStartTime, calStartTime);
       
  1254 	otherChildRpt.SetDtStart(calStartTime);
       
  1255 	otherChildRpt.SetUntil(recurrenceId1);
       
  1256 	otherChild->SetRRuleL(otherChildRpt);
       
  1257 	entriesToStore.Append(otherChild);
       
  1258 	CleanupStack::Pop(otherChild);
       
  1259 	CleanupStack::PopAndDestroy(entry);
       
  1260 	TRAPD(err, iTestLib->SynCGetEntryViewL().StoreL(entriesToStore, entriesStored));
       
  1261 	test(err == KErrNotSupported);
       
  1262 	
       
  1263 	CleanupStack::PopAndDestroy(&entriesToStore);
       
  1264 	}
       
  1265 
       
  1266 void CEntryAttributesTestManager::TestEndTimeBeforeStartTimeL()
       
  1267 	{
       
  1268 	_LIT8(KGuid, "guid");
       
  1269 	HBufC8* guid = KGuid().AllocLC();
       
  1270 	CCalEntry* entry = CCalEntry::NewL(CCalEntry::EAppt, guid, CCalEntry::EMethodRequest, 0);
       
  1271 	CleanupStack::Pop(guid);
       
  1272 	CleanupStack::PushL(entry);
       
  1273 
       
  1274 	TCalTime startTime, endTime;
       
  1275 	startTime.SetTimeLocalL(TDateTime(2005, EFebruary, 20, 10, 0, 0, 0));
       
  1276 	endTime.SetTimeLocalL(TDateTime(2005, EFebruary, 20, 9, 0, 0, 0));
       
  1277 
       
  1278 	test.Printf(_L("Test can't set end time earlier than start time"));
       
  1279 	TRAPD(err, entry->SetStartAndEndTimeL(startTime, endTime));
       
  1280 	test(err == KErrArgument);
       
  1281 
       
  1282 	CleanupStack::PopAndDestroy(entry);	
       
  1283 	}
       
  1284 
       
  1285 void CEntryAttributesTestManager::TestAlarmedTodoWithoutDueDateL()
       
  1286 	{
       
  1287 	// check that a Todo without a Due date cannot have an alarm
       
  1288 	const TInt KTimeOffset = 10;
       
  1289 	_LIT8(KGuid, "alarmed-todo");
       
  1290 	
       
  1291 	HBufC8* guid = KGuid().AllocLC();
       
  1292 	CCalEntry* todo = CCalEntry::NewL(CCalEntry::ETodo, guid, CCalEntry::EMethodNone, 0);
       
  1293 	CleanupStack::Pop(guid);
       
  1294 	CleanupStack::PushL(todo);
       
  1295 
       
  1296 	TCalTime start, end;
       
  1297 	start.SetTimeLocalL(TDateTime(2006, EJuly, 20, 9, 0, 0, 0));
       
  1298 	end.SetTimeLocalL(Time::NullTTime());
       
  1299 	todo->SetStartAndEndTimeL(start, end);
       
  1300 	
       
  1301 	CCalAlarm* alarm = CCalAlarm::NewL();
       
  1302 	CleanupStack::PushL(alarm);
       
  1303 	alarm->SetTimeOffset(KTimeOffset);
       
  1304 	todo->SetAlarmL(alarm);
       
  1305 	CleanupStack::PopAndDestroy(alarm);
       
  1306 	alarm = NULL;
       
  1307 	
       
  1308 	// check alarm not set
       
  1309 	alarm = todo->AlarmL();
       
  1310 	test(alarm == NULL);
       
  1311 	CleanupStack::PopAndDestroy(todo);
       
  1312 	}
       
  1313 
       
  1314 void CEntryAttributesTestManager::TestFetchAndDeleteNonExistentEntryL()
       
  1315 	{
       
  1316 	_LIT8(KGuid, "guid");
       
  1317 	
       
  1318 	// test fetching non-existing entry by GUID
       
  1319 	RPointerArray<CCalEntry> entries;
       
  1320 	CleanupResetAndDestroyPushL(entries);
       
  1321 	iTestLib->SynCGetEntryViewL().FetchL(KGuid, entries);
       
  1322 	test(entries.Count() == 0);
       
  1323 	CleanupStack::PopAndDestroy(&entries);
       
  1324 	
       
  1325 	// test fetching non-existing entry by LUID
       
  1326 	test(iTestLib->SynCGetEntryViewL().FetchL(5) == NULL);
       
  1327 	
       
  1328 	// test deleting non-existing entry by GUID
       
  1329 	CDesC8ArrayFlat* guidArray = new (ELeave) CDesC8ArrayFlat(1);
       
  1330 	CleanupStack::PushL(guidArray);
       
  1331 	guidArray->AppendL(KGuid);
       
  1332 	TRAPD(err, iTestLib->SynCGetEntryViewL().DeleteL(*guidArray));
       
  1333 	test(err == KErrNotFound);
       
  1334 	CleanupStack::PopAndDestroy(guidArray);
       
  1335 	
       
  1336 	// test deleting non-existing entry by LUID
       
  1337 	RArray<TCalLocalUid> luids;
       
  1338 	CleanupClosePushL(luids);
       
  1339 	luids.AppendL(40); // dummy number
       
  1340 	TInt success = 0;
       
  1341 	TRAP(err, iTestLib->SynCGetEntryViewL().DeleteL(luids, success)); // doesn't leave
       
  1342 	test(err == KErrNone);
       
  1343 	test(success == 1);
       
  1344 	CleanupStack::PopAndDestroy(&luids);
       
  1345 	}
       
  1346 
       
  1347 void CEntryAttributesTestManager::TestEndTimeNullL(CCalEntry::TType aType)
       
  1348 	{
       
  1349 	const TTime KStartTime(TDateTime(2006, EJanuary, 0, 0, 0, 0, 0));
       
  1350 	
       
  1351 	_LIT8(KGuid, "guid");
       
  1352 	HBufC8* guid = KGuid().AllocLC();
       
  1353 	CCalEntry* entry = CCalEntry::NewL(aType, guid, CCalEntry::EMethodNone, 0);
       
  1354 	CleanupStack::Pop(guid);
       
  1355 	CleanupStack::PushL(entry);
       
  1356 	
       
  1357 	TCalTime calStartTime, calNullTime;
       
  1358 	calStartTime.SetTimeLocalL(KStartTime);
       
  1359 	calNullTime.SetTimeLocalL(Time::NullTTime());
       
  1360 	entry->SetStartAndEndTimeL(calStartTime, calNullTime);
       
  1361 	if (aType == CCalEntry::ETodo)
       
  1362 		{
       
  1363 		test(entry->StartTimeL().TimeLocalL() == Time::NullTTime());
       
  1364 		}
       
  1365 	else
       
  1366 		{
       
  1367 		test(entry->StartTimeL().TimeLocalL() == KStartTime);
       
  1368 		}
       
  1369 	if (aType == CCalEntry::EReminder ||
       
  1370 		aType == CCalEntry::ETodo)
       
  1371 		{
       
  1372 		test(entry->EndTimeL().TimeLocalL() == Time::NullTTime());
       
  1373 		}
       
  1374 	else
       
  1375 		{
       
  1376 		test(entry->EndTimeL().TimeLocalL() == KStartTime);
       
  1377 		}
       
  1378 	CleanupStack::PopAndDestroy(entry);
       
  1379 	}
       
  1380 
       
  1381 void CEntryAttributesTestManager::TestEndTimeNullL()
       
  1382 	{
       
  1383 	TestEndTimeNullL(CCalEntry::EAppt);
       
  1384 	TestEndTimeNullL(CCalEntry::EEvent);
       
  1385 	TestEndTimeNullL(CCalEntry::EAnniv);
       
  1386 	// for these entry types, the end time remains NULL
       
  1387 	TestEndTimeNullL(CCalEntry::EReminder);
       
  1388 	TestEndTimeNullL(CCalEntry::ETodo);
       
  1389 	}
       
  1390 
       
  1391 /**
       
  1392 
       
  1393 @SYMTestCaseID     PIM-TCAL-ENTRYATTRIBUTES-0037
       
  1394 
       
  1395 */
       
  1396 
       
  1397 void CEntryAttributesTestManager::TestGEOAttributesL()
       
  1398 	{
       
  1399 	test.Next(_L("@SYMTESTCaseID:PIM-TCAL-ENTRYATTRIBUTES-0037 GEO testing"));
       
  1400 
       
  1401 	
       
  1402 	// Test set and get on the CCalGeoValue object - bounds, truncation and signs
       
  1403 	TestGEOValueSetAndGetL();
       
  1404 	// Test set and get on the entry and verify GEO values
       
  1405 	TestGEOEntrySetAndGetL();
       
  1406 	// Test internalizing and externalizing entry and verify GEO values
       
  1407 	TestGEOInternalizeAndExternalizeL();	
       
  1408 	// Test Compare and CopyFrom on the entry and verify GEO values
       
  1409 	TestGEOCompareAndCopyFromL();
       
  1410 	}
       
  1411 
       
  1412 void CEntryAttributesTestManager::TestGEOValueSetAndGetL()
       
  1413 	{
       
  1414 	// Positive testing
       
  1415 	TReal geoTestLatOrig(0);
       
  1416 	TReal geoTestLongOrig(0);
       
  1417 
       
  1418 	TReal geoTestLat(geoTestLatOrig);
       
  1419 	TReal geoTestLong(geoTestLongOrig);
       
  1420 	
       
  1421 	// Expected values
       
  1422 	TReal geoTestLatEx;
       
  1423 	TReal geoTestLongEx;
       
  1424 
       
  1425 	// Create a CCalGeoValue object for testing
       
  1426 	CCalGeoValue* geoValue = CCalGeoValue::NewL();
       
  1427 	CleanupStack::PushL(geoValue);
       
  1428 	
       
  1429 	// Get - Check the default initialisation
       
  1430 	test(!geoValue->GetLatLong(geoTestLat, geoTestLong));
       
  1431 	// Check no change in values
       
  1432 	test(geoTestLat==geoTestLatOrig && geoTestLong==geoTestLongOrig);
       
  1433 		
       
  1434 	// Test Set
       
  1435 	// Bounds checking
       
  1436 	// Within bounds
       
  1437 	geoTestLat 	=  45.123456;
       
  1438 	geoTestLong	=  90.123456;
       
  1439 	
       
  1440 	geoTestLatEx 	=  45.123456;
       
  1441 	geoTestLongEx	=  90.123456;
       
  1442 	
       
  1443 	TestGEOVerifySetAndGetL(geoTestLat,geoTestLong, geoTestLatEx,  geoTestLongEx, *geoValue);
       
  1444 	
       
  1445 	geoTestLat	=  -45.123456;
       
  1446 	geoTestLong	=  -90.123456;
       
  1447 	
       
  1448 	geoTestLatEx 	=  -45.123456;
       
  1449 	geoTestLongEx	=  -90.123456;
       
  1450 	
       
  1451 	TestGEOVerifySetAndGetL(geoTestLat,geoTestLong, geoTestLatEx,  geoTestLongEx, *geoValue);
       
  1452 	
       
  1453 	// Truncation and rounding
       
  1454 	// Rounding up
       
  1455 	geoTestLat 	=  45.1234567123;
       
  1456 	geoTestLong	=  90.1234567123;
       
  1457 	
       
  1458 	geoTestLatEx 	=  45.123457;
       
  1459 	geoTestLongEx	=  90.123457;
       
  1460 	
       
  1461 	TestGEOVerifySetAndGetL(geoTestLat,geoTestLong, geoTestLatEx,  geoTestLongEx, *geoValue);
       
  1462 
       
  1463 	geoTestLat 	=  -45.1234567123;
       
  1464 	geoTestLong	=  -90.1234567123;
       
  1465 	
       
  1466 	geoTestLatEx 	=  -45.123457;
       
  1467 	geoTestLongEx	=  -90.123457;
       
  1468 	
       
  1469 	TestGEOVerifySetAndGetL(geoTestLat,geoTestLong, geoTestLatEx,  geoTestLongEx, *geoValue);
       
  1470 	
       
  1471 	// Rounding down
       
  1472 	geoTestLat 	=  45.1234561234;
       
  1473 	geoTestLong	=  90.1234561234;
       
  1474 	
       
  1475 	geoTestLatEx 	=  45.123456;
       
  1476 	geoTestLongEx	=  90.123456;
       
  1477 	
       
  1478 	TestGEOVerifySetAndGetL(geoTestLat,geoTestLong, geoTestLatEx,  geoTestLongEx, *geoValue);
       
  1479 
       
  1480 	geoTestLat 	=  -45.1234561234;
       
  1481 	geoTestLong	=  -90.1234561234;
       
  1482 	
       
  1483 	geoTestLatEx 	=  -45.123456;
       
  1484 	geoTestLongEx	=  -90.123456;
       
  1485 	
       
  1486 	TestGEOVerifySetAndGetL(geoTestLat,geoTestLong, geoTestLatEx,  geoTestLongEx, *geoValue);
       
  1487 	
       
  1488 	// On bounds
       
  1489 	geoTestLat	= 0.000000;
       
  1490 	geoTestLong	= 0.000000;
       
  1491 	
       
  1492 	geoTestLatEx 	=  0.000000;
       
  1493 	geoTestLongEx	=  0.000000;
       
  1494 
       
  1495 	TestGEOVerifySetAndGetL(geoTestLat,geoTestLong, geoTestLatEx,  geoTestLongEx, *geoValue);
       
  1496 
       
  1497 	geoTestLat	= KCalGEOMaxLatitude;
       
  1498 	geoTestLong	= KCalGEOMaxLongitude;
       
  1499 	
       
  1500 	geoTestLatEx	= KCalGEOMaxLatitude;
       
  1501 	geoTestLongEx	= KCalGEOMaxLongitude;	
       
  1502 
       
  1503 	TestGEOVerifySetAndGetL(geoTestLat,geoTestLong, geoTestLatEx,  geoTestLongEx, *geoValue);
       
  1504 	
       
  1505 	geoTestLat	= KCalGEOMinLatitude;
       
  1506 	geoTestLong	= KCalGEOMinLongitude;
       
  1507 	
       
  1508 	geoTestLatEx	= KCalGEOMinLatitude;
       
  1509 	geoTestLongEx	= KCalGEOMinLongitude;	
       
  1510 
       
  1511 	TestGEOVerifySetAndGetL(geoTestLat,geoTestLong, geoTestLatEx,  geoTestLongEx, *geoValue);
       
  1512 	
       
  1513 	// Out of the bounds
       
  1514 	TInt geoErr=KErrNone;
       
  1515 	
       
  1516 	// latitude - posititve 
       
  1517 	geoTestLat	=  95.123456;
       
  1518 	geoTestLong	=  45.123456;
       
  1519 	
       
  1520 	TRAP(geoErr, geoValue->SetLatLongL(geoTestLat, geoTestLong));
       
  1521 	test(geoErr==KErrArgument);
       
  1522 	
       
  1523 	// longitude - posititve 
       
  1524 	geoTestLat	=  50.123456;
       
  1525 	geoTestLong	=  185.123456;
       
  1526 
       
  1527 	TRAP(geoErr, geoValue->SetLatLongL(geoTestLat, geoTestLong));
       
  1528 	test(geoErr==KErrArgument);
       
  1529 	
       
  1530 	// latitude - negative
       
  1531 	geoTestLat	=  -95.123456;
       
  1532 	geoTestLong	=  -45.123456;
       
  1533 	
       
  1534 	TRAP(geoErr, geoValue->SetLatLongL(geoTestLat, geoTestLong));
       
  1535 	test(geoErr==KErrArgument);
       
  1536 	
       
  1537 	// longitude - negative
       
  1538 	geoTestLat	=  -50.123456;
       
  1539 	geoTestLong	=  -185.123456;
       
  1540 
       
  1541 	TRAP(geoErr, geoValue->SetLatLongL(geoTestLat, geoTestLong));
       
  1542 	test(geoErr==KErrArgument);
       
  1543 	
       
  1544 	// latitude and longitude - positive
       
  1545 	geoTestLat	=  95.123456;
       
  1546 	geoTestLong	=  185.123456;
       
  1547 
       
  1548 	TRAP(geoErr, geoValue->SetLatLongL(geoTestLat, geoTestLong));
       
  1549 	test(geoErr==KErrArgument);
       
  1550 
       
  1551 	// latitude and longitude - negative
       
  1552 	geoTestLat	=  -95.123456;
       
  1553 	geoTestLong	=  -185.123456;
       
  1554 
       
  1555 	TRAP(geoErr, geoValue->SetLatLongL(geoTestLat, geoTestLong));
       
  1556 	test(geoErr==KErrArgument);
       
  1557 		
       
  1558 	CleanupStack::PopAndDestroy(geoValue);
       
  1559 	}
       
  1560 
       
  1561 void CEntryAttributesTestManager::TestGEOVerifySetAndGetL(const TReal& aSetLat, const TReal& aSetLong, const TReal& aExpLat, const TReal& aExpLong, CCalGeoValue& aCalGeoValue) const
       
  1562 	{
       
  1563 	TReal getLat;
       
  1564 	TReal getLong;
       
  1565 	
       
  1566 	aCalGeoValue.SetLatLongL(aSetLat,aSetLong);
       
  1567 	test(aCalGeoValue.GetLatLong(getLat, getLong));
       
  1568 	test(getLat==aExpLat && getLong==aExpLong);
       
  1569 	}
       
  1570 
       
  1571 void CEntryAttributesTestManager::TestGEOEntrySetAndGetL()
       
  1572 	{
       
  1573 	HBufC8* guid = NULL;
       
  1574 	
       
  1575 	// Entry for test purposes
       
  1576 	CCalEntry* entry = iTestLib->CreateCalEntryL(CCalEntry::EAppt,guid);
       
  1577 	CleanupStack::PushL(entry);
       
  1578 	
       
  1579 	// == Test default initialisation of GEO values on the entry
       
  1580 	// Retrieve GEO value from an entry when it has not been set
       
  1581 	CCalGeoValue* geoValue = entry->GeoValueL();
       
  1582 	// Default get on GEO values on the entry should return NULL 
       
  1583 	test(geoValue==NULL);
       
  1584 	
       
  1585 	// == Test Set and Get on the entry
       
  1586 	CCalGeoValue* geoValueSet = CCalGeoValue::NewL();
       
  1587 	CleanupStack::PushL(geoValueSet);
       
  1588 	
       
  1589 	// Set
       
  1590 	geoValueSet->SetLatLongL(TReal(KCalGEOMaxLatitude),TReal(KCalGEOMaxLongitude));
       
  1591 	// Set on entry
       
  1592 	entry->SetGeoValueL(*geoValueSet);
       
  1593 	
       
  1594 	CleanupStack::PopAndDestroy(geoValueSet);
       
  1595 	
       
  1596 	// Get and validate the retrieved CCalGeoValue
       
  1597 	// Get from entry
       
  1598 	CCalGeoValue* geoValueGet = entry->GeoValueL();
       
  1599 	CleanupStack::PushL(geoValueGet);
       
  1600 	TReal geoLat;
       
  1601 	TReal geoLong;
       
  1602 	// Get
       
  1603 	geoValueGet->GetLatLong(geoLat,geoLong);
       
  1604 	
       
  1605 	test(geoLat==KCalGEOMaxLatitude);
       
  1606 	test(geoLong==KCalGEOMaxLongitude);
       
  1607 	
       
  1608 	CleanupStack::PopAndDestroy(geoValueGet);
       
  1609 	
       
  1610 	// == Test clearing or resetting GEO value on the entry
       
  1611 	// Clear entry GEO values
       
  1612 	entry->ClearGeoValueL();
       
  1613 	
       
  1614 	// Retrieve GEO value from an entry when it has been cleared
       
  1615 	CCalGeoValue* geoValueClear = entry->GeoValueL();
       
  1616 	// Get on GEO values after clearing them on the entry should return NULL 
       
  1617 	test(geoValueClear==NULL);
       
  1618 
       
  1619 	CleanupStack::PopAndDestroy(entry);
       
  1620 	}
       
  1621 
       
  1622 void CEntryAttributesTestManager::TestGEOInternalizeAndExternalizeL()
       
  1623 	{
       
  1624 	// == Create a test entry with a GEO value
       
  1625 	HBufC8* guid = NULL;
       
  1626 
       
  1627 	CCalEntry* storeEntry = iTestLib->CreateCalEntryL(CCalEntry::EAppt,guid);
       
  1628 	CleanupStack::PushL(storeEntry);
       
  1629 	
       
  1630 	iTestLib->SetEntryStartAndEndTimeL(storeEntry);
       
  1631 	
       
  1632 	// Set GEO value on the entry to be stored
       
  1633 	CCalGeoValue* geoValueSet = CCalGeoValue::NewL();
       
  1634 	CleanupStack::PushL(geoValueSet);
       
  1635 	
       
  1636 	geoValueSet->SetLatLongL(TReal(KCalGEOMaxLatitude),TReal(KCalGEOMaxLongitude));
       
  1637 	storeEntry->SetGeoValueL(*geoValueSet);
       
  1638 	
       
  1639 	CleanupStack::PopAndDestroy(geoValueSet);
       
  1640 	
       
  1641 	// == Store Entry - Externalize to file
       
  1642 	iTestLib->StoreEntryL(*storeEntry);
       
  1643 
       
  1644 	TCalLocalUid storeEntryUid = storeEntry->LocalUidL();
       
  1645 	
       
  1646 	CleanupStack::PopAndDestroy(storeEntry);
       
  1647 	
       
  1648 	// Close file
       
  1649 	delete iTestLib;
       
  1650 	iTestLib = NULL;
       
  1651 	
       
  1652 	iTestLib = CCalTestLibrary::NewL(EFalse);
       
  1653 	iTestLib->OpenFileL(KCalName());
       
  1654 	
       
  1655 	// Re-open file - internalize from file
       
  1656 	CCalEntry* fetchEntry = iTestLib->SynCGetEntryViewL().FetchL(storeEntryUid);
       
  1657 	CleanupStack::PushL(fetchEntry); 
       
  1658 	
       
  1659 	// Get and validate the retrieved CCalGeoValue from the fetched entry 
       
  1660 	CCalGeoValue* geoValueGet = fetchEntry->GeoValueL();
       
  1661 	CleanupStack::PushL(geoValueGet);
       
  1662 	TReal geoLat;
       
  1663 	TReal geoLong;
       
  1664 	geoValueGet->GetLatLong(geoLat,geoLong);
       
  1665 	
       
  1666 	test(geoLat==KCalGEOMaxLatitude);
       
  1667 	test(geoLong==KCalGEOMaxLongitude);
       
  1668 	
       
  1669 	CleanupStack::PopAndDestroy(geoValueGet);	
       
  1670 	CleanupStack::PopAndDestroy(fetchEntry);	
       
  1671 	}
       
  1672 	
       
  1673 void CEntryAttributesTestManager::TestGEOCompareAndCopyFromL()
       
  1674 	{
       
  1675 	// Test Compare
       
  1676 	// Create two entries with GEO values and compare them
       
  1677 	// == First entry
       
  1678 	HBufC8* guidFirst = NULL;
       
  1679 
       
  1680 	CCalEntry* entryFirst = iTestLib->CreateCalEntryL(CCalEntry::EAppt,guidFirst);
       
  1681 	CleanupStack::PushL(entryFirst);
       
  1682 	
       
  1683 	iTestLib->SetEntryStartAndEndTimeL(entryFirst);
       
  1684 	
       
  1685 	// Set GEO value on the entry
       
  1686 	CCalGeoValue* geoValueFirst = CCalGeoValue::NewL();
       
  1687 	CleanupStack::PushL(geoValueFirst);
       
  1688 	
       
  1689 	geoValueFirst->SetLatLongL(TReal(KCalGEOMaxLatitude),TReal(KCalGEOMaxLongitude));
       
  1690 	entryFirst->SetGeoValueL(*geoValueFirst);
       
  1691 	
       
  1692 	CleanupStack::PopAndDestroy(geoValueFirst);
       
  1693 
       
  1694 	// == Second entry
       
  1695 	HBufC8* guidSecond = NULL;
       
  1696 
       
  1697 	CCalEntry* entrySecond = iTestLib->CreateCalEntryL(CCalEntry::EAppt,guidSecond);
       
  1698 	CleanupStack::PushL(entrySecond);
       
  1699 	
       
  1700 	iTestLib->SetEntryStartAndEndTimeL(entrySecond, entryFirst->StartTimeL().TimeUtcL(),entryFirst->EndTimeL().TimeUtcL());
       
  1701 	
       
  1702 	// Set GEO value on the entry
       
  1703 	CCalGeoValue* geoValueSecond = CCalGeoValue::NewL();
       
  1704 	CleanupStack::PushL(geoValueSecond);
       
  1705 	
       
  1706 	geoValueSecond->SetLatLongL(TReal(KCalGEOMaxLatitude),TReal(KCalGEOMaxLongitude));
       
  1707 	entrySecond->SetGeoValueL(*geoValueSecond);
       
  1708 	
       
  1709 	CleanupStack::PopAndDestroy(geoValueSecond);
       
  1710 
       
  1711 	// == Third entry
       
  1712 	HBufC8* guidThird = NULL;
       
  1713 
       
  1714 	CCalEntry* entryThird = iTestLib->CreateCalEntryL(CCalEntry::EAppt,guidThird);
       
  1715 	CleanupStack::PushL(entryThird);
       
  1716 	
       
  1717 	iTestLib->SetEntryStartAndEndTimeL(entryThird, entryFirst->StartTimeL().TimeUtcL(),entryFirst->EndTimeL().TimeUtcL());
       
  1718 	
       
  1719 	// Set GEO value on the entry
       
  1720 	CCalGeoValue* geoValueThird = CCalGeoValue::NewL();
       
  1721 	CleanupStack::PushL(geoValueThird);
       
  1722 	
       
  1723 	geoValueThird->SetLatLongL(TReal(KCalGEOMinLatitude),TReal(KCalGEOMinLongitude));
       
  1724 	entryThird->SetGeoValueL(*geoValueThird);
       
  1725 	
       
  1726 	CleanupStack::PopAndDestroy(geoValueThird);
       
  1727 
       
  1728 	test(entryFirst->CompareL(*entrySecond));
       
  1729 	test(!entryFirst->CompareL(*entryThird));
       
  1730 
       
  1731 	// Test CopyFrom
       
  1732 	// == Fourth entry
       
  1733 	HBufC8* guidFourth = NULL;
       
  1734 
       
  1735 	CCalEntry* entryFourth = iTestLib->CreateCalEntryL(CCalEntry::EAppt,guidFourth);
       
  1736 	CleanupStack::PushL(entryFourth);
       
  1737 	
       
  1738 	entryFourth->CopyFromL(*entrySecond);
       
  1739 	
       
  1740 	test(entryFourth->CompareL(*entrySecond));
       
  1741 	
       
  1742 	CleanupStack::PopAndDestroy(entryFourth);
       
  1743 	CleanupStack::PopAndDestroy(entryThird);
       
  1744 	CleanupStack::PopAndDestroy(entrySecond);	
       
  1745 	CleanupStack::PopAndDestroy(entryFirst);
       
  1746 	}
       
  1747 	
       
  1748 	
       
  1749 void CEntryAttributesTestManager::UpdateEntryHaveRdateOnlyL()
       
  1750 {
       
  1751 	    iTestLib->CleanDatabaseL();
       
  1752 	   	RPointerArray<CCalEntry> calEntryList;
       
  1753 		CleanupResetAndDestroyPushL(calEntryList);
       
  1754 
       
  1755 		_LIT8(KUid, "INC099532");
       
  1756 		HBufC8* guid = KUid().AllocLC();
       
  1757 
       
  1758 		CCalEntry* entry = CCalEntry::NewL(CCalEntry::EAppt, guid, CCalEntry::EMethodNone, 0);
       
  1759 		CleanupStack::Pop( guid );
       
  1760 		CleanupStack::PushL(entry);
       
  1761 		TTime startTime = TDateTime( 2006, EOctober, 24, 16, 0, 0, 0 );
       
  1762 		TTime endTime = TDateTime( 2006, EOctober, 24, 17, 0, 0, 0 );
       
  1763 
       
  1764 		TTime r1 = TDateTime( 2006, EOctober, 24, 16, 0, 0, 0 );
       
  1765 		TTime r2 = TDateTime( 2006, EOctober, 26, 16, 0, 0, 0 );
       
  1766 		TCalTime r1Cal;
       
  1767 		TCalTime r2Cal;
       
  1768 
       
  1769 		r1Cal.SetTimeLocalL( r1 );
       
  1770 		r2Cal.SetTimeLocalL( r2 );
       
  1771 
       
  1772 		TCalTime startCalTime;
       
  1773 		TCalTime endCalTime;
       
  1774 		startCalTime.SetTimeLocalL( startTime );
       
  1775 		endCalTime.SetTimeLocalL( endTime );
       
  1776 
       
  1777 		calEntryList.AppendL( entry );
       
  1778 		CleanupStack::Pop( entry );
       
  1779 		TInt success(0);
       
  1780 
       
  1781 		entry->SetStartAndEndTimeL( startCalTime, endCalTime );
       
  1782 
       
  1783 		//Fill RDates
       
  1784 		RArray<TCalTime> rDatesArray;
       
  1785 		CleanupClosePushL( rDatesArray );
       
  1786 		rDatesArray.AppendL( r1Cal );
       
  1787 		rDatesArray.AppendL( r2Cal );
       
  1788 		//Store the entry	
       
  1789 		entry->SetRDatesL( rDatesArray ); 
       
  1790 		iTestLib->SynCGetEntryViewL().StoreL(calEntryList, success);
       
  1791 		CleanupStack::PopAndDestroy( &rDatesArray );
       
  1792 		calEntryList.ResetAndDestroy();	
       
  1793 		//Fetch the entry	
       
  1794 		iTestLib->SynCGetEntryViewL().FetchL(KUid, calEntryList);
       
  1795 		test(calEntryList.Count()==1);
       
  1796 		//Update the first instance
       
  1797 		TCalTime recurrenceId;
       
  1798 		TTime recurrenceIdTime = TDateTime( 2006, EOctober, 24, 0, 0, 0, 0 );
       
  1799 		recurrenceId.SetTimeLocalL(recurrenceIdTime);
       
  1800 		guid = KUid().AllocLC();
       
  1801 		entry = CCalEntry::NewL(CCalEntry::EAppt, guid, CCalEntry::EMethodNone, 0, recurrenceId, CalCommon::EThisOnly);
       
  1802 		CleanupStack::Pop( guid );
       
  1803 		CleanupStack::PushL(entry);
       
  1804 			
       
  1805 		TTime newStartDate (TDateTime(2006, EOctober, 20, 16, 0, 0, 0));
       
  1806 		TTime newEndDate (TDateTime(2006, EOctober, 20, 18, 0, 0, 0));
       
  1807 			
       
  1808 		TCalTime newCalstartTime;
       
  1809 		newCalstartTime.SetTimeUtcL(newStartDate);
       
  1810 			
       
  1811 		TCalTime newCalendTime;
       
  1812 		newCalendTime.SetTimeUtcL(newEndDate);
       
  1813 			
       
  1814 		entry->SetStartAndEndTimeL(newCalstartTime, newCalendTime);
       
  1815 		 
       
  1816 		calEntryList.AppendL(entry);
       
  1817 		CleanupStack::Pop( entry );
       
  1818 		iTestLib->SynCGetEntryViewL().StoreL(calEntryList, success);
       
  1819 		CleanupStack::PopAndDestroy( &calEntryList );
       
  1820 			
       
  1821 		CalCommon::TCalViewFilter filter = CalCommon::EIncludeAll;
       
  1822 			
       
  1823 		TCalTime minTime;
       
  1824 		minTime.SetTimeUtcL(TCalTime::MinTime());
       
  1825 		TCalTime maxTime;
       
  1826 		maxTime.SetTimeUtcL(TCalTime::MaxTime());
       
  1827 		CalCommon::TCalTimeRange timeRange(minTime, maxTime);
       
  1828 			
       
  1829 		RPointerArray<CCalInstance> instances; 
       
  1830 		CleanupResetAndDestroyPushL(instances);
       
  1831 			
       
  1832 		iTestLib->SynCGetInstanceViewL().FindInstanceL(instances, filter, timeRange);
       
  1833 		TInt count = instances.Count();
       
  1834 		TBuf<100> tempBuf;	
       
  1835 		_LIT(KStartDateFormat,"Start Time: %H:%T:%S:%*C3 Date:%*1/%2/%3");
       
  1836 		_LIT(KEndDateFormat,"End Time: %H:%T:%S:%*C3 Date:%*1/%2/%3");
       
  1837 
       
  1838 		test(count==2);
       
  1839 		for (TInt i=0;i<count;i++)
       
  1840 			{
       
  1841 				TCalTime instancesStartTime = instances[i]->StartTimeL();	
       
  1842 				instancesStartTime.TimeLocalL().FormatL(tempBuf,KStartDateFormat);
       
  1843 				RDebug::Print(_L("%S\n\n"), &tempBuf);
       
  1844 				TCalTime instancesEndTime = instances[i]->EndTimeL();
       
  1845 				instancesEndTime.TimeLocalL().FormatL(tempBuf,KEndDateFormat);
       
  1846 				RDebug::Print(_L("%S\n\n"), &tempBuf);
       
  1847 				}
       
  1848 	CleanupStack::PopAndDestroy( &instances );
       
  1849 }
       
  1850 void CEntryAttributesTestManager::TestStartDateTestL()
       
  1851 	{
       
  1852 	_LIT8(KGuid, "guid-startdate");
       
  1853 	HBufC8* guid = KGuid().AllocLC();
       
  1854 	CCalEntry* entry = CCalEntry::NewL(CCalEntry::EAppt, guid, CCalEntry::EMethodNone, 0);
       
  1855 	CleanupStack::Pop(guid);
       
  1856 	CleanupStack::PushL(entry);
       
  1857 
       
  1858 	const TTime KOriginalStart(TDateTime(2006, ENovember, 12, 9, 0, 0, 0)); // 0900 on 13 Nov (Monday)
       
  1859 	const TTime KModifiedStart(TDateTime(2006, ENovember, 13, 11, 0, 0, 0)); // 1100 on 14 Nov (Tuesday)
       
  1860 	
       
  1861 	TCalTime startTime;
       
  1862 	startTime.SetTimeLocalL(KOriginalStart);
       
  1863 	entry->SetStartAndEndTimeL(startTime, startTime);
       
  1864 	
       
  1865 	TCalRRule rule(TCalRRule::EDaily);
       
  1866 	rule.SetDtStart(startTime);
       
  1867 	rule.SetCount(10);
       
  1868 	rule.SetInterval(7);
       
  1869 	entry->SetRRuleL(rule);
       
  1870 	iTestLib->StoreEntryL(*entry);
       
  1871 	TCalLocalUid luid = entry->LocalUidL();
       
  1872 	CleanupStack::PopAndDestroy(entry);
       
  1873 	//
       
  1874 	
       
  1875 	entry = iTestLib->SynCGetEntryViewL().FetchL(luid);
       
  1876 	CleanupStack::PushL(entry);
       
  1877 	
       
  1878 	TCalTime modifiedStartTime;
       
  1879 	modifiedStartTime.SetTimeLocalL(KModifiedStart);
       
  1880 	rule.SetDtStart(modifiedStartTime);
       
  1881 	rule.SetCount(10);
       
  1882 	entry->SetRRuleL(rule);
       
  1883 	iTestLib->StoreEntryL(*entry);
       
  1884 	
       
  1885 	const TTime KExpectedNewEntryStart(TDateTime(2006, ENovember, 13, 9, 0, 0, 0)); // 1100 on 14 Nov (Tuesday)
       
  1886  	TDateTime dt = entry->StartTimeL().TimeLocalL().DateTime();
       
  1887 	test(KExpectedNewEntryStart == dt);
       
  1888 	CleanupStack::PopAndDestroy(entry);
       
  1889 	}
       
  1890 	
       
  1891 void CEntryAttributesTestManager::TestStoreEntryWithTzL()
       
  1892 	{
       
  1893 	iTestLib->CleanDatabaseL();
       
  1894 	RPointerArray<CCalEntry> entriesToStore;
       
  1895 	CleanupResetAndDestroyPushL(entriesToStore);
       
  1896 //create a repeating entry (parent) and store it to the file
       
  1897 	_LIT8(KUid, "UID_EntryWithTz");
       
  1898 	HBufC8* guid = KUid().AllocLC();
       
  1899 	CCalEntry*	entry = CCalEntry::NewL(CCalEntry::EAppt, guid, CCalEntry::EMethodNone, 0);
       
  1900 	CleanupStack::Pop(guid);
       
  1901 	CleanupStack::PushL(entry);
       
  1902 	entriesToStore.AppendL(entry);
       
  1903 	CleanupStack::Pop(entry);
       
  1904 
       
  1905 	TTime startTime (TDateTime(2007, EFebruary, 1, 23, 30, 0, 0)); 
       
  1906 	TTime endTime (TDateTime(2007, EFebruary, 2, 0, 30, 0, 0)); 
       
  1907 	TTime rptendTime(TDateTime(2100, EDecember, 29, 0, 30, 0, 0));
       
  1908 	
       
  1909 	TCalTime calStartTime;
       
  1910 	calStartTime.SetTimeUtcL(startTime);
       
  1911 	TCalTime calEndTime;
       
  1912 	calEndTime.SetTimeUtcL(endTime);
       
  1913 	entry->SetStartAndEndTimeL(calStartTime, calEndTime);
       
  1914 	
       
  1915 	TCalRRule rpt = TCalRRule(TCalRRule::EWeekly);
       
  1916 
       
  1917 	RArray<TDay> days;
       
  1918 	CleanupClosePushL(days);
       
  1919 	days.AppendL(ESaturday);
       
  1920 	rpt.SetByDay(days);
       
  1921 	CleanupStack::PopAndDestroy(&days);
       
  1922 	
       
  1923 	TCalTime rptendTimeCal;
       
  1924 	rptendTimeCal.SetTimeUtcL(rptendTime);
       
  1925 
       
  1926 	rpt.SetDtStart(calStartTime);
       
  1927 	rpt.SetUntil(rptendTimeCal);
       
  1928 	rpt.SetInterval(1);
       
  1929 	entry->SetRRuleL(rpt);//take a copy of the rule
       
  1930 
       
  1931 
       
  1932 	RTz tz;
       
  1933 	User::LeaveIfError(tz.Connect());
       
  1934 	CleanupClosePushL(tz);
       
  1935 	_LIT8(KBeijing, "Asia/Hong_Kong");
       
  1936 	CTzId* tzId = CTzId::NewL(KBeijing);
       
  1937 	CleanupStack::PushL(tzId);
       
  1938 	CTzRules* tzBeijing = tz.GetTimeZoneRulesL(*tzId, startTime, rptendTime, ETzUtcTimeReference);
       
  1939 	CleanupStack::PopAndDestroy(tzId);
       
  1940 	CleanupStack::PushL(tzBeijing);
       
  1941 	entry->SetTzRulesL(*tzBeijing);
       
  1942 
       
  1943 	CleanupStack::PopAndDestroy(tzBeijing);
       
  1944 	CleanupStack::PopAndDestroy(&tz);
       
  1945 	
       
  1946 	TInt entriesStored;
       
  1947 	iTestLib->SynCGetEntryViewL().StoreL(entriesToStore, entriesStored);
       
  1948 	test(entriesStored ==1);
       
  1949 	entriesToStore.ResetAndDestroy();
       
  1950 	
       
  1951 	iTestLib->SynCGetEntryViewL().FetchL(KUid, entriesToStore);
       
  1952 	test(entriesToStore.Count() == 1);
       
  1953 	//Check the first instance datetime
       
  1954 	CalCommon::TCalViewFilter filter = CalCommon::EIncludeAll;
       
  1955 
       
  1956 	const TTime KFirstDayWithInstance(TDateTime(2007, EFebruary, 1, 23, 30, 0, 0));
       
  1957 
       
  1958 	TCalTime start;
       
  1959 	start.SetTimeLocalL(TCalTime::MinTime());
       
  1960 	TCalTime instanceFind = iTestLib->SynCGetInstanceViewL().NextInstanceL(filter, start);
       
  1961 	TTime instanceFindTTime = instanceFind.TimeLocalL();
       
  1962 	//The first instance date should be found
       
  1963 
       
  1964 	RDebug::Print(_L("Min time NextInstanceL"));
       
  1965 	TBuf<100> tempBuf;	
       
  1966 	_LIT(KTTimeDateFormat,"Time: %H:%T:%S:%*C3 Date:%*1/%2/%3");
       
  1967 	instanceFindTTime.FormatL(tempBuf,KTTimeDateFormat);
       
  1968 	RDebug::Print(_L("%S\n\n"), &tempBuf);
       
  1969 	
       
  1970 	test (instanceFindTTime == KFirstDayWithInstance);
       
  1971 	CleanupStack::PopAndDestroy(&entriesToStore);
       
  1972 	}
       
  1973 
       
  1974 
       
  1975 void CEntryAttributesTestManager::StoreAndExportL()
       
  1976 	{
       
  1977 	//Defect PDEF111565 
       
  1978 	RPointerArray<CCalEntry> entries;
       
  1979 	CleanupResetAndDestroyPushL(entries);
       
  1980 
       
  1981 	_LIT8(KGUID, "108188");
       
  1982 	HBufC8* guid = KGUID().AllocLC();
       
  1983 		
       
  1984 	CCalEntry* entry = CCalEntry::NewL(CCalEntry::EAppt, guid, CCalEntry::EMethodNone, 0);
       
  1985 	CleanupStack::Pop(guid);
       
  1986 	CleanupStack::PushL(entry);
       
  1987 	entries.AppendL(entry);
       
  1988 	CleanupStack::Pop(entry);
       
  1989 	
       
  1990 	TTime startTime = TDateTime(2007, EJune, 3, 07, 0, 0, 0);
       
  1991 	TTime endTime = TDateTime(2007, EJune, 3, 07, 30, 0, 0);
       
  1992 	TTime untilTime = TDateTime(2007, EJune, 10, 07, 0, 0, 0);
       
  1993  
       
  1994 	TCalTime startCalTime;
       
  1995 	TCalTime endCalTime;
       
  1996 	TCalTime untilCalTime;
       
  1997 	startCalTime.SetTimeUtcL(startTime);
       
  1998 	endCalTime.SetTimeUtcL(endTime);
       
  1999 	untilCalTime.SetTimeUtcL(untilTime);
       
  2000 	
       
  2001 	entry->SetStartAndEndTimeL(startCalTime, endCalTime);
       
  2002 	entry->SetSummaryL(_L("Weekly"));
       
  2003 
       
  2004 	TCalRRule weekly(TCalRRule::EWeekly);
       
  2005 	weekly.SetDtStart(startCalTime);
       
  2006 	weekly.SetUntil(untilCalTime);
       
  2007 	RArray<TDay> days;
       
  2008 	CleanupClosePushL(days);
       
  2009 	days.AppendL(EMonday);
       
  2010 	weekly.SetByDay(days);
       
  2011 	CleanupStack::PopAndDestroy(&days);
       
  2012 	entry->SetRRuleL(weekly);
       
  2013 	RArray<TCalTime> exceptions;
       
  2014 	CleanupClosePushL(exceptions);
       
  2015 	entry->SetExceptionDatesL(exceptions);//Set an empty exceptions that shouldn't set SetHasExceptions(ETrue)
       
  2016 	CleanupStack::PopAndDestroy(&exceptions);
       
  2017 	
       
  2018 	TInt numStored = 0;
       
  2019 	iTestLib->SynCGetEntryViewL().StoreL(entries, numStored);
       
  2020 	test(numStored == 1);
       
  2021 	
       
  2022 	entries.ResetAndDestroy();
       
  2023 	iTestLib->SynCGetEntryViewL().FetchL(KGUID(),entries);
       
  2024 	
       
  2025 	_LIT(KExportFile, "tcal_entry_108188.vcs");
       
  2026 	iTestLib->ExportL(KExportFile, entries);
       
  2027 	
       
  2028 	CleanupStack::PopAndDestroy(&entries);
       
  2029 	}
       
  2030 
       
  2031 
       
  2032 void CEntryAttributesTestManager::TestRdateL()
       
  2033 	{
       
  2034 	const TDesC8& uid1 = KGUID1();
       
  2035 	HBufC8* guid = uid1.AllocLC();
       
  2036 		
       
  2037 	CCalEntry* entry = CCalEntry::NewL(CCalEntry::EAppt, guid, CCalEntry::EMethodNone, 0);
       
  2038 	CleanupStack::Pop(guid);
       
  2039 	CleanupStack::PushL(entry);
       
  2040 	
       
  2041 	TTime startTime = TDateTime(2007, EJuly, 01, 16, 0, 0, 0);
       
  2042 	TTime endTime = TDateTime(2007, EJuly, 01, 17, 0, 0, 0);
       
  2043 	TTime untilTime = TDateTime(2007, EAugust, 05, 16, 0, 0, 0);
       
  2044  
       
  2045 	TTime rdate1 = TDateTime(2007, EJuly, 15, 16, 0, 0, 0);
       
  2046 	TTime rdate2 = TDateTime(2007, EJune, 17, 16, 0, 0, 0);
       
  2047 	
       
  2048 	// Fill RDates
       
  2049 	TCalTime calRdate1; // 16/07/2007 @ 16:00 UTC
       
  2050 	TCalTime calRdate2; // 18/06/2007 @ 16:00 UTC
       
  2051 	
       
  2052 	calRdate1.SetTimeUtcL(rdate1);
       
  2053 	calRdate2.SetTimeUtcL(rdate2);
       
  2054 	
       
  2055 	TCalTime startCalTime, endCalTime, untilCalTime;
       
  2056 	startCalTime.SetTimeUtcL(startTime);
       
  2057 	endCalTime.SetTimeUtcL(endTime);
       
  2058 	untilCalTime.SetTimeUtcL(untilTime);
       
  2059 	
       
  2060 	entry->SetStartAndEndTimeL(startCalTime, endCalTime);
       
  2061 	entry->SetSummaryL(_L("Weekly"));
       
  2062 	entry->SetLocationL(_L("Dallas"));
       
  2063 
       
  2064 	TCalRRule rptRule;
       
  2065 	
       
  2066 	rptRule.SetDtStart(startCalTime);
       
  2067 	rptRule.SetType(TCalRRule::EMonthly);
       
  2068 	
       
  2069 	RArray<TCalRRule::TDayOfMonth> byDayArray;
       
  2070 	CleanupClosePushL(byDayArray);
       
  2071 	TInt8 weekInMonth = 1;
       
  2072 	TDay day = EMonday;
       
  2073 	
       
  2074 	TCalRRule::TDayOfMonth byDay(day, weekInMonth);
       
  2075 	byDayArray.Append(byDay);
       
  2076 	
       
  2077 	rptRule.SetByDay(byDayArray);
       
  2078 	CleanupStack::PopAndDestroy(&byDayArray); 
       
  2079 	
       
  2080 	rptRule.SetUntil(untilCalTime);	 // 06/08/2007 @ 16:00 UTC
       
  2081 	rptRule.SetInterval(1);   // In 1 month period
       
  2082 	entry->SetRRuleL(rptRule);  // 1.st monday of the month
       
  2083 	
       
  2084 	RArray<TCalTime> rDatesArray;
       
  2085 	CleanupClosePushL(rDatesArray);
       
  2086 	rDatesArray.AppendL(calRdate1);
       
  2087 	rDatesArray.AppendL(calRdate2);
       
  2088 	
       
  2089 	entry->SetRDatesL(rDatesArray); 
       
  2090 	
       
  2091 	CleanupStack::PopAndDestroy(&rDatesArray);
       
  2092 
       
  2093 	RPointerArray<CCalEntry> entries;
       
  2094 	entries.AppendL(entry);
       
  2095 	CleanupStack::Pop(entry);
       
  2096 	CleanupResetAndDestroyPushL(entries);
       
  2097 	TInt numStored = 0;
       
  2098 	iTestLib->SynCGetEntryViewL().StoreL(entries, numStored);
       
  2099 	test(numStored == 1);
       
  2100 	
       
  2101 	CleanupStack::PopAndDestroy(&entries);
       
  2102 
       
  2103 	//------------------------------
       
  2104 	// Find all entries.
       
  2105 	//------------------------------
       
  2106 	TDateTime startDateTime(rdate2.DateTime());
       
  2107 	TDateTime endDateTime(rdate2.DateTime());
       
  2108 
       
  2109 	startDateTime.SetHour(0);
       
  2110 	startDateTime.SetMinute(0);
       
  2111 	startDateTime.SetSecond(0);
       
  2112 	startDateTime.SetMicroSecond(0);
       
  2113 
       
  2114 	endDateTime.SetHour(23);
       
  2115 	endDateTime.SetMinute(59);
       
  2116 	endDateTime.SetSecond(59);
       
  2117 	endDateTime.SetMicroSecond(0);
       
  2118 
       
  2119 	TCalTime endDate;
       
  2120 	endDate.SetTimeLocalL(TTime(endDateTime));
       
  2121 
       
  2122 	TCalTime startDate;
       
  2123 	startDate.SetTimeLocalL(TTime(startDateTime));
       
  2124 
       
  2125 	CalCommon::TCalTimeRange dayrange(startDate, endDate);
       
  2126 	CalCommon::TCalViewFilter filter = CalCommon::EIncludeAll;
       
  2127 
       
  2128 	RPointerArray<CCalInstance> instancesFound;
       
  2129 	CleanupResetAndDestroyPushL(instancesFound);
       
  2130 	iTestLib->SynCGetInstanceViewL().FindInstanceL(instancesFound, filter, dayrange);
       
  2131 
       
  2132 	for (TInt i = 0; i < instancesFound.Count(); i++)
       
  2133 		{
       
  2134 		TDateTime dt = instancesFound[i]->Time().TimeUtcL().DateTime();
       
  2135 		test.Printf(_L("Found instance on %d: %d/%d/%d"), i, 
       
  2136 			dt.Day()+1, dt.Month()+1, dt.Year(), dt.Hour());
       
  2137 		}
       
  2138 	
       
  2139 	test(instancesFound.Count() == 1);
       
  2140 	test(instancesFound[0]->Time().TimeUtcL() == rdate2);
       
  2141 	CleanupStack::PopAndDestroy(&instancesFound);
       
  2142 	}
       
  2143 
       
  2144 void CEntryAttributesTestManager::GetInstanceCrossDstL()
       
  2145 	{
       
  2146 	iTestLib->CleanDatabaseL();
       
  2147 	RPointerArray<CCalEntry> entries;
       
  2148 	CleanupResetAndDestroyPushL(entries);
       
  2149 	_LIT8(KUid,"nonExistTime_guid");
       
  2150 	HBufC8* guid = KUid().AllocLC();
       
  2151 	CCalEntry* entry = CCalEntry::NewL(CCalEntry::EAppt, guid, CCalEntry::EMethodNone, 0);
       
  2152 	CleanupStack::Pop(guid);
       
  2153 	CleanupStack::PushL(entry);
       
  2154 	TCalTime nonExistStartTime;
       
  2155 	TCalTime nonExistEndTime;
       
  2156 	nonExistStartTime.SetTimeLocalL(TDateTime(2007, EMarch, 10, 1, 1, 0, 0));
       
  2157 	nonExistEndTime.SetTimeLocalL(TDateTime(2007, EMarch, 10, 2, 1, 0, 0));
       
  2158 	entry->SetStartAndEndTimeL(nonExistStartTime, nonExistEndTime);
       
  2159 	
       
  2160 	TCalRRule rpt(TCalRRule::EDaily);
       
  2161 	rpt.SetDtStart(nonExistStartTime);
       
  2162 	rpt.SetInterval(1);
       
  2163 	rpt.SetCount(16);
       
  2164 	entry->SetRRuleL(rpt);//take a copy of the rule
       
  2165 	entries.AppendL(entry);
       
  2166 	CleanupStack::Pop(entry);
       
  2167 	TInt num;
       
  2168 	iTestLib->SynCGetEntryViewL().StoreL(entries, num);
       
  2169 	FindInstancesL(16);
       
  2170 	entries.ResetAndDestroy();
       
  2171 	iTestLib->CleanDatabaseL();
       
  2172 	FindInstancesL(0);
       
  2173 	guid = KUid().AllocLC();
       
  2174 	entry = CCalEntry::NewL(CCalEntry::EAppt, guid, CCalEntry::EMethodNone, 0);
       
  2175 	CleanupStack::Pop(guid);
       
  2176 	CleanupStack::PushL(entry);
       
  2177 	nonExistStartTime.SetTimeLocalL(TDateTime(2007, EMarch, 23, 2, 0, 0, 0));
       
  2178 	nonExistEndTime.SetTimeLocalL(TDateTime(2007, EMarch, 23, 2, 0, 0, 0));
       
  2179 	entry->SetStartAndEndTimeL(nonExistStartTime, nonExistEndTime);
       
  2180 	rpt.SetDtStart(nonExistStartTime);
       
  2181 	rpt.SetCount(3);
       
  2182 	entry->SetRRuleL(rpt);
       
  2183 	
       
  2184 	entries.AppendL(entry);
       
  2185 	CleanupStack::Pop(entry);
       
  2186 	iTestLib->SynCGetEntryViewL().StoreL(entries, num);
       
  2187 	FindInstancesL(3);
       
  2188 
       
  2189 	CleanupStack::PopAndDestroy(&entries);
       
  2190 	iTestLib->CleanDatabaseL();
       
  2191 //	
       
  2192 	}
       
  2193 
       
  2194 void CEntryAttributesTestManager::FindInstancesL(TInt aExpectedNumInstances)
       
  2195 	{
       
  2196 	RPointerArray<CCalInstance> instanceList;
       
  2197 	CleanupResetAndDestroyPushL(instanceList);
       
  2198 	CalCommon::TCalViewFilter filter = CalCommon::EIncludeAll;
       
  2199 	TCalTime minTime;
       
  2200 	minTime.SetTimeUtcL(TCalTime::MinTime());
       
  2201 	TCalTime maxTime;
       
  2202 	maxTime.SetTimeUtcL(TCalTime::MaxTime());
       
  2203 	CalCommon::TCalTimeRange timeRange(minTime, maxTime);
       
  2204 	iTestLib->SynCGetInstanceViewL().FindInstanceL(instanceList,filter,timeRange);
       
  2205 	TInt count = instanceList.Count();
       
  2206 	for(TInt i=0;i<instanceList.Count();i++)
       
  2207 		{
       
  2208 		TCalTime instanceStart = instanceList[i]->StartTimeL();
       
  2209 		TCalTime instanceEnd = instanceList[i]->EndTimeL();
       
  2210 		TTime instanceStartTTime = instanceStart.TimeLocalL();
       
  2211 		TTime instanceEndTTime = instanceEnd.TimeLocalL();
       
  2212 		RDebug::Print(_L("Next Instance start time"));
       
  2213 		TBuf<100> tempBuf;	
       
  2214 		_LIT(KTTimeDateFormat,"Time: %H:%T:%S:%*C3 Date:%*1/%2/%3");
       
  2215 		instanceStartTTime.FormatL(tempBuf,KTTimeDateFormat);
       
  2216 		RDebug::Print(_L("%S\n\n"), &tempBuf);
       
  2217 		instanceEndTTime.FormatL(tempBuf,KTTimeDateFormat);
       
  2218 		RDebug::Print(_L("%S\n\n"), &tempBuf);
       
  2219 		}
       
  2220 	
       
  2221 	test(aExpectedNumInstances == instanceList.Count());
       
  2222 	CleanupStack::PopAndDestroy(&instanceList);
       
  2223 		
       
  2224 	}
       
  2225 
       
  2226 
       
  2227 /** This testcase has been added to validate the fix for PDEF115349. 
       
  2228 The defect was reported on yearly repeating appointments with a 
       
  2229 repeat forever on 9.3. The time zone is changed to one with positive offset 
       
  2230 like Beijing or Sydney. An appointment is added with a repeat of yearly
       
  2231 on day. On editing the appointment, the repeat type is selected same as 
       
  2232 default entry's. The 'forever' option should be marked. 
       
  2233 */
       
  2234 void CEntryAttributesTestManager::TestEndTimeForeverL()
       
  2235 	{	
       
  2236 	test.Printf(_L("\nAdding an appointment which repeats forever"));
       
  2237 	TTime startTime(TDateTime(2007, EDecember, 0, 12, 0, 0, 0)); 
       
  2238 	TTime endTime(TCalTime::MaxTime()); 
       
  2239 	
       
  2240 	RTz tz;
       
  2241 	User::LeaveIfError(tz.Connect());
       
  2242 	CleanupClosePushL(tz);
       
  2243 	
       
  2244 	test.Printf(_L("Setting the time zone to Sydney"));
       
  2245 	iTestLib->SetTimeZoneL(_L8("Australia/Sydney"));
       
  2246 	_LIT8(KGUID, "Repeat Forever");
       
  2247 	HBufC8* guid = KGUID().AllocLC();
       
  2248 	CCalEntry* entry = CCalEntry::NewL(CCalEntry::EAppt, guid, CCalEntry::EMethodNone, 0);
       
  2249 	CleanupStack::Pop(guid);
       
  2250 
       
  2251 	TCalTime startTimeCal;
       
  2252 	startTimeCal.SetTimeLocalL(startTime);
       
  2253 	TCalTime endTimeCal;
       
  2254 	endTimeCal.SetTimeLocalL(endTime);
       
  2255 	entry->SetStartAndEndTimeL(startTimeCal, endTimeCal);
       
  2256 
       
  2257 	TCalRRule yearly(TCalRRule::EYearly);
       
  2258 	yearly.SetDtStart(startTimeCal);
       
  2259 	yearly.SetUntil(endTimeCal);
       
  2260 	
       
  2261 	TCalRRule::TDayOfMonth dayOfMonth(EThursday, 2);
       
  2262 	RArray<TCalRRule::TDayOfMonth> dayArray;
       
  2263 	dayArray.AppendL(dayOfMonth);
       
  2264 	yearly.SetByDay(dayArray);
       
  2265 	dayArray.Reset();
       
  2266 		
       
  2267 	RArray<TMonth> monthArray;
       
  2268 	monthArray.AppendL(EDecember);
       
  2269 	yearly.SetByMonth(monthArray);
       
  2270 	monthArray.Reset();
       
  2271 	
       
  2272 	entry->SetRRuleL(yearly);
       
  2273 	
       
  2274 	RPointerArray<CCalEntry> entries;
       
  2275 	TInt success(0);
       
  2276 	entries.AppendL(entry);
       
  2277 	iTestLib->SynCGetEntryViewL().StoreL(entries, success);
       
  2278 	test(success == 1);
       
  2279 	entries.ResetAndDestroy();
       
  2280 	
       
  2281 	iTestLib->SynCGetEntryViewL().FetchL(KGUID, entries);
       
  2282 	
       
  2283 	test.Printf(_L("Editing the entry. Storing the same details as before"));
       
  2284 	
       
  2285 	iTestLib->SynCGetEntryViewL().StoreL(entries, success);
       
  2286 	test(success == 1);
       
  2287 	
       
  2288 	TCalRRule rptRule;
       
  2289 	
       
  2290 	test(entries[0]->GetRRuleL(rptRule)); //Get the repeat rules of the entry
       
  2291 	TCalTime rptEndDate = rptRule.Until(); //Check the end date of the entry
       
  2292 	
       
  2293 	entries.ResetAndDestroy();
       
  2294 	
       
  2295 	TTime rptEndDateAsTTime = rptEndDate.TimeLocalL();
       
  2296 	
       
  2297 	test(rptEndDateAsTTime == TCalTime::MaxTime()); // Is the end time maxtime?
       
  2298 	test.Printf(_L("The entry repeats forever. Test is successful\n")); // Entry repeats forever
       
  2299 		
       
  2300 	iTestLib->SetTimeZoneL(KDefaultTimeZone);
       
  2301 	
       
  2302 	CleanupStack::PopAndDestroy(&tz);
       
  2303 	entries.ResetAndDestroy();
       
  2304 	}
       
  2305 
       
  2306 	
       
  2307 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
       
  2308  * DoTestL()
       
  2309  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
       
  2310 	
       
  2311 static void DoTestL()
       
  2312 	{
       
  2313 	CEntryAttributesTestManager* testManager = CEntryAttributesTestManager::NewLC();
       
  2314 
       
  2315 
       
  2316 	TPerformanceTimer timer(test);
       
  2317 	timer.Start();	
       
  2318 	
       
  2319 
       
  2320 	// Run the test suite
       
  2321 	testManager->TestFetchAndDeleteNonExistentEntryL();
       
  2322 
       
  2323 	testManager->CreateEntriesL();
       
  2324 	testManager->TestLiteEntriesL();
       
  2325 	
       
  2326 	/*
       
  2327 	 @SYMTestCaseID PIM-TCAL-ENTRYATTRIBUTES-Set_Get_Floating_Appointment-0001
       
  2328 	 */
       
  2329 	/*
       
  2330 	@SYMTestCaseID PIM-TCAL-ENTRYATTRIBUTES-Set_Get_Floating_Todo-0001
       
  2331 	 */
       
  2332 	/*
       
  2333 	@SYMTestCaseID PIM-TCAL-ENTRYATTRIBUTES-Set_Get_Floating_Event-0001
       
  2334 	 */
       
  2335 	/*
       
  2336 	@SYMTestCaseID PIM-TCAL-ENTRYATTRIBUTES-Set_Get_Floating_Anniversary-0001
       
  2337 	@SYMTestCaseDesc Set and get time for floating entries
       
  2338 	@SYMFssID App-Engines/CalInterimAPI/Data.007
       
  2339 	@SYMFssID App-Engines/CalInterimAPI/Data.009
       
  2340 	@SYMTestStatus Implemented
       
  2341 	@SYMTestPriority Medium
       
  2342 	@SYMTestActions Create floating appointment, todo, event and anniversary. Store into CalInterimAPI. 
       
  2343 	 				Get the lite entries to check that the time and time mode are the same. 
       
  2344 					Then get the full entries to check that the time and time mode are the same.
       
  2345 	@SYMTestExpectedResults The check shows that the time and time mode are as expected
       
  2346 	@SYMTestType CT	
       
  2347 	*/
       
  2348 	testManager->CreateEntriesL(ETrue);
       
  2349 	testManager->TestLiteEntriesL();
       
  2350 	testManager->TestLastChangedDateL();	
       
  2351 	testManager->TestCopySummaryAndDescriptionL();
       
  2352 	testManager->TestAlarmedCompletedTodoL();
       
  2353 	testManager->FindSummaryL();
       
  2354 	testManager->TestEndTimeBeforeStartTimeL();
       
  2355 	testManager->TestEndTimeNullL();
       
  2356 	testManager->TestEndTimeForeverL();
       
  2357 	testManager->TestAlarmedTodoWithoutDueDateL();
       
  2358 	
       
  2359 	// from former tcal_CopyEntryImpl
       
  2360 
       
  2361 	testManager->StoreAndExportL();
       
  2362 	
       
  2363 	testManager->CreateEntriesForCopyL();
       
  2364 	testManager->CreateEventForCopyPasteL();
       
  2365 	testManager->AddTwoRepeatingChildL();	
       
  2366 	testManager->TestGEOAttributesL();	
       
  2367 	testManager->UpdateEntryHaveRdateOnlyL();
       
  2368 	testManager->TestStartDateTestL();
       
  2369 	testManager->TestStoreEntryWithTzL();
       
  2370 	testManager->TestRdateL();
       
  2371 	testManager->GetInstanceCrossDstL();
       
  2372 	testManager->TestDeleteInstancesL(0);
       
  2373 	testManager->TestDeleteInstancesL(1);
       
  2374 	timer.Stop();
       
  2375 	test.Printf(_L("Done\n"));
       
  2376 	// printout performance time
       
  2377 	timer.PrintOut();
       
  2378 	
       
  2379 	CleanupStack::PopAndDestroy(testManager);
       
  2380 	}
       
  2381 
       
  2382 
       
  2383 /**
       
  2384 
       
  2385 @SYMTestCaseID     PIM-TCAL-ENTRYATTRIBUTES-0001
       
  2386 
       
  2387 */
       
  2388 
       
  2389 TInt E32Main()
       
  2390     {
       
  2391 	__UHEAP_MARK;
       
  2392 
       
  2393 	test.Start(_L("@SYMTESTCaseID:PIM-TCAL-ENTRYATTRIBUTES-0001 Calendar Interim API Entry Attributes test suite"));
       
  2394 
       
  2395 	test.Title();
       
  2396 
       
  2397 	CTrapCleanup* trapCleanup = CTrapCleanup::New();
       
  2398 	if (!trapCleanup)
       
  2399 		{
       
  2400 		return KErrNoMemory;
       
  2401 		}
       
  2402 
       
  2403 	CActiveScheduler* scheduler = new CActiveScheduler();
       
  2404 	if (!scheduler)
       
  2405 		{
       
  2406 		delete trapCleanup;
       
  2407 		return KErrNoMemory;
       
  2408 		}
       
  2409 	CActiveScheduler::Install(scheduler);	
       
  2410 
       
  2411 	TRAPD(ret, DoTestL());
       
  2412 	test(ret == KErrNone);
       
  2413 	
       
  2414 	delete scheduler;
       
  2415 	delete trapCleanup;	
       
  2416 
       
  2417 	test.End();
       
  2418 	test.Close();
       
  2419 
       
  2420 	__UHEAP_MARKEND;
       
  2421 
       
  2422 	return (KErrNone);
       
  2423     }