pimappservices/calendar/tsrc/tcal_alarmattach.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 //
       
    15 
       
    16 // Local includes
       
    17 #include "caltestlib.h"
       
    18 #include <calentry.h>
       
    19 #include <calentryview.h>
       
    20 #include <calalarm.h>
       
    21 #include <calcategory.h>
       
    22 #include <calinstance.h>
       
    23 #include <calinstanceview.h>
       
    24 #include <calrrule.h>
       
    25 
       
    26 // System includes
       
    27 #include <e32test.h>
       
    28 #include <s32file.h>
       
    29 #include <asshdalarm.h>
       
    30 #include <asshddefs.h>
       
    31 #include <asclisession.h>
       
    32 
       
    33 LOCAL_D RTest test(_L("tCal_alarmattach"));
       
    34 
       
    35 _LIT8(KGUID3, "GUID_TestDeleteSnoozedAlarmL"); /* do not use it for other tests */
       
    36 class CCalAlarmAttachTest : public CBase
       
    37 	{
       
    38 public:
       
    39 	static CCalAlarmAttachTest* NewLC();
       
    40  	void DoTestL();
       
    41 	~CCalAlarmAttachTest();
       
    42 
       
    43 
       
    44 	void TestDeleteSnoozedAlarmL() ;
       
    45 	void TestDeleteAlarmL() ;
       
    46 	
       
    47 	void TestFetchEntryAlarmContentL();
       
    48 	void TestDeleteAlarmWithAlarmContentL();
       
    49 	void TestCopyEntryWithAlarmContentL();
       
    50 	void TestCopyTwiceEntryWithAlarmContentL();
       
    51     void TestUpdateEntryHavingAlarmcontentL();
       
    52 		
       
    53 private:
       
    54 	void ConstructL();
       
    55 	void CreateEntriesL();
       
    56 	void TestAlarmL( CCalEntry* aEntry, const TDesC8& expectedContent,
       
    57         const TDesC8& expectedMimeType );
       
    58 	void FetchEntryL( const TDesC8& expectedContent, 
       
    59         const TDesC8& expectedMimeType );
       
    60 	void ClearAllAlarmsL();
       
    61 	TInt CountAlarmsL(TAlarmId& aFirstAlarmId);
       
    62 	CCalAlarm* StoreEntryWithAlarmContentLC(const TDesC8& aUid);
       
    63 
       
    64 
       
    65 private:
       
    66 	CCalTestLibrary* iTestLib;
       
    67 	RASCliSession		iAlarmServer;
       
    68 	};
       
    69 	
       
    70 
       
    71 _LIT8(KGUID1, "A_Global_UID1");
       
    72 
       
    73 
       
    74 _LIT(KCalName, "TestCalendar");
       
    75 
       
    76 _LIT8(KContent, "C:\\test.jpg");
       
    77 _LIT8(KMimeType, "mime type");
       
    78 _LIT(KSummary, "Summary");
       
    79 _LIT(KDescription, "Description");
       
    80 
       
    81 
       
    82 
       
    83 /**
       
    84 * Tests behaviour of the alarm attachments.
       
    85 *
       
    86 * Create 3 entries, a parent, and two child entries. The first child entry has
       
    87 * an alarm attachment and stores the entry. The second child also has an 
       
    88 * attachment and stores the entry. The second child's alarm attachment data 
       
    89 * should overwrite the first child's alarm data.
       
    90 */
       
    91 void CCalAlarmAttachTest::CreateEntriesL()
       
    92 	{
       
    93     //-----------------------------------------------------------------------
       
    94 	// Create parent entry with repeat rule
       
    95     //-----------------------------------------------------------------------
       
    96 	RPointerArray<CCalEntry> entries;
       
    97 	CleanupResetAndDestroyPushL(entries);
       
    98 	
       
    99 	HBufC8* guid = KGUID1().AllocLC();
       
   100 	CCalEntry* parentEntry = CCalEntry::NewL(CCalEntry::EEvent, guid, CCalEntry::EMethodNone, 0);
       
   101 	CleanupStack::Pop(guid);
       
   102 	CleanupStack::PushL(parentEntry);
       
   103 	
       
   104 	TCalTime calTime1;
       
   105 	calTime1.SetTimeUtcL(TDateTime(2007,EFebruary,15, 13, 30, 0, 0));
       
   106 	TCalTime calTime2;
       
   107 	calTime2.SetTimeUtcL(TDateTime(2007,EFebruary,15, 14, 30, 0, 0));
       
   108 	parentEntry->SetStartAndEndTimeL(calTime1, calTime2);
       
   109 	
       
   110 	parentEntry->SetSummaryL(_L("Test for Alarms"));
       
   111 	
       
   112 	TCalRRule rptRule;
       
   113     rptRule.SetDtStart( calTime1 );
       
   114     rptRule.SetType( TCalRRule::EDaily );
       
   115     rptRule.SetInterval( 1 );
       
   116     rptRule.SetCount(5);
       
   117 	
       
   118 	parentEntry->SetRRuleL(rptRule);
       
   119 
       
   120 	entries.AppendL(parentEntry);
       
   121    
       
   122     // Store parent entry.
       
   123 	TInt entriesStored = 0;
       
   124 	iTestLib->SynCGetEntryViewL().StoreL(entries, entriesStored);
       
   125 	
       
   126 	CleanupStack::Pop(parentEntry);
       
   127 	CleanupStack::PopAndDestroy(&entries);
       
   128 	
       
   129     //-----------------------------------------------------------------------
       
   130 	// Create child entry with recurrence id on 17th and with alarm attachment.
       
   131     //-----------------------------------------------------------------------
       
   132 	
       
   133 	RPointerArray<CCalEntry> entriesToStore1;
       
   134 	CleanupResetAndDestroyPushL(entriesToStore1);
       
   135 	
       
   136 	TCalTime recurrenceId;
       
   137 	recurrenceId.SetTimeUtcL(TDateTime(2007,EFebruary,17, 13, 30, 0, 0));
       
   138 	
       
   139 	HBufC8* parentGuid = KGUID1().AllocLC();
       
   140 	CCalEntry* childEntry1 = CCalEntry::NewL(CCalEntry::EEvent, parentGuid, 
       
   141         CCalEntry::EMethodNone, 0, recurrenceId, CalCommon::EThisOnly);
       
   142 	CleanupStack::Pop(parentGuid);
       
   143 	CleanupStack::PushL(childEntry1);
       
   144 	
       
   145 	TCalTime calTime3;
       
   146 	calTime3.SetTimeUtcL(TDateTime(2007,EFebruary,21, 13, 30, 0, 0));
       
   147 	TCalTime calTime4;
       
   148 	calTime4.SetTimeUtcL(TDateTime(2007,EFebruary,21, 14, 30, 0, 0));
       
   149 	childEntry1->SetStartAndEndTimeL(calTime3, calTime4);
       
   150 	
       
   151 	// Add an attachment to the alarm.
       
   152 	CCalAlarm* alarm = CCalAlarm::NewL();
       
   153 	CleanupStack::PushL(alarm);
       
   154 	alarm->SetTimeOffset(1);
       
   155 	
       
   156 	CCalContent* almContent = CCalContent::NewL();
       
   157 	CleanupStack::PushL(almContent);
       
   158 	// Add content and mimetype for the alarm.
       
   159 	_LIT8(KContent, "C:\\test.jpg");
       
   160 	_LIT8(KMimeType, "mime type");
       
   161 	HBufC8* content = KContent().AllocLC();
       
   162 	HBufC8* mimetype = KMimeType().AllocLC();
       
   163 	
       
   164     // Takes ownership of content and mimetype.
       
   165 	almContent->SetContentL(content, mimetype, CCalContent::EDispositionInline);
       
   166 	alarm->SetAlarmAction(almContent); // Takes ownership of almContent.
       
   167 	
       
   168 	childEntry1->SetAlarmL(alarm);
       
   169 	
       
   170 	CleanupStack::Pop(mimetype);
       
   171 	CleanupStack::Pop(content);    
       
   172 	CleanupStack::Pop(almContent); 
       
   173 	CleanupStack::PopAndDestroy(alarm);
       
   174 		
       
   175 	TInt entriesStored1 = 0;
       
   176 	entriesToStore1.AppendL(childEntry1);
       
   177 	iTestLib->SynCGetEntryViewL().StoreL(entriesToStore1, entriesStored1);
       
   178 	CleanupStack::Pop(childEntry1);
       
   179 		
       
   180     // Test if the alarm details retrieved are as expected.
       
   181 	CCalEntry* entry1 = entriesToStore1[0];
       
   182 	TestAlarmL(entry1, KContent(), KMimeType());
       
   183 
       
   184     // Fetch the entry and ensure the alarm details are still as expected.
       
   185     FetchEntryL( KContent(), KMimeType() );
       
   186 
       
   187 	CleanupStack::PopAndDestroy(&entriesToStore1);
       
   188 
       
   189     //-----------------------------------------------------------------------
       
   190 	// Create another child entry with recurrence id and range same as above. 
       
   191     // The entry should be updated.
       
   192     //-----------------------------------------------------------------------
       
   193 
       
   194 	RPointerArray<CCalEntry>	entriesToStore2;
       
   195 	CleanupResetAndDestroyPushL(entriesToStore2);
       
   196 	
       
   197 	HBufC8* parentGuid1 = KGUID1().AllocLC();
       
   198 	
       
   199 	TCalTime recurrenceId1;
       
   200 	recurrenceId1.SetTimeUtcL(TDateTime(2007,EFebruary,17, 13, 30, 0, 0));
       
   201 	
       
   202 	CCalEntry* childEntry2 = CCalEntry::NewL(CCalEntry::EEvent, parentGuid1, 
       
   203         CCalEntry::EMethodNone, 0, recurrenceId1, CalCommon::EThisOnly);
       
   204 	CleanupStack::Pop(parentGuid1);
       
   205 	CleanupStack::PushL(childEntry2);
       
   206 	
       
   207 	TCalTime calTime5;
       
   208 	calTime5.SetTimeUtcL(TDateTime(2007,EFebruary,22, 13, 30, 0, 0));
       
   209 	TCalTime calTime6;
       
   210 	calTime6.SetTimeUtcL(TDateTime(2007,EFebruary,22, 14, 30, 0, 0));
       
   211 	childEntry2->SetStartAndEndTimeL(calTime5, calTime6);
       
   212 	
       
   213 	childEntry2->SetSummaryL(_L("Update the child entry1"));
       
   214 	childEntry2->SetPriorityL(2);
       
   215 	
       
   216 	// Add attachment to the alarm.
       
   217 	CCalAlarm* alarm1 = CCalAlarm::NewL();
       
   218 	CleanupStack::PushL(alarm1);
       
   219 	alarm1->SetTimeOffset(1);
       
   220 	
       
   221 	CCalContent* almContent1 = CCalContent::NewL();
       
   222 	CleanupStack::PushL(almContent1);
       
   223 
       
   224 	// Add alarm attachment to the entry.
       
   225 	_LIT8(KContent1, "C:\\longtail.jpg");
       
   226     _LIT8(KMimeType1, "mime type 2");
       
   227 	HBufC8* content1 = KContent1().AllocLC();
       
   228 	HBufC8* mimetype1 = KMimeType1().AllocLC();
       
   229 	
       
   230 	almContent1->SetContentL(content1, mimetype1, CCalContent::EDispositionInline);
       
   231 	alarm1->SetAlarmAction(almContent1);
       
   232 	
       
   233 	childEntry2->SetAlarmL(alarm1);
       
   234 	
       
   235 	CleanupStack::Pop(mimetype1);
       
   236 	CleanupStack::Pop(content1);
       
   237 	CleanupStack::Pop(almContent1);
       
   238 	CleanupStack::PopAndDestroy(alarm1);
       
   239 	
       
   240 	entriesToStore2.AppendL(childEntry2);
       
   241 	
       
   242     // Store the child entry.
       
   243 	TInt entriesStored2 = 0;
       
   244 	iTestLib->SynCGetEntryViewL().StoreL(entriesToStore2, entriesStored2);
       
   245 
       
   246     // Store the entry again. The stream id for the alarm action will be 
       
   247     // re-used (in CAgnEntry). RAgendaServ::UpdateEntryL() will call 
       
   248     // CAgnEntry::UpdateAlarmAction() instead of StoreAlarmAction().
       
   249 	iTestLib->SynCGetEntryViewL().StoreL(entriesToStore2, entriesStored2);
       
   250 
       
   251 	CleanupStack::Pop(childEntry2);
       
   252 	
       
   253 	CCalEntry* entry2 = entriesToStore2[0];
       
   254 
       
   255 	// Test if the alarm details are retrieved as expected. 
       
   256 	TestAlarmL(entry2, KContent1(), KMimeType1());
       
   257 
       
   258     // Fetch the entry and ensure the alarm details are still as expected.
       
   259     FetchEntryL( KContent1(), KMimeType1() );
       
   260 
       
   261 	CleanupStack::PopAndDestroy(&entriesToStore2);
       
   262 	}
       
   263 
       
   264 /**
       
   265 * Test the alarm properties of the entry that has alarm content.
       
   266 *
       
   267 * @param aEntry The calendar entry to test.
       
   268 * @param expectedContent The expected content in aEntry.
       
   269 * @param expectedMimeType The expected mime type in aEntry.
       
   270 */	
       
   271 void CCalAlarmAttachTest::TestAlarmL( CCalEntry* aEntry, 
       
   272     const TDesC8& expectedContent, const TDesC8& expectedMimeType )
       
   273 	{
       
   274 	CCalAlarm* almEntry = aEntry->AlarmL();
       
   275 	CleanupStack::PushL(almEntry);
       
   276     test( almEntry != NULL );
       
   277 
       
   278 	CCalContent* alarmcontent1 = almEntry->AlarmAction();
       
   279     test( alarmcontent1 != NULL );
       
   280 
       
   281 	const TDesC8& content = alarmcontent1->Content();
       
   282     test( content == expectedContent );
       
   283 	const TDesC8& mimetype = alarmcontent1->MimeType();
       
   284     test( mimetype == expectedMimeType );
       
   285     
       
   286     CleanupStack::PopAndDestroy(almEntry);
       
   287 	}
       
   288 
       
   289 /**
       
   290 * Fetches all entries and checks the alarm properties for the child entry.
       
   291 * There should be two entries, a parent and the child entry.
       
   292 *
       
   293 * @param expectedContent The expected content of the child entry.
       
   294 * @param expectedMimeType The expected mime type of the child entry.
       
   295 */
       
   296 void CCalAlarmAttachTest::FetchEntryL( const TDesC8& expectedContent,
       
   297         const TDesC8& expectedMimeType )
       
   298     {
       
   299 	RPointerArray<CCalEntry> entriesFetched;
       
   300 	CleanupResetAndDestroyPushL(entriesFetched);
       
   301 	HBufC8* parentGuid1 = KGUID1().AllocLC();
       
   302 	iTestLib->SynCGetEntryViewL().FetchL(parentGuid1->Des(), entriesFetched);
       
   303 	
       
   304     // 1 parent and 1 child entry.
       
   305 	test(entriesFetched.Count() == 2); 
       
   306 	
       
   307     // The child entry should be the second entry.
       
   308 	CCalEntry* childEntry = entriesFetched[1];
       
   309 	
       
   310 	TPtrC summary = childEntry->SummaryL();
       
   311 
       
   312 	// Test if the alarm details are retrieved as expected. 
       
   313 	TestAlarmL(childEntry, expectedContent, expectedMimeType);
       
   314 
       
   315     CleanupStack::PopAndDestroy(parentGuid1);
       
   316 	CleanupStack::PopAndDestroy(&entriesFetched);
       
   317 	}
       
   318 	
       
   319 void CCalAlarmAttachTest::ClearAllAlarmsL()
       
   320 	{
       
   321 	iTestLib->CleanDatabaseL();
       
   322 	
       
   323 	// Delete all alarms
       
   324 	RArray<TAlarmCategory> categories;
       
   325 	CleanupClosePushL(categories);
       
   326 	
       
   327 	iAlarmServer.GetAvailableCategoryListL(categories);
       
   328 	
       
   329 	TInt count = categories.Count();
       
   330 	for(TInt i = 0; i < count; i++)
       
   331 		{
       
   332 		const TAlarmCategory& category = categories[i];
       
   333 		test(iAlarmServer.AlarmDeleteAllByCategory(category, EFalse) == KErrNone);
       
   334 		}
       
   335 		
       
   336 	CleanupStack::PopAndDestroy(&categories);
       
   337 
       
   338 	// Restore alarm sound
       
   339 	iAlarmServer.SetAlarmSoundState(EAlarmGlobalSoundStateOn);
       
   340 	}
       
   341 	
       
   342 void CCalAlarmAttachTest::DoTestL()
       
   343 	{
       
   344 	CreateEntriesL();
       
   345 	}
       
   346 
       
   347 CCalAlarmAttachTest* CCalAlarmAttachTest::NewLC()
       
   348 	{
       
   349 	CCalAlarmAttachTest* self = new (ELeave) CCalAlarmAttachTest();
       
   350 	CleanupStack::PushL(self);
       
   351 	self->ConstructL();
       
   352 	return self;
       
   353 	}
       
   354 
       
   355 void CCalAlarmAttachTest::ConstructL()
       
   356 	{
       
   357 	iTestLib = CCalTestLibrary::NewL();
       
   358 	iTestLib->ReplaceFileL(KCalName());
       
   359 	iTestLib->OpenFileL(KCalName());
       
   360 	
       
   361 	User::LeaveIfError(iAlarmServer.Connect());
       
   362 	}
       
   363 	
       
   364 CCalAlarmAttachTest::~CCalAlarmAttachTest()
       
   365 	{
       
   366 	iAlarmServer.Close();
       
   367 	delete iTestLib;
       
   368 	}
       
   369 
       
   370 static void PrintEventDetails(TInt aEvent)
       
   371 	{
       
   372 	switch(aEvent)
       
   373 		{
       
   374 	case EAlarmChangeEventState:
       
   375 		test.Printf(_L("\tEvent => EAlarmChangeEventState\n"));
       
   376 		break;
       
   377 	case EAlarmChangeEventStatus:
       
   378 		test.Printf(_L("\tEvent => EAlarmChangeEventStatus\n"));
       
   379 		break;
       
   380 	case EAlarmChangeEventCharacteristics:
       
   381 		test.Printf(_L("\tEvent => EAlarmChangeEventCharacteristics\n"));
       
   382 		break;
       
   383 	case EAlarmChangeEventAlarmDeletion:
       
   384 		test.Printf(_L("\tEvent => EAlarmChangeEventAlarmDeletion\n"));
       
   385 		break;
       
   386 	case EAlarmChangeEventAlarmAddition:
       
   387 		test.Printf(_L("\tEvent => EAlarmChangeEventAlarmAddition\n"));
       
   388 		break;
       
   389 	case EAlarmChangeEventTimerExpired:
       
   390 		test.Printf(_L("\tEvent => EAlarmChangeEventTimerExpired\n"));
       
   391 		break;
       
   392 	case EAlarmChangeEventSoundPlaying:
       
   393 		test.Printf(_L("\tEvent => EAlarmChangeEventSoundPlaying\n"));
       
   394 		break;
       
   395 	case EAlarmChangeEventSoundStopped:
       
   396 		test.Printf(_L("\tEvent => EAlarmChangeEventSoundStopped\n"));
       
   397 		break;
       
   398 	case EAlarmChangeEventPlayIntervalsChanged:
       
   399 		test.Printf(_L("\tEvent => EAlarmChangeEventPlayIntervalsChanged\n"));
       
   400 		break;
       
   401 	case EAlarmChangeEventGlobalSoundStateChanged:
       
   402 		test.Printf(_L("\tEvent => EAlarmChangeEventGlobalSoundStateChanged\n"));
       
   403 		break;
       
   404 	case EAlarmChangeEventHeadQueueItemChanged:
       
   405 		test.Printf(_L("\tEvent => EAlarmChangeEventHeadQueueItemChanged\n"));
       
   406 		break;
       
   407 	case EAlarmChangeEventUndefined:
       
   408 		test.Printf(_L("\tEvent => EAlarmChangeEventUndefined\n"));
       
   409 		break;
       
   410 	case EAlarmChangeEventAlarmUIVisible:
       
   411 		test.Printf(_L("\tEvent => EAlarmChangeEventAlarmUIVisible\n"));	
       
   412 		break;
       
   413 	case EAlarmChangeEventAlarmUIInvisible:
       
   414 		test.Printf(_L("\tEvent => EAlarmChangeEventAlarmUIInvisible\n"));	
       
   415 		break;		
       
   416 	case EAlarmChangeEventAlarmData:
       
   417 		test.Printf(_L("\tEvent => EAlarmChangeEventAlarmData\n"));	
       
   418 		break;			
       
   419 	default:
       
   420 		test.Printf(_L("\tEvent => Opss %d?\n"), aEvent);	
       
   421 		break;
       
   422 		}
       
   423 	}
       
   424 
       
   425 TInt CCalAlarmAttachTest::CountAlarmsL(TAlarmId& aFirstAlarmId)
       
   426 	{
       
   427 	RArray< TAlarmId > alarmIdArr;
       
   428 	
       
   429 	iAlarmServer.GetAlarmIdListL(alarmIdArr);
       
   430 	
       
   431 	const TInt KCount = alarmIdArr.Count();
       
   432 	if (KCount > 0)
       
   433 		{
       
   434 		aFirstAlarmId = alarmIdArr[0];
       
   435 		}
       
   436 	TASShdAlarm alarmDetails;
       
   437 	for (TInt i = 0; i < KCount; i++)
       
   438 		{
       
   439 		User::LeaveIfError(iAlarmServer.GetAlarmDetails(alarmIdArr[i], alarmDetails));
       
   440 		RDebug::Print(_L("alarm %d, state=%d, id=%d"), i, alarmDetails.State(), alarmIdArr[i]);
       
   441 		}
       
   442 	RDebug::Print(_L("alarm count: %d"), KCount);
       
   443 	alarmIdArr.Close();
       
   444 	
       
   445 	return KCount;
       
   446 	}
       
   447 
       
   448 void CCalAlarmAttachTest::TestDeleteSnoozedAlarmL()
       
   449 	{
       
   450 	
       
   451 	CCalEntryView &view = iTestLib->SynCGetEntryViewL() ;
       
   452 	CCalEntryView *calentryview = &view ;
       
   453 	
       
   454 	TInt num ;	
       
   455 
       
   456 	ClearAllAlarmsL() ;	
       
   457 	
       
   458 	test.Printf(_L("Going to check deletion of snoozed alarms\n")) ;
       
   459 	
       
   460 	/* create repeating parent entry	*/
       
   461 
       
   462 	HBufC8* guid = KGUID3().AllocLC(); // ownership of guid gets transferred
       
   463  	CCalEntry *entry = CCalEntry::NewL(CCalEntry::ETodo, guid, CCalEntry::EMethodNone, 0) ;
       
   464 	CleanupStack::Pop(guid);	
       
   465 	CleanupStack::PushL(entry) ;
       
   466 	
       
   467 	TTime now1;
       
   468 	now1.UniversalTime();
       
   469 	now1 += TTimeIntervalSeconds(30);
       
   470 
       
   471 	TCalTime startTime ;
       
   472 	TCalTime endTime ;	
       
   473 	startTime.SetTimeUtcL(now1) ;
       
   474 	endTime.SetTimeUtcL(now1 + TTimeIntervalSeconds(30)) ;
       
   475 			
       
   476 	entry->SetStartAndEndTimeL(startTime, endTime) ;
       
   477 
       
   478 	TCalRRule rrule(TCalRRule::EDaily) ;
       
   479 	rrule.SetDtStart(startTime);
       
   480 	
       
   481 	TCalTime endRTime ;		
       
   482 	endRTime.SetTimeUtcL(now1 + TTimeIntervalDays(7)) ;	
       
   483 	rrule.SetUntil(endRTime);
       
   484 	rrule.SetInterval(1);	
       
   485 	entry->SetRRuleL(rrule) ;
       
   486 
       
   487 	CCalAlarm *alarm = CCalAlarm::NewL() ;
       
   488 	CleanupStack::PushL(alarm) ;			
       
   489 	alarm->SetTimeOffset(TTimeIntervalMinutes(0)) ;
       
   490 	entry->SetAlarmL(alarm) ; //ownership does not get transferred
       
   491 	
       
   492 	RPointerArray<CCalEntry> entryarr ;		
       
   493 	entryarr.AppendL(entry) ; //ownership does not got transferred			
       
   494 	calentryview->StoreL(entryarr, num) ;
       
   495 	entryarr.Close() ;		
       
   496 		
       
   497 	CleanupStack::PopAndDestroy(alarm) ;	
       
   498 	CleanupStack::PopAndDestroy(entry) ;	
       
   499 	
       
   500 	/* Now let the alarm go off */
       
   501 	TAlarmId alarmId;
       
   502 	TInt cnt = CountAlarmsL(alarmId);
       
   503 	
       
   504 	test(cnt > 0) ;
       
   505 	
       
   506 	TRequestStatus status = 0;
       
   507 	
       
   508 	
       
   509 	test.Printf(_L("Waiting one minute for the alarm to go off...\n")) ;
       
   510 	
       
   511 	for(;;)
       
   512 		{
       
   513 		iAlarmServer.NotifyChange(status, alarmId);
       
   514 		User::WaitForRequest(status);
       
   515 		
       
   516 		PrintEventDetails(status.Int());
       
   517 		
       
   518 		if	(status.Int() == EAlarmChangeEventTimerExpired)
       
   519 			{			
       
   520 			break; // alarm expired
       
   521 			}
       
   522 		}
       
   523 
       
   524 	
       
   525 	/* snooze the alarm */
       
   526 	
       
   527 	TTime snooze = now1 + TTimeIntervalMinutes(2);	
       
   528 	iAlarmServer.__DbgSnoozeAlarm(alarmId, snooze);
       
   529 	for(;;)
       
   530 		{
       
   531 		iAlarmServer.NotifyChange(status, alarmId);
       
   532 		User::WaitForRequest(status);
       
   533 		
       
   534 		PrintEventDetails(status.Int());		
       
   535 		if (status.Int() == EAlarmChangeEventSoundStopped)
       
   536 			{			
       
   537 			break; // snooze has taken place 
       
   538 			}
       
   539 		}
       
   540 
       
   541 	/* now crossout the first entry */	
       
   542 
       
   543 	RPointerArray< CCalEntry > calEntryArray ;
       
   544 	calentryview->FetchL(KGUID3(), calEntryArray) ;
       
   545 	
       
   546 	test(calEntryArray.Count() == 1) ;
       
   547 	
       
   548 	CCalEntry *entry1 = calEntryArray[0] ;	
       
   549 	
       
   550 	entry1->SetCompletedL(ETrue, startTime) ;			
       
   551 		
       
   552 	calentryview->StoreL(calEntryArray, num) ;
       
   553 	
       
   554 	delete entry1 ;	
       
   555 	calEntryArray.Close() ;
       
   556 	
       
   557 	/* now check if the alarm still exists or not */
       
   558 	TAlarmId alarmId1;
       
   559 	TInt cnt1 = CountAlarmsL(alarmId1);
       
   560 	
       
   561 	test(cnt1 < cnt) ;		
       
   562 	
       
   563 	if (cnt1 > 0)
       
   564 		{
       
   565 		test(alarmId != alarmId1) ;
       
   566 		}		
       
   567 	
       
   568 	ClearAllAlarmsL() ;
       
   569 	
       
   570 	test.Printf(_L("Checking of snoozed alarms successful\n")) ;
       
   571 	
       
   572 	}
       
   573 
       
   574 
       
   575 void CCalAlarmAttachTest::TestDeleteAlarmL()
       
   576 	{
       
   577 	
       
   578 	CCalEntryView &view = iTestLib->SynCGetEntryViewL() ;
       
   579 	CCalEntryView *calentryview = &view ;
       
   580 	
       
   581 	TInt num ;	
       
   582 
       
   583 	ClearAllAlarmsL() ;	
       
   584 	
       
   585 	test.Printf(_L("Going to check deletion of non-snoozed alarms\n")) ;
       
   586 	
       
   587 	/* create repeating parent entry	*/
       
   588 
       
   589 	HBufC8* guid = KGUID3().AllocLC(); // ownership of guid gets transferred
       
   590  	CCalEntry *entry = CCalEntry::NewL(CCalEntry::ETodo, guid, CCalEntry::EMethodNone, 0) ;
       
   591 	CleanupStack::Pop(guid);	
       
   592 	CleanupStack::PushL(entry) ;
       
   593 	
       
   594 	TTime now1;
       
   595 	now1.UniversalTime();
       
   596 	now1 += TTimeIntervalSeconds(30);
       
   597 
       
   598 	TCalTime startTime ;
       
   599 	TCalTime endTime ;	
       
   600 	startTime.SetTimeUtcL(now1) ;
       
   601 	endTime.SetTimeUtcL(now1 + TTimeIntervalSeconds(30)) ;
       
   602 			
       
   603 	entry->SetStartAndEndTimeL(startTime, endTime) ;
       
   604 
       
   605 	TCalRRule rrule(TCalRRule::EDaily) ;
       
   606 	rrule.SetDtStart(startTime);
       
   607 	
       
   608 	TCalTime endRTime ;		
       
   609 	endRTime.SetTimeUtcL(now1 + TTimeIntervalDays(7)) ;	
       
   610 	rrule.SetUntil(endRTime);
       
   611 	rrule.SetInterval(1);	
       
   612 	entry->SetRRuleL(rrule) ;
       
   613 
       
   614 	CCalAlarm *alarm = CCalAlarm::NewL() ;
       
   615 	CleanupStack::PushL(alarm) ;			
       
   616 	alarm->SetTimeOffset(TTimeIntervalMinutes(0)) ;
       
   617 	entry->SetAlarmL(alarm) ; //ownership does not get transferred
       
   618 	
       
   619 	RPointerArray<CCalEntry> entryarr ;		
       
   620 	entryarr.AppendL(entry) ; //ownership does not got transferred			
       
   621 	calentryview->StoreL(entryarr, num) ;
       
   622 	entryarr.Close() ;		
       
   623 		
       
   624 	CleanupStack::PopAndDestroy(alarm) ;	
       
   625 	CleanupStack::PopAndDestroy(entry) ;	
       
   626 	
       
   627 	/* Now let the alarm go off */
       
   628 	
       
   629 	RArray< TAlarmId > alarmIdArr ;
       
   630 	
       
   631 	iAlarmServer.GetAlarmIdListL(alarmIdArr) ;
       
   632 	
       
   633 	TInt cnt = alarmIdArr.Count() ;
       
   634 	
       
   635 	test(cnt > 0) ;
       
   636 	
       
   637 	TRequestStatus status = 0;
       
   638 	TAlarmId alarmId = alarmIdArr[0];
       
   639 	
       
   640 	alarmIdArr.Close() ;
       
   641 	
       
   642 	test.Printf(_L("Waiting one minute for the alarm to go off...\n")) ;
       
   643 	
       
   644 	for(;;)
       
   645 		{
       
   646 		iAlarmServer.NotifyChange(status, alarmId);
       
   647 		User::WaitForRequest(status);
       
   648 		
       
   649 		PrintEventDetails(status.Int());
       
   650 		
       
   651 		if	(status.Int() == EAlarmChangeEventTimerExpired)
       
   652 			{			
       
   653 			break; // alarm expired
       
   654 			}
       
   655 		}
       
   656 
       
   657 	/* delete this entry - without snoozing */
       
   658 
       
   659 	RPointerArray< CCalEntry > calEntryArray ;
       
   660 	calentryview->FetchL(KGUID3(), calEntryArray) ;
       
   661 	
       
   662 	test(calEntryArray.Count() == 1) ;
       
   663 	
       
   664 	CCalEntry *entry1 = calEntryArray[0] ;		
       
   665 	
       
   666 	entry1->SetCompletedL(ETrue, startTime) ;
       
   667 		
       
   668 	calentryview->StoreL(calEntryArray, num) ;
       
   669 	
       
   670 	delete entry1 ;	
       
   671 	calEntryArray.Close() ;
       
   672 	
       
   673 	/* now check if the alarm still exists or not */
       
   674 	
       
   675 	RArray< TAlarmId > alarmIdArr1 ;
       
   676 	
       
   677 	iAlarmServer.GetAlarmIdListL(alarmIdArr1) ;
       
   678 	
       
   679 	TInt cnt1 = alarmIdArr1.Count() ;
       
   680 	
       
   681 	test(cnt1 < cnt) ;		
       
   682 	
       
   683 	if (cnt1 > 0)
       
   684 		{
       
   685 		TAlarmId alarmId1 = alarmIdArr1[0];	
       
   686 		test(alarmId != alarmId1) ;
       
   687 		}			
       
   688 	
       
   689 	alarmIdArr1.Close() ;	
       
   690 	
       
   691 	ClearAllAlarmsL() ;
       
   692 	
       
   693 	test.Printf(_L("Checking of non snoozed alarms successful\n")) ;
       
   694 	
       
   695 	}
       
   696 
       
   697 static void DoMainL()
       
   698 	{
       
   699 	CCalAlarmAttachTest* testApp = CCalAlarmAttachTest::NewLC();
       
   700 	
       
   701 	TPerformanceTimer timer(test);
       
   702 	timer.Start();
       
   703 	
       
   704 	testApp->DoTestL();
       
   705 	testApp->TestDeleteSnoozedAlarmL() ;
       
   706 	testApp->TestDeleteAlarmL() ;
       
   707 	
       
   708 	testApp->TestFetchEntryAlarmContentL();
       
   709 	testApp->TestDeleteAlarmWithAlarmContentL();
       
   710 	testApp->TestCopyEntryWithAlarmContentL();
       
   711 	testApp->TestCopyTwiceEntryWithAlarmContentL();
       
   712 	testApp->TestUpdateEntryHavingAlarmcontentL();
       
   713 	timer.Stop();
       
   714 	test.Printf(_L("Done\n"));
       
   715 	// printout performance time
       
   716 	timer.PrintOut();
       
   717 	
       
   718 	CleanupStack::PopAndDestroy(testApp);
       
   719 	}
       
   720 
       
   721 CCalAlarm* CCalAlarmAttachTest::StoreEntryWithAlarmContentLC(const TDesC8& aUid)
       
   722     {
       
   723     test.Printf(_L("Store an alarmed entry with alarm content\n"));
       
   724     // Create an attachment to the alarm.
       
   725     CCalAlarm* alarm = CCalAlarm::NewL();
       
   726     CleanupStack::PushL(alarm);
       
   727     alarm->SetTimeOffset(1);
       
   728     
       
   729     CCalContent* almContent = CCalContent::NewL();
       
   730     CleanupStack::PushL(almContent);
       
   731     // Add content and mimetype for the alarm.
       
   732     HBufC8* content = KContent().AllocLC();
       
   733     HBufC8* mimetype = KMimeType().AllocLC();
       
   734     
       
   735     almContent->SetContentL(content, mimetype, CCalContent::EDispositionInline);
       
   736     CleanupStack::Pop(mimetype);
       
   737     CleanupStack::Pop(content);    
       
   738     alarm->SetAlarmAction(almContent); // Takes ownership of almContent.
       
   739     CleanupStack::Pop(almContent); 
       
   740   
       
   741     //Create the entry with the alarm and store it
       
   742     RPointerArray<CCalEntry> entries;
       
   743     CleanupResetAndDestroyPushL(entries);
       
   744     HBufC8* guid = aUid.AllocLC();
       
   745     CCalEntry* entry = CCalEntry::NewL(CCalEntry::EEvent, guid, CCalEntry::EMethodNone, 0);
       
   746     CleanupStack::Pop(guid);
       
   747     CleanupStack::PushL(entry);
       
   748     entries.AppendL(entry);
       
   749     CleanupStack::Pop(entry);
       
   750 
       
   751     TCalTime calTime;
       
   752     calTime.SetTimeUtcL(TDateTime(2007,EFebruary,15, 13, 30, 0, 0));
       
   753     entry->SetStartAndEndTimeL(calTime, calTime);
       
   754     entry->SetSummaryL(KSummary());
       
   755     
       
   756     entry->SetDescriptionL(KDescription());
       
   757     entry->SetAlarmL(alarm);
       
   758     TInt entriesStored = 0;
       
   759     iTestLib->SynCGetEntryViewL().StoreL(entries, entriesStored);
       
   760     CleanupStack::PopAndDestroy(&entries);
       
   761     return alarm;
       
   762     }
       
   763     
       
   764 void CCalAlarmAttachTest::TestFetchEntryAlarmContentL()
       
   765     {
       
   766     test.Printf(_L("Test fetching entry twice and check it alarm conten\n"));
       
   767     _LIT8(KEntryUidFetchEntry, "FetchEntryUid");
       
   768     CCalAlarm* alarm = StoreEntryWithAlarmContentLC(KEntryUidFetchEntry());
       
   769     RPointerArray<CCalEntry> entries;
       
   770     CleanupResetAndDestroyPushL(entries);
       
   771 
       
   772     //Fetch the entry and test the alarm  content
       
   773     iTestLib->SynCGetEntryViewL().FetchL(KEntryUidFetchEntry(), entries);
       
   774     TInt entriesStored = 0;
       
   775     iTestLib->SynCGetEntryViewL().StoreL(entries, entriesStored);
       
   776     entries.ResetAndDestroy();
       
   777     iTestLib->SynCGetEntryViewL().FetchL(KEntryUidFetchEntry(), entries);
       
   778     CCalEntry* entry = entries[0];
       
   779     test( KSummary() == entry->SummaryL() );
       
   780     test( KDescription() == entry->DescriptionL());
       
   781     TestAlarmL(entry, KContent(), KMimeType());
       
   782     entries.ResetAndDestroy();
       
   783 
       
   784     //Close the serve and fetch the entry again
       
   785     iTestLib->CloseAgendaServer();
       
   786     iTestLib->OpenFileL(KCalName());
       
   787 
       
   788     iTestLib->SynCGetEntryViewL().FetchL(KEntryUidFetchEntry(), entries);
       
   789     TestAlarmL(entries[0], KContent(), KMimeType());
       
   790     CleanupStack::PopAndDestroy(&entries);
       
   791     CleanupStack::PopAndDestroy(alarm);
       
   792     }
       
   793 
       
   794 void CCalAlarmAttachTest::TestDeleteAlarmWithAlarmContentL()
       
   795     {
       
   796     test.Printf(_L("Test deleting alarm from an entry \n"));
       
   797     _LIT8(KEntryUidDeleteAlarm, "DeleteAlarmUid");
       
   798     CCalAlarm* alarm = StoreEntryWithAlarmContentLC(KEntryUidDeleteAlarm());
       
   799     RPointerArray<CCalEntry> entries;
       
   800     CleanupResetAndDestroyPushL(entries);
       
   801 
       
   802     //Update the entry by deleting its alarm
       
   803     iTestLib->SynCGetEntryViewL().FetchL(KEntryUidDeleteAlarm(), entries);
       
   804     CCalEntry* entry = entries[0];
       
   805     entry->SetAlarmL(NULL);
       
   806     TInt entriesStored = 0;
       
   807     iTestLib->SynCGetEntryViewL().StoreL(entries, entriesStored);
       
   808     
       
   809     //Update the entry by adding an alarm but without alarm content
       
   810     entries.ResetAndDestroy();
       
   811     iTestLib->SynCGetEntryViewL().FetchL(KEntryUidDeleteAlarm(), entries);
       
   812     alarm->SetAlarmAction(NULL);
       
   813     entry = entries[0];
       
   814     entry->SetAlarmL(alarm);
       
   815     iTestLib->SynCGetEntryViewL().StoreL(entries, entriesStored);
       
   816     entries.ResetAndDestroy();
       
   817 
       
   818     //Fetch the entry and test the entry has an alarm but not alarm content
       
   819     iTestLib->SynCGetEntryViewL().FetchL(KEntryUidDeleteAlarm(), entries);
       
   820     CCalAlarm* almEntry = entries[0]->AlarmL();
       
   821     CleanupStack::PushL(almEntry);
       
   822     test( almEntry != NULL );
       
   823 
       
   824     CCalContent* alarmcontent = almEntry->AlarmAction();
       
   825     test( alarmcontent == NULL );
       
   826     CleanupStack::PopAndDestroy(almEntry);
       
   827     CleanupStack::PopAndDestroy(&entries);
       
   828     CleanupStack::PopAndDestroy(alarm);
       
   829     }
       
   830 
       
   831 void CCalAlarmAttachTest::TestCopyEntryWithAlarmContentL()
       
   832     {
       
   833     test.Printf(_L("Test copying entry but delete the original one\n"));
       
   834     _LIT8(KUidEntryOriginal, "EntryOriginalUid");
       
   835     CCalAlarm* alarm = StoreEntryWithAlarmContentLC(KUidEntryOriginal());
       
   836     CleanupStack::PopAndDestroy(alarm);
       
   837     
       
   838     RPointerArray<CCalEntry> entries;
       
   839     CleanupResetAndDestroyPushL(entries);
       
   840     iTestLib->SynCGetEntryViewL().FetchL(KUidEntryOriginal(), entries);
       
   841     
       
   842     // Copy the entry from the original one
       
   843     _LIT8(KUidEntryCopy, "EntryCopyUid");
       
   844     HBufC8* guid1 = KUidEntryCopy().AllocLC();
       
   845     CCalEntry* copiedEntry = CCalEntry::NewL(CCalEntry::EEvent, guid1, CCalEntry::EMethodNone,0);
       
   846     CleanupStack::Pop(guid1);
       
   847     CleanupStack::PushL(copiedEntry);
       
   848     copiedEntry->CopyFromL(*entries[0],CCalEntry::EDontCopyId);//restore the alarmaction
       
   849     entries.ResetAndDestroy();
       
   850     entries.AppendL(copiedEntry);
       
   851     CleanupStack::Pop(copiedEntry);
       
   852      
       
   853  //delete the original entry that will delete the alarm and its content 
       
   854     CDesC8ArrayFlat* guidArray = new(ELeave)CDesC8ArrayFlat(1);
       
   855     CleanupStack::PushL(guidArray);
       
   856     guidArray->AppendL(KUidEntryOriginal());
       
   857     iTestLib->SynCGetEntryViewL().DeleteL(*guidArray);
       
   858     CleanupStack::PopAndDestroy(guidArray);
       
   859     
       
   860     //Store the copied entry and access its alarm content
       
   861     TestAlarmL(copiedEntry, KContent(), KMimeType());
       
   862     TInt entriesStored = 0;
       
   863     iTestLib->SynCGetEntryViewL().StoreL(entries, entriesStored);
       
   864     entries.ResetAndDestroy();
       
   865     iTestLib->SynCGetEntryViewL().FetchL(KUidEntryCopy(), entries);
       
   866 
       
   867     TestAlarmL(entries[0], KContent(), KMimeType());
       
   868     CleanupStack::PopAndDestroy(&entries);
       
   869     }
       
   870 
       
   871 void CCalAlarmAttachTest::TestCopyTwiceEntryWithAlarmContentL()
       
   872     {
       
   873     test.Printf(_L("Test copying entry twice \n"));
       
   874     _LIT8(KUidEntryOriginal, "EntryOriginalUid1");
       
   875     CCalAlarm* alarm = StoreEntryWithAlarmContentLC(KUidEntryOriginal());
       
   876     CleanupStack::PopAndDestroy(alarm);
       
   877     
       
   878     RPointerArray<CCalEntry> entries;
       
   879     CleanupResetAndDestroyPushL(entries);
       
   880     iTestLib->SynCGetEntryViewL().FetchL(KUidEntryOriginal(), entries);
       
   881     
       
   882     // Copy the entry from the original one
       
   883     _LIT8(KUidEntryCopy1, "EntryCopyUid1");
       
   884     HBufC8* guid1 = KUidEntryCopy1().AllocLC();
       
   885     CCalEntry* copiedEntry1 = CCalEntry::NewL(CCalEntry::EEvent, guid1, CCalEntry::EMethodNone,0);
       
   886     CleanupStack::Pop(guid1);
       
   887     CleanupStack::PushL(copiedEntry1);
       
   888     copiedEntry1->CopyFromL(*entries[0],CCalEntry::EDontCopyId);//Copied entry1 doesn't have the handel to the server but have iAlarmAction
       
   889     
       
   890     _LIT8(KUidEntryCopy2, "EntryCopyUid2");
       
   891     HBufC8* guid2 = KUidEntryCopy2().AllocLC();
       
   892     CCalEntry* copiedEntry2 = CCalEntry::NewL(CCalEntry::EEvent, guid2, CCalEntry::EMethodNone,0);
       
   893     CleanupStack::Pop(guid2);
       
   894     CleanupStack::PushL(copiedEntry2);
       
   895     copiedEntry2->CopyFromL(*copiedEntry1,CCalEntry::EDontCopyId);//Copyied entry1 should be reset with iAlarmAction
       
   896     TestAlarmL(copiedEntry1, KContent(), KMimeType());
       
   897     TestAlarmL(copiedEntry2, KContent(), KMimeType());
       
   898     TestAlarmL(entries[0], KContent(), KMimeType());
       
   899     CleanupStack::PopAndDestroy(copiedEntry2);
       
   900     CleanupStack::PopAndDestroy(copiedEntry1);
       
   901     CleanupStack::PopAndDestroy(&entries);
       
   902     }
       
   903 
       
   904 void CCalAlarmAttachTest::TestUpdateEntryHavingAlarmcontentL()
       
   905     {
       
   906     test.Printf(_L("Test updating an entry having AlarmContent \n"));
       
   907     
       
   908     //Create a Calendar entry with Alarm Content
       
   909     RPointerArray<CCalEntry> entries;
       
   910     CleanupResetAndDestroyPushL(entries);
       
   911     HBufC8* guid = KGUID1().AllocLC();
       
   912     CCalEntry* calentry = CCalEntry::NewL(CCalEntry::EEvent, guid, CCalEntry::EMethodNone, 0);
       
   913     CleanupStack::Pop(guid);
       
   914     CleanupStack::PushL(calentry);
       
   915     
       
   916     TCalTime calTime1;
       
   917     calTime1.SetTimeUtcL(TDateTime(2007,EFebruary,15, 13, 30, 0, 0));
       
   918     TCalTime calTime2;
       
   919     calTime2.SetTimeUtcL(TDateTime(2007,EFebruary,15, 14, 30, 0, 0));
       
   920     calentry->SetStartAndEndTimeL(calTime1, calTime2);
       
   921     calentry->SetSummaryL(_L("Test for Alarms"));
       
   922     CCalAlarm* alarm = CCalAlarm::NewL();
       
   923     CleanupStack::PushL(alarm);
       
   924     alarm->SetTimeOffset(1);
       
   925         
       
   926     CCalContent* almContent = CCalContent::NewL();
       
   927     CleanupStack::PushL(almContent);
       
   928     // Add content and mimetype for the alarm.
       
   929     HBufC8* content = KContent().AllocLC();
       
   930     HBufC8* mimetype = KMimeType().AllocLC();
       
   931         
       
   932     // Takes ownership of content and mimetype.
       
   933     almContent->SetContentL(content, mimetype, CCalContent::EDispositionInline);
       
   934     alarm->SetAlarmAction(almContent); // Takes ownership of almContent.
       
   935         
       
   936     calentry->SetAlarmL(alarm);
       
   937         
       
   938     CleanupStack::Pop(mimetype);
       
   939     CleanupStack::Pop(content);    
       
   940     CleanupStack::Pop(almContent); 
       
   941     CleanupStack::PopAndDestroy(alarm);
       
   942 
       
   943     TCalRRule rptRule;
       
   944     rptRule.SetDtStart( calTime1 );
       
   945     rptRule.SetType( TCalRRule::EYearly );
       
   946     rptRule.SetCount(5);  
       
   947     calentry->SetRRuleL(rptRule);
       
   948 
       
   949     entries.AppendL(calentry);
       
   950    
       
   951     // Store entry with Alarm content
       
   952     TInt entriesStored = 0;
       
   953     iTestLib->SynCGetEntryViewL().StoreL(entries, entriesStored);   
       
   954     CleanupStack::Pop(calentry);
       
   955     CleanupStack::PopAndDestroy(&entries);
       
   956     
       
   957     //Fetch stored entry and modify alarm time.
       
   958     CleanupResetAndDestroyPushL(entries);
       
   959     iTestLib->SynCGetEntryViewL().FetchL(KGUID1(), entries);
       
   960     CCalEntry* entry = entries[0];
       
   961     alarm = entry->AlarmL();
       
   962     CleanupStack::PushL(alarm);
       
   963     alarm->SetTimeOffset(1);
       
   964     entry->SetAlarmL(alarm);
       
   965     CleanupStack::PopAndDestroy(alarm);
       
   966 
       
   967     //Update the entry with changes.
       
   968     iTestLib->SynCGetEntryViewL().UpdateL(entries, entriesStored); 
       
   969     CleanupStack::PopAndDestroy(&entries);
       
   970 
       
   971     //Fetch updated entry and check if Alarm content is intact.
       
   972     CleanupResetAndDestroyPushL(entries);
       
   973     iTestLib->SynCGetEntryViewL().FetchL(KGUID1(), entries);
       
   974     TestAlarmL(entries[0], KContent(), KMimeType());
       
   975     CleanupStack::PopAndDestroy(&entries);
       
   976     }
       
   977 	
       
   978 /**
       
   979 
       
   980 @SYMTestCaseID     PIM-TCAL-ALARMATTACH-0001
       
   981 
       
   982 */
       
   983 
       
   984 TInt E32Main()
       
   985     {
       
   986 	__UHEAP_MARK;
       
   987 	CTrapCleanup* trapCleanup = CTrapCleanup::New();
       
   988 	CActiveScheduler* scheduler = new CActiveScheduler;
       
   989 	test(scheduler != NULL);
       
   990 	CActiveScheduler::Install(scheduler);
       
   991 	
       
   992 	test.Start(_L("@SYMTESTCaseID:PIM-TCAL-ALARMATTACH-0001 Calendar entry alarm attachment tests"));
       
   993 
       
   994 	test.Title();
       
   995 	TRAPD(r, DoMainL());
       
   996 	test(r == KErrNone);
       
   997 	test.End();
       
   998 	test.Close();
       
   999 	
       
  1000 	delete scheduler;
       
  1001 	delete trapCleanup;
       
  1002 
       
  1003 	__UHEAP_MARKEND;
       
  1004 	return KErrNone;
       
  1005     }