|
1 /* |
|
2 * Copyright (c) 2002-2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <e32svr.h> |
|
20 #include <StifParser.h> |
|
21 #include <StifTestEventInterface.h> |
|
22 #include <StifTestInterface.h> |
|
23 #include "HarvesterClientTestScripter.h" |
|
24 #include "mdcserializationbuffer.h" |
|
25 #include "mdeharvestersession.h" |
|
26 #include "mdsutils.h" |
|
27 |
|
28 // ============================ MEMBER FUNCTIONS =============================== |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CHarvesterClientTestScripter::Delete |
|
32 // Delete here all resources allocated and opened from test methods. |
|
33 // Called from destructor. |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 void CHarvesterClientTestScripter::Delete() |
|
37 { |
|
38 |
|
39 } |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CHarvesterClientTestScripter::RunMethodL |
|
43 // Run specified method. Contains also table of test mothods and their names. |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 TInt CHarvesterClientTestScripter::RunMethodL( |
|
47 CStifItemParser& aItem ) |
|
48 { |
|
49 static TStifFunctionInfo const KFunctions[] = |
|
50 { |
|
51 // Copy this line for every implemented function. |
|
52 // First string is the function name used in TestScripter script file. |
|
53 // Second is the actual implementation member function. |
|
54 |
|
55 ENTRY( "SetUp", CHarvesterClientTestScripter::SetUp ), |
|
56 ENTRY( "TearDown", CHarvesterClientTestScripter::TearDown ), |
|
57 |
|
58 // Test helper methods |
|
59 ENTRY( "AddObjectObserver", CHarvesterClientTestScripter::AddObjectObserverL ), |
|
60 ENTRY( "RemoveObjectObserver", CHarvesterClientTestScripter::RemoveObjectObserverL ), |
|
61 ENTRY( "SetUpHarvesting", CHarvesterClientTestScripter::BeginHarvesterSessionL ), |
|
62 ENTRY( "EndHarvesterSession", CHarvesterClientTestScripter::EndHarvesterSessionL ), |
|
63 |
|
64 // Harvester tests |
|
65 ENTRY( "HarvesterClientConnect", CHarvesterClientTestScripter::HarvesterClientConnectL ), |
|
66 ENTRY( "HarvesterClientClose", CHarvesterClientTestScripter::HarvesterClientCloseL ), |
|
67 ENTRY( "HarvesterClientPause", CHarvesterClientTestScripter::HarvesterClientPauseL ), |
|
68 ENTRY( "HarvesterClientResume", CHarvesterClientTestScripter::HarvesterClientResumeL ), |
|
69 ENTRY( "SetHarvesterObserver", CHarvesterClientTestScripter::SetHarvesterObserverL ), |
|
70 ENTRY( "RemoveHarvesterObserver", CHarvesterClientTestScripter::RemoveHarvesterObserverL ), |
|
71 ENTRY( "SetLocationInfo", CHarvesterClientTestScripter::SetLocationInfoL ), |
|
72 ENTRY( "HarvestFile", CHarvesterClientTestScripter::HarvestFileL ), |
|
73 ENTRY( "HarvestFileWithUID", CHarvesterClientTestScripter::HarvestFileWithUIDL ), |
|
74 ENTRY( "QueryImageObjectByIdIndex", CHarvesterClientTestScripter::QueryImageObjectByIdIndexL ), |
|
75 ENTRY( "QueryAudioObjectByIdIndex", CHarvesterClientTestScripter::QueryAudioObjectByIdIndexL ), |
|
76 ENTRY( "RemoveObject", CHarvesterClientTestScripter::RemoveObjectL ), |
|
77 ENTRY( "Results", CHarvesterClientTestScripter::Results ), |
|
78 ENTRY( "AddHarvesterEventObserver", CHarvesterClientTestScripter::AddHarvesterEventObserverL ), |
|
79 ENTRY( "RemoveHarvesterEventObserver", CHarvesterClientTestScripter::RemoveHarvesterEventObserverL ), |
|
80 }; |
|
81 |
|
82 const TInt count = sizeof( KFunctions ) / sizeof( TStifFunctionInfo ); |
|
83 |
|
84 return RunInternalL( KFunctions, count, aItem ); |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CHarvesterClientTest::SetUp |
|
89 // Set up test. |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 TInt CHarvesterClientTestScripter::SetUp( CStifItemParser& /* aItem */ ) |
|
93 { |
|
94 _LIT( KMsg1, "SetUp" ); |
|
95 iLog->Log( KMsg1 ); |
|
96 RDebug::Print( KMsg1 ); |
|
97 |
|
98 iHarvestingComplete = EFalse; |
|
99 iPlaceholderComplete = EFalse; |
|
100 iNewObjectComplete = EFalse; |
|
101 iObjectNotification = EFalse; |
|
102 iSetLocation = EFalse; |
|
103 iObjectIdArray.Reset(); |
|
104 TRAP_IGNORE( iMdeSession = CMdESession::NewL( *this ) ); |
|
105 |
|
106 return KErrNone; |
|
107 } |
|
108 |
|
109 // ----------------------------------------------------------------------------- |
|
110 // CHarvesterClientTest::TearDown |
|
111 // Tear down test. |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 TInt CHarvesterClientTestScripter::TearDown( CStifItemParser& /* aItem */ ) |
|
115 { |
|
116 _LIT( KMsg1, "TearDown" ); |
|
117 iLog->Log( KMsg1 ); |
|
118 RDebug::Print( KMsg1 ); |
|
119 |
|
120 delete iHarvesterSession; |
|
121 iHarvesterSession = NULL; |
|
122 delete iMdeSession; |
|
123 iMdeSession = NULL; |
|
124 |
|
125 return KErrNone; |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CHarvesterClientTest::HarvesterClientConnectL |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 TInt CHarvesterClientTestScripter::HarvesterClientConnectL( CStifItemParser& /*aItem*/ ) |
|
133 { |
|
134 _LIT( KMsg1, "HarvesterClientConnectL" ); |
|
135 iLog->Log( KMsg1 ); |
|
136 RDebug::Print( KMsg1 ); |
|
137 |
|
138 User::LeaveIfError( iHc.Connect() ); |
|
139 |
|
140 return KErrNone; |
|
141 } |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // CHarvesterClientTest::HarvesterClientCloseL |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 TInt CHarvesterClientTestScripter::HarvesterClientCloseL( CStifItemParser& /*aItem*/ ) |
|
148 { |
|
149 _LIT( KMsg1, "HarvesterClientCloseL" ); |
|
150 iLog->Log( KMsg1 ); |
|
151 RDebug::Print( KMsg1 ); |
|
152 |
|
153 iHc.Close(); |
|
154 |
|
155 return KErrNone; |
|
156 } |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // CHarvesterClientTest::HarvesterClientPauseL |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 TInt CHarvesterClientTestScripter::HarvesterClientPauseL( CStifItemParser& /*aItem*/ ) |
|
163 { |
|
164 _LIT( KMsg1, "Enter HarvesterClientPauseL" ); |
|
165 iLog->Log( KMsg1 ); |
|
166 RDebug::Print( KMsg1 ); |
|
167 |
|
168 User::LeaveIfError( iHc.Pause() ); |
|
169 |
|
170 _LIT( KMsg2, "Exit HarvesterClientPauseL" ); |
|
171 iLog->Log( KMsg2 ); |
|
172 RDebug::Print( KMsg2 ); |
|
173 |
|
174 return KErrNone; |
|
175 } |
|
176 |
|
177 // ----------------------------------------------------------------------------- |
|
178 // CHarvesterClientTest::HarvesterClientResumeL |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 TInt CHarvesterClientTestScripter::HarvesterClientResumeL( CStifItemParser& /*aItem*/ ) |
|
182 { |
|
183 _LIT( KMsg1, "Enter HarvesterClientResumeL" ); |
|
184 iLog->Log( KMsg1 ); |
|
185 RDebug::Print( KMsg1 ); |
|
186 |
|
187 User::LeaveIfError( iHc.Resume() ); |
|
188 |
|
189 _LIT( KMsg2, "Exit HarvesterClientResumeL" ); |
|
190 iLog->Log( KMsg2 ); |
|
191 RDebug::Print( KMsg2 ); |
|
192 |
|
193 return KErrNone; |
|
194 } |
|
195 |
|
196 // ----------------------------------------------------------------------------- |
|
197 // CHarvesterClientTest::SetHarvesterObserverL |
|
198 // ----------------------------------------------------------------------------- |
|
199 // |
|
200 TInt CHarvesterClientTestScripter::SetHarvesterObserverL( CStifItemParser& /*aItem*/ ) |
|
201 { |
|
202 _LIT( KMsg1, "SetHarvesterObserverL" ); |
|
203 iLog->Log( KMsg1 ); |
|
204 RDebug::Print( KMsg1 ); |
|
205 |
|
206 iHc.SetObserver( this ); |
|
207 |
|
208 return KErrNone; |
|
209 } |
|
210 |
|
211 // ----------------------------------------------------------------------------- |
|
212 // CHarvesterClientTest::RemoveHarvesterObserverL |
|
213 // ----------------------------------------------------------------------------- |
|
214 // |
|
215 TInt CHarvesterClientTestScripter::RemoveHarvesterObserverL( CStifItemParser& /*aItem*/ ) |
|
216 { |
|
217 _LIT( KMsg1, "RemoveHarvesterObserverL" ); |
|
218 iLog->Log( KMsg1 ); |
|
219 RDebug::Print( KMsg1 ); |
|
220 |
|
221 iHc.RemoveObserver( this ); |
|
222 |
|
223 return KErrNone; |
|
224 } |
|
225 |
|
226 // ----------------------------------------------------------------------------- |
|
227 // CHarvesterClientTest::AddObjectObserverL |
|
228 // ----------------------------------------------------------------------------- |
|
229 // |
|
230 TInt CHarvesterClientTestScripter::AddObjectObserverL( CStifItemParser& /* aItem */ ) |
|
231 { |
|
232 _LIT( KMsg1, "AddObjectObserverL" ); |
|
233 iLog->Log( KMsg1 ); |
|
234 RDebug::Print( KMsg1 ); |
|
235 |
|
236 iMdeSession->AddObjectObserverL( *this ); |
|
237 |
|
238 return KErrNone; |
|
239 } |
|
240 |
|
241 // ----------------------------------------------------------------------------- |
|
242 // CHarvesterClientTest::AddObjectObserverL |
|
243 // ----------------------------------------------------------------------------- |
|
244 // |
|
245 TInt CHarvesterClientTestScripter::RemoveObjectObserverL( CStifItemParser& /* aItem */ ) |
|
246 { |
|
247 _LIT( KMsg1, "RemoveObjectObserverL" ); |
|
248 iLog->Log( KMsg1 ); |
|
249 RDebug::Print( KMsg1 ); |
|
250 |
|
251 TRAP_IGNORE( iMdeSession->RemoveObjectObserverL( *this ) ); |
|
252 |
|
253 return KErrNone; |
|
254 } |
|
255 |
|
256 // ----------------------------------------------------------------------------- |
|
257 // CHarvesterClientTest::AddObjectObserverL |
|
258 // ----------------------------------------------------------------------------- |
|
259 // |
|
260 TInt CHarvesterClientTestScripter::SetLocationInfoL( CStifItemParser& /* aItem */ ) |
|
261 { |
|
262 iSetLocation = ETrue; |
|
263 |
|
264 return KErrNone; |
|
265 } |
|
266 |
|
267 // ----------------------------------------------------------------------------- |
|
268 // CHarvesterClientTest::StartHarvesterSessionL |
|
269 // ----------------------------------------------------------------------------- |
|
270 // |
|
271 TInt CHarvesterClientTestScripter::BeginHarvesterSessionL( CStifItemParser& aItem ) |
|
272 { |
|
273 _LIT( KMsg1, "Enter BeginHarvesterSessionL" ); |
|
274 iLog->Log( KMsg1 ); |
|
275 RDebug::Print( KMsg1 ); |
|
276 |
|
277 TPtrC inputFile; |
|
278 User::LeaveIfError( aItem.GetNextString( inputFile )); |
|
279 |
|
280 TRAP_IGNORE( iMdeSession->RemoveObjectL(inputFile) ); |
|
281 |
|
282 _LIT( KMsg2, "Exit BeginHarvesterSessionL" ); |
|
283 iLog->Log( KMsg2 ); |
|
284 RDebug::Print( KMsg2 ); |
|
285 |
|
286 return KErrNone; |
|
287 } |
|
288 |
|
289 // ----------------------------------------------------------------------------- |
|
290 // CHarvesterClientTest::HarvestFileTestL |
|
291 // ----------------------------------------------------------------------------- |
|
292 // |
|
293 TInt CHarvesterClientTestScripter::HarvestFileL( CStifItemParser& aItem ) |
|
294 { |
|
295 _LIT( KMsg1, "Enter HarvestFileL" ); |
|
296 iLog->Log( KMsg1 ); |
|
297 RDebug::Print( KMsg1 ); |
|
298 |
|
299 TPtrC inputFile; |
|
300 User::LeaveIfError( aItem.GetNextString( inputFile )); |
|
301 iAlbumIds.Append( 1 ); |
|
302 iQuerySuccess = EFalse; |
|
303 |
|
304 iUri = inputFile; |
|
305 iHc.HarvestFile( inputFile, iAlbumIds, iSetLocation ); |
|
306 |
|
307 _LIT( KMsg2, "Exit HarvestFileL" ); |
|
308 iLog->Log( KMsg2 ); |
|
309 RDebug::Print( KMsg2 ); |
|
310 |
|
311 return KErrNone; |
|
312 } |
|
313 |
|
314 // ----------------------------------------------------------------------------- |
|
315 // CHarvesterClientTest::HarvestFileTestL |
|
316 // ----------------------------------------------------------------------------- |
|
317 // |
|
318 TInt CHarvesterClientTestScripter::HarvestFileWithUIDL( CStifItemParser& aItem ) |
|
319 { |
|
320 _LIT( KMsg1, "Enter HarvestFileWithUIDL" ); |
|
321 iLog->Log( KMsg1 ); |
|
322 RDebug::Print( KMsg1 ); |
|
323 |
|
324 TUid uid( KNullUid ); |
|
325 |
|
326 TPtrC inputFile; |
|
327 User::LeaveIfError( aItem.GetNextString( inputFile )); |
|
328 iAlbumIds.Append( 1 ); |
|
329 iQuerySuccess = EFalse; |
|
330 |
|
331 iUri = inputFile; |
|
332 iHc.HarvestFileWithUID( inputFile, iAlbumIds, EFalse, uid ); |
|
333 |
|
334 _LIT( KMsg2, "Exit HarvestFileWithUIDL" ); |
|
335 iLog->Log( KMsg2 ); |
|
336 RDebug::Print( KMsg2 ); |
|
337 |
|
338 return KErrNone; |
|
339 } |
|
340 |
|
341 // ----------------------------------------------------------------------------- |
|
342 // CHarvesterClientTest::HarvestingCompleteL |
|
343 // ----------------------------------------------------------------------------- |
|
344 // |
|
345 TInt CHarvesterClientTestScripter::EndHarvesterSessionL( CStifItemParser& /* aItem */ ) |
|
346 { |
|
347 _LIT( KMsg1, "EndHarvesterSessionL" ); |
|
348 iLog->Log( KMsg1 ); |
|
349 RDebug::Print( KMsg1 ); |
|
350 |
|
351 iAlbumIds.Close(); |
|
352 |
|
353 return KErrNone; |
|
354 } |
|
355 |
|
356 // ----------------------------------------------------------------------------- |
|
357 // CHarvesterClientTest::QueryObjectByIdIndexL |
|
358 // ----------------------------------------------------------------------------- |
|
359 // |
|
360 TInt CHarvesterClientTestScripter::QueryImageObjectByIdIndexL( CStifItemParser& aItem ) |
|
361 { |
|
362 _LIT( KMsg1, "QueryImageObjectByIdIndexL" ); |
|
363 iLog->Log( KMsg1 ); |
|
364 RDebug::Print( KMsg1 ); |
|
365 |
|
366 TInt index; |
|
367 User::LeaveIfError( aItem.GetNextInt( index )); |
|
368 |
|
369 CMdENamespaceDef& defNS = iMdeSession->GetDefaultNamespaceDefL(); |
|
370 CMdEObjectDef& objDef = defNS.GetObjectDefL( MdeConstants::Image::KImageObject ); |
|
371 iQuery = iMdeSession->NewObjectQueryL( defNS, objDef, this ); |
|
372 |
|
373 iQuery->SetResultMode( EQueryResultModeItem ); |
|
374 |
|
375 iQuery->FindL(); |
|
376 |
|
377 return KErrNone; |
|
378 } |
|
379 |
|
380 // ----------------------------------------------------------------------------- |
|
381 // CHarvesterClientTest::QueryObjectByIdIndexL |
|
382 // ----------------------------------------------------------------------------- |
|
383 // |
|
384 TInt CHarvesterClientTestScripter::QueryAudioObjectByIdIndexL( CStifItemParser& aItem ) |
|
385 { |
|
386 _LIT( KMsg1, "QueryAudioObjectByIdIndexL" ); |
|
387 iLog->Log( KMsg1 ); |
|
388 RDebug::Print( KMsg1 ); |
|
389 |
|
390 TInt index; |
|
391 User::LeaveIfError( aItem.GetNextInt( index )); |
|
392 |
|
393 CMdENamespaceDef& defNS = iMdeSession->GetDefaultNamespaceDefL(); |
|
394 CMdEObjectDef& objDef = defNS.GetObjectDefL( MdeConstants::Audio::KAudioObject ); |
|
395 iQuery = iMdeSession->NewObjectQueryL( defNS, objDef, this ); |
|
396 |
|
397 iQuery->SetResultMode( EQueryResultModeItem ); |
|
398 |
|
399 iQuery->FindL(); |
|
400 |
|
401 return KErrNone; |
|
402 } |
|
403 |
|
404 // ----------------------------------------------------------------------------- |
|
405 // CHarvesterClientTest::RemoveObjectL |
|
406 // ----------------------------------------------------------------------------- |
|
407 // |
|
408 TInt CHarvesterClientTestScripter::RemoveObjectL( CStifItemParser& aItem ) |
|
409 { |
|
410 _LIT( KMsg1, "RemoveObjectL" ); |
|
411 iLog->Log( KMsg1 ); |
|
412 RDebug::Print( KMsg1 ); |
|
413 |
|
414 TPtrC inputFile; |
|
415 User::LeaveIfError( aItem.GetNextString( inputFile )); |
|
416 |
|
417 TRAP_IGNORE( iMdeSession->RemoveObjectL( inputFile ) ); |
|
418 return KErrNone; |
|
419 } |
|
420 |
|
421 // ----------------------------------------------------------------------------- |
|
422 // CHarvesterClientTest::Results |
|
423 // ----------------------------------------------------------------------------- |
|
424 // |
|
425 TInt CHarvesterClientTestScripter::Results( CStifItemParser& /*aItem*/ ) |
|
426 { |
|
427 _LIT( KMsg1, "Enter Results" ); |
|
428 iLog->Log( KMsg1 ); |
|
429 RDebug::Print( KMsg1 ); |
|
430 |
|
431 if( !iQuerySuccess ) |
|
432 { |
|
433 return KErrNotFound; |
|
434 } |
|
435 |
|
436 if( !iHarvestingComplete ) |
|
437 { |
|
438 return KErrUnknown; |
|
439 } |
|
440 |
|
441 _LIT( KMsg2, "Enter Results" ); |
|
442 iLog->Log( KMsg2 ); |
|
443 RDebug::Print( KMsg2 ); |
|
444 |
|
445 return KErrNone; |
|
446 } |
|
447 |
|
448 // ----------------------------------------------------------------------------- |
|
449 // CHarvesterClientTest::AddHarvesterEventObserver |
|
450 // ----------------------------------------------------------------------------- |
|
451 // |
|
452 TInt CHarvesterClientTestScripter::AddHarvesterEventObserverL( CStifItemParser& aItem ) |
|
453 { |
|
454 _LIT( KMsg1, "AddHarvesterEventObserverL" ); |
|
455 iLog->Log( KMsg1 ); |
|
456 RDebug::Print( KMsg1 ); |
|
457 |
|
458 TInt testCount( 0 ); |
|
459 User::LeaveIfError( aItem.GetNextInt( testCount ) ); |
|
460 for( TInt i = 0; i < testCount; i++ ) |
|
461 { |
|
462 TInt err = iHc.AddHarvesterEventObserver( *this, EHEObserverTypePlaceholder, 3 ); |
|
463 TL( err == KErrNone ); |
|
464 } |
|
465 |
|
466 return KErrNone; |
|
467 } |
|
468 |
|
469 // ----------------------------------------------------------------------------- |
|
470 // CHarvesterClientTest::RemoveHarvesterEventObserver |
|
471 // ----------------------------------------------------------------------------- |
|
472 // |
|
473 TInt CHarvesterClientTestScripter::RemoveHarvesterEventObserverL( CStifItemParser& aItem ) |
|
474 { |
|
475 _LIT( KMsg1, "RemoveHarvesterEventObserverL" ); |
|
476 iLog->Log( KMsg1 ); |
|
477 RDebug::Print( KMsg1 ); |
|
478 |
|
479 TInt testCount( 0 ); |
|
480 User::LeaveIfError( aItem.GetNextInt( testCount ) ); |
|
481 |
|
482 for( TInt i = 0; i < testCount; i++ ) |
|
483 { |
|
484 TInt err = iHc.RemoveHarvesterEventObserver( *this ); |
|
485 TL( err == KErrNone ); |
|
486 } |
|
487 |
|
488 return KErrNone; |
|
489 } |
|
490 |
|
491 // ----------------------------------------------------------------------------- |
|
492 // CHarvesterClientTest::HarvestingUpdated |
|
493 // ----------------------------------------------------------------------------- |
|
494 // |
|
495 void CHarvesterClientTestScripter::HarvestingUpdated( |
|
496 HarvesterEventObserverType /*aHEObserverType*/, |
|
497 HarvesterEventState /*aHarvesterEventState*/, |
|
498 TInt /*aItemsLeft*/ ) |
|
499 { |
|
500 _LIT( KMsg1, "CallBck HarvestingUpdated" ); |
|
501 iLog->Log( KMsg1 ); |
|
502 RDebug::Print( KMsg1 ); |
|
503 } |
|
504 |
|
505 // ----------------------------------------------------------------------------- |
|
506 // CHarvesterClientTest::HarvestingComplete |
|
507 // ----------------------------------------------------------------------------- |
|
508 // |
|
509 void CHarvesterClientTestScripter::HarvestingComplete( TDesC& aURI, TInt aError ) |
|
510 { |
|
511 _LIT( KMsg, "CallBck HarvestingComplete - Error code : %d" ); |
|
512 TBuf <100> msg; |
|
513 msg.Format(KMsg, aError); |
|
514 iLog->Log( msg ); |
|
515 RDebug::Print( msg ); |
|
516 |
|
517 if( MdsUtils::Compare( aURI, iUri ) == 0 ) |
|
518 { |
|
519 if( iObjectNotification ) |
|
520 { |
|
521 iHarvestingComplete = ETrue; |
|
522 // session event |
|
523 TEventIf event( TEventIf::ESetEvent, _L("Continue") ); |
|
524 TestModuleIf().Event( event ); |
|
525 } |
|
526 else |
|
527 { |
|
528 iHarvestingComplete = ETrue; |
|
529 } |
|
530 } |
|
531 } |
|
532 |
|
533 // ----------------------------------------------------------------------------- |
|
534 // CHarvesterClientTest::HandleSessionOpened |
|
535 // ----------------------------------------------------------------------------- |
|
536 // |
|
537 void CHarvesterClientTestScripter::HandleSessionOpened( CMdESession& /* aSession */, TInt aError ) |
|
538 { |
|
539 _LIT( KMsg, "CallBck HandleSessionOpened - Error code : %d" ); |
|
540 TBuf <100> msg; |
|
541 msg.Format(KMsg, aError); |
|
542 iLog->Log( msg ); |
|
543 RDebug::Print( msg ); |
|
544 |
|
545 // session event |
|
546 TEventIf event( TEventIf::ESetEvent, _L("Session") ); |
|
547 TestModuleIf().Event( event ); |
|
548 } |
|
549 |
|
550 // ----------------------------------------------------------------------------- |
|
551 // CHarvesterClientTest::HandleSessionError |
|
552 // ----------------------------------------------------------------------------- |
|
553 // |
|
554 void CHarvesterClientTestScripter::HandleSessionError( CMdESession& /* aSession */, TInt aError ) |
|
555 { |
|
556 _LIT( KMsg, "CallBck HandleSessionError - Error code : %d" ); |
|
557 TBuf <100> msg; |
|
558 msg.Format(KMsg, aError); |
|
559 iLog->Log( msg ); |
|
560 RDebug::Print( msg ); |
|
561 |
|
562 // session event |
|
563 TEventIf event( TEventIf::ESetEvent, _L("Session") ); |
|
564 TestModuleIf().Event( event ); |
|
565 } |
|
566 |
|
567 // ----------------------------------------------------------------------------- |
|
568 // CHarvesterClientTest::HandleObjectNotification |
|
569 // ----------------------------------------------------------------------------- |
|
570 // |
|
571 void CHarvesterClientTestScripter::HandleObjectNotification( |
|
572 CMdESession& /* aSession */, |
|
573 TObserverNotificationType aType, |
|
574 const RArray<TItemId>& aObjectIdArray ) |
|
575 { |
|
576 _LIT( KMsg1, "CallBck HandleObjectNotification" ); |
|
577 iLog->Log( KMsg1 ); |
|
578 RDebug::Print( KMsg1 ); |
|
579 |
|
580 switch( aType ) |
|
581 { |
|
582 case ENotifyAdd: |
|
583 { |
|
584 iPlaceholderComplete = ETrue; |
|
585 break; |
|
586 } |
|
587 case ENotifyModify: |
|
588 { |
|
589 iNewObjectComplete = ETrue; |
|
590 break; |
|
591 } |
|
592 case ENotifyRemove: |
|
593 { |
|
594 break; |
|
595 } |
|
596 } |
|
597 |
|
598 CMdEObject* temp = NULL; |
|
599 TRAP_IGNORE( temp = iMdeSession->GetObjectL( iUri ) ); |
|
600 if( temp && iHarvestingComplete ) |
|
601 { |
|
602 for ( TInt i = 0; i < aObjectIdArray.Count(); ++i ) |
|
603 { |
|
604 iObjectIdArray.Append( aObjectIdArray[i] ); |
|
605 } |
|
606 // session event |
|
607 TEventIf event( TEventIf::ESetEvent, _L("Continue") ); |
|
608 TestModuleIf().Event( event ); |
|
609 iObjectNotification = ETrue; |
|
610 } |
|
611 else if( temp ) |
|
612 { |
|
613 for ( TInt i = 0; i < aObjectIdArray.Count(); ++i ) |
|
614 { |
|
615 iObjectIdArray.Append( aObjectIdArray[i] ); |
|
616 } |
|
617 iObjectNotification = ETrue; |
|
618 } |
|
619 } |
|
620 |
|
621 // ----------------------------------------------------------------------------- |
|
622 // CHarvesterClientTest::HandleQueryNewResults |
|
623 // ----------------------------------------------------------------------------- |
|
624 // |
|
625 void CHarvesterClientTestScripter::HandleQueryNewResults( CMdEQuery& /* aQuery */, |
|
626 TInt /* aFirstNewItemIndex */, |
|
627 TInt /* aNewItemCount */ ) |
|
628 { |
|
629 _LIT( KMsg1, "CallBck HandleQueryNewResults" ); |
|
630 iLog->Log( KMsg1 ); |
|
631 RDebug::Print( KMsg1 ); |
|
632 } |
|
633 |
|
634 // ----------------------------------------------------------------------------- |
|
635 // CHarvesterClientTest::HandleQueryCompleted |
|
636 // ----------------------------------------------------------------------------- |
|
637 // |
|
638 void CHarvesterClientTestScripter::HandleQueryCompleted( CMdEQuery& aQuery, TInt aError) |
|
639 { |
|
640 _LIT( KMsg, "CallBck HandleQueryCompleted - Error code : %d" ); |
|
641 TBuf <100> msg; |
|
642 msg.Format(KMsg, aError); |
|
643 iLog->Log( msg ); |
|
644 RDebug::Print( msg ); |
|
645 |
|
646 if( iQuery && iQuery == &aQuery ) |
|
647 { |
|
648 for( TInt i = 0; i < aQuery.Count(); i++ ) |
|
649 { |
|
650 TInt id = aQuery.ResultItem( i ).Id(); |
|
651 CMdEObject* temp = NULL; |
|
652 TRAP_IGNORE( temp = iMdeSession->GetFullObjectL( id ) ); |
|
653 if( MdsUtils::Compare( temp->Uri(), iUri ) == 0 ) |
|
654 { |
|
655 iQuerySuccess = ETrue; |
|
656 break; |
|
657 } |
|
658 } |
|
659 } |
|
660 |
|
661 if( iQuerySuccess ) |
|
662 { |
|
663 // session event |
|
664 TEventIf event( TEventIf::ESetEvent, _L("Query") ); |
|
665 TestModuleIf().Event( event ); |
|
666 } |
|
667 } |
|
668 |
|
669 // End of File |