pimappservices/calendar/tsrc/tcal_dataexchange.h
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __DATAEXCHANGETESTMANAGER_H__
       
    17 #define __DATAEXCHANGETESTMANAGER_H__
       
    18 
       
    19 
       
    20 #include <caldataexchange.h>
       
    21 #include "caltestlib.h"
       
    22 #include <tz.h>
       
    23 #include <coreappstest/testserver.h>
       
    24 
       
    25 enum TImportedDaylightTest
       
    26      {
       
    27      EImportedDLRuleBadStart,
       
    28      EImportedDLRuleBadEnd,
       
    29      EImportedDLRuleEndBeforeStart,
       
    30      EImportedDLRuleMissing,
       
    31      EImportedDLOneGoodRule,
       
    32      EImportedDLTwoBadRules,
       
    33      EImportedDLOneBadOneGoodRule,
       
    34      EImportedDLNoTZOneGoodRule,
       
    35      EImportedDLNoTZTwoBadRules,
       
    36      EImportedDLNoTZOneBadOneGoodRule,
       
    37      EImportedDLNoTZMissing
       
    38      };
       
    39       
       
    40 
       
    41 class CCalInstance;
       
    42 class CDataExchangeTestManager;
       
    43 
       
    44 // A callback for the multi async import test.
       
    45 class CAsyncImportDataExCallback : public MCalDataExchangeCallBack
       
    46     {
       
    47     public:
       
    48         void Progress( TInt aPercentageCompleted );
       
    49 	    void Completed();
       
    50     };
       
    51 
       
    52 //Used by CDataExchangeTestManager::ChangeTimeZoneAndRunTest
       
    53 typedef void (CDataExchangeTestManager::*Test)(TBool aIsSynch);
       
    54 
       
    55 class CDataExchangeTestManager : public CBase, public MCalDataExchangeCallBack
       
    56 	{
       
    57 public:
       
    58     static CDataExchangeTestManager* NewLC();
       
    59     ~CDataExchangeTestManager();
       
    60 	void ChangeTimeZoneAndRunTestL(const TDesC8& aTimeZone, Test aTestToRun, TBool aIsSynch);	    
       
    61     
       
    62     // from MCalDataExchangeCallBack
       
    63 	void Progress(TInt aPercentageCompleted);
       
    64 	void Completed();
       
    65 	TInt NumberOfEntriesToHandleAtOnce();
       
    66 
       
    67     void ExtractAlarmL(TBool aIsSynch);
       
    68     void ExportFloatingAlarmL(TBool aIsSynch);
       
    69 	void TestImportEntriesL(TBool aIsSynch);
       
    70 	void TestLUIDFromImportEntriesL(TBool aIsSynch);
       
    71 	void TestImportNEntriesL();
       
    72 	void TestImportEntriesWithTrailingSpaceL(TBool aIsSynch);
       
    73 	void TestExportEntriesL(TBool aIsSynch);
       
    74 	void TestImportingInvalidChildEntriesL(TBool aIsSynch);
       
    75 	void TestPhoneOwnerPersistenceL();
       
    76 	void TestOrganizerIsStoredL(TBool aIsSynch);
       
    77 	void TestOrganizerIsStored2();
       
    78 	void TestGSEntriesL(TBool aIsSynch);
       
    79 	void TestEntriesL(CCalEntry::TType aType, TBool aIsSynch);
       
    80 	void TestAlarmEntriesL(CCalEntry::TType aType, TBool aIsSynch);
       
    81 
       
    82 	void TestEntryUpdateL(TBool aIsSynch);
       
    83 	void TestReminderEntryExportL(TBool aIsSynch);
       
    84 	void TestReminderEntryImportL(TBool aIsSynch);
       
    85 	void TestAsyncImportL(const TDesC& aFileName);
       
    86 	void TestAsyncExportL(const TDesC& aFileName);
       
    87 	void SetNumEntriesToImportAndExport(TInt aNumEntries);
       
    88 	void BadExceptionDateTestL(TBool aIsSynch);
       
    89 	void TestTzPropertiesL(TBool aIsSynch);
       
    90 	void ResetAgendaFileL();
       
    91 	void TestFixedAndFloatingTodoL(TBool aIsSynch);
       
    92 	void TestTodoWithoutDueDateL(TBool aIsSynch);
       
    93 	void TestAlarmedTodoWithoutDueDateL(TBool aIsSynch);
       
    94 	void TestEntriesWithoutDatesL(TBool aIsSynch);
       
    95 	void TestFloatingExceptionL(TBool aIsSynch);
       
    96 	void TestTodoCompletedDateL(TBool aIsSynch);
       
    97 	void TestOutOfRangeRDateL(TBool aIsSynch);
       
    98 	void TestInvalidUntilDateL(TBool aIsSynch);
       
    99 	void TestInvalidExceptionsL(TBool aIsSynch);
       
   100 	
       
   101 	void CreateVcalFileL(const TDesC8& aVCalData, const TDesC& aFileName);
       
   102 	void DeleteVcalFileL(const TDesC& aFileName);
       
   103 	void DoImportL(const TDesC& aVCalendarFile);
       
   104 	void DoImportLastDayL(const TDesC& aVCalendarFile);
       
   105 	void TestEntriesL();
       
   106 	void TestChildEntryL();
       
   107  	void TestVCalTypeSequenceL(TBool aIsSynch);
       
   108  	void TestMidnightRecIdL(TBool aIsSynch);
       
   109  	void TestMidnightRecId2L(TBool aIsSynch);
       
   110  	void TestMidnightRecId3L(TBool aIsSynch);
       
   111 
       
   112 	void TestImportTodoWithTzL(TBool aIsSynch);
       
   113 
       
   114 	void TestImportTodoWithWrongTzL(TBool aIsSynch);
       
   115 	void TestUIDImportL(const TDesC& aFileToImport, const TDesC& aFileToExport, TBool aIsSynch);
       
   116 	void TestRRuleEndDateL(TBool aIsSynch);
       
   117  	
       
   118     void TestOrphanedEntryL(TBool aIsSynch);
       
   119 	void ImportAndExportL(const TDesC8& aVCalData, const TDesC& aImportVCalendarFile, TInt aNumEntry, TBool aIsSynch);
       
   120 	void TestExceptionDatesConversionL(TBool aIsSynch);
       
   121     void TestMultipleAsyncImportL();
       
   122 
       
   123     void TestUntilDateImportL(TBool aIsSynch);
       
   124     void TestUntilDateImportForVCalL(const TDesC8& aVcal, TInt aDay, TInt aHour, TCalTime::TTimeMode aTimeMode, TBool aIsSynch);
       
   125     
       
   126     void TestRDateAndExceptionL(TBool aIsSynch);
       
   127 
       
   128     void StoreEntryL(CCalEntry* aEntry);
       
   129     void FetchAllL( RPointerArray<CCalInstance>& aInstances );
       
   130     void OutputAllL( RPointerArray<CCalInstance>& aInstances );
       
   131     
       
   132     void TestToDoStartDateL(TBool aIsSynch);
       
   133     void TestFloatingToDoStartDateL(TBool aIsSynch);
       
   134     void TestFloatingRecIdL(TBool aIsSynch);
       
   135     void TestMonthlyRepeatDateL(TBool aIsSynch);
       
   136 	void TestImportingAlarmedFloatingAniversaryL(TBool aIsSynch);
       
   137     void TestImportExportParentChildEntriesL(const TDesC8& aVcal,
       
   138 	    									 TBool aIsSynch,	
       
   139                                              const TBool aTestParentRptStartTrimToRecId = EFalse,
       
   140                                              const TBool aTestParentRptUntilTrimToRecId = EFalse,
       
   141                                              const TTime& aNewRecId = Time::NullTTime());
       
   142     void TestImportStoreParentChildEntriesL(TBool aIsSynch);
       
   143     void BadDaylightRuleL(TBool aIsSynch);
       
   144     void TestImportParentChildEntriesL(const TDesC8& aVcal, TBool aIsSynch);
       
   145     void TestImportStoreNotMatchingParentChildEntriesL(TBool aIsSynch);
       
   146 	void TestAttachmentImportExportL(TBool aIsSynch, TBool aNegtiveTest = EFalse);
       
   147 	void TestAttachmentExportImportL(TBool aIsSynch);
       
   148 	void PrepareFileForContentIdAttachmentL();
       
   149 	void TestTzInstanceCountL(TBool aIsSynch);
       
   150 	void TestFloatingEntryFixedExDateL(TBool aIsSynch);
       
   151 	void TestExceptedEntryWithRDateL(TBool aIsSynch);
       
   152 	void TestRDateExceptionL(TBool aIsSynch);
       
   153     void PanicOnUpdateL(TBool aIsSynch);
       
   154 	void TestChildDTSTARTExportL(TBool aIsSynch);
       
   155 	void TestReccurenceIDRangeL(TBool aIsSynch);
       
   156 	void TestParentDTENDExportL(TBool aIsSynch) ;
       
   157 	void TestExDateTimeL(TBool aIsSynch);
       
   158     void TestImportingInvalidDayLightL(TImportedDaylightTest aTestToRun, TBool aExpectDaylight, TBool aIsSynch);
       
   159     void TestLUIDL(TBool aIsSynch);
       
   160     void TestRRuleUntilTimeL(TBool aIsSynch);
       
   161 	void TestBadTimeZoneL(TBool aIsSynch);
       
   162 	void TestRepeatEntryHasCountAndEndDateL(TBool aIsSynch);
       
   163 	void TestExDateUntilTimeL(TBool aIsSynch);
       
   164 	void TestOOMExportL(TBool aIsSynch);
       
   165 	void TestImportTodoWithXEpocAlarmL(TBool aIsSynch);
       
   166 	void TestImportvCalsGeneratesUniqueIdL(TBool aIsSynch);
       
   167 	void TestImportWithInvalidRRuleDateL(TBool aIsSynch);
       
   168 	void TestMP1RRuleL(TBool aIsSynch);
       
   169 	void TestLostRangeL(TBool aIsSynch);
       
   170 	void EmptyAttachmentL(TBool aIsSynch);
       
   171 
       
   172 	void TestMailtoL();
       
   173 	void TestExDateTzProblemL(TBool aIsSynch);
       
   174 	void AlarmOffsetForUndatedTodoL(TBool aIsSynch);
       
   175 	void TestTzExportL(TBool aIsSynch);
       
   176 	void TestTzImportL(TBool aIsSynch);
       
   177 	void TestCategoryL(TBool aIsSynch);
       
   178     void ImportInvalidChildEntryL(TBool aIsSynch);
       
   179 	void TestImportParentWithoutRRuleL(TBool aIsSynch);
       
   180 	void TestExportToDoStartDateEqualDueDateL(TBool aIsSynch);
       
   181 	void TestGEOImportAndExportL(TBool aIsSynch);
       
   182 	void TestGEOImportL(RPointerArray<HBufC8>& aBufArray, RPointerArray<CCalEntry>& aEntryArray, TBool aIsSynch);
       
   183 	void TestGEOExportL(RPointerArray<CCalEntry>& aEntryArray, TBool aIsSynch);
       
   184 	TBool TestGEOVerifyImportL(const TReal& aExpLat, const TReal& aExpLong, CCalEntry& aEntry);
       
   185 	TBool TestGEOVerifyExportL(const TDesC &aFileName, CCalEntry& aEntry);
       
   186 	void TestChildAddedToFirstInstanceL(TBool aIsSynch);
       
   187 	void TestEntryAlarmTimeL(TBool aIsSynch);
       
   188 	void TestRDATEOOMExportL(TBool aIsSynch);
       
   189 	void TestOOMImportL(TBool aIsSynch);
       
   190 	void TestLocalToUtcConversionAgainstEventDurationL(TBool aIsSynch);
       
   191 	void TestMaxDateTimeHandlingForRepeatRuleLocalTimeL(TBool aIsSynch);
       
   192 	//PDEF111292 - Begin
       
   193 	void TestTzExportKSTL(TBool aIsSynch);
       
   194 	void TestTzExportPSTL(TBool aIsSynch);
       
   195 	//PDEF111292 - End
       
   196 	void TestImportEntryWithoutGuidL(TBool aIsSynch);
       
   197 	void TestMultipleTZPropertiesL();
       
   198 	
       
   199     void TestImportParentAndChildEntryL(const TDesC8& aParentEntry,
       
   200                                         const TDesC8& aChildEntry,
       
   201                                         const TInt aExpectedNumOfEntriesStored,
       
   202                                         TBool aIsSynch);
       
   203     
       
   204     void TestDaylightExportOverlapL(TBool aIsSynch);
       
   205     void SyncAndAsynchronousTests(TBool aIsSynch);
       
   206   	
       
   207 private:
       
   208 	void ConstructL();
       
   209 	void CreateTestFileL(const TDesC8& aVCalData, const TDesC& aFileName);	
       
   210 	void ImportL(const TDesC& aImportVCalendarFile, RPointerArray<CCalEntry>& aEntriesImported, TBool aIsSynch);
       
   211 	void ExportL(const TDesC& aExportVCalendarFile, RPointerArray<CCalEntry>& aEntriesExported, TBool aIsSynch);	
       
   212 	void ExportImportAndCheckL(RPointerArray<CCalEntry>& aEntryArray, TBool aIsSynch);
       
   213 	void TestToDoEntryL(CCalEntry& aEntry);
       
   214 	TBool TestEntry1L(CCalEntry& aEntry);
       
   215 	TBool TestEntry2L(CCalEntry& aEntry);
       
   216 	TBool TestEntry3L(CCalEntry& aEntry);
       
   217     TBool TestTodoDateImportL( CCalEntry& aEntry, TPtrC8 uidValue );
       
   218     void TestAttendeeImportL( CCalEntry& aEntry );
       
   219 	void TestRecurrenceIdImportL( CCalEntry& aParentEntry, CCalEntry& aChildEntry );
       
   220 	void PrintAttendeeL(CCalAttendee* aAttendee);
       
   221 	void ModifyRRuleL(CCalEntry& aEntry, TInt aStartYear, TInt aEndYear, TBool aRepeatForever, TMonth aMonth);
       
   222 	TBool TestEntriesForTzPropertiesL(RPointerArray<CCalEntry>& aEntryArray, TInt* aExpectedYears, TBool aIsSynch);
       
   223 	TInt  GetDaylightYear(const TDesC8& aLine);
       
   224 	TInt  GetDaylightYearsL(const TDesC& aFile, RArray<TInt>& aYears);
       
   225 	void  SetTimeZoneL(const TDesC8& aTimeZone);
       
   226 	void  SetCurrentYear(RTz& aTz, TInt aYear);
       
   227 	TBool CheckTwoArrayEntryL(RPointerArray<CCalEntry>& aSouceArray, RPointerArray<CCalEntry>& aCompareArray);
       
   228 	void CreateEntriesL(CCalEntry::TType aType, RPointerArray<CCalEntry>& aEntryArray);
       
   229 	void CreateAlarmTestEntriesL(CCalEntry::TType aType, RPointerArray<CCalEntry>& aEntryArray);
       
   230 
       
   231  	TBool CheckStringInFileL(const TDesC8 &aString, const TDesC &aFileName, TBool aToBeFound) ;
       
   232 
       
   233 private:	// TestVCalTypeSequence
       
   234 	struct TEntryCheckData
       
   235 		{
       
   236 		TInt iPos;
       
   237 		CCalEntry::TType iType;
       
   238 		TTime iStartTime;
       
   239 		TTime iEndTime;
       
   240 		};
       
   241 	void TestVCalTypeSequenceL(const TDesC8& aVCalData, TInt aKEntryNum, 
       
   242 								TInt aExpectToStore,TEntryCheckData& aCheckData, TBool aIsSynch);
       
   243 	void ListEntriesL(RPointerArray<CCalEntry>& aEntryArray);
       
   244 	TInt NumberAllEntryL();
       
   245 	
       
   246 private:
       
   247 	CCalTestLibrary*  iTestLib;
       
   248 	CCalDataExchange* iDataExchange;
       
   249 	TInt              iNumEntriesToImportAndExport;
       
   250 	CAsyncImportDataExCallback* iAsyncImportCallback;
       
   251 	};
       
   252 
       
   253 	
       
   254 #endif