1 /* |
|
2 * Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: T_ui_context_utility_api test module. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // DEFINITION OF GLOBAL VARIABLES |
|
20 #ifdef TEST_VAR_DECLARATIONS |
|
21 // here You can define global objects used all over code |
|
22 CHgContextUtility* iContextUtility; |
|
23 #endif |
|
24 |
|
25 // testing code starts here |
|
26 #ifdef TEST_CASES |
|
27 |
|
28 #ifndef KNAME |
|
29 #define KNAME |
|
30 _LIT(KName,"James Bond"); |
|
31 #endif |
|
32 |
|
33 // STIF_SETUP defines activities needed before every test case. |
|
34 STIF_SETUP |
|
35 { |
|
36 iContextUtility = CHgContextUtility::NewL(); |
|
37 return KErrNone; |
|
38 } |
|
39 |
|
40 // STIF_TEARDOWN defines activities needed after every test case |
|
41 STIF_TEARDOWN |
|
42 { |
|
43 delete iContextUtility; |
|
44 return KErrNone; |
|
45 } |
|
46 |
|
47 // a Canary test to verify test environment. |
|
48 STIF_TESTDEFINE( CanaryTest ) |
|
49 { |
|
50 |
|
51 } |
|
52 |
|
53 STIF_TESTDEFINE( T_MemoryOnlyTest ) |
|
54 { |
|
55 /*private implementation IsForeground |
|
56 cant be covered by tests because covered by previous condition*/ |
|
57 iContextUtility->AllowPublishFromBackground( ETrue ); |
|
58 iContextUtility->AllowPublishFromBackground( EFalse ); |
|
59 return KErrNone; |
|
60 } |
|
61 //Test code for testing PublishContextL function call |
|
62 STIF_TESTDEFINE( T_PublishContextL ) |
|
63 { |
|
64 // publish the Hg.Contact context to CF |
|
65 iContextUtility->PublishContextL( KHgCFTypeContact, KName ); |
|
66 //private implementation with dalay cant be covered by test because its never called |
|
67 return KErrNone; |
|
68 } |
|
69 |
|
70 //Test code for testing T_PublishContextDelayedL function call |
|
71 STIF_TESTDEFINE( T_PublishContextDelayedL ) |
|
72 { |
|
73 // publish the Hg.Contact context to CF |
|
74 iContextUtility->PublishContextDelayedL( KHgCFTypeContact, KName ,50000); |
|
75 iContextUtility->PublishContextDelayedL( KHgCFTypeContact, KName ,0); |
|
76 return KErrNone; |
|
77 } |
|
78 |
|
79 //Test code for testing GetContextL function call |
|
80 STIF_TESTDEFINE( T_GetContextL ) |
|
81 { |
|
82 HBufC* icontext = iContextUtility->GetContextL( _L( "NonExistContextType" )); |
|
83 |
|
84 STIF_ASSERT_TRUE_DESC( icontext == NULL, _L( "Item found" ) ); |
|
85 delete icontext; |
|
86 |
|
87 // publish the Hg.Contact context to CF |
|
88 iContextUtility->PublishContextL( KHgCFTypeContact, KName ); |
|
89 |
|
90 icontext = iContextUtility->GetContextL( KHgCFTypeContact); |
|
91 |
|
92 STIF_ASSERT_TRUE_DESC( icontext != NULL, _L( "Context is not found" ) ); |
|
93 delete icontext; |
|
94 |
|
95 return KErrNone; |
|
96 } |
|
97 |
|
98 //Test code for testing GetContextL function call |
|
99 STIF_TESTDEFINE( T_GetContextLWithContextSource ) |
|
100 { |
|
101 HBufC* icontext = iContextUtility->GetContextL(KHgCFSource,_L( "NonExistContextType" )); |
|
102 |
|
103 STIF_ASSERT_TRUE_DESC( icontext == NULL, _L( "Item found" ) ); |
|
104 delete icontext; |
|
105 |
|
106 // publish the Hg.Contact context to CF |
|
107 iContextUtility->PublishContextL( KHgCFTypeContact, KName ); |
|
108 |
|
109 icontext = iContextUtility->GetContextL(KHgCFSource,KHgCFTypeContact); |
|
110 |
|
111 STIF_ASSERT_TRUE_DESC( icontext != NULL, _L( "Context is not found" ) ); |
|
112 delete icontext; |
|
113 |
|
114 return KErrNone; |
|
115 } |
|
116 |
|
117 //Test code for testing spliting combined context |
|
118 STIF_TESTDEFINE( T_SplitCombinedStringL ) |
|
119 { |
|
120 HBufC* val( NULL ); |
|
121 _LIT( KDummyContext, "CtxUtilApiTest" ); |
|
122 const TInt KArrayGranularity( 3 ); |
|
123 CDesCArray* sourceArray = new( ELeave ) CDesC16ArrayFlat(KArrayGranularity); |
|
124 CDesCArray* resultArray = new( ELeave ) CDesC16ArrayFlat(KArrayGranularity); |
|
125 CleanupStack::PushL( sourceArray ); |
|
126 CleanupStack::PushL( resultArray ); |
|
127 |
|
128 iContextUtility->PublishContextL( KDummyContext, *sourceArray ); |
|
129 //Can't be verified if current context is NULL, because could be already published |
|
130 |
|
131 sourceArray->AppendL( _L( "https://somedomain.com?param=parmaValue" ) ); |
|
132 iContextUtility->PublishContextL( KDummyContext, *sourceArray );//there only one value. nothing to combine but returned value should be equal |
|
133 val = iContextUtility->GetContextL( KDummyContext ); |
|
134 CleanupStack::PushL( val ); |
|
135 STIF_ASSERT_TRUE( val && val->Length() ); |
|
136 CHgContextUtility::SplitCombinedStringL( *val, *resultArray ); |
|
137 CleanupStack::PopAndDestroy(val); |
|
138 STIF_ASSERT_TRUE( resultArray->Count() == sourceArray->Count() ); |
|
139 for( TInt iter( 0 ); iter < sourceArray->Count(); ++iter ) |
|
140 { |
|
141 STIF_ASSERT_TRUE( 0 == (*sourceArray)[iter].Compare((*resultArray)[iter]) ); |
|
142 } |
|
143 CleanupStack::PopAndDestroy(resultArray); |
|
144 |
|
145 resultArray = new( ELeave ) CDesC16ArrayFlat(KArrayGranularity); |
|
146 CleanupStack::PushL( resultArray ); |
|
147 sourceArray->AppendL( _L( "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\" )); |
|
148 sourceArray->AppendL( _L( "!@#$%^&&*()/\<>[]|~,." ) ); |
|
149 |
|
150 iContextUtility->PublishContextL( KDummyContext, *sourceArray ); |
|
151 |
|
152 val = iContextUtility->GetContextL( KDummyContext ); |
|
153 STIF_ASSERT_TRUE( val && val->Length() ); |
|
154 CleanupStack::PushL(val); |
|
155 CHgContextUtility::SplitCombinedStringL( *val, *resultArray ); |
|
156 CleanupStack::PopAndDestroy( val ); |
|
157 STIF_ASSERT_TRUE( resultArray->Count() == sourceArray->Count() ); |
|
158 for( TInt iter( 0 ); iter < sourceArray->Count(); ++iter ) |
|
159 { |
|
160 STIF_ASSERT_TRUE( 0 == (*sourceArray)[iter].Compare((*resultArray)[iter]) ); |
|
161 } |
|
162 CleanupStack::PopAndDestroy(resultArray); |
|
163 CleanupStack::PopAndDestroy(sourceArray); |
|
164 return KErrNone; |
|
165 } |
|
166 |
|
167 //Test code for testing PublishContextL with array argument |
|
168 STIF_TESTDEFINE( T_PublishContextLWithArray ) |
|
169 { |
|
170 _LIT( KDummyContext, "CtxUtilApiTest" ); |
|
171 CDesCArray* arr = new ( ELeave ) CDesC16ArrayFlat( 4 ); |
|
172 CleanupStack::PushL( arr ); |
|
173 |
|
174 iContextUtility->PublishContextL( KDummyContext, *arr ); |
|
175 |
|
176 arr->AppendL( _L( "first item" ) ); |
|
177 arr->AppendL( _L( "second item" ) ); |
|
178 arr->AppendL( _L( "third item" ) ); |
|
179 iContextUtility->PublishContextL( KDummyContext, *arr ); |
|
180 HBufC* val = iContextUtility->GetContextL( KDummyContext ); |
|
181 STIF_ASSERT_TRUE( val && val->Length() ); |
|
182 delete val; |
|
183 CleanupStack::PopAndDestroy( arr ); |
|
184 return KErrNone; |
|
185 } |
|
186 |
|
187 //Test code for testing PublishContextDelayedL with array argument |
|
188 STIF_TESTDEFINE( T_PublishContextDelayedLWithArray ) |
|
189 { |
|
190 _LIT( KDummyContext, "CtxUtilApiTest2" ); |
|
191 CDesCArray* arr = new ( ELeave ) CDesC16ArrayFlat( 4 ); |
|
192 CleanupStack::PushL( arr ); |
|
193 arr->AppendL( _L( "first item" ) ); |
|
194 arr->AppendL( _L( "second item" ) ); |
|
195 arr->AppendL( _L( "third item" ) ); |
|
196 iContextUtility->PublishContextDelayedL( KDummyContext, *arr, 500000 ); |
|
197 iContextUtility->PublishContextDelayedL( KDummyContext, *arr, 0 ); |
|
198 iContextUtility->PublishContextDelayedL( KDummyContext, *arr, 500000 ); |
|
199 CWait* wait = CWait::NewL(); |
|
200 wait->Start( 2000000 ); |
|
201 delete wait; |
|
202 HBufC* val = iContextUtility->GetContextL( KDummyContext ); |
|
203 STIF_ASSERT_TRUE( val && val->Length() ); |
|
204 delete val; |
|
205 CleanupStack::PopAndDestroy( arr ); |
|
206 return KErrNone; |
|
207 } |
|
208 |
|
209 //Test code for testing RePublishWhenFgL with different arguments |
|
210 //Most probably nothing will happen because there is no CCoeEnv but |
|
211 //it should never crash. |
|
212 STIF_TESTDEFINE( T_RePublishWhenFgL ) |
|
213 { |
|
214 iContextUtility->RePublishWhenFgL( ETrue ); |
|
215 iContextUtility->RePublishWhenFgL( EFalse ); |
|
216 iContextUtility->RePublishWhenFgL( ETrue ); |
|
217 return KErrNone; |
|
218 } |
|
219 |
|
220 /* IMPORT_C void PublishContactContextL( const MVPbkStoreContact& aContact, |
|
221 const TTimeIntervalMicroSeconds32& aDelay = 0 );*/ |
|
222 STIF_TESTDEFINE( T_PublishContactContextL1 ) |
|
223 { |
|
224 CHgCtxContactMatcher* m = CHgCtxContactMatcher::NewLC(); |
|
225 m->OpenDefaultMatchStoresL(); |
|
226 CVPbkContactManager& cm( m->GetContactManager() ); |
|
227 MVPbkContactStoreList& sl( m->GetContactStoresL() ); |
|
228 MVPbkStoreContact* newContact = sl.At( 0 ).CreateNewContactLC(); |
|
229 const MVPbkFieldType* fieldType = m->FieldTypes().Find(R_VPBK_FIELD_TYPE_FIRSTNAME); |
|
230 MVPbkStoreContactField* newField = newContact->CreateFieldLC(*fieldType); |
|
231 MVPbkContactFieldTextData* textData = &(MVPbkContactFieldTextData::Cast(newField->FieldData())); |
|
232 _LIT(KName, "ctxutiltester"); |
|
233 textData->SetTextL( KName ); |
|
234 newContact->AddFieldL(newField); |
|
235 CleanupStack::Pop(newField); |
|
236 CWait* wait = CWait::NewLC(); |
|
237 struct TDummyObs : public MVPbkContactObserver |
|
238 { |
|
239 CWait* iWait; |
|
240 TDummyObs( CWait* aWait ) : iWait( aWait ) { } |
|
241 void ContactOperationCompleted(TContactOpResult /*aResult*/) |
|
242 { |
|
243 iWait->Stop(); |
|
244 } |
|
245 void ContactOperationFailed(TContactOp /*aOpCode*/, |
|
246 TInt /*aErrorCode*/, |
|
247 TBool /*aErrorNotified*/) { } |
|
248 } dummyObs( wait ); |
|
249 newContact->CommitL( dummyObs ); |
|
250 wait->Start( 2000000 ); |
|
251 CleanupStack::PopAndDestroy( wait ); |
|
252 |
|
253 iContextUtility->PublishContactContextL( *newContact, 0 ); |
|
254 iContextUtility->PublishContactContextL( *newContact, 500000 ); |
|
255 wait = CWait::NewL(); |
|
256 wait->Start( 2000000 ); |
|
257 delete wait; |
|
258 HBufC* ctx = iContextUtility->GetContextL( KHgCFTypeContact); |
|
259 STIF_ASSERT_TRUE_DESC( ctx != NULL, _L( "Context not found" ) ); |
|
260 delete ctx; |
|
261 |
|
262 CVPbkContactLinkArray* ca = CVPbkContactLinkArray::NewLC(); |
|
263 ca->AppendL( newContact->CreateLinkLC() ); |
|
264 CleanupStack::Pop(); |
|
265 wait = CWait::NewL(); |
|
266 struct TDummyObs2 : public MVPbkBatchOperationObserver |
|
267 { |
|
268 CWait* iWait; |
|
269 TDummyObs2( CWait* aWait ) : iWait( aWait ) { } |
|
270 void StepComplete( |
|
271 MVPbkContactOperationBase& /*aOperation*/, |
|
272 TInt /*aStepSize*/ ) { } |
|
273 TBool StepFailed( |
|
274 MVPbkContactOperationBase& /*aOperation*/, |
|
275 TInt /*aStepSize*/, TInt /*aError*/ ) |
|
276 { |
|
277 return EFalse; |
|
278 } |
|
279 void OperationComplete( |
|
280 MVPbkContactOperationBase& /*aOperation*/ ) |
|
281 { |
|
282 iWait->Stop(); |
|
283 } |
|
284 } dummyObs2( wait ); |
|
285 MVPbkContactOperationBase* op = cm.DeleteContactsL( *ca, dummyObs2 ); |
|
286 CleanupDeletePushL( op ); |
|
287 wait->Start( 2000000 ); |
|
288 delete wait; |
|
289 CleanupStack::PopAndDestroy( 4 ); // op, ca, newContact, m |
|
290 |
|
291 return KErrNone; |
|
292 } |
|
293 |
|
294 /* IMPORT_C void PublishContactContextL( const MVPbkContactLink& aContactLink, |
|
295 const TTimeIntervalMicroSeconds32& aDelay = 0 );*/ |
|
296 STIF_TESTDEFINE( T_PublishContactContextL2 ) |
|
297 { |
|
298 CHgCtxContactMatcher* m = CHgCtxContactMatcher::NewLC(); |
|
299 m->OpenDefaultMatchStoresL(); |
|
300 CVPbkContactManager& cm( m->GetContactManager() ); |
|
301 MVPbkContactStoreList& sl( m->GetContactStoresL() ); |
|
302 MVPbkStoreContact* newContact = sl.At( 0 ).CreateNewContactLC(); |
|
303 const MVPbkFieldType* fieldType = m->FieldTypes().Find(R_VPBK_FIELD_TYPE_FIRSTNAME); |
|
304 MVPbkStoreContactField* newField = newContact->CreateFieldLC(*fieldType); |
|
305 MVPbkContactFieldTextData* textData = &(MVPbkContactFieldTextData::Cast(newField->FieldData())); |
|
306 _LIT(KName, "ctxutiltester"); |
|
307 textData->SetTextL( KName ); |
|
308 newContact->AddFieldL(newField); |
|
309 CleanupStack::Pop(newField); |
|
310 CWait* wait = CWait::NewL(); |
|
311 struct TDummyObs : public MVPbkContactObserver |
|
312 { |
|
313 CWait* iWait; |
|
314 TDummyObs( CWait* aWait ) : iWait( aWait ) { } |
|
315 void ContactOperationCompleted(TContactOpResult /*aResult*/) |
|
316 { |
|
317 iWait->Stop(); |
|
318 } |
|
319 void ContactOperationFailed(TContactOp /*aOpCode*/, |
|
320 TInt /*aErrorCode*/, |
|
321 TBool /*aErrorNotified*/){ } |
|
322 } dummyObs( wait ); |
|
323 newContact->CommitL( dummyObs ); |
|
324 wait->Start( 2000000 ); |
|
325 delete wait; |
|
326 |
|
327 CVPbkContactLinkArray* ca = CVPbkContactLinkArray::NewLC(); |
|
328 ca->AppendL( newContact->CreateLinkLC() ); |
|
329 CleanupStack::Pop(); |
|
330 |
|
331 iContextUtility->PublishContactContextL( ca->At( 0 ), 0 ); |
|
332 iContextUtility->PublishContactContextL( ca->At( 0 ), 500000 ); |
|
333 wait = CWait::NewL(); |
|
334 wait->Start( 2000000 ); |
|
335 delete wait; |
|
336 HBufC* ctx = iContextUtility->GetContextL( KHgCFTypeContact); |
|
337 STIF_ASSERT_TRUE_DESC( ctx != NULL, _L( "Context not found" ) ); |
|
338 delete ctx; |
|
339 |
|
340 wait = CWait::NewL(); |
|
341 struct TDummyObs2 : public MVPbkBatchOperationObserver |
|
342 { |
|
343 CWait* iWait; |
|
344 TDummyObs2( CWait* aWait ) : iWait( aWait ) { } |
|
345 void StepComplete( |
|
346 MVPbkContactOperationBase& /*aOperation*/, |
|
347 TInt /*aStepSize*/ ) { } |
|
348 TBool StepFailed( |
|
349 MVPbkContactOperationBase& /*aOperation*/, |
|
350 TInt /*aStepSize*/, TInt /*aError*/ ) |
|
351 { |
|
352 return EFalse; |
|
353 } |
|
354 void OperationComplete( |
|
355 MVPbkContactOperationBase& /*aOperation*/ ) { iWait->Stop(); } |
|
356 } dummyObs2( wait ); |
|
357 MVPbkContactOperationBase* op = cm.DeleteContactsL( *ca, dummyObs2 ); |
|
358 CleanupDeletePushL( op ); |
|
359 wait->Start( 2000000 ); |
|
360 delete wait; |
|
361 |
|
362 // test with (surely) non-existing link |
|
363 iContextUtility->PublishContactContextL( ca->At( 0 ) ); |
|
364 wait = CWait::NewL(); |
|
365 wait->Start( 2000000 ); |
|
366 delete wait; |
|
367 |
|
368 CleanupStack::PopAndDestroy( 4 ); // op, ca, newContact, m |
|
369 |
|
370 return KErrNone; |
|
371 } |
|
372 |
|
373 /* IMPORT_C void PublishContactContextL( const TDesC& aContactName, |
|
374 const TTimeIntervalMicroSeconds32& aDelay = 0 );*/ |
|
375 STIF_TESTDEFINE( T_PublishContactContextL3 ) |
|
376 { |
|
377 iContextUtility->PublishContactContextL( KName ); |
|
378 HBufC* ctx = iContextUtility->GetContextL( KHgCFTypeContact); |
|
379 STIF_ASSERT_TRUE_DESC( ctx != NULL, _L( "Context not found" ) ); |
|
380 delete ctx; |
|
381 |
|
382 iContextUtility->PublishContactContextL( KName, 500000 ); |
|
383 iContextUtility->PublishContactContextL( KName, 500000 ); |
|
384 iContextUtility->PublishContactContextL( KName, 500000 ); |
|
385 ctx = iContextUtility->GetContextL( KHgCFTypeContact); |
|
386 STIF_ASSERT_TRUE_DESC( ctx != NULL, _L( "Context not found" ) ); |
|
387 delete ctx; |
|
388 |
|
389 return KErrNone; |
|
390 } |
|
391 |
|
392 /* IMPORT_C void PublishContactContextL( |
|
393 const RPointerArray<MVPbkStoreContact>& aContacts, |
|
394 const TTimeIntervalMicroSeconds32& aDelay = 0 );*/ |
|
395 STIF_TESTDEFINE( T_PublishContactContextL4 ) |
|
396 { |
|
397 CHgCtxContactMatcher* m = CHgCtxContactMatcher::NewLC(); |
|
398 m->OpenDefaultMatchStoresL(); |
|
399 CVPbkContactManager& cm( m->GetContactManager() ); |
|
400 MVPbkContactStoreList& sl( m->GetContactStoresL() ); |
|
401 MVPbkStoreContact* newContact = sl.At( 0 ).CreateNewContactLC(); |
|
402 const MVPbkFieldType* fieldType = m->FieldTypes().Find(R_VPBK_FIELD_TYPE_FIRSTNAME); |
|
403 MVPbkStoreContactField* newField = newContact->CreateFieldLC(*fieldType); |
|
404 MVPbkContactFieldTextData* textData = &(MVPbkContactFieldTextData::Cast(newField->FieldData())); |
|
405 _LIT(KName, "ctxutiltester"); |
|
406 textData->SetTextL( KName ); |
|
407 newContact->AddFieldL(newField); |
|
408 CleanupStack::Pop(newField); |
|
409 CWait* wait = CWait::NewL(); |
|
410 struct TDummyObs : public MVPbkContactObserver |
|
411 { |
|
412 CWait* iWait; |
|
413 TDummyObs( CWait* aWait ) : iWait( aWait ) { } |
|
414 void ContactOperationCompleted(TContactOpResult /*aResult*/) { iWait->Stop(); } |
|
415 void ContactOperationFailed(TContactOp /*aOpCode*/, TInt /*aErrorCode*/, TBool /*aErrorNotified*/) { } |
|
416 } dummyObs( wait ); |
|
417 newContact->CommitL( dummyObs ); |
|
418 wait->Start( 2000000 ); |
|
419 delete wait; |
|
420 |
|
421 RPointerArray<MVPbkStoreContact> pa; |
|
422 CleanupClosePushL( pa ); |
|
423 pa.AppendL( newContact ); |
|
424 iContextUtility->PublishContactContextL( pa, 0 ); |
|
425 iContextUtility->PublishContactContextL( pa, 500000 ); |
|
426 CleanupStack::PopAndDestroy( &pa ); |
|
427 wait = CWait::NewL(); |
|
428 wait->Start( 2000000 ); |
|
429 delete wait; |
|
430 HBufC* ctx = iContextUtility->GetContextL( KHgCFTypeContact); |
|
431 STIF_ASSERT_TRUE_DESC( ctx != NULL, _L( "Context not found" ) ); |
|
432 delete ctx; |
|
433 |
|
434 RPointerArray<MVPbkStoreContact> pa2; |
|
435 CleanupClosePushL( pa2 ); |
|
436 pa2.AppendL( newContact ); |
|
437 pa2.AppendL( newContact ); |
|
438 pa2.AppendL( newContact ); |
|
439 pa2.AppendL( newContact ); |
|
440 iContextUtility->PublishContactContextL( pa2, 500000 ); |
|
441 iContextUtility->PublishContactContextL( pa2, 0 ); |
|
442 CleanupStack::PopAndDestroy( &pa2 ); |
|
443 wait = CWait::NewL(); |
|
444 wait->Start( 2000000 ); |
|
445 delete wait; |
|
446 ctx = iContextUtility->GetContextL( KHgCFTypeContact); |
|
447 STIF_ASSERT_TRUE_DESC( ctx != NULL, _L( "Context not found" ) ); |
|
448 delete ctx; |
|
449 |
|
450 CVPbkContactLinkArray* ca = CVPbkContactLinkArray::NewLC(); |
|
451 ca->AppendL( newContact->CreateLinkLC() ); |
|
452 CleanupStack::Pop(); |
|
453 wait = CWait::NewL(); |
|
454 struct TDummyObs2 : public MVPbkBatchOperationObserver |
|
455 { |
|
456 CWait* iWait; |
|
457 TDummyObs2( CWait* aWait ) : iWait( aWait ) { } |
|
458 void StepComplete( |
|
459 MVPbkContactOperationBase& /*aOperation*/, |
|
460 TInt /*aStepSize*/ ) { } |
|
461 TBool StepFailed( |
|
462 MVPbkContactOperationBase& /*aOperation*/, |
|
463 TInt /*aStepSize*/, TInt /*aError*/ ) |
|
464 { |
|
465 return EFalse; |
|
466 } |
|
467 void OperationComplete( |
|
468 MVPbkContactOperationBase& /*aOperation*/ ) { iWait->Stop(); } |
|
469 } dummyObs2( wait ); |
|
470 MVPbkContactOperationBase* op = cm.DeleteContactsL( *ca, dummyObs2 ); |
|
471 CleanupDeletePushL( op ); |
|
472 wait->Start( 2000000 ); |
|
473 delete wait; |
|
474 CleanupStack::PopAndDestroy( 4 ); // op, ca, newContact, m |
|
475 |
|
476 return KErrNone; |
|
477 } |
|
478 |
|
479 /* IMPORT_C void PublishContactContextL( |
|
480 const RPointerArray<MVPbkContactLink>& aContactLinks, |
|
481 const TTimeIntervalMicroSeconds32& aDelay = 0 );*/ |
|
482 STIF_TESTDEFINE( T_PublishContactContextL5 ) |
|
483 { |
|
484 CHgCtxContactMatcher* m = CHgCtxContactMatcher::NewLC(); |
|
485 m->OpenDefaultMatchStoresL(); |
|
486 CVPbkContactManager& cm( m->GetContactManager() ); |
|
487 MVPbkContactStoreList& sl( m->GetContactStoresL() ); |
|
488 MVPbkStoreContact* newContact = sl.At( 0 ).CreateNewContactLC(); |
|
489 const MVPbkFieldType* fieldType = |
|
490 m->FieldTypes().Find(R_VPBK_FIELD_TYPE_FIRSTNAME); |
|
491 MVPbkStoreContactField* newField = newContact->CreateFieldLC(*fieldType); |
|
492 MVPbkContactFieldTextData* textData = |
|
493 &(MVPbkContactFieldTextData::Cast(newField->FieldData())); |
|
494 _LIT(KName, "ctxutiltester"); |
|
495 textData->SetTextL( KName ); |
|
496 newContact->AddFieldL(newField); |
|
497 CleanupStack::Pop(newField); |
|
498 CWait* wait = CWait::NewL(); |
|
499 struct TDummyObs : public MVPbkContactObserver |
|
500 { |
|
501 CWait* iWait; |
|
502 TDummyObs( CWait* aWait ) : iWait( aWait ) { } |
|
503 void ContactOperationCompleted(TContactOpResult /*aResult*/) |
|
504 { |
|
505 iWait->Stop(); |
|
506 } |
|
507 void ContactOperationFailed(TContactOp /*aOpCode*/, |
|
508 TInt /*aErrorCode*/, |
|
509 TBool /*aErrorNotified*/) { } |
|
510 } dummyObs( wait ); |
|
511 newContact->CommitL( dummyObs ); |
|
512 wait->Start( 2000000 ); |
|
513 delete wait; |
|
514 |
|
515 CVPbkContactLinkArray* pa = CVPbkContactLinkArray::NewLC(); |
|
516 pa->AppendL( newContact->CreateLinkLC() ); |
|
517 CleanupStack::Pop(); |
|
518 iContextUtility->PublishContactContextL( *pa, 0 ); |
|
519 iContextUtility->PublishContactContextL( *pa, 500000 ); |
|
520 CleanupStack::PopAndDestroy( pa ); |
|
521 wait = CWait::NewL(); |
|
522 wait->Start( 2000000 ); |
|
523 delete wait; |
|
524 HBufC* ctx = iContextUtility->GetContextL( KHgCFTypeContact); |
|
525 STIF_ASSERT_TRUE_DESC( ctx != NULL, _L( "Context not found" ) ); |
|
526 delete ctx; |
|
527 |
|
528 CVPbkContactLinkArray* pa2 = CVPbkContactLinkArray::NewLC(); |
|
529 pa2->AppendL( newContact->CreateLinkLC() ); |
|
530 CleanupStack::Pop(); |
|
531 pa2->AppendL( newContact->CreateLinkLC() ); |
|
532 CleanupStack::Pop(); |
|
533 pa2->AppendL( newContact->CreateLinkLC() ); |
|
534 CleanupStack::Pop(); |
|
535 iContextUtility->PublishContactContextL( *pa2, 500000 ); |
|
536 iContextUtility->PublishContactContextL( *pa2, 0 ); |
|
537 CleanupStack::PopAndDestroy( pa2 ); |
|
538 wait = CWait::NewL(); |
|
539 wait->Start( 2000000 ); |
|
540 delete wait; |
|
541 ctx = iContextUtility->GetContextL( KHgCFTypeContact); |
|
542 STIF_ASSERT_TRUE_DESC( ctx != NULL, _L( "Context not found" ) ); |
|
543 delete ctx; |
|
544 |
|
545 CVPbkContactLinkArray* ca = CVPbkContactLinkArray::NewLC(); |
|
546 ca->AppendL( newContact->CreateLinkLC() ); |
|
547 CleanupStack::Pop(); |
|
548 wait = CWait::NewL(); |
|
549 struct TDummyObs2 : public MVPbkBatchOperationObserver |
|
550 { |
|
551 CWait* iWait; |
|
552 TDummyObs2( CWait* aWait ) : iWait( aWait ) { } |
|
553 void StepComplete( |
|
554 MVPbkContactOperationBase& /*aOperation*/, |
|
555 TInt /*aStepSize*/ ) { } |
|
556 TBool StepFailed( |
|
557 MVPbkContactOperationBase& /*aOperation*/, |
|
558 TInt /*aStepSize*/, TInt /*aError*/ ) |
|
559 { |
|
560 return EFalse; |
|
561 } |
|
562 void OperationComplete( |
|
563 MVPbkContactOperationBase& /*aOperation*/ ) { iWait->Stop(); } |
|
564 } dummyObs2( wait ); |
|
565 MVPbkContactOperationBase* op = cm.DeleteContactsL( *ca, dummyObs2 ); |
|
566 CleanupDeletePushL( op ); |
|
567 wait->Start( 2000000 ); |
|
568 delete wait; |
|
569 CleanupStack::PopAndDestroy( 4 ); // op, ca, newContact, m |
|
570 |
|
571 return KErrNone; |
|
572 } |
|
573 |
|
574 /*IMPORT_C void PublishContactContextL( const MDesCArray& aContactNames, |
|
575 const TTimeIntervalMicroSeconds32& aDelay = 0 );*/ |
|
576 STIF_TESTDEFINE( T_PublishContactContextL6 ) |
|
577 { |
|
578 CDesCArray* arr = new ( ELeave ) CDesC16ArrayFlat( 4 ); |
|
579 CleanupStack::PushL( arr ); |
|
580 arr->AppendL( _L( "first item" ) ); |
|
581 arr->AppendL( _L( "second item" ) ); |
|
582 arr->AppendL( _L( "third item" ) ); |
|
583 iContextUtility->PublishContactContextL( *arr ); |
|
584 iContextUtility->PublishContactContextL( *arr, 500000 ); |
|
585 iContextUtility->PublishContactContextL( *arr ); |
|
586 CleanupStack::PopAndDestroy( arr ); |
|
587 return KErrNone; |
|
588 } |
|
589 |
|
590 /* IMPORT_C void PublishTextContextL( const TDesC& aText, |
|
591 const TTimeIntervalMicroSeconds32& aDelay = 0 );*/ |
|
592 STIF_TESTDEFINE( T_PublishTextContextL ) |
|
593 { |
|
594 iContextUtility->PublishTextContextL( KNullDesC, 100 ); |
|
595 iContextUtility->PublishTextContextL( _L("fbngiuwetghorb rteogvhetui gherigth" ) ); |
|
596 iContextUtility->PublishTextContextL( KNullDesC ); |
|
597 iContextUtility->PublishTextContextL( _L("+35442754") ); |
|
598 iContextUtility->PublishTextContextL( _L("35442754") ); |
|
599 iContextUtility->PublishTextContextL( _L("abcdef@ghijk.com") ); |
|
600 iContextUtility->PublishTextContextL( _L(" " ) ); |
|
601 return KErrNone; |
|
602 } |
|
603 |
|
604 /* IMPORT_C void PublishUrlContextL( const TDesC& aUrl, |
|
605 const TTimeIntervalMicroSeconds32& aDelay = 0 );*/ |
|
606 STIF_TESTDEFINE( T_PublishUrlContextL ) |
|
607 { |
|
608 _LIT( KNokiaDomain, "http://www.nokia.com" ); |
|
609 _LIT( KSomeDomain, "http://www.somedomain.com" ); |
|
610 iContextUtility->PublishUrlContextL( KNokiaDomain, 1000 ); |
|
611 iContextUtility->PublishUrlContextL( KSomeDomain ); |
|
612 iContextUtility->PublishUrlContextL( KNokiaDomain ); |
|
613 HBufC* ctx = iContextUtility->GetContextL( KHgCFTypeUrl ); |
|
614 STIF_ASSERT_TRUE_DESC( ctx != NULL, _L( "Context not found" ) ); |
|
615 STIF_ASSERT_TRUE( 0 == ctx->Compare( KNokiaDomain ) ); |
|
616 delete ctx; |
|
617 return KErrNone; |
|
618 } |
|
619 |
|
620 /* IMPORT_C void PublishTimeContextL( const TTime& aTime, |
|
621 const TTimeIntervalMicroSeconds32& aDelay = 0 );*/ |
|
622 STIF_TESTDEFINE( T_PublishTimeContextL ) |
|
623 { |
|
624 TTime t( 0 ); |
|
625 iContextUtility->PublishTimeContextL( t, 100 ); |
|
626 iContextUtility->PublishTimeContextL( t ); |
|
627 HBufC* ctx = iContextUtility->GetContextL( KHgCFTypeActiveDate ); |
|
628 STIF_ASSERT_TRUE_DESC( ctx != NULL, _L( "Context not found" ) ); |
|
629 delete ctx; |
|
630 return KErrNone; |
|
631 } |
|
632 |
|
633 /* IMPORT_C void PublishPhotoContextL( const TDesC& aFilename, |
|
634 const TTimeIntervalMicroSeconds32& aDelay = 0 );*/ |
|
635 STIF_TESTDEFINE( T_PublishPhotoContextL ) |
|
636 { |
|
637 _LIT( KJpegPath, "c:\\image.jpg" ); |
|
638 _LIT( KPngPath, "c:\\image.png" ); |
|
639 iContextUtility->PublishPhotoContextL( KJpegPath, 100 ); |
|
640 iContextUtility->PublishPhotoContextL( KPngPath, 0 ); |
|
641 iContextUtility->PublishPhotoContextL( KJpegPath ); |
|
642 HBufC* ctx = iContextUtility->GetContextL( KHgCFTypePhoto ); |
|
643 STIF_ASSERT_TRUE_DESC( ctx != NULL, _L( "Context not found" ) ); |
|
644 STIF_ASSERT_TRUE( 0 == ctx->Compare(KJpegPath) ); |
|
645 delete ctx; |
|
646 |
|
647 iContextUtility->PublishPhotoContextL( KPngPath, 100000 ); |
|
648 ctx = iContextUtility->GetContextL( KHgCFTypePhoto ); |
|
649 STIF_ASSERT_TRUE_DESC( ctx != NULL, _L( "Context not found" ) ); |
|
650 STIF_ASSERT_TRUE( 0 == ctx->Compare(KJpegPath) ); |
|
651 delete ctx; |
|
652 return KErrNone; |
|
653 } |
|
654 |
|
655 /* IMPORT_C void PublishPhotoContextL( TItemId aMdeItemId, |
|
656 CMdESession& aMdeSession, |
|
657 const TTimeIntervalMicroSeconds32& aDelay = 0 );*/ |
|
658 STIF_TESTDEFINE( T_PublishPhotoContextL2 ) |
|
659 { |
|
660 CWait* wait = CWait::NewLC(); |
|
661 struct TObs : public MMdESessionObserver { |
|
662 CWait* iWait; |
|
663 TObs( CWait* aWait ) : iWait( aWait ) { } |
|
664 void HandleSessionOpened( CMdESession& /*aSession*/, TInt /*aError*/ ) { iWait->Stop(); } |
|
665 void HandleSessionError( CMdESession& /*aSession*/, TInt /*aError*/ ) { } |
|
666 } mdeobs( wait ); |
|
667 CMdESession* s = CMdESession::NewLC( mdeobs ); |
|
668 wait->Start( 5000000 ); |
|
669 // invalid item id |
|
670 TRAPD( err, iContextUtility->PublishPhotoContextL( 0, *s ) ); |
|
671 STIF_ASSERT_TRUE( err != KErrNone ); // leave should have occured |
|
672 for ( TInt i = 0; i < 100; ++i ) |
|
673 { |
|
674 TRAP_IGNORE( iContextUtility->PublishPhotoContextL( TItemId( i ), *s ) ); |
|
675 } |
|
676 CleanupStack::PopAndDestroy( 2 ); |
|
677 return KErrNone; |
|
678 } |
|
679 |
|
680 /* IMPORT_C void PublishTvContextL( const TDesC& aChannelName, |
|
681 const TDesC& aProgramName, const TDesC& aProgramDescription, |
|
682 const TDesC& aGenre ); */ |
|
683 STIF_TESTDEFINE( T_PublishTvContextL ) |
|
684 { |
|
685 _LIT( K1, "channel A" ); |
|
686 _LIT( K2, "program X" ); |
|
687 _LIT( K3, "very interesting program" ); |
|
688 iContextUtility->PublishTvContextL( K1, K2, K3, KNullDesC ); |
|
689 iContextUtility->PublishTvContextL( K1, K2, K3, KNullDesC ); |
|
690 iContextUtility->PublishTvContextL( K1, K2, KNullDesC, KNullDesC ); |
|
691 HBufC* ctx = iContextUtility->GetContextL( KHgCFTypeTvProgramName ); |
|
692 STIF_ASSERT_TRUE_DESC( ctx != NULL && !ctx->Compare( K2 ), |
|
693 _L( "Context not found" ) ); |
|
694 delete ctx; |
|
695 |
|
696 iContextUtility->PublishTvContextL( KNullDesC, K2, KNullDesC, KNullDesC ); |
|
697 iContextUtility->PublishTvContextL( KNullDesC, KNullDesC, KNullDesC, KNullDesC ); |
|
698 iContextUtility->PublishTvContextL( KNullDesC, K2, KNullDesC, KNullDesC ); |
|
699 iContextUtility->PublishTvContextL( KNullDesC, KNullDesC, KNullDesC, _L("movie") ); |
|
700 ctx = iContextUtility->GetContextL( KHgCFTypeTvChannelName ); |
|
701 STIF_ASSERT_TRUE_DESC( ctx != NULL && !ctx->Compare( KHgCFValueUnknownInfo ), |
|
702 _L( "Context not found" ) ); |
|
703 delete ctx; |
|
704 return KErrNone; |
|
705 } |
|
706 |
|
707 /* IMPORT_C void PublishServiceIdL( const TDesC& aServiceId, |
|
708 const TDesC& aAccountId, |
|
709 const TTimeIntervalMicroSeconds32& aDelay = 0 ); */ |
|
710 STIF_TESTDEFINE( T_PublishServiceIdL ) |
|
711 { |
|
712 iContextUtility->PublishServiceIdL( _L("Ovi"), _L("someid") ); |
|
713 iContextUtility->PublishServiceIdL( _L("Ovi"), _L("someid"), 1000000 ); |
|
714 iContextUtility->PublishServiceIdL( _L("Ovi"), _L("someid") ); |
|
715 } |
|
716 |
|
717 /* IMPORT_C void AddMusicContextInfoL( |
|
718 const TDesC& aKey, |
|
719 const TDesC& aData ); */ |
|
720 STIF_TESTDEFINE( T_AddMusicContextInfoL ) |
|
721 { |
|
722 // Fetch the pointer to hash table for testing purposes |
|
723 RPtrHashMap<TDesC, TDesC>* hash = GetImplHashTablePtr(); |
|
724 _LIT( KPlaying, "Playing" ); |
|
725 _LIT( KArtist, "Hans Zimmer"); |
|
726 _LIT( KTitle, "Why so serious" ); |
|
727 _LIT( KAlbum, "Dark Knight" ); |
|
728 _LIT( KGenre, "Soundtrack" ); |
|
729 |
|
730 STIF_ASSERT_TRUE_DESC( hash->Count() == 0, _L("There is stuff in the list!") ); |
|
731 STIF_ASSERT_TRUE_DESC( hash->Find( KHgCFTypeMusicState ) == NULL, _L( "State in the list!" ) ); |
|
732 STIF_ASSERT_TRUE_DESC( hash->Find( KHgCFTypeMusicArtist ) == NULL, _L( "Artist in the list!" ) ); |
|
733 STIF_ASSERT_TRUE_DESC( hash->Find( KHgCFTypeMusicTitle ) == NULL, _L( "Title in the list!" ) ); |
|
734 STIF_ASSERT_TRUE_DESC( hash->Find( KHgCFTypeMusicAlbum ) == NULL, _L( "Album in the list!" ) ); |
|
735 STIF_ASSERT_TRUE_DESC( hash->Find( KHgCFTypeMusicAlbumArt ) == NULL, _L( "Art in the list!" ) ); |
|
736 STIF_ASSERT_TRUE_DESC( hash->Find( KHgCFTypeMusicUri ) == NULL, _L( "Uri in the list!" ) ); |
|
737 STIF_ASSERT_TRUE_DESC( hash->Find( KHgCFTypeMusicGenre ) == NULL, _L( "Genre in the list!" ) ); |
|
738 STIF_ASSERT_TRUE_DESC( hash->Find( KHgCFTypeMusicType ) == NULL, _L( "Type in the list!" ) ); |
|
739 |
|
740 // No room for empty keys |
|
741 TRAPD( err, iContextUtility->AddMusicContextInfoL( KNullDesC, KPlaying ) ); |
|
742 STIF_ASSERT_TRUE_DESC( err == KErrNotFound, _L( "Empty key didn't cause leave!" ) ); |
|
743 STIF_ASSERT_TRUE_DESC( hash->Count() == 0, _L( "There is stuff in the list!" ) ); |
|
744 |
|
745 // Fill all values and test they will be there. |
|
746 iContextUtility->AddMusicContextInfoL( KHgCFTypeMusicState, KPlaying ); |
|
747 iContextUtility->AddMusicContextInfoL( KHgCFTypeMusicArtist, KArtist ); |
|
748 iContextUtility->AddMusicContextInfoL( KHgCFTypeMusicTitle, KTitle ); |
|
749 iContextUtility->AddMusicContextInfoL( KHgCFTypeMusicAlbum, KAlbum ); |
|
750 iContextUtility->AddMusicContextInfoL( KHgCFTypeMusicAlbumArt, KHgCFValueUnknownInfo ); |
|
751 iContextUtility->AddMusicContextInfoL( KHgCFTypeMusicUri, KNullDesC ); |
|
752 iContextUtility->AddMusicContextInfoL( KHgCFTypeMusicGenre, KGenre ); |
|
753 iContextUtility->AddMusicContextInfoL( KHgCFTypeMusicType, KHgCFValueMusicTypePlayer ); |
|
754 |
|
755 STIF_ASSERT_TRUE_DESC( hash->Count() == 8, _L( "List should contain 8 items." ) ); |
|
756 STIF_ASSERT_TRUE_DESC( !hash->Find( KHgCFTypeMusicState )->CompareC( KPlaying ), |
|
757 _L( "Wrong state in the table!" ) ); |
|
758 STIF_ASSERT_TRUE_DESC( !hash->Find( KHgCFTypeMusicArtist )->CompareC( KArtist ), |
|
759 _L( "Wrong artist in the table!" ) ); |
|
760 STIF_ASSERT_TRUE_DESC( !hash->Find( KHgCFTypeMusicTitle )->CompareC( KTitle ), |
|
761 _L( "Wrong title in the table!" ) ); |
|
762 STIF_ASSERT_TRUE_DESC( !hash->Find( KHgCFTypeMusicAlbum )->CompareC( KAlbum ), |
|
763 _L( "Wrong album in the table!" ) ); |
|
764 STIF_ASSERT_TRUE_DESC( !hash->Find( KHgCFTypeMusicAlbumArt )->CompareC( KHgCFValueUnknownInfo ), |
|
765 _L( "Wrong art in the table!" ) ); |
|
766 STIF_ASSERT_TRUE_DESC( !hash->Find( KHgCFTypeMusicUri )->CompareC( KHgCFValueUnknownInfo ), |
|
767 _L( "Wrong uri in the table!" ) ); |
|
768 STIF_ASSERT_TRUE_DESC( !hash->Find( KHgCFTypeMusicGenre )->CompareC( KGenre ), |
|
769 _L( "Wrong genre in the table!" ) ); |
|
770 STIF_ASSERT_TRUE_DESC( !hash->Find( KHgCFTypeMusicType )->CompareC( KHgCFValueMusicTypePlayer ), |
|
771 _L( "Wrong type in the table!" ) ); |
|
772 |
|
773 // An attempt to add same key twice, causes problems. |
|
774 TRAP( err, iContextUtility->AddMusicContextInfoL( KHgCFTypeMusicState, KPlaying ) ); |
|
775 STIF_ASSERT_TRUE_DESC( err == KErrAlreadyExists, _L( "Adding same key should cause a leave!" ) ); |
|
776 STIF_ASSERT_TRUE_DESC( hash->Count() == 8, _L( "List should contain 8 items!" ) ); |
|
777 |
|
778 return KErrNone; |
|
779 } |
|
780 |
|
781 /** IMPORT_C void PublishMusicContextL( |
|
782 const TTimeIntervalMicroSeconds32& aDelay = 0 ); */ |
|
783 STIF_TESTDEFINE( T_PublishMusicContextL ) |
|
784 { |
|
785 RPtrHashMap<TDesC, TDesC>* hash = GetImplHashTablePtr(); |
|
786 _LIT( KPlaying, "Playing" ); |
|
787 _LIT( KArtist, "John Williams"); |
|
788 _LIT( KTitle, "Raiders March" ); |
|
789 _LIT( KAlbum, "Raiders of the Lost Ark" ); |
|
790 |
|
791 STIF_ASSERT_TRUE_DESC( hash->Count() == 0, _L( "There is stuff in the list!" ) ); |
|
792 TRAPD( err, iContextUtility->PublishMusicContextL() ); |
|
793 STIF_ASSERT_TRUE_DESC( err == KErrNotReady, _L( "No point to publish anything, when list is empty!" ) ); |
|
794 |
|
795 iContextUtility->AddMusicContextInfoL( KHgCFTypeMusicState, KPlaying ); |
|
796 iContextUtility->AddMusicContextInfoL( KHgCFTypeMusicArtist, KArtist ); |
|
797 iContextUtility->AddMusicContextInfoL( KHgCFTypeMusicTitle, KTitle ); |
|
798 iContextUtility->AddMusicContextInfoL( KHgCFTypeMusicAlbum, KAlbum ); |
|
799 iContextUtility->AddMusicContextInfoL( KHgCFTypeMusicAlbumArt, KHgCFValueUnknownInfo ); |
|
800 |
|
801 iContextUtility->PublishMusicContextL(); |
|
802 STIF_ASSERT_TRUE_DESC( hash->Count() == 0, _L( "There is stuff in the list!" ) ); |
|
803 |
|
804 HBufC* musicState = iContextUtility->GetContextL( KHgCFTypeMusicState ); |
|
805 HBufC* musicArtist = iContextUtility->GetContextL( KHgCFTypeMusicArtist ); |
|
806 HBufC* musicTitle = iContextUtility->GetContextL( KHgCFTypeMusicTitle ); |
|
807 HBufC* musicAlbum = iContextUtility->GetContextL( KHgCFTypeMusicAlbum ); |
|
808 HBufC* musicAlbumArt = iContextUtility->GetContextL( KHgCFTypeMusicAlbumArt ); |
|
809 HBufC* musicGeneralUri = iContextUtility->GetContextL( KHgCFTypeMusicUri ); |
|
810 HBufC* musicGenre = iContextUtility->GetContextL( KHgCFTypeMusicGenre ); |
|
811 HBufC* musicType = iContextUtility->GetContextL( KHgCFTypeMusicType ); |
|
812 |
|
813 STIF_ASSERT_TRUE_DESC( musicState != NULL |
|
814 && !musicState->Compare( KPlaying ), _L( "Music context not found" ) ); |
|
815 STIF_ASSERT_TRUE_DESC( musicArtist != NULL |
|
816 && !musicArtist->Compare( KArtist ), _L( "Artist context not found" ) ); |
|
817 STIF_ASSERT_TRUE_DESC( musicTitle != NULL |
|
818 && !musicTitle->Compare( KTitle ), _L( "Title context not found" ) ); |
|
819 STIF_ASSERT_TRUE_DESC( musicAlbum != NULL |
|
820 && !musicAlbum->Compare( KAlbum ), _L( "Album context not found" ) ); |
|
821 STIF_ASSERT_TRUE_DESC( musicAlbumArt != NULL |
|
822 && !musicAlbumArt->Compare( KHgCFValueUnknownInfo ), _L( "Art context not found" ) ); |
|
823 STIF_ASSERT_TRUE_DESC( musicGeneralUri != NULL |
|
824 && !musicGeneralUri->Compare( KHgCFValueUnknownInfo ), _L( "Uri context not found" ) ); |
|
825 STIF_ASSERT_TRUE_DESC( musicGenre != NULL |
|
826 && !musicGenre->Compare( KHgCFValueUnknownInfo ), _L( "Genre context not found" ) ); |
|
827 STIF_ASSERT_TRUE_DESC( musicType != NULL |
|
828 && !musicType->Compare( KHgCFValueUnknownInfo ), _L( "Type context not found" ) ); |
|
829 |
|
830 delete musicState; |
|
831 delete musicArtist; |
|
832 delete musicTitle; |
|
833 delete musicAlbum; |
|
834 delete musicAlbumArt; |
|
835 delete musicGeneralUri; |
|
836 delete musicGenre; |
|
837 delete musicType; |
|
838 |
|
839 return KErrNone; |
|
840 } |
|
841 |
|
842 STIF_TESTDEFINE( T_PublishRadioContextL ) |
|
843 { |
|
844 _LIT( KTestRadioName, "radio test name" ); |
|
845 _LIT( KTestRadioUrl, "radio test url" ); |
|
846 _LIT( KTestRadioFrequency, "radio test frequency" ); |
|
847 _LIT( KTestRadioRDSPI, "radio test rdspi" ); |
|
848 |
|
849 HBufC* ctxRadioName = NULL; |
|
850 HBufC* ctxRadioUrl = NULL; |
|
851 HBufC* ctxRadioFrequency = NULL; |
|
852 HBufC* ctxRadioRDSPI = NULL; |
|
853 |
|
854 RArray<TPtrC> testData; |
|
855 CleanupClosePushL(testData); |
|
856 |
|
857 // Empty Values |
|
858 iContextUtility->PublishRadioContextL(KNullDesC, KNullDesC, KNullDesC, KNullDesC); |
|
859 ctxRadioName = iContextUtility->GetContextL(KHgCFTypeMusicRadioName); |
|
860 ctxRadioUrl = iContextUtility->GetContextL(KHgCFTypeMusicRadioUrl); |
|
861 ctxRadioFrequency = iContextUtility->GetContextL(KHgCFTypeMusicRadioFrequency); |
|
862 ctxRadioRDSPI = iContextUtility->GetContextL(KHgCFTypeMusicRadioRDSPI); |
|
863 STIF_ASSERT_TRUE_DESC( ctxRadioName != NULL && !ctxRadioName->Compare( KHgCFValueUnknownInfo ), |
|
864 _L( "Empty value: ctxRadioName error." ) ); |
|
865 STIF_ASSERT_TRUE_DESC( ctxRadioUrl != NULL && !ctxRadioUrl->Compare( KHgCFValueUnknownInfo ), |
|
866 _L( "Empty value: ctxRadioUrl error." ) ); |
|
867 STIF_ASSERT_TRUE_DESC( ctxRadioFrequency != NULL && !ctxRadioFrequency->Compare( KHgCFValueUnknownInfo ), |
|
868 _L( "Empty value: ctxRadioFrequency error." ) ); |
|
869 STIF_ASSERT_TRUE_DESC( ctxRadioRDSPI != NULL && !ctxRadioRDSPI->Compare( KHgCFValueUnknownInfo ), |
|
870 _L( "Empty value: ctxRadioRDSPI error." ) ); |
|
871 delete ctxRadioName; |
|
872 delete ctxRadioUrl; |
|
873 delete ctxRadioFrequency; |
|
874 delete ctxRadioRDSPI; |
|
875 |
|
876 // One value |
|
877 testData.Reset(); |
|
878 testData.ReserveL(16); |
|
879 for(TInt i = 0; i < 12; i++) |
|
880 { |
|
881 testData.AppendL(KNullDesC()); |
|
882 } |
|
883 testData.Insert(KTestRadioName(), 0); |
|
884 testData.Insert(KTestRadioUrl(), 5); |
|
885 testData.Insert(KTestRadioFrequency(), 10); |
|
886 testData.Insert(KTestRadioRDSPI(), 15); |
|
887 for(TInt i = 0; i < 16; i += 4) |
|
888 { |
|
889 iContextUtility->PublishRadioContextL(testData[i], testData[i+1], testData[i+2], testData[i+3]); |
|
890 ctxRadioName = iContextUtility->GetContextL(KHgCFTypeMusicRadioName); |
|
891 ctxRadioUrl = iContextUtility->GetContextL(KHgCFTypeMusicRadioUrl); |
|
892 ctxRadioFrequency = iContextUtility->GetContextL(KHgCFTypeMusicRadioFrequency); |
|
893 ctxRadioRDSPI = iContextUtility->GetContextL(KHgCFTypeMusicRadioRDSPI); |
|
894 STIF_ASSERT_TRUE_DESC( ctxRadioName != NULL && |
|
895 !ctxRadioName->Compare( testData[i].Length() ? testData[i] : KHgCFValueUnknownInfo() ), |
|
896 _L( "One value: ctxRadioName error." ) ); |
|
897 STIF_ASSERT_TRUE_DESC( ctxRadioUrl != NULL && |
|
898 !ctxRadioUrl->Compare( testData[i+1].Length() ? testData[i+1] : KHgCFValueUnknownInfo() ), |
|
899 _L( "One value: ctxRadioUrl error." ) ); |
|
900 STIF_ASSERT_TRUE_DESC( ctxRadioFrequency != NULL && |
|
901 !ctxRadioFrequency->Compare( testData[i+2].Length() ? testData[i+2] : KHgCFValueUnknownInfo() ), |
|
902 _L( "One value: ctxRadioFrequency error." ) ); |
|
903 STIF_ASSERT_TRUE_DESC( ctxRadioRDSPI != NULL && |
|
904 !ctxRadioRDSPI->Compare( testData[i+3].Length() ? testData[i+3] : KHgCFValueUnknownInfo() ), |
|
905 _L( "One value: ctxRadioRDSPI error." ) ); |
|
906 delete ctxRadioName; |
|
907 delete ctxRadioUrl; |
|
908 delete ctxRadioFrequency; |
|
909 delete ctxRadioRDSPI; |
|
910 } |
|
911 |
|
912 // Two values |
|
913 testData.Reset(); |
|
914 testData.ReserveL(24); |
|
915 for(TInt i = 0; i < 12; i++) |
|
916 { |
|
917 testData.AppendL(KNullDesC()); |
|
918 } |
|
919 testData.Insert(KTestRadioName(), 0); |
|
920 testData.Insert(KTestRadioUrl(), 1); |
|
921 testData.Insert(KTestRadioName(), 4); |
|
922 testData.Insert(KTestRadioFrequency(), 6); |
|
923 testData.Insert(KTestRadioName(), 8); |
|
924 testData.Insert(KTestRadioRDSPI(), 11); |
|
925 testData.Insert(KTestRadioUrl(), 13); |
|
926 testData.Insert(KTestRadioFrequency(), 14); |
|
927 testData.Insert(KTestRadioUrl(), 17); |
|
928 testData.Insert(KTestRadioRDSPI(), 19); |
|
929 testData.Insert(KTestRadioFrequency(), 22); |
|
930 testData.Insert(KTestRadioRDSPI(), 23); |
|
931 for(TInt i = 0; i < 24; i += 4) |
|
932 { |
|
933 iContextUtility->PublishRadioContextL(testData[i], testData[i+1], testData[i+2], testData[i+3]); |
|
934 ctxRadioName = iContextUtility->GetContextL(KHgCFTypeMusicRadioName); |
|
935 ctxRadioUrl = iContextUtility->GetContextL(KHgCFTypeMusicRadioUrl); |
|
936 ctxRadioFrequency = iContextUtility->GetContextL(KHgCFTypeMusicRadioFrequency); |
|
937 ctxRadioRDSPI = iContextUtility->GetContextL(KHgCFTypeMusicRadioRDSPI); |
|
938 STIF_ASSERT_TRUE_DESC( ctxRadioName != NULL && |
|
939 !ctxRadioName->Compare( testData[i].Length() ? testData[i] : KHgCFValueUnknownInfo() ), |
|
940 _L( "Two values: ctxRadioName error." ) ); |
|
941 STIF_ASSERT_TRUE_DESC( ctxRadioUrl != NULL && |
|
942 !ctxRadioUrl->Compare( testData[i+1].Length() ? testData[i+1] : KHgCFValueUnknownInfo() ), |
|
943 _L( "Two values: ctxRadioUrl error." ) ); |
|
944 STIF_ASSERT_TRUE_DESC( ctxRadioFrequency != NULL && |
|
945 !ctxRadioFrequency->Compare( testData[i+2].Length() ? testData[i+2] : KHgCFValueUnknownInfo() ), |
|
946 _L( "Two values: ctxRadioFrequency error." ) ); |
|
947 STIF_ASSERT_TRUE_DESC( ctxRadioRDSPI != NULL && |
|
948 !ctxRadioRDSPI->Compare( testData[i+3].Length() ? testData[i+3] : KHgCFValueUnknownInfo() ), |
|
949 _L( "Two values: ctxRadioRDSPI error." ) ); |
|
950 delete ctxRadioName; |
|
951 delete ctxRadioUrl; |
|
952 delete ctxRadioFrequency; |
|
953 delete ctxRadioRDSPI; |
|
954 } |
|
955 |
|
956 // Three values |
|
957 testData.Reset(); |
|
958 testData.ReserveL(16); |
|
959 for(TInt i = 0; i < 4; i++) |
|
960 { |
|
961 testData.AppendL(KTestRadioName()); |
|
962 testData.AppendL(KTestRadioUrl()); |
|
963 testData.AppendL(KTestRadioFrequency()); |
|
964 testData.AppendL(KTestRadioRDSPI()); |
|
965 } |
|
966 testData.Remove(3); |
|
967 testData.Insert(KNullDesC(), 3); |
|
968 testData.Remove(6); |
|
969 testData.Insert(KNullDesC(), 6); |
|
970 testData.Remove(9); |
|
971 testData.Insert(KNullDesC(), 9); |
|
972 testData.Remove(12); |
|
973 testData.Insert(KNullDesC(), 12); |
|
974 for(TInt i = 0; i < 16; i += 4) |
|
975 { |
|
976 iContextUtility->PublishRadioContextL(testData[i], testData[i+1], testData[i+2], testData[i+3]); |
|
977 ctxRadioName = iContextUtility->GetContextL(KHgCFTypeMusicRadioName); |
|
978 ctxRadioUrl = iContextUtility->GetContextL(KHgCFTypeMusicRadioUrl); |
|
979 ctxRadioFrequency = iContextUtility->GetContextL(KHgCFTypeMusicRadioFrequency); |
|
980 ctxRadioRDSPI = iContextUtility->GetContextL(KHgCFTypeMusicRadioRDSPI); |
|
981 STIF_ASSERT_TRUE_DESC( ctxRadioName != NULL && |
|
982 !ctxRadioName->Compare( testData[i].Length() ? testData[i] : KHgCFValueUnknownInfo() ), |
|
983 _L( "Three values: ctxRadioName error." ) ); |
|
984 STIF_ASSERT_TRUE_DESC( ctxRadioUrl != NULL && |
|
985 !ctxRadioUrl->Compare( testData[i+1].Length() ? testData[i+1] : KHgCFValueUnknownInfo() ), |
|
986 _L( "Three values: ctxRadioUrl error." ) ); |
|
987 STIF_ASSERT_TRUE_DESC( ctxRadioFrequency != NULL && |
|
988 !ctxRadioFrequency->Compare( testData[i+2].Length() ? testData[i+2] : KHgCFValueUnknownInfo() ), |
|
989 _L( "Three values: ctxRadioFrequency error." ) ); |
|
990 STIF_ASSERT_TRUE_DESC( ctxRadioRDSPI != NULL && |
|
991 !ctxRadioRDSPI->Compare( testData[i+3].Length() ? testData[i+3] : KHgCFValueUnknownInfo() ), |
|
992 _L( "Three values: ctxRadioRDSPI error." ) ); |
|
993 delete ctxRadioName; |
|
994 delete ctxRadioUrl; |
|
995 delete ctxRadioFrequency; |
|
996 delete ctxRadioRDSPI; |
|
997 } |
|
998 |
|
999 // Four values |
|
1000 iContextUtility->PublishRadioContextL(KTestRadioName, KTestRadioUrl, KTestRadioFrequency, KTestRadioRDSPI); |
|
1001 ctxRadioName = iContextUtility->GetContextL(KHgCFTypeMusicRadioName); |
|
1002 ctxRadioUrl = iContextUtility->GetContextL(KHgCFTypeMusicRadioUrl); |
|
1003 ctxRadioFrequency = iContextUtility->GetContextL(KHgCFTypeMusicRadioFrequency); |
|
1004 ctxRadioRDSPI = iContextUtility->GetContextL(KHgCFTypeMusicRadioRDSPI); |
|
1005 STIF_ASSERT_TRUE_DESC( ctxRadioName != NULL && !ctxRadioName->Compare( KTestRadioName ), |
|
1006 _L( "Four values: ctxRadioName error." ) ); |
|
1007 STIF_ASSERT_TRUE_DESC( ctxRadioUrl != NULL && !ctxRadioUrl->Compare( KTestRadioUrl ), |
|
1008 _L( "Four values: ctxRadioUrl error." ) ); |
|
1009 STIF_ASSERT_TRUE_DESC( ctxRadioFrequency != NULL && !ctxRadioFrequency->Compare( KTestRadioFrequency ), |
|
1010 _L( "Four values: ctxRadioFrequency error." ) ); |
|
1011 STIF_ASSERT_TRUE_DESC( ctxRadioRDSPI != NULL && !ctxRadioRDSPI->Compare( KTestRadioRDSPI ), |
|
1012 _L( "Four values: ctxRadioRDSPI error." ) ); |
|
1013 delete ctxRadioName; |
|
1014 delete ctxRadioUrl; |
|
1015 delete ctxRadioFrequency; |
|
1016 delete ctxRadioRDSPI; |
|
1017 |
|
1018 CleanupStack::PopAndDestroy(&testData); |
|
1019 |
|
1020 return KErrNone; |
|
1021 } |
|
1022 |
|
1023 #endif |
|
1024 |
|
1025 // end of file |
|