pimappservices/calendar/tsrc/tcal_dc.cpp
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 // Copyright (c) 2006-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 // tcal_dc - Test to ensure backwards compatibility between 9.1 and 9.2 Calendar files.
       
    15 // This test loads in files from v9.1 and v9.2 and verifies that they are converted correctly to v9.5.
       
    16 // 
       
    17 //
       
    18 
       
    19 // local includes
       
    20 #include "caltestlib.h"
       
    21 #include <calalarm.h>
       
    22 #include <calcategory.h>
       
    23 #include <calcategorymanager.h>
       
    24 #include <calcontent.h>
       
    25 #include <caldataformat.h>
       
    26 #include <caldataexchange.h>
       
    27 #include <calentry.h>
       
    28 #include <calentryview.h>
       
    29 #include <calinstance.h>
       
    30 #include <calinstanceview.h>
       
    31 #include <caliterator.h>
       
    32 #include <calsession.h>
       
    33 #include <caltime.h>
       
    34 #include <caluser.h>
       
    35 
       
    36 // System includes
       
    37 #include <e32test.h>
       
    38 #include <s32file.h>
       
    39 #include <calrrule.h>
       
    40 #include <vtzrules.h>
       
    41 
       
    42 // Uncomment out one of these line to regenerate the DC file from scratch against either v9.1 or v9.2 code
       
    43 // When running the test in v9.3, comment out both these lines.
       
    44 
       
    45 // Note that the .mmp file needs updating too.
       
    46 //#define __REGENERATE_9_1_DC_FILE__
       
    47 //#define __REGENERATE_9_2_DC_FILE__
       
    48 //#define __REGENERATE_9_4_DC_FILE__
       
    49 //#define __REGENERATE_9_5_DC_FILE__
       
    50 
       
    51 #if defined(__REGENERATE_9_1_DC_FILE__) || defined(__REGENERATE_9_2_DC_FILE__) || defined(__REGENERATE_9_4_DC_FILE__) || defined(__REGENERATE_9_5_DC_FILE__)
       
    52 #define __REGENERATE_DC_FILE__
       
    53 #endif
       
    54 
       
    55 #ifdef __REGENERATE_DC_FILE__
       
    56 
       
    57 #ifndef __REGENERATE_9_5_DC_FILE__
       
    58 #include "agmentry.h"
       
    59 #include "agmmodel.h"
       
    60 #include "..\..\agnmodel\agtest\agntestlibrary.h"
       
    61 #include <txtfmlyr.h>
       
    62 #endif
       
    63 
       
    64 _LIT(KCalendarFileToGenerate,"c:tcal_dc");
       
    65 #else
       
    66 
       
    67 _LIT(KCalendar81File,"tcal_dc_81");
       
    68 _LIT(KCalendar91File,"tcal_dc_91");
       
    69 _LIT(KCalendar92File,"tcal_dc_92");
       
    70 _LIT(KCalendar94File,"tcal_dc_94");
       
    71 _LIT(KCalendar95File,"tcal_dc_95");
       
    72 _LIT(KCalendar91LargeFile,"tcal_dc_91_1200");
       
    73 _LIT(KCalendar92CorruptFile,"tcal_dc_92_corrupt");
       
    74 
       
    75 #endif
       
    76 
       
    77 LOCAL_D RTest test(_L("tcal_dc"));
       
    78 
       
    79 const TDateTime KParentStartTDateTime(2006, EJanuary, 0, 0, 0, 0, 0);
       
    80 const TInt KParentDurationInHours = 2;
       
    81 
       
    82 _LIT(KParentLocation, "location 1");
       
    83 _LIT(KParentSummary, "summary 1");
       
    84 _LIT(KParentDescription, "description 1");
       
    85 
       
    86 _LIT(KParentAlarmName, "alarm name 1");
       
    87 _LIT8(KParentAlarmContent, "alarm content 1");
       
    88 _LIT8(KParentAlarmContentMimeType, "text/http");
       
    89 
       
    90 _LIT(KChildLocation, "location 2");
       
    91 _LIT(KChildSummary, "summary 2");
       
    92 _LIT(KChildDescription, "description 2");
       
    93 
       
    94 _LIT8(KGUID, "GUID");
       
    95 _LIT8(KWeeklyGUID, "weekly");
       
    96 _LIT8(KMonthlyByDayGUID, "monthly1");
       
    97 _LIT8(KMonthlyByDateGUID, "monthly2");
       
    98 _LIT8(KYearlyByDayGUID, "yearly1");
       
    99 _LIT8(KYearlyByDateGUID, "yearly2");
       
   100 
       
   101 const TDateTime KWeeklyStartTDateTime(2006, EJanuary, 2, 9, 0, 0, 0); // Tuesday
       
   102 const TDateTime KWeeklyUntilTDateTime(2006, EMarch, 3, 9, 0, 0, 0);
       
   103 
       
   104 const TDateTime KMonthlyByDayStartTDateTime(2006, EJanuary, 10, 9, 0, 0, 0); // second Wednesday
       
   105 const TDateTime KMonthlyByDayUntilTDateTime(2006, EOctober, 10, 9, 0, 0, 0);
       
   106 
       
   107 const TDateTime KMonthlyByDateStartTDateTime(2006, EJanuary, 24, 9, 0, 0, 0);
       
   108 const TDateTime KMonthlyByDateUntilTDateTime(2006, EAugust, 24, 9, 0, 0, 0);
       
   109 
       
   110 const TDateTime KYearlyByDayStartTDateTime(2006, EFebruary, 2, 9, 0, 0, 0); // 1st Fri in Feb
       
   111 const TDateTime KYearlyByDayUntilTDateTime(2008, EFebruary, 2, 9, 0, 0, 0);
       
   112 
       
   113 const TDateTime KYearlyByDateStartTDateTime(2006, EFebruary, 11, 9, 0, 0, 0);
       
   114 const TDateTime KYearlyByDateUntilTDateTime(2009, EFebruary, 11, 9, 0, 0, 0);
       
   115 
       
   116 const TDateTime	KEntryWithoutGuidTDateTime(2006, EApril, 17, 9, 0, 0, 0);
       
   117 
       
   118 const TDateTime KEntryAllPropLastModTDateTime(2006, EApril, 15, 12, 30, 2, 0);
       
   119 const TDateTime KEntryAllPropDTStampTDateTime(2006, EApril, 15, 13, 45, 0, 3);
       
   120 const TDateTime KEntryAllPropCompleteTDateTime(2006, EApril, 15, 16, 58, 0, 0);
       
   121 const TDateTime KEntryAllPropRDate1TDateTime(2006, EMay, 0, 12, 0, 0, 0);
       
   122 const TDateTime KEntryAllPropRDate2TDateTime(2006, EMay, 1, 18, 0, 0, 0);
       
   123 	
       
   124 _LIT(KUserDefinedCategoryName, "user-defined category");
       
   125 _LIT(KUserDefinedCategoryName2, "another user-defined one");
       
   126 
       
   127 _LIT(KAttendeeAddress1, "address 1");
       
   128 _LIT(KAttendeeSentBy1, "me@me.com");
       
   129 
       
   130 _LIT(KAttendeeAddress2, "house");
       
   131 _LIT(KAttendeeSentBy2, "1234567890@zxcvbnm.com");
       
   132 
       
   133 _LIT(KAttendeeAddress3, "road");
       
   134 _LIT(KAttendeeSentBy3, "@@@@@");
       
   135 
       
   136 _LIT8(KPacificAuckland, "Pacific/Auckland");
       
   137 _LIT8(KGUIDAllProperties, "all-props");
       
   138 
       
   139 _LIT8(KNegativeAlarmGUID, "negative_alarm");
       
   140 const TDateTime KNegativeAlarmEventTime(2006, EApril, 12, 9, 0, 0, 0);
       
   141 const TInt KNegativeAlarmOffset = -180;
       
   142 
       
   143 _LIT8(KSamedayAlarmGUID, "sameday_alarm");
       
   144 const TDateTime KSamedayAlarmEventTime(2006, EApril, 12, 8, 0, 0, 0);
       
   145 const TInt KSamedayAlarmOffset = 180;
       
   146 
       
   147 _LIT8(KPreviousDayAlarmGUID, "prevday_alarm");
       
   148 const TDateTime KPreviousDayAlarmEventTime(2006, EApril, 12, 7, 0, 0, 0);
       
   149 const TInt KPreviousDayAlarmOffset = 1440;
       
   150 
       
   151 _LIT8(KLargeOffsetAlarmGUID, "largeoffset_alarm");
       
   152 const TDateTime KLargeOffsetAlarmEventTime(2006, EApril, 12, 5, 0, 0, 0);
       
   153 const TInt KLargeOffsetAlarmOffset = 12345;
       
   154 
       
   155 _LIT8(KMidnightAlarmGUID, "midnight_alarm");
       
   156 const TDateTime KMidnightAlarmEventTime(2006, EApril, 12, 6, 0, 0, 0);
       
   157 const TInt KMidnightAlarmOffset = 360;
       
   158 
       
   159 _LIT8(KFloatingAppt, "floating_appt");
       
   160 const TDateTime KFloatingApptStartTime(2005, EDecember, 0, 9, 0, 0, 0);
       
   161 const TDateTime KFloatingApptEndTime(2005, EDecember, 1, 9, 0, 0, 0);
       
   162 const TDateTime KFloatingApptUntilTime(2005, EDecember, 29, 9, 0, 0, 0);
       
   163 
       
   164 _LIT8(KFloatingTodo, "floating_todo");
       
   165 const TDateTime KFloatingTodoStartTime(2005, EDecember, 0, 12, 0, 0, 0);
       
   166 const TDateTime KFloatingTodoEndTime(2005, EDecember, 1, 12, 0, 0, 0);
       
   167 const TDateTime KFloatingTodoUntilTime(2005, EDecember, 29, 12, 0, 0, 0);
       
   168 
       
   169 //
       
   170 
       
   171 class CCalEntryTestApp : public CBase, public MCalProgressCallBack
       
   172 	{
       
   173 public:
       
   174 	~CCalEntryTestApp();
       
   175 
       
   176 	void DoTestsL();
       
   177 	
       
   178 	// from MCalProgressCallBack
       
   179 	void Progress(TInt aPercentageCompleted);
       
   180 	void Completed(TInt aError);
       
   181 	TBool NotifyProgress();
       
   182 	
       
   183 private:
       
   184 	void StoreEntryL(CCalEntry* aEntry);
       
   185 	void CopyToCDriveL(const TDesC& aFileName);
       
   186 	void OpenBlankFileL();
       
   187 
       
   188  	void CreateDCFileL();
       
   189  	void AddParentAndChildEntriesL(CCalEntry::TType aType); 	
       
   190 	void AddRepeatRuleTypesL();
       
   191 	void AddEntryWithoutGUIDL();
       
   192 	void AddEntryWithAllPropertiesSetL();
       
   193 	void AddAlarmedEntriesL();
       
   194 	void AddAlarmedEntryL(const TDesC8& aGuid, const TTime& aEventTime, TInt aOffset);
       
   195 	void AddFloatingEntriesL();
       
   196 	void AddFloatingEntryL(CCalEntry::TType aType, const TDesC8& aGuid, const TTime& aStartTime, const TTime& aEndTime, const TTime& aUntilTime);
       
   197 
       
   198  	void TestFileLoadedL(TBool aTestAlarmAction);
       
   199  	void TestFileLoadedV94L();
       
   200  	void TestFileLoadedV95L();
       
   201  	void TestParentAndChildEntriesL(TBool aTestAlarmAction, TBool aTodoStartTimeStored);
       
   202  	void TestRepeatRuleTypesL();
       
   203 	void TestEntryWithoutGUIDL();
       
   204 	void TestEntryWithAllPropertiesSetL(TBool aTestTimeZoneYears);
       
   205 	void TestAlarmedEntriesL();
       
   206 	void TestAlarmedEntryL(const TDesC8& aGuid, TInt aOffset);
       
   207 	void TestFloatingEntriesL();
       
   208 	void TestFloatingEntryL(const TDesC8& aGuid, const TTime& aStartTime, const TTime& aEndTime, const TTime& aUntilTime);
       
   209 
       
   210 #ifndef __REGENERATE_DC_FILE__
       
   211 	void TestCategoriesL(const TDesC& aFile);
       
   212 	void TestFilterCategoriesL();
       
   213 	void TestAddCategoriesL();
       
   214 	void TestDeleteCategoriesL();
       
   215 	void TestCategoryWithoutBuiltIndexesL();
       
   216 	void TestOpeningFileDuringConversionL();
       
   217 
       
   218 	// old v9.2 tests
       
   219  	void V92AddEntriesDCFileL();
       
   220  	void V92ReadEntriesDCFileL();
       
   221  	void V92AddEntriesL(CCalEntry::TType aType);
       
   222  	void V92UpdateEntriesL();
       
   223  	void V92Test92CalendarFileCleanL();
       
   224 	void V92Test92CalendarFileEntriesAddedL();
       
   225 	void V92Test91CalendarFileCleanL();
       
   226 	void V92Test91CalendarFileEntriesAddedL();
       
   227 #endif
       
   228 
       
   229 private:
       
   230 	CCalTestLibrary* iTestLib;
       
   231 	HBufC8* iFileName;
       
   232 	TInt iErr;
       
   233 	};
       
   234 	
       
   235 //
       
   236 
       
   237 void CCalEntryTestApp::Progress(TInt )
       
   238 	{
       
   239 	}
       
   240 	
       
   241 void CCalEntryTestApp::Completed(TInt aError)
       
   242 	{
       
   243 	iErr = aError;
       
   244 	CActiveScheduler::Stop();
       
   245 	}
       
   246 
       
   247 TBool CCalEntryTestApp::NotifyProgress()
       
   248 	{
       
   249 	return EFalse;
       
   250 	}
       
   251 	
       
   252 void CCalEntryTestApp::CreateDCFileL()
       
   253 	{
       
   254 	// Create a number of entries to test DC.
       
   255 	// Repeating alarmed entry of each type with summary, location, description and alarm action, and a child entry
       
   256 	
       
   257 	AddEntryWithoutGUIDL();
       
   258 	
       
   259 	AddParentAndChildEntriesL(CCalEntry::EAppt);
       
   260 	AddParentAndChildEntriesL(CCalEntry::EEvent);
       
   261 	AddParentAndChildEntriesL(CCalEntry::EAnniv);
       
   262 	AddParentAndChildEntriesL(CCalEntry::EReminder);
       
   263 	AddParentAndChildEntriesL(CCalEntry::ETodo);
       
   264 	
       
   265 	AddRepeatRuleTypesL();
       
   266 	AddEntryWithAllPropertiesSetL();
       
   267 	AddAlarmedEntriesL();
       
   268 	AddFloatingEntriesL();
       
   269 	
       
   270 	TestFileLoadedL(EFalse);
       
   271 	}
       
   272 
       
   273 CCalEntryTestApp::~CCalEntryTestApp()
       
   274 	{
       
   275 	delete iTestLib;
       
   276 	}
       
   277 	
       
   278 void CCalEntryTestApp::TestFileLoadedL(TBool aTestAlarmAction)
       
   279 	{
       
   280 	test.Printf(_L("Checking calendar entry data...\n"));
       
   281  	TestParentAndChildEntriesL(aTestAlarmAction, EFalse);
       
   282  	TestRepeatRuleTypesL();
       
   283 	TestEntryWithoutGUIDL();
       
   284 	TestEntryWithAllPropertiesSetL(ETrue);
       
   285 	TestAlarmedEntriesL();
       
   286 	TestFloatingEntriesL();
       
   287 	}
       
   288 
       
   289 void CCalEntryTestApp::TestFileLoadedV94L()
       
   290 	{
       
   291 	test.Printf(_L("Checking calendar entry data...\n"));
       
   292  	TestParentAndChildEntriesL(ETrue, EFalse);
       
   293  	TestRepeatRuleTypesL();
       
   294 	TestEntryWithoutGUIDL();
       
   295 	TestEntryWithAllPropertiesSetL(EFalse);
       
   296 	TestAlarmedEntriesL();
       
   297 	TestFloatingEntriesL();
       
   298 	}
       
   299 
       
   300 void CCalEntryTestApp::TestFileLoadedV95L()
       
   301 	{
       
   302 	test.Printf(_L("Checking calendar entry data...\n"));
       
   303  	TestParentAndChildEntriesL(ETrue, ETrue);
       
   304  	TestRepeatRuleTypesL();
       
   305 	TestEntryWithAllPropertiesSetL(EFalse);
       
   306 	TestAlarmedEntriesL();
       
   307 	TestFloatingEntriesL();
       
   308 	}
       
   309 
       
   310 void CCalEntryTestApp::StoreEntryL(CCalEntry* aEntry)
       
   311 	{
       
   312 	RPointerArray<CCalEntry> entryArray;
       
   313 	CleanupClosePushL(entryArray);
       
   314 	TInt success = 0;
       
   315 	entryArray.AppendL(aEntry);
       
   316 	iTestLib->SynCGetEntryViewL().StoreL(entryArray, success);
       
   317 	CleanupStack::PopAndDestroy(&entryArray);
       
   318 	}
       
   319 	
       
   320 void CCalEntryTestApp::AddParentAndChildEntriesL(CCalEntry::TType aType)
       
   321 	{
       
   322 	TTime startTime = TTime(KParentStartTDateTime) + TTimeIntervalDays(aType);
       
   323 	
       
   324 	TBuf8<64> buffer;
       
   325 	buffer.Copy(KGUID);
       
   326 	buffer.AppendNum(aType);
       
   327 	HBufC8* hBuf = buffer.AllocLC();
       
   328 	CCalEntry* parentEntry = iTestLib->CreateCalEntryL(aType, hBuf);
       
   329 	CleanupStack::Pop(hBuf);
       
   330 	CleanupStack::PushL(parentEntry);
       
   331 	
       
   332 	TCalTime calStartTime, calEndTime;
       
   333 	calStartTime.SetTimeLocalL(startTime);
       
   334 	calEndTime.SetTimeLocalL(startTime + TTimeIntervalHours(KParentDurationInHours));
       
   335 	parentEntry->SetStartAndEndTimeL(calStartTime, calEndTime);
       
   336 	
       
   337 	parentEntry->SetLocationL(KParentLocation);
       
   338 	parentEntry->SetSummaryL(KParentSummary);
       
   339 	parentEntry->SetDescriptionL(KParentDescription);
       
   340 
       
   341 	CCalAlarm* alarm = CCalAlarm::NewL();
       
   342 	CleanupStack::PushL(alarm);
       
   343 	alarm->SetAlarmSoundNameL(KParentAlarmName);
       
   344 	alarm->SetTimeOffset(TTimeIntervalMinutes(5));
       
   345 	
       
   346 #ifndef __REGENERATE_9_1_DC_FILE__
       
   347 	CCalContent* alarmContent = CCalContent::NewL();
       
   348 	CleanupStack::PushL(alarmContent);
       
   349 	
       
   350 	HBufC8* urlContentBuf = KParentAlarmContent().AllocLC();
       
   351 	HBufC8* urlTypeBuf = KParentAlarmContentMimeType().AllocLC();
       
   352 	
       
   353 	alarmContent->SetContentL(urlContentBuf, urlTypeBuf, CCalContent::EDispositionUrl);
       
   354 	
       
   355 	alarm->SetAlarmAction(alarmContent);
       
   356 	CleanupStack::Pop(urlTypeBuf);
       
   357 	CleanupStack::Pop(urlContentBuf);
       
   358 	CleanupStack::Pop(alarmContent);
       
   359 #endif // __REGENERATE_9_2_DC_FILE__
       
   360 	
       
   361 	parentEntry->SetAlarmL(alarm);
       
   362 	CleanupStack::PopAndDestroy(alarm);
       
   363 
       
   364 	TCalRRule rule(TCalRRule::EDaily);
       
   365 	rule.SetInterval(1);
       
   366 	rule.SetDtStart(calStartTime);
       
   367 	rule.SetCount(100);
       
   368 	parentEntry->SetRRuleL(rule);
       
   369 	
       
   370 	StoreEntryL(parentEntry);
       
   371 	CleanupStack::PopAndDestroy(parentEntry);
       
   372 	
       
   373 	// create child entry
       
   374 	hBuf = buffer.AllocLC();
       
   375 	CCalEntry* childEntry = CCalEntry::NewL(aType, hBuf, CCalEntry::EMethodNone, 0, calStartTime, CalCommon::EThisOnly);
       
   376 	CleanupStack::Pop(hBuf);
       
   377 	CleanupStack::PushL(childEntry);
       
   378 	
       
   379 	childEntry->SetStartAndEndTimeL(calStartTime, calStartTime);
       
   380 	childEntry->SetLocationL(KChildLocation);
       
   381 	childEntry->SetSummaryL(KChildSummary);
       
   382 	childEntry->SetDescriptionL(KChildDescription);
       
   383 	
       
   384 	StoreEntryL(childEntry);
       
   385 	CleanupStack::PopAndDestroy(childEntry);
       
   386 	}
       
   387 
       
   388 void CCalEntryTestApp::TestParentAndChildEntriesL(TBool aTestAlarmAction, TBool aTodoStartTimeStored)
       
   389 	{
       
   390 	// check parent / child entries
       
   391 	TCalTime startDate;
       
   392 	startDate.SetTimeLocalL(TCalTime::MinTime());
       
   393 	TCalTime endDate;
       
   394 	endDate.SetTimeLocalL(TCalTime::MaxTime());
       
   395 	
       
   396 	CalCommon::TCalTimeRange timeRange(startDate, endDate);
       
   397 	CalCommon::TCalViewFilter filter = CalCommon::EIncludeAll|CalCommon::EIncludeRptsNextInstanceOnly;
       
   398 	
       
   399 	RPointerArray<CCalInstance> instanceArray;
       
   400 	iTestLib->SynCGetInstanceViewL().FindInstanceL(instanceArray, filter, timeRange);
       
   401 	test(instanceArray.Count() > 0);
       
   402 	
       
   403 	TInt instancesChecked = 0;
       
   404 	for (TInt i = 0; i < instanceArray.Count(); i++)
       
   405 		{
       
   406 		CCalEntry* entry = &instanceArray[i]->Entry();
       
   407 		if (entry->UidL().Left(KGUID().Length()) == KGUID())
       
   408 			{
       
   409 			instancesChecked++;
       
   410 			TCalRRule rule;
       
   411 			if (entry->GetRRuleL(rule))
       
   412 				{
       
   413 				// must be parent entry
       
   414 				CCalEntry::TType type = entry->EntryTypeL();
       
   415 				
       
   416 				TTime expectedLocalStartTime = TTime(KParentStartTDateTime) + TTimeIntervalDays(type);
       
   417 				TTime expectedLocalEndTime = expectedLocalStartTime + TTimeIntervalHours(KParentDurationInHours);
       
   418 				
       
   419 				if (type == CCalEntry::ETodo && !aTodoStartTimeStored)
       
   420 					{
       
   421 					expectedLocalStartTime = expectedLocalEndTime;
       
   422 					}
       
   423 				else if (type == CCalEntry::EReminder)
       
   424 					{
       
   425 					expectedLocalEndTime = Time::NullTTime();
       
   426 					}
       
   427 				
       
   428 #ifndef __REGENERATE_9_5_DC_FILE__				
       
   429 				test(entry->StartTimeL().TimeLocalL() == expectedLocalStartTime);
       
   430 #endif
       
   431 				test(entry->EndTimeL().TimeLocalL() == expectedLocalEndTime);
       
   432 				
       
   433 				test(entry->LocationL() == KParentLocation());
       
   434 				test(entry->SummaryL() == KParentSummary());
       
   435 				test(entry->DescriptionL() == KParentDescription());
       
   436 				test(rule.Count() == 100);
       
   437 				CCalAlarm* alarm = entry->AlarmL();
       
   438 				test(alarm->AlarmSoundNameL() == KParentAlarmName());
       
   439 				test(alarm->TimeOffset() == TTimeIntervalMinutes(5)); 
       
   440 #ifndef __REGENERATE_9_1_DC_FILE__
       
   441 				if (aTestAlarmAction)
       
   442 					{
       
   443 					CCalContent* content = alarm->AlarmAction();
       
   444 					
       
   445 					test(content->Content() == KParentAlarmContent());
       
   446 					test(content->MimeType() == KParentAlarmContentMimeType());
       
   447 					}
       
   448 #endif
       
   449 				delete alarm;
       
   450 				}
       
   451 			else
       
   452 				{
       
   453 				test(entry->LocationL() == KChildLocation());
       
   454 				test(entry->SummaryL() == KChildSummary());
       
   455 				test(entry->DescriptionL() == KChildDescription());
       
   456 				}
       
   457 			}
       
   458 		}
       
   459 		
       
   460 	test(instancesChecked > 0);
       
   461 	test(instancesChecked == 10); // 5 of each entry type
       
   462 	
       
   463 	instanceArray.ResetAndDestroy();
       
   464 	}
       
   465 
       
   466 
       
   467 void CCalEntryTestApp::AddRepeatRuleTypesL()
       
   468 	{
       
   469 	// weekly
       
   470 	HBufC8* wkGuid = KWeeklyGUID().AllocLC();
       
   471 	CCalEntry* wkEntry = CCalEntry::NewL(CCalEntry::EAppt, wkGuid, CCalEntry::EMethodNone, 0);
       
   472 	CleanupStack::Pop(wkGuid);
       
   473 	CleanupStack::PushL(wkEntry);
       
   474 	
       
   475 	TCalTime wkStart, wkUntil;
       
   476 	wkStart.SetTimeLocalL(TTime(KWeeklyStartTDateTime));
       
   477 	wkUntil.SetTimeLocalL(TTime(KWeeklyUntilTDateTime));
       
   478 	wkEntry->SetStartAndEndTimeL(wkStart, wkStart);
       
   479 	
       
   480 	TCalRRule wkRule(TCalRRule::EWeekly);
       
   481 	wkRule.SetDtStart(wkStart);
       
   482 	wkRule.SetUntil(wkUntil);
       
   483 	
       
   484 	RArray<TDay> wkDays;
       
   485 	CleanupClosePushL(wkDays);
       
   486 	wkDays.AppendL(ETuesday);
       
   487 	wkRule.SetByDay(wkDays);
       
   488 	CleanupStack::PopAndDestroy(&wkDays); // wkDays.Close()
       
   489 
       
   490 	wkEntry->SetRRuleL(wkRule);
       
   491 	StoreEntryL(wkEntry);
       
   492 	CleanupStack::PopAndDestroy(wkEntry);
       
   493 	
       
   494 	// monthly by day
       
   495 	HBufC8* mn1Guid = KMonthlyByDayGUID().AllocLC();
       
   496 	CCalEntry* mn1Entry = CCalEntry::NewL(CCalEntry::EAppt, mn1Guid, CCalEntry::EMethodNone, 0);
       
   497 	CleanupStack::Pop(mn1Guid);
       
   498 	CleanupStack::PushL(mn1Entry);
       
   499 	
       
   500 	TCalTime mn1Start, mn1Until;
       
   501 	mn1Start.SetTimeLocalL(TTime(KMonthlyByDayStartTDateTime));
       
   502 	mn1Until.SetTimeLocalL(TTime(KMonthlyByDayUntilTDateTime));
       
   503 	mn1Entry->SetStartAndEndTimeL(mn1Start, mn1Start);
       
   504 	
       
   505 	TCalRRule mn1Rule(TCalRRule::EMonthly);
       
   506 	mn1Rule.SetDtStart(mn1Start);
       
   507 	mn1Rule.SetUntil(mn1Until);
       
   508 	
       
   509 	RArray<TCalRRule::TDayOfMonth> mn1Days;
       
   510 	CleanupClosePushL(mn1Days);
       
   511 	mn1Days.AppendL(TCalRRule::TDayOfMonth(EWednesday, 2));
       
   512 	mn1Rule.SetByDay(mn1Days);
       
   513 	CleanupStack::PopAndDestroy(&mn1Days); // mn1Days.Close()
       
   514 
       
   515 	mn1Entry->SetRRuleL(mn1Rule);
       
   516 	StoreEntryL(mn1Entry);
       
   517 	CleanupStack::PopAndDestroy(mn1Entry);
       
   518 	
       
   519 	// monthly by date
       
   520 	HBufC8* mn2Guid = KMonthlyByDateGUID().AllocLC();
       
   521 	CCalEntry* mn2Entry = CCalEntry::NewL(CCalEntry::EAppt, mn2Guid, CCalEntry::EMethodNone, 0);
       
   522 	CleanupStack::Pop(mn2Guid);
       
   523 	CleanupStack::PushL(mn2Entry);
       
   524 	
       
   525 	TCalTime mn2Start, mn2Until;
       
   526 	mn2Start.SetTimeLocalL(TTime(KMonthlyByDateStartTDateTime));
       
   527 	mn2Until.SetTimeLocalL(TTime(KMonthlyByDateUntilTDateTime));
       
   528 	mn2Entry->SetStartAndEndTimeL(mn2Start, mn2Start);
       
   529 	
       
   530 	TCalRRule mn2Rule(TCalRRule::EMonthly);
       
   531 	mn2Rule.SetDtStart(mn2Start);
       
   532 	mn2Rule.SetUntil(mn2Until);
       
   533 	
       
   534 	RArray<TInt> mn2Days;
       
   535 	CleanupClosePushL(mn2Days);
       
   536 	mn2Days.AppendL(24);
       
   537 	mn2Rule.SetByMonthDay(mn2Days);
       
   538 	CleanupStack::PopAndDestroy(&mn2Days); // mn2Days.Close()
       
   539 
       
   540 	mn2Entry->SetRRuleL(mn2Rule);
       
   541 	StoreEntryL(mn2Entry);
       
   542 	CleanupStack::PopAndDestroy(mn2Entry);
       
   543 	
       
   544 	// yearly by day
       
   545 	HBufC8* yr1Guid = KYearlyByDayGUID().AllocLC();
       
   546 	CCalEntry* yr1Entry = CCalEntry::NewL(CCalEntry::EAppt, yr1Guid, CCalEntry::EMethodNone, 0);
       
   547 	CleanupStack::Pop(yr1Guid);
       
   548 	CleanupStack::PushL(yr1Entry);
       
   549 	
       
   550 	TCalTime yr1Start, yr1Until;
       
   551 	yr1Start.SetTimeLocalL(TTime(KYearlyByDayStartTDateTime));
       
   552 	yr1Until.SetTimeLocalL(TTime(KYearlyByDayUntilTDateTime));
       
   553 	yr1Entry->SetStartAndEndTimeL(yr1Start, yr1Start);
       
   554 	
       
   555 	TCalRRule yr1Rule(TCalRRule::EYearly);
       
   556 	yr1Rule.SetDtStart(yr1Start);
       
   557 	yr1Rule.SetUntil(yr1Until);
       
   558 	
       
   559 	RArray<TCalRRule::TDayOfMonth> yr1Days;
       
   560 	CleanupClosePushL(yr1Days);
       
   561 	yr1Days.AppendL(TCalRRule::TDayOfMonth(EFriday, 1));
       
   562 	yr1Rule.SetByDay(yr1Days);
       
   563 	CleanupStack::PopAndDestroy(&yr1Days); // yr1Days.Close()
       
   564 
       
   565 	RArray<TMonth> yr1Months;
       
   566 	CleanupClosePushL(yr1Months);
       
   567 	yr1Months.AppendL(EFebruary);
       
   568 	yr1Rule.SetByMonth(yr1Months);
       
   569 	CleanupStack::PopAndDestroy(&yr1Months); // yr1Months.Close()
       
   570 	
       
   571 	yr1Entry->SetRRuleL(yr1Rule);
       
   572 	StoreEntryL(yr1Entry);
       
   573 	CleanupStack::PopAndDestroy(yr1Entry);
       
   574 	
       
   575 	// yearly by date
       
   576 	HBufC8* yr2Guid = KYearlyByDateGUID().AllocLC();
       
   577 	CCalEntry* yr2Entry = CCalEntry::NewL(CCalEntry::EAppt, yr2Guid, CCalEntry::EMethodNone, 0);
       
   578 	CleanupStack::Pop(yr2Guid);
       
   579 	CleanupStack::PushL(yr2Entry);
       
   580 	
       
   581 	TCalTime yr2Start, yr2Until;
       
   582 	yr2Start.SetTimeLocalL(TTime(KYearlyByDateStartTDateTime));
       
   583 	yr2Until.SetTimeLocalL(TTime(KYearlyByDateUntilTDateTime));
       
   584 	yr2Entry->SetStartAndEndTimeL(yr2Start, yr2Start);
       
   585 	
       
   586 	TCalRRule yr2Rule(TCalRRule::EYearly);
       
   587 	yr2Rule.SetDtStart(yr2Start);
       
   588 	yr2Rule.SetUntil(yr2Until);
       
   589 	
       
   590 	yr2Entry->SetRRuleL(yr2Rule);
       
   591 	StoreEntryL(yr2Entry);
       
   592 	CleanupStack::PopAndDestroy(yr2Entry);
       
   593 	}
       
   594 
       
   595 void CCalEntryTestApp::TestRepeatRuleTypesL()
       
   596 	{
       
   597 	// check repeat rule types
       
   598 	RPointerArray<CCalEntry> entries;
       
   599 	CleanupResetAndDestroyPushL(entries);
       
   600 	
       
   601 	iTestLib->SynCGetEntryViewL().FetchL(KWeeklyGUID, entries);
       
   602 	test(entries.Count() == 1);
       
   603 	TCalRRule weekly;
       
   604 	entries[0]->GetRRuleL(weekly);
       
   605 	test(weekly.Type() == TCalRRule::EWeekly);
       
   606 	test(weekly.DtStart().TimeLocalL() == KWeeklyStartTDateTime);
       
   607 	test(weekly.Until().TimeLocalL() == KWeeklyUntilTDateTime);
       
   608 	RArray<TDay> wkDays;
       
   609 	weekly.GetByDayL(wkDays);
       
   610 	test(wkDays.Count() == 1);
       
   611 	test(wkDays[0] == ETuesday);
       
   612 	wkDays.Close();
       
   613 	entries.ResetAndDestroy();
       
   614 	
       
   615 	iTestLib->SynCGetEntryViewL().FetchL(KMonthlyByDayGUID, entries);
       
   616 	test(entries.Count() == 1);
       
   617 	TCalRRule monthly1;
       
   618 	entries[0]->GetRRuleL(monthly1);
       
   619 	test(monthly1.Type() == TCalRRule::EMonthly);
       
   620 	test(monthly1.DtStart().TimeLocalL() == KMonthlyByDayStartTDateTime);
       
   621 	test(monthly1.Until().TimeLocalL() == KMonthlyByDayUntilTDateTime);
       
   622 	RArray<TCalRRule::TDayOfMonth> monthDays;
       
   623 	monthly1.GetByDayL(monthDays);
       
   624 	test(monthDays.Count() == 1);
       
   625 	test(monthDays[0].Day() == EWednesday);
       
   626 	test(monthDays[0].WeekInMonth() == 2);
       
   627 	monthDays.Close();
       
   628 	entries.ResetAndDestroy();
       
   629 	
       
   630 	iTestLib->SynCGetEntryViewL().FetchL(KMonthlyByDateGUID, entries);
       
   631 	test(entries.Count() == 1);
       
   632 	TCalRRule monthly2;
       
   633 	entries[0]->GetRRuleL(monthly2);
       
   634 	test(monthly2.Type() == TCalRRule::EMonthly);
       
   635 	test(monthly2.DtStart().TimeLocalL() == KMonthlyByDateStartTDateTime);
       
   636 	test(monthly2.Until().TimeLocalL() == KMonthlyByDateUntilTDateTime);
       
   637 	RArray<TInt> monthDates;
       
   638 	monthly2.GetByMonthDayL(monthDates);
       
   639 	test(monthDates.Count() == 1);
       
   640 	test(monthDates[0] == 24);
       
   641 	monthDates.Close();
       
   642 	entries.ResetAndDestroy();
       
   643 	
       
   644 	iTestLib->SynCGetEntryViewL().FetchL(KYearlyByDayGUID, entries);
       
   645 	test(entries.Count() == 1);
       
   646 	TCalRRule yearly1;
       
   647 	entries[0]->GetRRuleL(yearly1);
       
   648 	test(yearly1.Type() == TCalRRule::EYearly);
       
   649 	test(yearly1.DtStart().TimeLocalL() == KYearlyByDayStartTDateTime);
       
   650 	test(yearly1.Until().TimeLocalL() == KYearlyByDayUntilTDateTime);
       
   651 	RArray<TMonth> months;
       
   652 	yearly1.GetByMonthL(months);
       
   653 	test(months.Count() == 1);
       
   654 	test(months[0] == EFebruary);
       
   655 	months.Close();
       
   656 	RArray<TCalRRule::TDayOfMonth> yearlyDayOfMonths;
       
   657 	yearly1.GetByDayL(yearlyDayOfMonths);
       
   658 	test(yearlyDayOfMonths.Count() == 1);
       
   659 	test(yearlyDayOfMonths[0].Day() == EFriday);
       
   660 	test(yearlyDayOfMonths[0].WeekInMonth() == 1);
       
   661 	yearlyDayOfMonths.Close();
       
   662 	entries.ResetAndDestroy();
       
   663 	
       
   664 	iTestLib->SynCGetEntryViewL().FetchL(KYearlyByDateGUID, entries);
       
   665 	test(entries.Count() == 1);
       
   666 	TCalRRule yearly2;
       
   667 	entries[0]->GetRRuleL(yearly2);
       
   668 	test(yearly2.Type() == TCalRRule::EYearly);
       
   669 	test(yearly2.DtStart().TimeLocalL() == KYearlyByDateStartTDateTime);
       
   670 	test(yearly2.Until().TimeLocalL() == KYearlyByDateUntilTDateTime);
       
   671 	entries.ResetAndDestroy();
       
   672 
       
   673 	CleanupStack::PopAndDestroy(&entries);
       
   674 	}
       
   675 
       
   676 void CCalEntryTestApp::AddEntryWithoutGUIDL()
       
   677 	{
       
   678 #if defined(__REGENERATE_DC_FILE__) && !defined(__REGENERATE_9_5_DC_FILE__)
       
   679 	CAgnTest* agnTest = CAgnTest::NewLC();
       
   680 	CAgnEntryModel* model = agnTest->CreateModelL(CAgnTest::EEntry, KCalendarFileToGenerate());
       
   681 	model->OpenL(KCalendarFileToGenerate(), 0, 0, 0);
       
   682 	
       
   683 	CAgnAppt* appt = static_cast<CAgnAppt*>(agnTest->CreateEntryLC(CAgnEntry::EAppt));
       
   684 	appt->SetStartAndEndDateTime(KEntryWithoutGuidTDateTime, KEntryWithoutGuidTDateTime);
       
   685 	model->AddEntryL(appt);
       
   686 	CleanupStack::PopAndDestroy(appt);
       
   687 	
       
   688 	CleanupStack::PopAndDestroy(agnTest);
       
   689 #endif
       
   690 	}
       
   691 
       
   692 void CCalEntryTestApp::TestEntryWithoutGUIDL()
       
   693 	{
       
   694 #if ! defined(__REGENERATE_9_5_DC_FILE__)
       
   695 	// check entry without guid
       
   696 	TCalTime startDate;
       
   697 	startDate.SetTimeLocalL(TTime(KEntryWithoutGuidTDateTime));
       
   698 	RPointerArray<CCalInstance> instanceArray;
       
   699 	CleanupResetAndDestroyPushL(instanceArray);
       
   700 	iTestLib->SynCGetInstanceViewL().FindInstanceL(instanceArray, CalCommon::EIncludeAll, CalCommon::TCalTimeRange(startDate, startDate));
       
   701 	test(instanceArray.Count() == 1);		
       
   702 	CCalEntry* entryWithoutGuid = &instanceArray[0]->Entry();
       
   703 	test(entryWithoutGuid != NULL);
       
   704 	TInt guidLength = entryWithoutGuid->UidL().Length();
       
   705 	test(guidLength > 0);
       
   706 	for (TInt i = 0; i < guidLength; i++)
       
   707 		{
       
   708 		TChar ch = entryWithoutGuid->UidL()[i];
       
   709 		test(ch >= '0' && ch <= '9');
       
   710 		}
       
   711 	test(entryWithoutGuid->StartTimeL().TimeLocalL() == KEntryWithoutGuidTDateTime);
       
   712 	CleanupStack::PopAndDestroy(); // instanceArray.ResetAndDestroy()
       
   713 #endif
       
   714 	}	
       
   715 
       
   716 void CCalEntryTestApp::AddEntryWithAllPropertiesSetL()
       
   717 	{
       
   718 	HBufC8* guid = KGUIDAllProperties().AllocLC();
       
   719 	CCalEntry* entry = CCalEntry::NewL(CCalEntry::ETodo, guid, CCalEntry::EMethodNone, 0);
       
   720 	CleanupStack::Pop(guid);
       
   721 	CleanupStack::PushL(entry);
       
   722 	
       
   723 	TCalTime dtStamp, compTime, rDate1, rDate2;
       
   724 	dtStamp.SetTimeLocalL(TTime(KEntryAllPropDTStampTDateTime));
       
   725 	compTime.SetTimeLocalL(TTime(KEntryAllPropCompleteTDateTime));
       
   726 	rDate1.SetTimeLocalL(TTime(KEntryAllPropRDate1TDateTime));
       
   727 	rDate2.SetTimeLocalL(TTime(KEntryAllPropRDate2TDateTime));
       
   728 
       
   729 	entry->SetDTStampL(dtStamp);
       
   730 	entry->SetCompletedL(ETrue, compTime);
       
   731 	
       
   732 	RArray<TCalTime> rDateList;
       
   733 	CleanupClosePushL(rDateList);
       
   734 	rDateList.AppendL(rDate1);
       
   735 	rDateList.AppendL(rDate2);
       
   736 	entry->SetRDatesL(rDateList);
       
   737 	
       
   738 	rDateList.Remove(0);
       
   739 	entry->SetExceptionDatesL(rDateList);
       
   740 	CleanupStack::PopAndDestroy(&rDateList);
       
   741 	
       
   742 	CCalCategory* cat1 = CCalCategory::NewL(CCalCategory::ECalHoliday);
       
   743 	CleanupStack::PushL(cat1);
       
   744 	entry->AddCategoryL(cat1);
       
   745 	CleanupStack::Pop(cat1);
       
   746 
       
   747 	CCalCategory* cat2 = CCalCategory::NewL(KUserDefinedCategoryName());
       
   748 	CleanupStack::PushL(cat2);
       
   749 	entry->AddCategoryL(cat2);
       
   750 	CleanupStack::Pop(cat2);
       
   751 
       
   752 	CCalAttendee* att1 = CCalAttendee::NewL(KAttendeeAddress1(), KAttendeeSentBy1());
       
   753 	CleanupStack::PushL(att1);
       
   754 	entry->AddAttendeeL(att1);
       
   755 	CleanupStack::Pop(att1);
       
   756 
       
   757 	CCalAttendee* att2 = CCalAttendee::NewL(KAttendeeAddress2(), KAttendeeSentBy2());
       
   758 	CleanupStack::PushL(att2);
       
   759 	entry->AddAttendeeL(att2);
       
   760 	entry->SetPhoneOwnerL(att2);
       
   761 	CleanupStack::Pop(att2);
       
   762 
       
   763 	CCalAttendee* att3 = CCalAttendee::NewL(KAttendeeAddress3(), KAttendeeSentBy3());
       
   764 	CleanupStack::PushL(att3);
       
   765 	entry->SetOrganizerL(att3);
       
   766 	CleanupStack::Pop(att3);
       
   767 	
       
   768 	entry->SetReplicationStatusL(CCalEntry::ERestricted);
       
   769 	entry->SetPriorityL(66);
       
   770 	
       
   771 	TTime startTime = TDateTime(2003, EJanuary, 0, 0, 0, 0, 0);
       
   772 	TTime endTime = startTime + TTimeIntervalYears(5);
       
   773 	
       
   774 	RTz tzServer;
       
   775 	CleanupClosePushL(tzServer);
       
   776 	User::LeaveIfError(tzServer.Connect());
       
   777 	
       
   778 	CTzId* tzId = CTzId::NewL(KPacificAuckland());
       
   779 	CleanupStack::PushL(tzId);
       
   780 	
       
   781 	CTzRules* rules = tzServer.GetTimeZoneRulesL(*tzId, startTime, endTime, ETzWallTimeReference);
       
   782 	CleanupStack::PushL(rules);
       
   783 	entry->SetTzRulesL(*rules);
       
   784 	CleanupStack::PopAndDestroy(rules);
       
   785 	
       
   786 	CleanupStack::PopAndDestroy(tzId);
       
   787 	CleanupStack::PopAndDestroy(&tzServer);
       
   788 
       
   789 	StoreEntryL(entry);
       
   790 	CleanupStack::PopAndDestroy(entry);
       
   791 	}
       
   792 
       
   793 void CCalEntryTestApp::TestEntryWithAllPropertiesSetL(TBool aTestTimeZoneYears)
       
   794 	{
       
   795 	// check entry with all properties set
       
   796 	RPointerArray<CCalEntry> entries;
       
   797 	CleanupResetAndDestroyPushL(entries);
       
   798 	iTestLib->SynCGetEntryViewL().FetchL(KGUIDAllProperties(), entries);
       
   799 	test(entries.Count() == 1);
       
   800 	CCalEntry* entryAllProperties = entries[0];
       
   801 	TTime lastModTime = entryAllProperties->LastModifiedDateL().TimeLocalL();
       
   802 	test(lastModTime > TCalTime::MinTime() && lastModTime < TCalTime::MaxTime());
       
   803 	test(entryAllProperties->DTStampL().TimeLocalL() == TTime(KEntryAllPropDTStampTDateTime));
       
   804 	test(entryAllProperties->CompletedTimeL().TimeLocalL() == TTime(KEntryAllPropCompleteTDateTime));
       
   805 	
       
   806 	RArray<TCalTime> rdates;
       
   807 	CleanupClosePushL(rdates);
       
   808 	entryAllProperties->GetRDatesL(rdates);
       
   809 	test(rdates.Count() == 2);
       
   810 	test(rdates[0].TimeLocalL() == TTime(KEntryAllPropRDate1TDateTime));
       
   811 	test(rdates[1].TimeLocalL() == TTime(KEntryAllPropRDate2TDateTime));
       
   812 	rdates.Reset();
       
   813 	
       
   814 	entryAllProperties->GetExceptionDatesL(rdates);
       
   815 	test(rdates.Count() == 1);
       
   816 	test(rdates[0].TimeLocalL() == TTime(KEntryAllPropRDate2TDateTime));
       
   817 	CleanupStack::PopAndDestroy(&rdates);
       
   818 	
       
   819 	RPointerArray<CCalCategory> categories = entryAllProperties->CategoryListL();
       
   820 	test(categories.Count() == 2);
       
   821 	test(categories[0]->Category() == CCalCategory::ECalHoliday);
       
   822 	test(categories[1]->Category() == CCalCategory::ECalExtended);
       
   823 	test(categories[1]->ExtendedCategoryName() == KUserDefinedCategoryName());
       
   824 
       
   825 	RPointerArray<CCalAttendee> attendees = entryAllProperties->AttendeesL();
       
   826 	test(attendees.Count() == 2);
       
   827 	test(attendees[0]->Address() == KAttendeeAddress1());
       
   828 	test(attendees[0]->SentBy() == KAttendeeSentBy1());
       
   829 	test(attendees[1]->Address() == KAttendeeAddress2());
       
   830 	test(attendees[1]->SentBy() == KAttendeeSentBy2());
       
   831 
       
   832 	test(entryAllProperties->ReplicationStatusL() == CCalEntry::ERestricted);
       
   833 	test(entryAllProperties->PriorityL() == 66);
       
   834 	
       
   835 	if (aTestTimeZoneYears)
       
   836 		{
       
   837 #if !(defined(__REGENERATE_9_5_DC_FILE__) || defined(__REGENERATE_9_4_DC_FILE__))  
       
   838 		// years are different in PREQ1090
       
   839 		CTzRules* rules = entryAllProperties->TzRulesL();
       
   840 		CleanupStack::PushL(rules);
       
   841 		test(rules != NULL);
       
   842 		test(rules->StartYear() == 2003);
       
   843 		test(rules->EndYear() == 2008);
       
   844 		CleanupStack::PopAndDestroy(rules);
       
   845 #endif
       
   846 		}
       
   847 	CleanupStack::PopAndDestroy(&entries);
       
   848 	}
       
   849 
       
   850 void CCalEntryTestApp::AddAlarmedEntriesL()
       
   851 	{
       
   852 	AddAlarmedEntryL(KNegativeAlarmGUID, KNegativeAlarmEventTime, KNegativeAlarmOffset);
       
   853 	AddAlarmedEntryL(KSamedayAlarmGUID, KSamedayAlarmEventTime, KSamedayAlarmOffset);
       
   854 	AddAlarmedEntryL(KPreviousDayAlarmGUID, KPreviousDayAlarmEventTime, KPreviousDayAlarmOffset);
       
   855 	AddAlarmedEntryL(KLargeOffsetAlarmGUID, KLargeOffsetAlarmEventTime, KLargeOffsetAlarmOffset);
       
   856 	AddAlarmedEntryL(KMidnightAlarmGUID, KMidnightAlarmEventTime, KMidnightAlarmOffset);
       
   857 	}
       
   858 
       
   859 void CCalEntryTestApp::AddAlarmedEntryL(const TDesC8& aGuid, const TTime& aEventTime, TInt aOffset)
       
   860 	{
       
   861 	HBufC8* guid = aGuid.AllocLC();
       
   862 	CCalEntry* entry = CCalEntry::NewL(CCalEntry::EAppt, guid, CCalEntry::EMethodNone, 0);
       
   863 	CleanupStack::Pop(guid);
       
   864 	CleanupStack::PushL(entry);
       
   865 	
       
   866 	TCalTime startTime;
       
   867 	if (aOffset < 0)
       
   868 		{
       
   869 		// negative offsets only valid on floating alarms
       
   870 		startTime.SetTimeLocalFloatingL(aEventTime);
       
   871 		}
       
   872 	else
       
   873 		{
       
   874 		startTime.SetTimeLocalL(aEventTime);
       
   875 		}
       
   876 	entry->SetStartAndEndTimeL(startTime, startTime);
       
   877 	
       
   878 	CCalAlarm* alarm = CCalAlarm::NewL();
       
   879 	CleanupStack::PushL(alarm);
       
   880 	alarm->SetTimeOffset(aOffset);
       
   881 	entry->SetAlarmL(alarm);
       
   882 	CleanupStack::PopAndDestroy(alarm);
       
   883 	
       
   884 	StoreEntryL(entry);
       
   885 	CleanupStack::PopAndDestroy(entry);
       
   886 	}
       
   887 	
       
   888 void CCalEntryTestApp::TestAlarmedEntriesL()
       
   889 	{
       
   890 	TestAlarmedEntryL(KNegativeAlarmGUID, KNegativeAlarmOffset);
       
   891 	TestAlarmedEntryL(KSamedayAlarmGUID, KSamedayAlarmOffset);
       
   892 	TestAlarmedEntryL(KPreviousDayAlarmGUID, KPreviousDayAlarmOffset);
       
   893 	TestAlarmedEntryL(KLargeOffsetAlarmGUID, KLargeOffsetAlarmOffset);
       
   894 	TestAlarmedEntryL(KMidnightAlarmGUID, KMidnightAlarmOffset);
       
   895 	}
       
   896 
       
   897 void CCalEntryTestApp::TestAlarmedEntryL(const TDesC8& aGuid, TInt aOffset)
       
   898 	{
       
   899 	RPointerArray<CCalEntry> entries;
       
   900 	CleanupResetAndDestroyPushL(entries);
       
   901 	
       
   902 	iTestLib->SynCGetEntryViewL().FetchL(aGuid, entries);
       
   903 	test(entries.Count() == 1);
       
   904 	CCalAlarm* alarm = entries[0]->AlarmL();
       
   905 	test(alarm->TimeOffset().Int()== aOffset);
       
   906 	delete alarm;
       
   907 	
       
   908 	CleanupStack::PopAndDestroy(&entries);
       
   909 	}
       
   910 
       
   911 void CCalEntryTestApp::AddFloatingEntriesL()
       
   912 	{
       
   913 	AddFloatingEntryL(CCalEntry::EAppt, KFloatingAppt(), KFloatingApptStartTime, KFloatingApptEndTime, KFloatingApptUntilTime);
       
   914 	AddFloatingEntryL(CCalEntry::ETodo, KFloatingTodo(), KFloatingTodoStartTime, KFloatingTodoEndTime, KFloatingTodoUntilTime);
       
   915 	}
       
   916 	
       
   917 void CCalEntryTestApp::AddFloatingEntryL(CCalEntry::TType aType, const TDesC8& aGuid, const TTime& aStartTime, const TTime& aEndTime, const TTime& aUntilTime)
       
   918 	{
       
   919 	HBufC8* guid = aGuid.AllocLC();
       
   920 	CCalEntry* entry = CCalEntry::NewL(aType, guid, CCalEntry::EMethodNone, 0);
       
   921 	CleanupStack::Pop(guid);
       
   922 	CleanupStack::PushL(entry);
       
   923 	
       
   924 	TCalTime startTime, endTime, untilTime;
       
   925 	startTime.SetTimeLocalFloatingL(aStartTime);
       
   926 	endTime.SetTimeLocalFloatingL(aEndTime);
       
   927 	untilTime.SetTimeLocalFloatingL(aUntilTime);
       
   928 	entry->SetStartAndEndTimeL(startTime, endTime);
       
   929 	
       
   930 	TCalRRule rule(TCalRRule::EDaily);
       
   931 	if (aType == CCalEntry::ETodo)
       
   932 		{
       
   933 		rule.SetDtStart(endTime);
       
   934 		}
       
   935 	else
       
   936 		{
       
   937 		rule.SetDtStart(startTime);
       
   938 		}
       
   939 	rule.SetUntil(untilTime);
       
   940 	entry->SetRRuleL(rule);
       
   941 	
       
   942 	StoreEntryL(entry);
       
   943 	CleanupStack::PopAndDestroy(entry);
       
   944 	}
       
   945 
       
   946 void CCalEntryTestApp::TestFloatingEntriesL()
       
   947 	{
       
   948 	TestFloatingEntryL(KFloatingAppt(), KFloatingApptStartTime, KFloatingApptEndTime, KFloatingApptUntilTime);
       
   949 	TestFloatingEntryL(KFloatingTodo(), KFloatingTodoStartTime, KFloatingTodoEndTime, KFloatingTodoUntilTime);	
       
   950 	}
       
   951 
       
   952 void CCalEntryTestApp::TestFloatingEntryL(const TDesC8& aGuid, const TTime& aStartTime, const TTime& aEndTime, const TTime& aUntilTime)
       
   953 	{
       
   954 	RPointerArray<CCalEntry> entries;
       
   955 	CleanupResetAndDestroyPushL(entries);
       
   956 	
       
   957 	iTestLib->SynCGetEntryViewL().FetchL(aGuid, entries);
       
   958 	test(entries.Count() == 1);
       
   959 	test(entries[0]->StartTimeL().TimeLocalL() == aStartTime);
       
   960 	test(entries[0]->EndTimeL().TimeLocalL() == aEndTime);
       
   961 	TCalRRule rule;
       
   962 	entries[0]->GetRRuleL(rule);
       
   963 	test(rule.Until().TimeLocalL() == aUntilTime);
       
   964 	
       
   965 	test(entries[0]->StartTimeL().TimeMode() == TCalTime::EFloating);
       
   966 	test(entries[0]->EndTimeL().TimeMode() == TCalTime::EFloating);
       
   967 #ifndef __REGENERATE_DC_FILE__
       
   968 	test(rule.Until().TimeMode() == TCalTime::EFloating);
       
   969 #endif 
       
   970 	
       
   971 	CleanupStack::PopAndDestroy(&entries);
       
   972 	}
       
   973 
       
   974 #ifndef __REGENERATE_DC_FILE__
       
   975 void CCalEntryTestApp::TestCategoriesL(const TDesC& aFile)
       
   976 	{
       
   977 	CalCommon::TCalFileVersionSupport status;
       
   978 	
       
   979 	CopyToCDriveL(aFile);
       
   980 	test.Printf(_L("Testing Using Categories without building indexes...\n"));
       
   981 	iTestLib->GetSession().OpenL(aFile, status);
       
   982 	TestCategoryWithoutBuiltIndexesL();
       
   983 	
       
   984 	CopyToCDriveL(aFile);
       
   985 	test.Printf(_L("Testing Filtering Categories...\n"));
       
   986 	iTestLib->GetSession().OpenL(aFile, status);
       
   987 	iTestLib->SynCGetEntryViewL();
       
   988 	TestFilterCategoriesL();
       
   989 
       
   990 	CopyToCDriveL(aFile);
       
   991 	test.Printf(_L("Testing Adding Categories...\n"));
       
   992 	iTestLib->DeleteViews();
       
   993 	iTestLib->GetSession().OpenL(aFile, status);
       
   994 	iTestLib->SynCGetEntryViewL();
       
   995 	TestAddCategoriesL();
       
   996 	
       
   997 	CopyToCDriveL(aFile);
       
   998 	test.Printf(_L("Testing Deleting Categories...\n"));
       
   999 	iTestLib->GetSession().OpenL(aFile, status);
       
  1000 	iTestLib->SynCGetEntryViewL();
       
  1001 	TestDeleteCategoriesL();
       
  1002 	iTestLib->DeleteFileL(aFile, ETrue);
       
  1003 	}
       
  1004 
       
  1005 void CCalEntryTestApp::TestFilterCategoriesL()
       
  1006 	{
       
  1007 	test.Printf(_L("Test opening an old file then filtering categories\n"));
       
  1008 	CCalCategoryManager* catMan = CCalCategoryManager::NewL(iTestLib->GetSession());
       
  1009 	CleanupStack::PushL(catMan);
       
  1010 
       
  1011 	RPointerArray<CCalEntry> entries;
       
  1012 	CleanupResetAndDestroyPushL(entries);
       
  1013 
       
  1014 	CCalCategory* cat1 = CCalCategory::NewL(KUserDefinedCategoryName());
       
  1015 	CleanupStack::PushL(cat1);
       
  1016 
       
  1017 	// find all entries in category
       
  1018 	catMan->FilterCategoryL(*cat1, entries, *iTestLib);
       
  1019 	CActiveScheduler::Start();
       
  1020 	
       
  1021 	test(entries.Count() == 1);
       
  1022 	test(entries[0]->UidL() == KGUIDAllProperties());
       
  1023 	entries.ResetAndDestroy();
       
  1024 
       
  1025 	CleanupStack::PopAndDestroy(cat1);
       
  1026 	CleanupStack::PopAndDestroy(&entries); // entries.ResetAndDestroy()
       
  1027 	CleanupStack::PopAndDestroy(catMan);
       
  1028 	}
       
  1029 
       
  1030 void CCalEntryTestApp::TestCategoryWithoutBuiltIndexesL()
       
  1031 	{
       
  1032 	test.Printf(_L("Test filtering categories before building the indexes\n"));
       
  1033 	CCalCategoryManager* catMan = CCalCategoryManager::NewL(iTestLib->GetSession());
       
  1034 	CleanupStack::PushL(catMan);
       
  1035 
       
  1036 	RPointerArray<CCalEntry> entries;
       
  1037 
       
  1038 	CCalCategory* cat1 = CCalCategory::NewL(KUserDefinedCategoryName());
       
  1039 	CleanupStack::PushL(cat1);
       
  1040 
       
  1041 	// find all entries in category
       
  1042 	catMan->FilterCategoryL(*cat1, entries, *this);
       
  1043 	CActiveScheduler::Start();
       
  1044 	
       
  1045 	test(iErr == KErrNotSupported);
       
  1046 	test(entries.Count() == 0);
       
  1047 
       
  1048 	CleanupStack::PopAndDestroy(cat1);
       
  1049 	CleanupStack::PopAndDestroy(catMan);
       
  1050 	}
       
  1051 
       
  1052 void CCalEntryTestApp::TestAddCategoriesL()
       
  1053 	{
       
  1054 	test.Printf(_L("Test opening an old file then adding categories\n"));
       
  1055 	CCalCategoryManager* catMan = CCalCategoryManager::NewL(iTestLib->GetSession());
       
  1056 	CleanupStack::PushL(catMan);
       
  1057 
       
  1058 	RPointerArray<CCalEntry> entries;
       
  1059 	CleanupResetAndDestroyPushL(entries);
       
  1060 
       
  1061 	CCalCategory* cat1 = CCalCategory::NewL(KUserDefinedCategoryName2());
       
  1062 	CleanupStack::PushL(cat1);
       
  1063 	catMan->AddCategoryL(*cat1);
       
  1064 	
       
  1065 	// find all entries in category
       
  1066 	catMan->FilterCategoryL(*cat1, entries, *iTestLib);
       
  1067 	CActiveScheduler::Start();
       
  1068 	
       
  1069 	test(entries.Count() == 0);
       
  1070 
       
  1071 	CleanupStack::PopAndDestroy(cat1);
       
  1072 	CleanupStack::PopAndDestroy(&entries); // entries.ResetAndDestroy()
       
  1073 	CleanupStack::PopAndDestroy(catMan);
       
  1074 	}
       
  1075 
       
  1076 void CCalEntryTestApp::TestDeleteCategoriesL()
       
  1077 	{
       
  1078 	test.Printf(_L("Test opening an old file then deleting categories\n"));
       
  1079 	CCalCategoryManager* catMan = CCalCategoryManager::NewL(iTestLib->GetSession());
       
  1080 	CleanupStack::PushL(catMan);
       
  1081 
       
  1082 	RPointerArray<CCalEntry> entries;
       
  1083 	CleanupResetAndDestroyPushL(entries);
       
  1084 
       
  1085 	CCalCategory* cat1 = CCalCategory::NewL(KUserDefinedCategoryName());
       
  1086 	CleanupStack::PushL(cat1);
       
  1087 
       
  1088 	// delete category
       
  1089 	catMan->DeleteCategoryL(*cat1, *iTestLib);
       
  1090 	CActiveScheduler::Start();
       
  1091 
       
  1092 	// find all entries in category
       
  1093 	TRAPD(err, catMan->FilterCategoryL(*cat1, entries, *iTestLib));
       
  1094 	test(err == KErrNotFound);
       
  1095 	test(entries.Count() == 0);
       
  1096 
       
  1097 	CleanupStack::PopAndDestroy(cat1);
       
  1098 	CleanupStack::PopAndDestroy(&entries); // entries.ResetAndDestroy()
       
  1099 	CleanupStack::PopAndDestroy(catMan);
       
  1100 	}
       
  1101 
       
  1102 //
       
  1103 // Tests written for v9.2 that should still work
       
  1104 //
       
  1105 // Add a parent and a child entry
       
  1106 //
       
  1107 void CCalEntryTestApp::V92AddEntriesL(CCalEntry::TType aType)
       
  1108 	{
       
  1109 	RPointerArray<CCalEntry> entryArray;
       
  1110 	CleanupResetAndDestroyPushL(entryArray);
       
  1111 	
       
  1112 	TTime startTime;
       
  1113 	startTime.HomeTime();
       
  1114 	startTime += TTimeIntervalDays(aType);
       
  1115 	
       
  1116 	TBuf8<64> buffer;
       
  1117 	iTestLib->RandomText8(buffer);
       
  1118 	HBufC8* hBuf = buffer.AllocLC();
       
  1119 	CCalEntry* parentEntry = iTestLib->CreateCalEntryL(aType, hBuf);
       
  1120 	CleanupStack::Pop(hBuf);
       
  1121 	
       
  1122 	TCalTime calStartTime;
       
  1123 	calStartTime.SetTimeLocalL(startTime);
       
  1124 	parentEntry->SetStartAndEndTimeL(calStartTime, calStartTime);
       
  1125 	
       
  1126 	parentEntry->SetLocationL(KParentLocation);
       
  1127 	parentEntry->SetSummaryL(KParentSummary);
       
  1128 	parentEntry->SetDescriptionL(KParentDescription);
       
  1129 
       
  1130 	CCalAlarm* alarm = CCalAlarm::NewL();
       
  1131 	CleanupStack::PushL(alarm);
       
  1132 	alarm->SetAlarmSoundNameL(KParentAlarmName);
       
  1133 	alarm->SetTimeOffset(TTimeIntervalMinutes(5));
       
  1134 	
       
  1135 	parentEntry->SetAlarmL(alarm);
       
  1136 	CleanupStack::PopAndDestroy(alarm);
       
  1137 
       
  1138 	TCalRRule rule(TCalRRule::EDaily);
       
  1139 	rule.SetInterval(1);
       
  1140 	rule.SetDtStart(calStartTime);
       
  1141 	rule.SetCount(100);
       
  1142 	parentEntry->SetRRuleL(rule);
       
  1143 	
       
  1144 	entryArray.AppendL(parentEntry);
       
  1145 	
       
  1146 	// create child entry
       
  1147 	hBuf = buffer.AllocLC();
       
  1148 	CCalEntry* childEntry = CCalEntry::NewL(aType, hBuf, CCalEntry::EMethodNone, 0, calStartTime, CalCommon::EThisOnly);
       
  1149 	CleanupStack::Pop(hBuf);
       
  1150 	
       
  1151 	entryArray.AppendL(childEntry);
       
  1152 	
       
  1153 	childEntry->SetStartAndEndTimeL(calStartTime, calStartTime);
       
  1154 	childEntry->SetLocationL(KChildLocation);
       
  1155 	childEntry->SetSummaryL(KChildSummary);
       
  1156 	childEntry->SetDescriptionL(KChildDescription);
       
  1157 		
       
  1158 	TInt success = 0;
       
  1159 	iTestLib->SynCGetEntryViewL().StoreL(entryArray, success);
       
  1160 	CleanupStack::PopAndDestroy(&entryArray);
       
  1161 	}
       
  1162 
       
  1163 void CCalEntryTestApp::V92AddEntriesDCFileL()
       
  1164 	{
       
  1165 	// Create a number of entries to test DC.
       
  1166 	// Repeating alarmed entry of each type with summary, location, description and alarm action, and a child entry
       
  1167 	V92AddEntriesL(CCalEntry::EAppt);
       
  1168 	V92AddEntriesL(CCalEntry::EEvent);
       
  1169 	V92AddEntriesL(CCalEntry::EAnniv);
       
  1170 	V92AddEntriesL(CCalEntry::EReminder);
       
  1171 	V92AddEntriesL(CCalEntry::ETodo);
       
  1172 	}
       
  1173 	
       
  1174 void CCalEntryTestApp::V92ReadEntriesDCFileL()
       
  1175 	{
       
  1176 	TCalTime startDate;
       
  1177 	startDate.SetTimeLocalL(TCalTime::MinTime());
       
  1178 	TCalTime endDate;
       
  1179 	endDate.SetTimeLocalL(TCalTime::MaxTime());
       
  1180 	
       
  1181 	CalCommon::TCalTimeRange timeRange(startDate, endDate);
       
  1182 	CalCommon::TCalViewFilter filter = CalCommon::EIncludeAll|CalCommon::EIncludeRptsNextInstanceOnly;
       
  1183 	
       
  1184 	RPointerArray<CCalInstance> instanceArray;
       
  1185 	iTestLib->SynCGetInstanceViewL().FindInstanceL(instanceArray, filter, timeRange);
       
  1186 	
       
  1187 	for (TInt i = 0; i < instanceArray.Count(); i++)
       
  1188 		{
       
  1189 		CCalEntry* entry = &instanceArray[i]->Entry();
       
  1190 		TCalRRule rule;
       
  1191 		if (entry->GetRRuleL(rule))
       
  1192 			{
       
  1193 			// must be parent entry
       
  1194 			test(entry->LocationL() == KParentLocation());
       
  1195 			test(entry->SummaryL() == KParentSummary());
       
  1196 			test(entry->DescriptionL() == KParentDescription());
       
  1197 			test(rule.Count() == 100);
       
  1198 			CCalAlarm* alarm = entry->AlarmL();
       
  1199 			test(alarm->AlarmSoundNameL() == KParentAlarmName());
       
  1200 			delete alarm;
       
  1201 			}
       
  1202 		else
       
  1203 			{
       
  1204 			test(entry->LocationL() == KChildLocation());
       
  1205 			test(entry->SummaryL() == KChildSummary());
       
  1206 			test(entry->DescriptionL() == KChildDescription());
       
  1207 			}
       
  1208 		}
       
  1209 	
       
  1210 	// check stuff
       
  1211 	instanceArray.ResetAndDestroy();
       
  1212 	}
       
  1213 
       
  1214 // Fetch and update all the entries - parent and child in the Calendar file
       
  1215 void CCalEntryTestApp::V92UpdateEntriesL()
       
  1216 	{
       
  1217 	CCalIter* entryIter = CCalIter::NewL(iTestLib->GetSession());
       
  1218 	CleanupStack::PushL(entryIter);
       
  1219 	TPtrC8 uidIter(entryIter->FirstL());
       
  1220 
       
  1221 	RPointerArray<CCalEntry> calEntryArray;
       
  1222 	CleanupResetAndDestroyPushL(calEntryArray);
       
  1223 	
       
  1224 	RPointerArray<CCalEntry> tempEntryArray;
       
  1225 	CleanupClosePushL(tempEntryArray);
       
  1226 	
       
  1227 	CCalEntry* entry = NULL;
       
  1228 		
       
  1229 	TInt successEntryCount=0;
       
  1230 
       
  1231 	// Iterate through all the entries' UIDs and fetch all the entries (parent and child) with the UID
       
  1232 	// Call UpdateL on Parent Entries and StoreL on Child Entries
       
  1233 	while (uidIter != KNullDesC8())
       
  1234 		{
       
  1235 		iTestLib->SynCGetEntryViewL().FetchL(uidIter,calEntryArray);
       
  1236 		
       
  1237 		for(TInt entryCount=0;entryCount<calEntryArray.Count();++entryCount)
       
  1238 			{
       
  1239 			entry = calEntryArray[entryCount];
       
  1240 
       
  1241 			tempEntryArray.AppendL(calEntryArray[entryCount]);
       
  1242 			
       
  1243 			if(entry->RecurrenceIdL().TimeUtcL()==Time::NullTTime())
       
  1244 				{
       
  1245 				// Parent Entry
       
  1246 				entry->SetLocationL(_L("Updated Parent Location 1"));
       
  1247 				entry->SetSummaryL(_L("Updated Parent Summary 1"));
       
  1248 				entry->SetDescriptionL(_L("Updated Parent Description 1"));
       
  1249 
       
  1250 				successEntryCount=0;
       
  1251 				iTestLib->SynCGetEntryViewL().UpdateL(tempEntryArray, successEntryCount);
       
  1252 				test(successEntryCount==1);
       
  1253 				}
       
  1254 			else
       
  1255 				{
       
  1256 				// Child Entry
       
  1257 				entry->SetLocationL(_L("Updated Child Location 1"));
       
  1258 				entry->SetSummaryL(_L("Updated Child Summary 1"));
       
  1259 				entry->SetDescriptionL(_L("Updated Child Description 1"));
       
  1260 				
       
  1261 				successEntryCount=0;
       
  1262 				//iTestLib->SynCGetEntryViewL().StoreL(RPointerArray<CCalEntry>(&calEntryArray[entryCount],1),successEntryCount);
       
  1263 				iTestLib->SynCGetEntryViewL().StoreL(tempEntryArray, successEntryCount);
       
  1264 				test(successEntryCount==1);
       
  1265 				}
       
  1266 				
       
  1267 			tempEntryArray.Reset();
       
  1268 			}
       
  1269 		calEntryArray.ResetAndDestroy();
       
  1270 		uidIter.Set(entryIter->NextL());
       
  1271 		}
       
  1272 	CleanupStack::PopAndDestroy(&tempEntryArray);
       
  1273 	CleanupStack::PopAndDestroy(&calEntryArray);
       
  1274 	CleanupStack::PopAndDestroy(entryIter);
       
  1275 	}
       
  1276 	
       
  1277 // ===========
       
  1278 // 9.2 Calendar File - Clean / No entries
       
  1279 // ===========
       
  1280 
       
  1281 
       
  1282 void CCalEntryTestApp::V92Test92CalendarFileCleanL()
       
  1283 	{
       
  1284 	test.Next(_L("9.2 Calendar File - Clean / No entries"));
       
  1285 
       
  1286 	
       
  1287 	_LIT(KOriginalCalendarFileBravoCleanFullPath, "z:\\private\\10003a5b\\tcal_dc_92_CalFile_Clean");
       
  1288 	_LIT(KCalendarFileBravoCleanFullPath, "c:\\private\\10003a5b\\tcal_dc_92_CalFile_Clean");
       
  1289 	_LIT(KCalendarFileBravoCleanTestFullPath, "c:\\private\\10003a5b\\tcal_dc_92_CalFile_Clean_Test");
       
  1290 	
       
  1291 	_LIT(KCalendarFileBravoCleanTest, "c:tcal_dc_92_CalFile_Clean_Test");
       
  1292 
       
  1293 	// Copy the 9.2 Calendar file from the ROM drive to the C: to enable writing into it
       
  1294 	iTestLib->PIMTestServer().CopyFileL(KOriginalCalendarFileBravoCleanFullPath, KCalendarFileBravoCleanFullPath);
       
  1295 	
       
  1296 	// Step 1 = Create a copy of a clean (no entries) Bravo v9.2 Calendar file for test purposes
       
  1297 	iTestLib->PIMTestServer().CopyFileL(KCalendarFileBravoCleanFullPath, KCalendarFileBravoCleanTestFullPath);
       
  1298 	
       
  1299 	// Step 2 = Open the 9.2 test Calendar file
       
  1300 	iTestLib->OpenFileL(KCalendarFileBravoCleanTest());
       
  1301 	
       
  1302 	// Step 3 = Add multiple 9.2 parent and child entries to the 9.2 test Calendar file
       
  1303 	V92AddEntriesDCFileL();
       
  1304 	
       
  1305 	// Step 4 = Read and verify previously added 9.2 multiple parent and child entries within the 9.2 test Calendar file
       
  1306 	V92ReadEntriesDCFileL();
       
  1307 	
       
  1308 	// Step 5 = Update all entries in the 9.2 Calendar file	
       
  1309 	V92UpdateEntriesL();
       
  1310 	
       
  1311 	// Step 6 = Delete all entries in the 9.2 Calendar file	
       
  1312 	iTestLib->CleanDatabaseL();
       
  1313 	
       
  1314 	// Step 7 = Delete the 9.2 test Calendar files
       
  1315 	iTestLib->DeleteFileL(KCalendarFileBravoCleanTest());
       
  1316 	iTestLib->PIMTestServer().DeleteFileL(KCalendarFileBravoCleanFullPath());
       
  1317 	}
       
  1318 
       
  1319 // ===========
       
  1320 // 9.2 Calendar File - Previously Added Entries
       
  1321 // ===========
       
  1322 
       
  1323 
       
  1324 void CCalEntryTestApp::V92Test92CalendarFileEntriesAddedL()
       
  1325 	{
       
  1326 	test.Next(_L("Calendar File - Previously Added Entries"));
       
  1327 
       
  1328 	
       
  1329 	_LIT(KOriginalCalendarFileBravoEntriesAddedFullPath, "z:\\private\\10003a5b\\tcal_dc_92_CalFile_EntriesAdded");
       
  1330 	_LIT(KCalendarFileBravoEntriesAddedFullPath, "c:\\private\\10003a5b\\tcal_dc_92_CalFile_EntriesAdded");
       
  1331 	_LIT(KCalendarFileBravoTestEntriesAddedFullPath, "c:\\private\\10003a5b\\tcal_dc_92_CalFile_EntriesAdded_Test");
       
  1332 	
       
  1333 	_LIT(KCalendarFileBravoTestEntriesAdded,"c:tcal_dc_92_CalFile_EntriesAdded_Test");
       
  1334 	
       
  1335 	// Copy the 9.2 Calendar file from the ROM drive to the C: to enable writing into it
       
  1336 	iTestLib->PIMTestServer().CopyFileL(KOriginalCalendarFileBravoEntriesAddedFullPath, KCalendarFileBravoEntriesAddedFullPath);
       
  1337 	
       
  1338 	// Step 1 = Create a copy of Bravo v9.2 Calendar file saved earlier with 9.2 entries for test purposes
       
  1339 	iTestLib->PIMTestServer().CopyFileL(KCalendarFileBravoEntriesAddedFullPath, KCalendarFileBravoTestEntriesAddedFullPath);
       
  1340 	
       
  1341 	// Step 2 = Open the 9.2 test Calendar file
       
  1342 	iTestLib->OpenFileL(KCalendarFileBravoTestEntriesAdded());
       
  1343 	
       
  1344 	// Step 3 = Read and verify previously added 9.2 multiple parent and child entries within the 9.2 test environment
       
  1345 	V92ReadEntriesDCFileL();
       
  1346 	
       
  1347 	// Step 4 = Delete all entries in the 9.2 Calendar file	
       
  1348 	iTestLib->CleanDatabaseL();
       
  1349 	
       
  1350 	// Step 5 = Add multiple 9.2 parent and child entries to the 9.2 test Calendar file
       
  1351 	V92AddEntriesDCFileL();
       
  1352 	
       
  1353 	// Step 6 = Read and verify previously added 9.2 multiple parent and child entries within the 9.2 test Calendar file
       
  1354 	V92ReadEntriesDCFileL();
       
  1355 	
       
  1356 	// Step 7 = Update all entries in the 9.2 Calendar file	
       
  1357 	V92UpdateEntriesL();
       
  1358 	
       
  1359 	// Step 8 = Delete all entries in the 9.2 Calendar file	
       
  1360 	iTestLib->CleanDatabaseL();
       
  1361 
       
  1362 	// Step 9 = Delete the 9.2 test Calendar files
       
  1363 	iTestLib->DeleteFileL(KCalendarFileBravoTestEntriesAdded());
       
  1364 	iTestLib->PIMTestServer().DeleteFileL(KCalendarFileBravoEntriesAddedFullPath());
       
  1365 	}
       
  1366 
       
  1367 // ===========
       
  1368 // 9.1 Calendar File - Clean / No entries
       
  1369 // ===========
       
  1370 
       
  1371 
       
  1372 void CCalEntryTestApp::V92Test91CalendarFileCleanL()
       
  1373 	{
       
  1374 	test.Next(_L("9.1 Calendar File - Clean / No Entries"));
       
  1375 
       
  1376 	
       
  1377 	_LIT(KOriginalCalendarFileMikeCleanFullPath, "z:\\private\\10003a5b\\tcal_dc_91_CalFile_Clean");
       
  1378 	_LIT(KCalendarFileMikeCleanFullPath, "c:\\private\\10003a5b\\tcal_dc_91_CalFile_Clean");
       
  1379 	_LIT(KCalendarFileMikeCleanTestFullPath, "c:\\private\\10003a5b\\tcal_dc_91_CalFile_Clean_Test");
       
  1380 	
       
  1381 	_LIT(KCalendarFileMikeCleanTest, "c:tcal_dc_91_CalFile_Clean_Test");
       
  1382 	
       
  1383 	// Copy 9.1 Calendar file from the ROM drive to the C: to enable writing into it
       
  1384 	iTestLib->PIMTestServer().CopyFileL(KOriginalCalendarFileMikeCleanFullPath, KCalendarFileMikeCleanFullPath);
       
  1385 	
       
  1386 	// Step 1 = Create a copy of a clean (no entries) Mike v9.1 Calendar file for test purposes
       
  1387 	iTestLib->PIMTestServer().CopyFileL(KCalendarFileMikeCleanFullPath, KCalendarFileMikeCleanTestFullPath);
       
  1388 	
       
  1389 	// Step 2 = Open the 9.1 Calendar file for test purposes
       
  1390 	iTestLib->OpenFileL(KCalendarFileMikeCleanTest());
       
  1391 		
       
  1392 	// Step 3 = Add multiple 9.2 parent and child entries to the 9.1 test Calendar file
       
  1393 	V92AddEntriesDCFileL();
       
  1394 	
       
  1395 	// Step 4 = Read and verify previously added 9.2 multiple parent and child entries within the 9.1 test Calendar file
       
  1396 	V92ReadEntriesDCFileL();
       
  1397 
       
  1398 	// Step 5 = Update all entries in the 9.1 Calendar file	
       
  1399 	V92UpdateEntriesL();
       
  1400 	
       
  1401 	// Step 6 = Delete all entries in the 9.1 Calendar file	
       
  1402 	iTestLib->CleanDatabaseL();
       
  1403 
       
  1404 	// Step 7 = Delete the 9.1 test Calendar files
       
  1405 	iTestLib->DeleteFileL(KCalendarFileMikeCleanTest());
       
  1406 	iTestLib->PIMTestServer().DeleteFileL(KCalendarFileMikeCleanFullPath());
       
  1407 	}
       
  1408 	
       
  1409 // ===========
       
  1410 // 9.1 Calendar File - Previously Added Entries
       
  1411 // ===========
       
  1412 
       
  1413 
       
  1414 void CCalEntryTestApp::V92Test91CalendarFileEntriesAddedL()
       
  1415 	{
       
  1416 	test.Next(_L("9.1 Calendar File - Previously Added Entries"));
       
  1417 
       
  1418 	
       
  1419 	_LIT(KOriginalCalendarFileMikeEntriesAddedFullPath, "z:\\private\\10003a5b\\tcal_dc_91_CalFile_EntriesAdded");
       
  1420 	_LIT(KCalendarFileMikeEntriesAddedFullPath, "c:\\private\\10003a5b\\tcal_dc_91_CalFile_EntriesAdded");
       
  1421 	_LIT(KCalendarFileMikeTestEntriesAddedFullPath, "c:\\private\\10003a5b\\tcal_dc_91_CalFile_EntriesAdded_Test");
       
  1422 	
       
  1423 	_LIT(KCalendarFileMikeTestEntriesAdded,"c:tcal_dc_91_CalFile_EntriesAdded_Test");
       
  1424 	
       
  1425 	// Copy the 9.1 Calendar file from the ROM drive to the C: to enable writing into it
       
  1426 	iTestLib->PIMTestServer().CopyFileL(KOriginalCalendarFileMikeEntriesAddedFullPath, KCalendarFileMikeEntriesAddedFullPath);
       
  1427 	
       
  1428 	// Step 1 = Create a copy of Mike v9.1 Calendar file saved earlier with 9.1 entries for test purposes
       
  1429 	iTestLib->PIMTestServer().CopyFileL(KCalendarFileMikeEntriesAddedFullPath, KCalendarFileMikeTestEntriesAddedFullPath);
       
  1430 	
       
  1431 	// Step 2 = Open the 9.1 test Calendar file
       
  1432 	iTestLib->OpenFileL(KCalendarFileMikeTestEntriesAdded());
       
  1433 	
       
  1434 	// Step 3 = Read and verify previously added 9.1 multiple parent and child entries within the 9.2 test environment
       
  1435 	V92ReadEntriesDCFileL();
       
  1436 	
       
  1437 	// Step 4 = Delete all entries in the 9.1 Calendar file	
       
  1438 	iTestLib->CleanDatabaseL();
       
  1439 	
       
  1440 	// Step 5 = Add multiple 9.2 parent and child entries to the 9.1 test Calendar file
       
  1441 	V92AddEntriesDCFileL();
       
  1442 	
       
  1443 	// Step 6 = Read and verify previously added 9.2 multiple parent and child entries within the 9.1 test Calendar file
       
  1444 	V92ReadEntriesDCFileL();
       
  1445 	
       
  1446 	// Step 7 = Update all entries in the 9.1 Calendar file	
       
  1447 	V92UpdateEntriesL();
       
  1448 	
       
  1449 	// Step 8 = Delete all entries in the 9.1 Calendar file	
       
  1450 	iTestLib->CleanDatabaseL();
       
  1451 	
       
  1452 	// Step 9 = Delete the 9.1 test Calendar files
       
  1453 	iTestLib->DeleteFileL(KCalendarFileMikeTestEntriesAdded());
       
  1454 	iTestLib->PIMTestServer().DeleteFileL(KCalendarFileMikeEntriesAddedFullPath());
       
  1455 	}
       
  1456 #endif 
       
  1457 
       
  1458 void CCalEntryTestApp::OpenBlankFileL()
       
  1459 	{
       
  1460 	TBuf<8> buf;
       
  1461 	buf.AppendNum(0);
       
  1462 	iTestLib->ReplaceFileL(buf);
       
  1463 	iTestLib->DeleteViews();
       
  1464 	iTestLib->OpenFileL(buf);
       
  1465 	}
       
  1466 	
       
  1467 void CCalEntryTestApp::CopyToCDriveL(const TDesC& aFileName)
       
  1468 	{
       
  1469 	iTestLib->DeleteViews();
       
  1470 	
       
  1471 	_LIT(KCalendarDirectory,"\\private\\10003a5b\\");
       
  1472 	
       
  1473 	TFileName originalLocation, newLocation;
       
  1474 	originalLocation.Copy(_L("z:"));
       
  1475 	originalLocation.Append(KCalendarDirectory);
       
  1476 	originalLocation.Append(aFileName);
       
  1477 	newLocation.Copy(_L("c:"));
       
  1478 	newLocation.Append(KCalendarDirectory);
       
  1479 	newLocation.Append(aFileName);
       
  1480 	TRAPD(err, iTestLib->DeleteFileL(aFileName));
       
  1481 	if (err == KErrInUse)
       
  1482 		{
       
  1483 		OpenBlankFileL();
       
  1484 		iTestLib->DeleteFileL(aFileName);
       
  1485 		}
       
  1486 	TRAP(err, iTestLib->PIMTestServer().CopyFileL(originalLocation, newLocation));
       
  1487 	if (err != KErrNone)
       
  1488 		{
       
  1489 		test.Printf(_L("Failed to copy from %S to %S, err=%d\n"), &originalLocation, &newLocation, err);
       
  1490 		}
       
  1491 	}
       
  1492 
       
  1493 #ifndef __REGENERATE_DC_FILE__
       
  1494 static void DoOpenCalendarFileL()
       
  1495 	{
       
  1496 	TInt err = KErrNotFound;
       
  1497 	while (err != KErrNone)
       
  1498 		{
       
  1499 		CCalTestLibrary* testLib = CCalTestLibrary::NewLC(ETrue);
       
  1500 		testLib->OpenFileL(KCalendar91File);
       
  1501 		TRAP(err, testLib->SynCGetEntryViewL());
       
  1502 		test(err == KErrInUse || err == KErrNone);
       
  1503 		CleanupStack::PopAndDestroy(testLib);
       
  1504 		}	
       
  1505 	}
       
  1506 
       
  1507 static TInt OpenCalendarFile(TAny*)
       
  1508 	{
       
  1509 	CTrapCleanup* trapCleanup = CTrapCleanup::New();
       
  1510 	if (!trapCleanup)
       
  1511 		{
       
  1512 		return KErrNoMemory;
       
  1513 		}
       
  1514 
       
  1515 	CActiveScheduler* scheduler = new CActiveScheduler();
       
  1516 	if (!scheduler)
       
  1517 		{
       
  1518 		delete trapCleanup;
       
  1519 		return KErrNoMemory;
       
  1520 		}
       
  1521 	CActiveScheduler::Install(scheduler);
       
  1522 
       
  1523 	TRAPD(err, DoOpenCalendarFileL());
       
  1524 
       
  1525 	delete scheduler;
       
  1526 	delete trapCleanup;
       
  1527 
       
  1528 	return err;
       
  1529 	}
       
  1530 
       
  1531 void CCalEntryTestApp::TestOpeningFileDuringConversionL()
       
  1532 	{
       
  1533 	test.Printf(_L("Loading v9.1 calendar file in two threads at once...\n"));
       
  1534 	CopyToCDriveL(KCalendar91File);
       
  1535 	CalCommon::TCalFileVersionSupport status = static_cast<CalCommon::TCalFileVersionSupport>(-1);
       
  1536 	iTestLib->GetSession().OpenL(KCalendar91File, status);
       
  1537 	test(status == CalCommon::EFileNeedsConverting);
       
  1538 	iTestLib->AsynCGetEntryViewL();
       
  1539 
       
  1540 	//
       
  1541 	const TInt KMaxHeapSize = 0x20000;
       
  1542 	RThread otherThread;
       
  1543 	TName threadName = _L("TestOpenCalendarThread");
       
  1544 	TInt err = otherThread.Create(threadName, OpenCalendarFile, KDefaultStackSize, 
       
  1545 							      KMinHeapSize, KMaxHeapSize, NULL, EOwnerProcess);
       
  1546 	if (err != KErrNone)
       
  1547 		{
       
  1548 		User::Panic(_L("Thread's not been created"), err);
       
  1549 		}
       
  1550 
       
  1551 	TRequestStatus threadStatus;
       
  1552 	otherThread.Logon(threadStatus);
       
  1553 	otherThread.Resume(); 
       
  1554 	//wait until the other thread is dead?
       
  1555 	User::WaitForRequest(threadStatus);
       
  1556 	test(threadStatus.Int() == KErrNone);
       
  1557 	
       
  1558 	CActiveScheduler::Start();
       
  1559 	}
       
  1560 #endif
       
  1561 
       
  1562 void CCalEntryTestApp::DoTestsL()
       
  1563 	{
       
  1564 	iTestLib = CCalTestLibrary::NewL(ETrue);
       
  1565 
       
  1566 #ifdef __REGENERATE_DC_FILE__
       
  1567 
       
  1568 	iTestLib->ReplaceFileL(KCalendarFileToGenerate());
       
  1569 	iTestLib->OpenFileL(KCalendarFileToGenerate());
       
  1570 	CreateDCFileL();
       
  1571 	
       
  1572 #else
       
  1573 
       
  1574 	CalCommon::TCalFileVersionSupport status = static_cast<CalCommon::TCalFileVersionSupport>(-1);
       
  1575 	
       
  1576 	CopyToCDriveL(KCalendar81File);
       
  1577 	iTestLib->RegisterCalFileL(KCalendar81File);
       
  1578 	test.Printf(_L("Loading v8.1 calendar file...\n"));
       
  1579 	TRAPD(err, iTestLib->GetSession().OpenL(KCalendar81File, status));
       
  1580 	test(err == KErrNotSupported);
       
  1581 	test(status == CalCommon::EUnsupportedFileVersion);
       
  1582 	
       
  1583 	CopyToCDriveL(KCalendar91File);
       
  1584 	iTestLib->RegisterCalFileL(KCalendar91File);
       
  1585 	test.Printf(_L("Loading v9.1 calendar file...\n"));
       
  1586 	status = static_cast<CalCommon::TCalFileVersionSupport>(-1);
       
  1587 	iTestLib->GetSession().OpenL(KCalendar91File, status);
       
  1588 	test(status == CalCommon::EFileNeedsConverting);
       
  1589 	TestFileLoadedL(EFalse);
       
  1590 	
       
  1591 	CopyToCDriveL(KCalendar92File);
       
  1592 	iTestLib->RegisterCalFileL(KCalendar92File);
       
  1593 	test.Printf(_L("Loading v9.2 calendar file...\n"));
       
  1594 	status = static_cast<CalCommon::TCalFileVersionSupport>(-1);
       
  1595 	iTestLib->GetSession().OpenL(KCalendar92File, status);
       
  1596 	test(status == CalCommon::EFileNeedsConverting);
       
  1597 	TestFileLoadedL(ETrue);
       
  1598 
       
  1599 	CopyToCDriveL(KCalendar94File);
       
  1600 	iTestLib->RegisterCalFileL(KCalendar94File);
       
  1601 	test.Printf(_L("Loading v9.4 compacted calendar file...\n"));
       
  1602 	status = static_cast<CalCommon::TCalFileVersionSupport>(-1);
       
  1603 	iTestLib->GetSession().OpenL(KCalendar94File, status);
       
  1604 	test(status == CalCommon::EFileNeedsConverting);
       
  1605 	TestFileLoadedV94L();
       
  1606 	
       
  1607 	CopyToCDriveL(KCalendar95File);
       
  1608 	iTestLib->RegisterCalFileL(KCalendar95File);
       
  1609 	test.Printf(_L("Loading v9.5 calendar file...\n"));
       
  1610 	status = static_cast<CalCommon::TCalFileVersionSupport>(-1);
       
  1611 	iTestLib->GetSession().OpenL(KCalendar95File, status);
       
  1612 	test(status == CalCommon::EFileIsCurrentVersion);
       
  1613 	TestFileLoadedV95L();
       
  1614 	
       
  1615 	test.Printf(_L("Loading v9.2 calendar file from read-only drive...\n"));
       
  1616 	TFileName fileOnZDrive;
       
  1617 	fileOnZDrive.Copy(_L("z:"));
       
  1618 	fileOnZDrive.Append(KCalendar92File);
       
  1619 	status = static_cast<CalCommon::TCalFileVersionSupport>(-1);
       
  1620 	iTestLib->DeleteViews();
       
  1621 	TRAP(err, iTestLib->GetSession().OpenL(fileOnZDrive, status));
       
  1622 	test(err == KErrAccessDenied);
       
  1623 	test(status == CalCommon::EFileNeedsConverting);
       
  1624 	
       
  1625 	test.Printf(_L("Loading converted 9.2 calendar file...\n"));
       
  1626 	status = static_cast<CalCommon::TCalFileVersionSupport>(-1);
       
  1627 	iTestLib->DeleteViews();
       
  1628 	iTestLib->GetSession().OpenL(KCalendar92File, status);
       
  1629 	test(status == CalCommon::EFileIsCurrentVersion);
       
  1630 	TestFileLoadedL(ETrue);
       
  1631 
       
  1632 	test.Printf(_L("Loading converted 9.4 calendar file ...\n"));
       
  1633 	status = static_cast<CalCommon::TCalFileVersionSupport>(-1);
       
  1634 	iTestLib->DeleteViews();
       
  1635 	iTestLib->GetSession().OpenL(KCalendar94File, status);
       
  1636 	test(status == CalCommon::EFileIsCurrentVersion);
       
  1637 	TestFileLoadedV94L();
       
  1638 	
       
  1639 	test.Printf(_L("Loading large v9.1 calendar file...\n"));
       
  1640 	CopyToCDriveL(KCalendar91LargeFile);
       
  1641 	iTestLib->RegisterCalFileL(KCalendar91LargeFile);
       
  1642 	TTime start, end;
       
  1643 	start.UniversalTime();
       
  1644 	status = static_cast<CalCommon::TCalFileVersionSupport>(-1);
       
  1645 	iTestLib->GetSession().OpenL(KCalendar91LargeFile, status);
       
  1646 	test(status == CalCommon::EFileNeedsConverting);
       
  1647 	iTestLib->SynCGetEntryViewL(); // build indexes
       
  1648 	end.UniversalTime();
       
  1649 	TTimeIntervalMicroSeconds microseconds = end.MicroSecondsFrom(start);
       
  1650 	TInt32 milliseconds = microseconds.Int64() / 1000;
       
  1651 	test.Printf(_L("Time to convert 1200 entries from v9.1 to v9.3: %d milliseconds\n"), milliseconds);
       
  1652 
       
  1653 	CopyToCDriveL(KCalendar92CorruptFile);
       
  1654 	iTestLib->RegisterCalFileL(KCalendar92CorruptFile);
       
  1655 	test.Printf(_L("Loading corrupt v9.2 calendar file...\n"));
       
  1656 	iTestLib->GetSession().OpenL(KCalendar92CorruptFile, status);
       
  1657 	test(status == CalCommon::EFileNeedsConverting);
       
  1658 	TRAP(err, iTestLib->SynCGetEntryViewL()); // build indexes
       
  1659 	test(err == KErrCorrupt);
       
  1660 	
       
  1661 	TestCategoriesL(KCalendar91File);
       
  1662 	TestCategoriesL(KCalendar92File);
       
  1663 	
       
  1664 	TestOpeningFileDuringConversionL();
       
  1665 	
       
  1666 	OpenBlankFileL();
       
  1667 	// Old v9.2 tests:
       
  1668 	
       
  1669 	// 9.2 Calendar File - Clean / No Entries
       
  1670 	V92Test92CalendarFileCleanL();
       
  1671 
       
  1672 	// 9.2 Calendar File - Previously Added Entries
       
  1673 	V92Test92CalendarFileEntriesAddedL();
       
  1674 
       
  1675 	// 9.1 Calendar File - Clean / No Entries
       
  1676 	V92Test91CalendarFileCleanL();
       
  1677 
       
  1678 	// 9.1 Calendar File - Previously Added Entries
       
  1679 	V92Test91CalendarFileEntriesAddedL();
       
  1680 
       
  1681 	//there are still converted files left
       
  1682 	//manual delete of them
       
  1683 	TRAP_IGNORE(iTestLib->DeleteFileL( _L("tcal_dc_91"), 1) );
       
  1684 	TRAP_IGNORE(iTestLib->DeleteFileL( _L("tcal_dc_91_calfile_clean_test_converted"), 1) );
       
  1685 	TRAP_IGNORE(iTestLib->DeleteFileL( _L("tcal_dc_91Idx"), 1) );
       
  1686 	TRAP_IGNORE(iTestLib->DeleteFileL( _L("tcal_dc_92_calfile_clean_test_converted"), 1) );
       
  1687 	TRAP_IGNORE(iTestLib->DeleteFileL( _L("tcal_dc_92_corrupt_converted"), 1) ); // will not be deleted because in use
       
  1688 	
       
  1689 #endif
       
  1690 	}
       
  1691 
       
  1692 
       
  1693 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
       
  1694  * DoTestL()
       
  1695  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
       
  1696 	
       
  1697 static void DoTestL()
       
  1698 	{
       
  1699 	CCalEntryTestApp* testManager = new (ELeave) CCalEntryTestApp;
       
  1700 	CleanupStack::PushL(testManager);
       
  1701 
       
  1702 
       
  1703 	TPerformanceTimer timer(test);
       
  1704 	timer.Start();
       
  1705 
       
  1706 
       
  1707 	// Run the test suite
       
  1708 
       
  1709 	testManager->DoTestsL();
       
  1710 	
       
  1711 	
       
  1712 	timer.Stop();
       
  1713 	test.Printf(_L("Done\n"));
       
  1714 	// printout performance time
       
  1715 	timer.PrintOut();
       
  1716 
       
  1717 	
       
  1718 	CleanupStack::PopAndDestroy(testManager);
       
  1719 	}
       
  1720 
       
  1721 void MyCleanL(void)
       
  1722 	{
       
  1723 	CCalTestLibrary	*pTestLib = CCalTestLibrary::NewLC(ETrue);
       
  1724 	pTestLib->DeleteFileL(_L("tcal_dc_92_corrupt_converted"), ETrue);
       
  1725 	CleanupStack::PopAndDestroy(pTestLib);
       
  1726 	}
       
  1727 
       
  1728 /**
       
  1729 
       
  1730 @SYMTestCaseID     PIM-TCAL-DC-0001
       
  1731 
       
  1732 */
       
  1733 
       
  1734 TInt E32Main()
       
  1735     {
       
  1736 	__UHEAP_MARK;
       
  1737 
       
  1738 	test.Start(_L("@SYMTESTCaseID:PIM-TCAL-DC-0001 Calendar Interim API Data Conversion test suite"));
       
  1739 
       
  1740 	test.Title();
       
  1741 
       
  1742 	CTrapCleanup* trapCleanup = CTrapCleanup::New();
       
  1743 	if (!trapCleanup)
       
  1744 		{
       
  1745 		return KErrNoMemory;
       
  1746 		}
       
  1747 
       
  1748 	CActiveScheduler* scheduler = new CActiveScheduler();
       
  1749 	if (!scheduler)
       
  1750 		{
       
  1751 		delete trapCleanup;
       
  1752 		return KErrNoMemory;
       
  1753 		}
       
  1754 	CActiveScheduler::Install(scheduler);	
       
  1755 
       
  1756 	TRAPD(ret, DoTestL());
       
  1757 	test(ret == KErrNone);
       
  1758 	
       
  1759 	TRAP_IGNORE(MyCleanL());
       
  1760 
       
  1761 	test.End();
       
  1762 	test.Close();
       
  1763 
       
  1764 	delete scheduler;
       
  1765 	delete trapCleanup;	
       
  1766 	
       
  1767 	__UHEAP_MARKEND;
       
  1768 
       
  1769 	return (KErrNone);
       
  1770     }