/** * Test the alarm properties of the entry that has alarm content. * * @param aEntry The calendar entry to test. * @param expectedContent The expected content in aEntry. * @param expectedMimeType The expected mime type in aEntry. */ void CCalAlarmAttachTest::TestAlarmL( CCalEntry* aEntry, const TDesC8& expectedContent, const TDesC8& expectedMimeType ) { CCalAlarm* almEntry = aEntry->AlarmL(); CleanupStack::PushL(almEntry); test( almEntry != NULL ); CCalContent* alarmcontent1 = almEntry->AlarmAction(); test( alarmcontent1 != NULL ); const TDesC8& content = alarmcontent1->Content(); test( content == expectedContent ); const TDesC8& mimetype = alarmcontent1->MimeType(); test( mimetype == expectedMimeType ); CleanupStack::PopAndDestroy(almEntry); }
void CCalAlarmAttachTest::TestDeleteAlarmWithAlarmContentL() { test.Printf(_L("Test deleting alarm from an entry \n")); _LIT8(KEntryUidDeleteAlarm, "DeleteAlarmUid"); CCalAlarm* alarm = StoreEntryWithAlarmContentLC(KEntryUidDeleteAlarm()); RPointerArray<CCalEntry> entries; CleanupResetAndDestroyPushL(entries); //Update the entry by deleting its alarm iTestLib->SynCGetEntryViewL().FetchL(KEntryUidDeleteAlarm(), entries); CCalEntry* entry = entries[0]; entry->SetAlarmL(NULL); TInt entriesStored = 0; iTestLib->SynCGetEntryViewL().StoreL(entries, entriesStored); //Update the entry by adding an alarm but without alarm content entries.ResetAndDestroy(); iTestLib->SynCGetEntryViewL().FetchL(KEntryUidDeleteAlarm(), entries); alarm->SetAlarmAction(NULL); entry = entries[0]; entry->SetAlarmL(alarm); iTestLib->SynCGetEntryViewL().StoreL(entries, entriesStored); entries.ResetAndDestroy(); //Fetch the entry and test the entry has an alarm but not alarm content iTestLib->SynCGetEntryViewL().FetchL(KEntryUidDeleteAlarm(), entries); CCalAlarm* almEntry = entries[0]->AlarmL(); CleanupStack::PushL(almEntry); test( almEntry != NULL ); CCalContent* alarmcontent = almEntry->AlarmAction(); test( alarmcontent == NULL ); CleanupStack::PopAndDestroy(almEntry); CleanupStack::PopAndDestroy(&entries); CleanupStack::PopAndDestroy(alarm); }
TVerdict CTestCalInterimApiRichAlarmFormatStep::doTestStepL() { CActiveScheduler* scheduler = new(ELeave)CActiveScheduler; CleanupStack::PushL(scheduler); CActiveScheduler::Install(scheduler); iSession = CCalSession::NewL(); CTestCalInterimApiCallbackForRichAlarms* alarmCallback = CTestCalInterimApiCallbackForRichAlarms::NewL(this); CleanupStack::PushL(alarmCallback); OpenSessionFileL(); iEntryView = CCalEntryView::NewL(*iSession,*alarmCallback); CActiveScheduler::Add(alarmCallback); CActiveScheduler::Start(); //build the CCalDataExchange object and import CCalDataExchange* dataExchange = CCalDataExchange::NewL(*iSession); CleanupStack::PushL(dataExchange); //IMPORT the calendar info from a known file RFs fs; fs.Connect(); CleanupClosePushL(fs); RFile inFile; CleanupClosePushL(inFile); TInt errR = inFile.Open(fs, GetFullFileName(KEntryImportFile), EFileRead); RFileReadStream readStream(inFile); CleanupClosePushL(readStream); RPointerArray<CCalEntry> secondEntryArray; CleanupStack::PushL(TCleanupItem(CloseAndDeleteRPtrArrayEntries, &secondEntryArray)); secondEntryArray.Reset(); INFO_PRINTF1(KImporting); TInt index = 0; for (index = 0; index < KNumEntriesInFile; index++) { dataExchange->ImportL(KUidVCalendar, readStream, secondEntryArray); } CleanupStack::Pop(&secondEntryArray); CleanupStack::PopAndDestroy(&readStream); CleanupStack::PopAndDestroy(&inFile); CleanupStack::PushL(TCleanupItem(CloseAndDeleteRPtrArrayEntries, &secondEntryArray)); SetTestStepResult(CompareAlarmDataL(&secondEntryArray)); //Test for importing from a badly formatted file RFile badInFile; CleanupClosePushL(badInFile); TInt baddErr = badInFile.Open(fs, GetFullFileName(KEntryBadImportFile), EFileRead); RFileReadStream badStream(badInFile); CleanupClosePushL(badStream); RPointerArray<CCalEntry> badEntryArray; CleanupStack::PushL(TCleanupItem(CloseAndDeleteRPtrArrayEntries, &badEntryArray)); badEntryArray.Reset(); INFO_PRINTF1(KImporting); TInt i = 0; for (i = 0; i < 1; i++) { dataExchange->ImportL(KUidVCalendar, badStream, badEntryArray); } CCalEntry* pEntry = badEntryArray[0]; CCalAlarm* pAlarm = pEntry->AlarmL(); if (pAlarm) { CleanupStack::PushL(pAlarm); CCalContent* pContent = pAlarm->AlarmAction(); if (pContent != NULL) { ERR_PRINTF1(KUnexpectedAlarmAction); SetTestStepResult(EFail); } delete pContent; CleanupStack::PopAndDestroy(pAlarm); } CleanupStack::PopAndDestroy(&badEntryArray); CleanupStack::PopAndDestroy(&badStream); CleanupStack::PopAndDestroy(&badInFile); CleanupStack::PopAndDestroy(5 , scheduler); return TestStepResult(); }