37 // Delete here all resources allocated and opened from test methods. |
35 // Delete here all resources allocated and opened from test methods. |
38 // Called from destructor. |
36 // Called from destructor. |
39 // ----------------------------------------------------------------------------- |
37 // ----------------------------------------------------------------------------- |
40 // |
38 // |
41 void CCalenInterimUtils2Test::Delete() |
39 void CCalenInterimUtils2Test::Delete() |
42 { |
40 { |
43 // Nothing. |
41 // Nothing. |
44 } |
42 if(iCalenInterimUtils) |
|
43 { |
|
44 delete iCalenInterimUtils; |
|
45 iCalenInterimUtils = NULL; |
|
46 } |
|
47 |
|
48 if(iCalEntryView) |
|
49 { |
|
50 delete iCalEntryView; |
|
51 iCalEntryView = NULL; |
|
52 } |
|
53 |
|
54 if(iWait) |
|
55 { |
|
56 delete iWait; |
|
57 iWait = NULL; |
|
58 } |
|
59 |
|
60 if(iCalSession) |
|
61 { |
|
62 delete iCalSession; |
|
63 iCalSession = NULL; |
|
64 } |
|
65 } |
45 |
66 |
46 // ----------------------------------------------------------------------------- |
67 // ----------------------------------------------------------------------------- |
47 // CCalendarCommonUtilsTest::RunMethodL |
68 // CCalendarCommonUtilsTest::RunMethodL |
48 // Run specified method. Contains also table of test mothods and their names. |
69 // Run specified method. Contains also table of test mothods and their names. |
49 // ----------------------------------------------------------------------------- |
70 // ----------------------------------------------------------------------------- |
50 // |
71 // |
51 TInt CCalenInterimUtils2Test::RunMethodL( |
72 TInt CCalenInterimUtils2Test::RunMethodL( |
52 CStifItemParser& aItem ) |
73 CStifItemParser& aItem ) |
53 { |
74 { |
54 |
75 TRAP(iError, iCalSession = CCalSession::NewL();); |
|
76 const TDesC& file = iCalSession->DefaultFileNameL(); |
|
77 TRAP(iError, iCalSession->OpenL(file)); |
|
78 iCalenInterimUtils = CCalenInterimUtils2::NewL(); |
55 static TStifFunctionInfo const KFunctions[] = |
79 static TStifFunctionInfo const KFunctions[] = |
56 { |
80 { |
57 // Copy this line for every implemented function. |
81 // Copy this line for every implemented function. |
58 // First string is the function name used in TestScripter script file. |
82 // First string is the function name used in TestScripter script file. |
59 // Second is the actual implementation member function. |
83 // Second is the actual implementation member function. |
60 // Example: ENTRY( "Example", CCalenInterimUtils2Test::ExampleL ), |
84 // Example: ENTRY( "Example", CCalenInterimUtils2Test::ExampleL ), |
61 |
85 |
62 /** Test functions for API CalenDateUtils */ |
86 /** Test functions for API CalenDateUtils */ |
63 ENTRY( "TestGlobalUUID", |
87 ENTRY( "TestGlobalUUID", |
64 CCalenInterimUtils2Test::TestGlobalUUIDL ), |
88 CCalenInterimUtils2Test::TestGlobalUUIDL ), |
|
89 ENTRY( "TestPopulateChildEntry", |
|
90 CCalenInterimUtils2Test::TestPopulateChildEntryL ), |
|
91 ENTRY( "TestStore", |
|
92 CCalenInterimUtils2Test::TestStoreL ), |
65 //ADD NEW ENTRY HERE |
93 //ADD NEW ENTRY HERE |
66 // [test cases entries] - Do not remove |
94 // [test cases entries] - Do not remove |
67 }; |
95 }; |
68 |
96 |
69 const TInt count = sizeof( KFunctions ) / sizeof( TStifFunctionInfo ); |
97 const TInt count = sizeof( KFunctions ) / sizeof( TStifFunctionInfo ); |
75 // CCalenInterimUtils2Test::TestGlobalUUIDL |
103 // CCalenInterimUtils2Test::TestGlobalUUIDL |
76 // Test funtion to test the API CCalenInterimUtils2::GlobalUidL |
104 // Test funtion to test the API CCalenInterimUtils2::GlobalUidL |
77 // (other items were commented in a header). |
105 // (other items were commented in a header). |
78 // ----------------------------------------------------------------------------- |
106 // ----------------------------------------------------------------------------- |
79 // |
107 // |
80 TInt CCalenInterimUtils2Test::TestGlobalUUIDL( CStifItemParser& aItem ) |
108 TInt CCalenInterimUtils2Test::TestGlobalUUIDL( CStifItemParser& /*aItem*/ ) |
81 { |
109 { |
82 TInt retValue = KErrNone; |
110 TInt retValue = KErrNone; |
83 // Print to UI |
111 // Print to UI |
84 _LIT( KCalenInterimUtils2Test, "CalenInterimUtils2Test" ); |
112 _LIT( KCalenInterimUtils2Test, "CalenInterimUtils2Test" ); |
85 _LIT( KDuplicateUids, "Uids are duplicate" ); |
113 _LIT( KDuplicateUids, "Uids are duplicate" ); |
88 |
116 |
89 TestModuleIf().Printf( 0, KCalenInterimUtils2Test, KTestGlobalUUID ); |
117 TestModuleIf().Printf( 0, KCalenInterimUtils2Test, KTestGlobalUUID ); |
90 // Print to log file |
118 // Print to log file |
91 iLog->Log( KTestGlobalUUID ); |
119 iLog->Log( KTestGlobalUUID ); |
92 iLog->Log( KTestGlobalUUIDs ); |
120 iLog->Log( KTestGlobalUUIDs ); |
93 // Construct the calendar global data. |
|
94 CCalProgressCallBackListener *callBack = NULL; |
|
95 callBack = CCalProgressCallBackListener::NewL(); |
|
96 CCalenGlobalData* globalData = CCalenGlobalData::NewL( *callBack ); |
|
97 // Make the call to the API. |
121 // Make the call to the API. |
98 // Create unique ID. |
122 // Create unique ID. |
99 RPointerArray<HBufC8> guids; |
123 RPointerArray<HBufC8> guids; |
100 |
|
101 TInt i = 0; |
124 TInt i = 0; |
102 |
|
103 for( ; i<20; i++ ) |
125 for( ; i<20; i++ ) |
104 { |
126 { |
105 HBufC8* guid = globalData->InterimUtilsL().GlobalUidL(); |
127 HBufC8* guid = iCalenInterimUtils->GlobalUidL(); |
106 iLog->Log( *guid ); |
128 iLog->Log( *guid ); |
107 guids.AppendL(guid); |
129 guids.AppendL(guid); |
108 } |
130 } |
109 |
131 |
|
132 // Validate the guids so that none of them will be duplicates |
110 for(i=1; i < 20; i++) |
133 for(i=1; i < 20; i++) |
111 { |
134 { |
112 for(TInt j = 0; j < i; j++) |
135 for(TInt j = 0; j < i; j++) |
113 { |
136 { |
114 if( guids[j] == guids[i] ) |
137 if( guids[j] == guids[i] ) |
118 break; |
141 break; |
119 } |
142 } |
120 } |
143 } |
121 } |
144 } |
122 guids.ResetAndDestroy(); |
145 guids.ResetAndDestroy(); |
123 globalData->Release(); |
|
124 |
|
125 // Validate the result. |
|
126 |
146 |
127 return retValue; |
147 return retValue; |
128 |
|
129 } |
148 } |
130 |
149 |
131 |
150 // ----------------------------------------------------------------------------- |
132 |
151 // CCalenInterimUtils2Test::TestPopulateChildEntryL |
|
152 // Test funtion to test the API CCalenInterimUtils2::PopulateChildEntryL |
|
153 // (other items were commented in a header). |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 TInt CCalenInterimUtils2Test::TestPopulateChildEntryL( CStifItemParser& /*aItem*/ ) |
|
157 { |
|
158 TInt retValue = KErrNone; |
|
159 _LIT8( KTestUid, "123547"); |
|
160 // Print to UI |
|
161 _LIT( KCalenInterimUtils2Test, "CalenInterimUtils2Test" ); |
|
162 _LIT( KTestGlobalUUID, "In TestPopulateChildEntryL" ); |
|
163 |
|
164 TestModuleIf().Printf( 0, KCalenInterimUtils2Test, KTestGlobalUUID ); |
|
165 |
|
166 // Create a parent entry |
|
167 //entry |
|
168 CCalEntry* parentEntry = NULL; |
|
169 |
|
170 parentEntry = CCalEntry::NewL(CCalEntry::EEvent, KTestUid().AllocL(), CCalEntry::EMethodNone, 0 ); |
|
171 // Set necessary field |
|
172 parentEntry->SetSummaryL(_L("test Entry")); |
|
173 parentEntry->SetLocationL(_L("test Location")); |
|
174 parentEntry->SetStatusL(CCalEntry::EConfirmed); |
|
175 CleanupStack::PushL( parentEntry ); |
|
176 |
|
177 // Create the child entry |
|
178 CCalEntry* childEntry = NULL; |
|
179 |
|
180 childEntry = CCalEntry::NewL(CCalEntry::EEvent, KTestUid().AllocL(), CCalEntry::EMethodNone, 0 ); |
|
181 CleanupStack::PushL( childEntry ); |
|
182 // Call the api so that all the parent attributes gets transfered to child |
|
183 iCalenInterimUtils->PopulateChildFromParentL(*childEntry, *parentEntry); |
|
184 |
|
185 // Validation |
|
186 if(childEntry->SummaryL().Compare(parentEntry->SummaryL())) |
|
187 { |
|
188 retValue = KErrGeneral; |
|
189 } |
|
190 else if(childEntry->LocationL().Compare(parentEntry->LocationL())) |
|
191 { |
|
192 retValue = KErrGeneral; |
|
193 } |
|
194 else if(childEntry->StatusL() != parentEntry->StatusL()) |
|
195 { |
|
196 retValue = KErrGeneral; |
|
197 } |
|
198 CleanupStack::PopAndDestroy(childEntry); |
|
199 CleanupStack::PopAndDestroy(parentEntry); |
|
200 return retValue; |
|
201 } |
|
202 |
|
203 // ----------------------------------------------------------------------------- |
|
204 // CCalenInterimUtils2Test::TestStoreL |
|
205 // Test funtion to test the API CCalenInterimUtils2::StoreL |
|
206 // (other items were commented in a header). |
|
207 // ----------------------------------------------------------------------------- |
|
208 // |
|
209 TInt CCalenInterimUtils2Test::TestStoreL( CStifItemParser& /*aItem*/ ) |
|
210 { |
|
211 TInt retValue = KErrNone; |
|
212 // Print to UI |
|
213 _LIT( KCalenInterimUtils2Test, "CalenInterimUtils2Test" ); |
|
214 _LIT( KTestGlobalUUID, "In TestStoreL" ); |
|
215 TestModuleIf().Printf( 0, KCalenInterimUtils2Test, KTestGlobalUUID ); |
|
216 |
|
217 // Create the entry view |
|
218 TRAPD(error, iCalEntryView = CCalEntryView::NewL(*iCalSession, *this);) |
|
219 if(!iWait) |
|
220 { |
|
221 TRAP(error, iWait = new (ELeave) CActiveSchedulerWait;); |
|
222 if(!iWait->IsStarted()) |
|
223 { |
|
224 iWait->Start(); |
|
225 } |
|
226 } |
|
227 if(iError != KErrNone) |
|
228 { |
|
229 return KErrGeneral; |
|
230 } |
|
231 else |
|
232 { |
|
233 // Entry view creation is complete |
|
234 // Create the CcalEntry and store it |
|
235 _LIT8( KTestUid, "123548"); |
|
236 CCalEntry* parentEntry = NULL; |
|
237 |
|
238 parentEntry = CCalEntry::NewL(CCalEntry::EEvent, KTestUid().AllocL(), CCalEntry::EMethodNone, 0 ); |
|
239 // Set necessary field |
|
240 parentEntry->SetSummaryL(_L("test Entry")); |
|
241 parentEntry->SetLocationL(_L("test Location")); |
|
242 TCalTime startTime; |
|
243 TDateTime dateTime; |
|
244 dateTime.Set(2010, TMonth(1), 1, 10, 0, 0, 0); |
|
245 TTime time(dateTime); |
|
246 startTime.SetTimeLocalL(time); |
|
247 parentEntry->SetStartAndEndTimeL(startTime, startTime); |
|
248 parentEntry->SetStatusL(CCalEntry::EConfirmed); |
|
249 CleanupStack::PushL( parentEntry ); |
|
250 |
|
251 // Store it |
|
252 iCalenInterimUtils->StoreL(*iCalEntryView, *parentEntry, false); |
|
253 CleanupStack::PopAndDestroy(parentEntry); |
|
254 } |
|
255 return retValue; |
|
256 } |
|
257 |
|
258 // ----------------------------------------------------------------------------- |
|
259 // CCalenInterimUtils2Test::Completed |
|
260 // Callback function for entry view creation. |
|
261 // (other items were commented in a header). |
|
262 // ----------------------------------------------------------------------------- |
|
263 // |
|
264 void CCalenInterimUtils2Test::Completed(TInt aError) |
|
265 { |
|
266 iError = aError; |
|
267 // Stop the wait timer |
|
268 if( iWait && iWait->IsStarted()) |
|
269 { |
|
270 iWait->AsyncStop(); |
|
271 } |
|
272 } |
133 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
273 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
134 // None |
274 // None |
135 |
275 |
136 // [End of File] - Do not remove |
276 // [End of File] - Do not remove |