60
|
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 |
ENTRY( "SetUpBlacklist", CHarvesterClientTestScripter::SetUpBlacklistL ),
|
|
81 |
ENTRY( "TearDownBlacklist", CHarvesterClientTestScripter::TearDownBlacklistL ),
|
|
82 |
ENTRY( "AddFileToBlacklist", CHarvesterClientTestScripter::AddFileToBlacklistL ),
|
|
83 |
ENTRY( "CheckBlacklist", CHarvesterClientTestScripter::CheckBlacklistL ),
|
|
84 |
ENTRY( "RemoveFileFromBlacklist", CHarvesterClientTestScripter::RemoveFileFromBlacklistL ),
|
|
85 |
};
|
|
86 |
|
|
87 |
const TInt count = sizeof( KFunctions ) / sizeof( TStifFunctionInfo );
|
|
88 |
|
|
89 |
return RunInternalL( KFunctions, count, aItem );
|
|
90 |
}
|
|
91 |
|
|
92 |
// -----------------------------------------------------------------------------
|
|
93 |
// CHarvesterClientTest::SetUp
|
|
94 |
// Set up test.
|
|
95 |
// -----------------------------------------------------------------------------
|
|
96 |
//
|
|
97 |
TInt CHarvesterClientTestScripter::SetUp( CStifItemParser& /* aItem */ )
|
|
98 |
{
|
|
99 |
_LIT( KMsg1, "SetUp" );
|
|
100 |
iLog->Log( KMsg1 );
|
|
101 |
RDebug::Print( KMsg1 );
|
|
102 |
|
|
103 |
iHarvestingComplete = EFalse;
|
|
104 |
iPlaceholderComplete = EFalse;
|
|
105 |
iNewObjectComplete = EFalse;
|
|
106 |
iObjectNotification = EFalse;
|
|
107 |
iSetLocation = EFalse;
|
|
108 |
iObjectIdArray.Reset();
|
|
109 |
TRAP_IGNORE( iMdeSession = CMdESession::NewL( *this ) );
|
|
110 |
|
|
111 |
return KErrNone;
|
|
112 |
}
|
|
113 |
|
|
114 |
// -----------------------------------------------------------------------------
|
|
115 |
// CHarvesterClientTest::TearDown
|
|
116 |
// Tear down test.
|
|
117 |
// -----------------------------------------------------------------------------
|
|
118 |
//
|
|
119 |
TInt CHarvesterClientTestScripter::TearDown( CStifItemParser& /* aItem */ )
|
|
120 |
{
|
|
121 |
_LIT( KMsg1, "TearDown" );
|
|
122 |
iLog->Log( KMsg1 );
|
|
123 |
RDebug::Print( KMsg1 );
|
|
124 |
|
|
125 |
delete iHarvesterSession;
|
|
126 |
iHarvesterSession = NULL;
|
|
127 |
delete iMdeSession;
|
|
128 |
iMdeSession = NULL;
|
|
129 |
|
|
130 |
return KErrNone;
|
|
131 |
}
|
|
132 |
|
|
133 |
// -----------------------------------------------------------------------------
|
|
134 |
// CHarvesterClientTest::HarvesterClientConnectL
|
|
135 |
// -----------------------------------------------------------------------------
|
|
136 |
//
|
|
137 |
TInt CHarvesterClientTestScripter::HarvesterClientConnectL( CStifItemParser& /*aItem*/ )
|
|
138 |
{
|
|
139 |
_LIT( KMsg1, "HarvesterClientConnectL" );
|
|
140 |
iLog->Log( KMsg1 );
|
|
141 |
RDebug::Print( KMsg1 );
|
|
142 |
|
|
143 |
User::LeaveIfError( iHc.Connect() );
|
|
144 |
|
|
145 |
return KErrNone;
|
|
146 |
}
|
|
147 |
|
|
148 |
// -----------------------------------------------------------------------------
|
|
149 |
// CHarvesterClientTest::HarvesterClientCloseL
|
|
150 |
// -----------------------------------------------------------------------------
|
|
151 |
//
|
|
152 |
TInt CHarvesterClientTestScripter::HarvesterClientCloseL( CStifItemParser& /*aItem*/ )
|
|
153 |
{
|
|
154 |
_LIT( KMsg1, "HarvesterClientCloseL" );
|
|
155 |
iLog->Log( KMsg1 );
|
|
156 |
RDebug::Print( KMsg1 );
|
|
157 |
|
|
158 |
iHc.Close();
|
|
159 |
|
|
160 |
return KErrNone;
|
|
161 |
}
|
|
162 |
|
|
163 |
// -----------------------------------------------------------------------------
|
|
164 |
// CHarvesterClientTest::HarvesterClientPauseL
|
|
165 |
// -----------------------------------------------------------------------------
|
|
166 |
//
|
|
167 |
TInt CHarvesterClientTestScripter::HarvesterClientPauseL( CStifItemParser& /*aItem*/ )
|
|
168 |
{
|
|
169 |
_LIT( KMsg1, "Enter HarvesterClientPauseL" );
|
|
170 |
iLog->Log( KMsg1 );
|
|
171 |
RDebug::Print( KMsg1 );
|
|
172 |
|
|
173 |
User::LeaveIfError( iHc.Pause() );
|
|
174 |
|
|
175 |
_LIT( KMsg2, "Exit HarvesterClientPauseL" );
|
|
176 |
iLog->Log( KMsg2 );
|
|
177 |
RDebug::Print( KMsg2 );
|
|
178 |
|
|
179 |
return KErrNone;
|
|
180 |
}
|
|
181 |
|
|
182 |
// -----------------------------------------------------------------------------
|
|
183 |
// CHarvesterClientTest::HarvesterClientResumeL
|
|
184 |
// -----------------------------------------------------------------------------
|
|
185 |
//
|
|
186 |
TInt CHarvesterClientTestScripter::HarvesterClientResumeL( CStifItemParser& /*aItem*/ )
|
|
187 |
{
|
|
188 |
_LIT( KMsg1, "Enter HarvesterClientResumeL" );
|
|
189 |
iLog->Log( KMsg1 );
|
|
190 |
RDebug::Print( KMsg1 );
|
|
191 |
|
|
192 |
User::LeaveIfError( iHc.Resume() );
|
|
193 |
|
|
194 |
_LIT( KMsg2, "Exit HarvesterClientResumeL" );
|
|
195 |
iLog->Log( KMsg2 );
|
|
196 |
RDebug::Print( KMsg2 );
|
|
197 |
|
|
198 |
return KErrNone;
|
|
199 |
}
|
|
200 |
|
|
201 |
// -----------------------------------------------------------------------------
|
|
202 |
// CHarvesterClientTest::SetHarvesterObserverL
|
|
203 |
// -----------------------------------------------------------------------------
|
|
204 |
//
|
|
205 |
TInt CHarvesterClientTestScripter::SetHarvesterObserverL( CStifItemParser& /*aItem*/ )
|
|
206 |
{
|
|
207 |
_LIT( KMsg1, "SetHarvesterObserverL" );
|
|
208 |
iLog->Log( KMsg1 );
|
|
209 |
RDebug::Print( KMsg1 );
|
|
210 |
|
|
211 |
iHc.SetObserver( this );
|
|
212 |
|
|
213 |
return KErrNone;
|
|
214 |
}
|
|
215 |
|
|
216 |
// -----------------------------------------------------------------------------
|
|
217 |
// CHarvesterClientTest::RemoveHarvesterObserverL
|
|
218 |
// -----------------------------------------------------------------------------
|
|
219 |
//
|
|
220 |
TInt CHarvesterClientTestScripter::RemoveHarvesterObserverL( CStifItemParser& /*aItem*/ )
|
|
221 |
{
|
|
222 |
_LIT( KMsg1, "RemoveHarvesterObserverL" );
|
|
223 |
iLog->Log( KMsg1 );
|
|
224 |
RDebug::Print( KMsg1 );
|
|
225 |
|
|
226 |
iHc.RemoveObserver( this );
|
|
227 |
|
|
228 |
return KErrNone;
|
|
229 |
}
|
|
230 |
|
|
231 |
// -----------------------------------------------------------------------------
|
|
232 |
// CHarvesterClientTest::AddObjectObserverL
|
|
233 |
// -----------------------------------------------------------------------------
|
|
234 |
//
|
|
235 |
TInt CHarvesterClientTestScripter::AddObjectObserverL( CStifItemParser& /* aItem */ )
|
|
236 |
{
|
|
237 |
_LIT( KMsg1, "AddObjectObserverL" );
|
|
238 |
iLog->Log( KMsg1 );
|
|
239 |
RDebug::Print( KMsg1 );
|
|
240 |
|
|
241 |
iMdeSession->AddObjectObserverL( *this );
|
|
242 |
|
|
243 |
return KErrNone;
|
|
244 |
}
|
|
245 |
|
|
246 |
// -----------------------------------------------------------------------------
|
|
247 |
// CHarvesterClientTest::AddObjectObserverL
|
|
248 |
// -----------------------------------------------------------------------------
|
|
249 |
//
|
|
250 |
TInt CHarvesterClientTestScripter::RemoveObjectObserverL( CStifItemParser& /* aItem */ )
|
|
251 |
{
|
|
252 |
_LIT( KMsg1, "RemoveObjectObserverL" );
|
|
253 |
iLog->Log( KMsg1 );
|
|
254 |
RDebug::Print( KMsg1 );
|
|
255 |
|
|
256 |
TRAP_IGNORE( iMdeSession->RemoveObjectObserverL( *this ) );
|
|
257 |
|
|
258 |
return KErrNone;
|
|
259 |
}
|
|
260 |
|
|
261 |
// -----------------------------------------------------------------------------
|
|
262 |
// CHarvesterClientTest::AddObjectObserverL
|
|
263 |
// -----------------------------------------------------------------------------
|
|
264 |
//
|
|
265 |
TInt CHarvesterClientTestScripter::SetLocationInfoL( CStifItemParser& /* aItem */ )
|
|
266 |
{
|
|
267 |
iSetLocation = ETrue;
|
|
268 |
|
|
269 |
return KErrNone;
|
|
270 |
}
|
|
271 |
|
|
272 |
// -----------------------------------------------------------------------------
|
|
273 |
// CHarvesterClientTest::StartHarvesterSessionL
|
|
274 |
// -----------------------------------------------------------------------------
|
|
275 |
//
|
|
276 |
TInt CHarvesterClientTestScripter::BeginHarvesterSessionL( CStifItemParser& aItem )
|
|
277 |
{
|
|
278 |
_LIT( KMsg1, "Enter BeginHarvesterSessionL" );
|
|
279 |
iLog->Log( KMsg1 );
|
|
280 |
RDebug::Print( KMsg1 );
|
|
281 |
|
|
282 |
TPtrC inputFile;
|
|
283 |
User::LeaveIfError( aItem.GetNextString( inputFile ));
|
|
284 |
|
|
285 |
TRAP_IGNORE( iMdeSession->RemoveObjectL(inputFile) );
|
|
286 |
|
|
287 |
_LIT( KMsg2, "Exit BeginHarvesterSessionL" );
|
|
288 |
iLog->Log( KMsg2 );
|
|
289 |
RDebug::Print( KMsg2 );
|
|
290 |
|
|
291 |
return KErrNone;
|
|
292 |
}
|
|
293 |
|
|
294 |
// -----------------------------------------------------------------------------
|
|
295 |
// CHarvesterClientTest::HarvestFileTestL
|
|
296 |
// -----------------------------------------------------------------------------
|
|
297 |
//
|
|
298 |
TInt CHarvesterClientTestScripter::HarvestFileL( CStifItemParser& aItem )
|
|
299 |
{
|
|
300 |
_LIT( KMsg1, "Enter HarvestFileL" );
|
|
301 |
iLog->Log( KMsg1 );
|
|
302 |
RDebug::Print( KMsg1 );
|
|
303 |
|
|
304 |
TPtrC inputFile;
|
|
305 |
User::LeaveIfError( aItem.GetNextString( inputFile ));
|
|
306 |
iAlbumIds.Append( 1 );
|
|
307 |
iQuerySuccess = EFalse;
|
|
308 |
|
|
309 |
iUri = inputFile;
|
|
310 |
iHc.HarvestFile( inputFile, iAlbumIds, iSetLocation );
|
|
311 |
|
|
312 |
_LIT( KMsg2, "Exit HarvestFileL" );
|
|
313 |
iLog->Log( KMsg2 );
|
|
314 |
RDebug::Print( KMsg2 );
|
|
315 |
|
|
316 |
return KErrNone;
|
|
317 |
}
|
|
318 |
|
|
319 |
// -----------------------------------------------------------------------------
|
|
320 |
// CHarvesterClientTest::HarvestFileTestL
|
|
321 |
// -----------------------------------------------------------------------------
|
|
322 |
//
|
|
323 |
TInt CHarvesterClientTestScripter::HarvestFileWithUIDL( CStifItemParser& aItem )
|
|
324 |
{
|
|
325 |
_LIT( KMsg1, "Enter HarvestFileWithUIDL" );
|
|
326 |
iLog->Log( KMsg1 );
|
|
327 |
RDebug::Print( KMsg1 );
|
|
328 |
|
|
329 |
TUid uid( KNullUid );
|
|
330 |
|
|
331 |
TPtrC inputFile;
|
|
332 |
User::LeaveIfError( aItem.GetNextString( inputFile ));
|
|
333 |
iAlbumIds.Append( 1 );
|
|
334 |
iQuerySuccess = EFalse;
|
|
335 |
|
|
336 |
iUri = inputFile;
|
|
337 |
iHc.HarvestFileWithUID( inputFile, iAlbumIds, EFalse, uid );
|
|
338 |
|
|
339 |
_LIT( KMsg2, "Exit HarvestFileWithUIDL" );
|
|
340 |
iLog->Log( KMsg2 );
|
|
341 |
RDebug::Print( KMsg2 );
|
|
342 |
|
|
343 |
return KErrNone;
|
|
344 |
}
|
|
345 |
|
|
346 |
// -----------------------------------------------------------------------------
|
|
347 |
// CHarvesterClientTest::HarvestingCompleteL
|
|
348 |
// -----------------------------------------------------------------------------
|
|
349 |
//
|
|
350 |
TInt CHarvesterClientTestScripter::EndHarvesterSessionL( CStifItemParser& /* aItem */ )
|
|
351 |
{
|
|
352 |
_LIT( KMsg1, "EndHarvesterSessionL" );
|
|
353 |
iLog->Log( KMsg1 );
|
|
354 |
RDebug::Print( KMsg1 );
|
|
355 |
|
|
356 |
iAlbumIds.Close();
|
|
357 |
|
|
358 |
return KErrNone;
|
|
359 |
}
|
|
360 |
|
|
361 |
// -----------------------------------------------------------------------------
|
|
362 |
// CHarvesterClientTest::QueryObjectByIdIndexL
|
|
363 |
// -----------------------------------------------------------------------------
|
|
364 |
//
|
|
365 |
TInt CHarvesterClientTestScripter::QueryImageObjectByIdIndexL( CStifItemParser& aItem )
|
|
366 |
{
|
|
367 |
_LIT( KMsg1, "QueryImageObjectByIdIndexL" );
|
|
368 |
iLog->Log( KMsg1 );
|
|
369 |
RDebug::Print( KMsg1 );
|
|
370 |
|
|
371 |
TInt index;
|
|
372 |
User::LeaveIfError( aItem.GetNextInt( index ));
|
|
373 |
|
|
374 |
CMdENamespaceDef& defNS = iMdeSession->GetDefaultNamespaceDefL();
|
|
375 |
CMdEObjectDef& objDef = defNS.GetObjectDefL( MdeConstants::Image::KImageObject );
|
|
376 |
iQuery = iMdeSession->NewObjectQueryL( defNS, objDef, this );
|
|
377 |
|
|
378 |
iQuery->SetResultMode( EQueryResultModeItem );
|
|
379 |
|
|
380 |
iQuery->FindL();
|
|
381 |
|
|
382 |
return KErrNone;
|
|
383 |
}
|
|
384 |
|
|
385 |
// -----------------------------------------------------------------------------
|
|
386 |
// CHarvesterClientTest::QueryObjectByIdIndexL
|
|
387 |
// -----------------------------------------------------------------------------
|
|
388 |
//
|
|
389 |
TInt CHarvesterClientTestScripter::QueryAudioObjectByIdIndexL( CStifItemParser& aItem )
|
|
390 |
{
|
|
391 |
_LIT( KMsg1, "QueryAudioObjectByIdIndexL" );
|
|
392 |
iLog->Log( KMsg1 );
|
|
393 |
RDebug::Print( KMsg1 );
|
|
394 |
|
|
395 |
TInt index;
|
|
396 |
User::LeaveIfError( aItem.GetNextInt( index ));
|
|
397 |
|
|
398 |
CMdENamespaceDef& defNS = iMdeSession->GetDefaultNamespaceDefL();
|
|
399 |
CMdEObjectDef& objDef = defNS.GetObjectDefL( MdeConstants::Audio::KAudioObject );
|
|
400 |
iQuery = iMdeSession->NewObjectQueryL( defNS, objDef, this );
|
|
401 |
|
|
402 |
iQuery->SetResultMode( EQueryResultModeItem );
|
|
403 |
|
|
404 |
iQuery->FindL();
|
|
405 |
|
|
406 |
return KErrNone;
|
|
407 |
}
|
|
408 |
|
|
409 |
// -----------------------------------------------------------------------------
|
|
410 |
// CHarvesterClientTest::RemoveObjectL
|
|
411 |
// -----------------------------------------------------------------------------
|
|
412 |
//
|
|
413 |
TInt CHarvesterClientTestScripter::RemoveObjectL( CStifItemParser& aItem )
|
|
414 |
{
|
|
415 |
_LIT( KMsg1, "RemoveObjectL" );
|
|
416 |
iLog->Log( KMsg1 );
|
|
417 |
RDebug::Print( KMsg1 );
|
|
418 |
|
|
419 |
TPtrC inputFile;
|
|
420 |
User::LeaveIfError( aItem.GetNextString( inputFile ));
|
|
421 |
|
|
422 |
TRAP_IGNORE( iMdeSession->RemoveObjectL( inputFile ) );
|
|
423 |
return KErrNone;
|
|
424 |
}
|
|
425 |
|
|
426 |
// -----------------------------------------------------------------------------
|
|
427 |
// CHarvesterClientTest::Results
|
|
428 |
// -----------------------------------------------------------------------------
|
|
429 |
//
|
|
430 |
TInt CHarvesterClientTestScripter::Results( CStifItemParser& /*aItem*/ )
|
|
431 |
{
|
|
432 |
_LIT( KMsg1, "Enter Results" );
|
|
433 |
iLog->Log( KMsg1 );
|
|
434 |
RDebug::Print( KMsg1 );
|
|
435 |
|
|
436 |
if( !iQuerySuccess )
|
|
437 |
{
|
|
438 |
return KErrNotFound;
|
|
439 |
}
|
|
440 |
|
|
441 |
if( !iHarvestingComplete )
|
|
442 |
{
|
|
443 |
return KErrUnknown;
|
|
444 |
}
|
|
445 |
|
|
446 |
_LIT( KMsg2, "Enter Results" );
|
|
447 |
iLog->Log( KMsg2 );
|
|
448 |
RDebug::Print( KMsg2 );
|
|
449 |
|
|
450 |
return KErrNone;
|
|
451 |
}
|
|
452 |
|
|
453 |
// -----------------------------------------------------------------------------
|
|
454 |
// CHarvesterClientTest::AddHarvesterEventObserver
|
|
455 |
// -----------------------------------------------------------------------------
|
|
456 |
//
|
|
457 |
TInt CHarvesterClientTestScripter::AddHarvesterEventObserverL( CStifItemParser& aItem )
|
|
458 |
{
|
|
459 |
_LIT( KMsg1, "AddHarvesterEventObserverL" );
|
|
460 |
iLog->Log( KMsg1 );
|
|
461 |
RDebug::Print( KMsg1 );
|
|
462 |
|
|
463 |
TInt testCount( 0 );
|
|
464 |
User::LeaveIfError( aItem.GetNextInt( testCount ) );
|
|
465 |
for( TInt i = 0; i < testCount; i++ )
|
|
466 |
{
|
|
467 |
TInt err = iHc.AddHarvesterEventObserver( *this, EHEObserverTypePlaceholder, 3 );
|
|
468 |
TL( err == KErrNone );
|
|
469 |
}
|
|
470 |
|
|
471 |
return KErrNone;
|
|
472 |
}
|
|
473 |
|
|
474 |
// -----------------------------------------------------------------------------
|
|
475 |
// CHarvesterClientTest::RemoveHarvesterEventObserver
|
|
476 |
// -----------------------------------------------------------------------------
|
|
477 |
//
|
|
478 |
TInt CHarvesterClientTestScripter::RemoveHarvesterEventObserverL( CStifItemParser& aItem )
|
|
479 |
{
|
|
480 |
_LIT( KMsg1, "RemoveHarvesterEventObserverL" );
|
|
481 |
iLog->Log( KMsg1 );
|
|
482 |
RDebug::Print( KMsg1 );
|
|
483 |
|
|
484 |
TInt testCount( 0 );
|
|
485 |
User::LeaveIfError( aItem.GetNextInt( testCount ) );
|
|
486 |
|
|
487 |
for( TInt i = 0; i < testCount; i++ )
|
|
488 |
{
|
|
489 |
TInt err = iHc.RemoveHarvesterEventObserver( *this );
|
|
490 |
TL( err == KErrNone );
|
|
491 |
}
|
|
492 |
|
|
493 |
return KErrNone;
|
|
494 |
}
|
|
495 |
|
|
496 |
// -----------------------------------------------------------------------------
|
|
497 |
// CHarvesterClientTest::SetUpBlacklistL
|
|
498 |
// -----------------------------------------------------------------------------
|
|
499 |
//
|
|
500 |
TInt CHarvesterClientTestScripter::SetUpBlacklistL( CStifItemParser& /*aItem*/ )
|
|
501 |
{
|
|
502 |
_LIT( KMsg1, "Enter SetUpBlacklistL" );
|
|
503 |
iLog->Log( KMsg1 );
|
|
504 |
RDebug::Print( KMsg1 );
|
|
505 |
|
|
506 |
User::LeaveIfError( iBlacklistClient.Connect() );
|
|
507 |
iBlacklistClient.LoadBlacklistL();
|
|
508 |
iMediaIdUtil = &RMediaIdUtil::GetInstanceL();
|
|
509 |
User::LeaveIfError( iFs.Connect() );
|
|
510 |
|
|
511 |
_LIT( KMsg2, "Exit SetUpBlacklistL" );
|
|
512 |
iLog->Log( KMsg2 );
|
|
513 |
RDebug::Print( KMsg2 );
|
|
514 |
|
|
515 |
return KErrNone;
|
|
516 |
}
|
|
517 |
|
|
518 |
// -----------------------------------------------------------------------------
|
|
519 |
// CHarvesterClientTest::TearDownBlacklistL
|
|
520 |
// -----------------------------------------------------------------------------
|
|
521 |
//
|
|
522 |
TInt CHarvesterClientTestScripter::TearDownBlacklistL( CStifItemParser& /*aItem*/ )
|
|
523 |
{
|
|
524 |
_LIT( KMsg1, "Enter TearDownBlacklistL" );
|
|
525 |
iLog->Log( KMsg1 );
|
|
526 |
RDebug::Print( KMsg1 );
|
|
527 |
|
|
528 |
iBlacklistClient.CloseDBL();
|
|
529 |
iBlacklistClient.Close();
|
|
530 |
RMediaIdUtil::ReleaseInstance();
|
|
531 |
iMediaIdUtil = NULL;
|
|
532 |
iFs.Close();
|
|
533 |
|
|
534 |
_LIT( KMsg2, "Exit TearDownBlacklistL" );
|
|
535 |
iLog->Log( KMsg2 );
|
|
536 |
RDebug::Print( KMsg2 );
|
|
537 |
|
|
538 |
return KErrNone;
|
|
539 |
}
|
|
540 |
|
|
541 |
// -----------------------------------------------------------------------------
|
|
542 |
// CHarvesterClientTest::AddFileToBlacklistL
|
|
543 |
// -----------------------------------------------------------------------------
|
|
544 |
//
|
|
545 |
TInt CHarvesterClientTestScripter::AddFileToBlacklistL( CStifItemParser& aItem )
|
|
546 |
{
|
|
547 |
_LIT( KMsg1, "Enter AddFileToBlacklistL" );
|
|
548 |
iLog->Log( KMsg1 );
|
|
549 |
RDebug::Print( KMsg1 );
|
|
550 |
|
|
551 |
TPtrC inputFile;
|
|
552 |
User::LeaveIfError( aItem.GetNextString( inputFile ));
|
|
553 |
|
|
554 |
TUint32 mediaId( 0 );
|
|
555 |
TTime modified ( 0 );
|
|
556 |
|
|
557 |
TRAPD( err, iBlacklistClient.AddL( inputFile, mediaId, modified ) );
|
|
558 |
if( err != KErrNone )
|
|
559 |
{
|
|
560 |
return err;
|
|
561 |
}
|
|
562 |
|
|
563 |
_LIT( KMsg2, "Exit AddFileToBlacklistL" );
|
|
564 |
iLog->Log( KMsg2 );
|
|
565 |
RDebug::Print( KMsg2 );
|
|
566 |
|
|
567 |
return KErrNone;
|
|
568 |
}
|
|
569 |
|
|
570 |
// -----------------------------------------------------------------------------
|
|
571 |
// CHarvesterClientTest::CheckBlacklistL
|
|
572 |
// -----------------------------------------------------------------------------
|
|
573 |
//
|
|
574 |
TInt CHarvesterClientTestScripter::CheckBlacklistL( CStifItemParser& aItem )
|
|
575 |
{
|
|
576 |
_LIT( KMsg1, "Enter CheckBlacklistL" );
|
|
577 |
iLog->Log( KMsg1 );
|
|
578 |
RDebug::Print( KMsg1 );
|
|
579 |
|
|
580 |
TPtrC inputFile;
|
|
581 |
User::LeaveIfError( aItem.GetNextString( inputFile ));
|
|
582 |
|
|
583 |
TUint32 mediaId( 0 );
|
|
584 |
TTime modified ( 0 );
|
|
585 |
|
|
586 |
TBool isBlacklisted( ETrue );
|
|
587 |
_LIT( KMsg2, "Check blacklist prepare state" );
|
|
588 |
iLog->Log( KMsg2 );
|
|
589 |
RDebug::Print( KMsg2 );
|
|
590 |
TRAP_IGNORE( isBlacklisted = iBlacklistClient.IsBlacklistedL( inputFile, mediaId, modified ) );
|
|
591 |
if( isBlacklisted )
|
|
592 |
{
|
|
593 |
return KErrBadName;
|
|
594 |
}
|
|
595 |
|
|
596 |
_LIT( KMsg3, "Close blacklist to commit the changes" );
|
|
597 |
iLog->Log( KMsg3 );
|
|
598 |
RDebug::Print( KMsg3 );
|
|
599 |
iBlacklistClient.CloseDBL();
|
|
600 |
iBlacklistClient.Close();
|
|
601 |
|
|
602 |
_LIT( KMsg4, "Re-open blacklist to check changes" );
|
|
603 |
iLog->Log( KMsg4 );
|
|
604 |
RDebug::Print( KMsg4 );
|
|
605 |
User::LeaveIfError( iBlacklistClient.Connect() );
|
|
606 |
iBlacklistClient.LoadBlacklistL();
|
|
607 |
|
|
608 |
_LIT( KMsg5, "Check changes" );
|
|
609 |
iLog->Log( KMsg5 );
|
|
610 |
RDebug::Print( KMsg5 );
|
|
611 |
|
|
612 |
isBlacklisted = EFalse;
|
|
613 |
TRAP_IGNORE( isBlacklisted = iBlacklistClient.IsBlacklistedL( inputFile, mediaId, modified ) );
|
|
614 |
if( !isBlacklisted )
|
|
615 |
{
|
|
616 |
return KErrNotFound;
|
|
617 |
}
|
|
618 |
|
|
619 |
_LIT( KMsg6, "Exit CheckBlacklistL" );
|
|
620 |
iLog->Log( KMsg6 );
|
|
621 |
RDebug::Print( KMsg6 );
|
|
622 |
|
|
623 |
return KErrNone;
|
|
624 |
}
|
|
625 |
|
|
626 |
// -----------------------------------------------------------------------------
|
|
627 |
// CHarvesterClientTest::RemoveFileFromBlacklistL
|
|
628 |
// -----------------------------------------------------------------------------
|
|
629 |
//
|
|
630 |
TInt CHarvesterClientTestScripter::RemoveFileFromBlacklistL( CStifItemParser& aItem )
|
|
631 |
{
|
|
632 |
_LIT( KMsg1, "Enter CheckBlacklistL" );
|
|
633 |
iLog->Log( KMsg1 );
|
|
634 |
RDebug::Print( KMsg1 );
|
|
635 |
|
|
636 |
TPtrC inputFile;
|
|
637 |
User::LeaveIfError( aItem.GetNextString( inputFile ));
|
|
638 |
|
|
639 |
TUint32 mediaId( 0 );
|
|
640 |
TTime modified ( 0 );
|
|
641 |
|
|
642 |
TRAPD( err, iBlacklistClient.RemoveL( inputFile, mediaId ) );
|
|
643 |
if( err != KErrNone )
|
|
644 |
{
|
|
645 |
return err;
|
|
646 |
}
|
|
647 |
|
|
648 |
_LIT( KMsg2, "Exit CheckBlacklistL" );
|
|
649 |
iLog->Log( KMsg2 );
|
|
650 |
RDebug::Print( KMsg2 );
|
|
651 |
|
|
652 |
return KErrNone;
|
|
653 |
}
|
|
654 |
|
|
655 |
// -----------------------------------------------------------------------------
|
|
656 |
// CHarvesterClientTest::HarvestingUpdated
|
|
657 |
// -----------------------------------------------------------------------------
|
|
658 |
//
|
|
659 |
void CHarvesterClientTestScripter::HarvestingUpdated(
|
|
660 |
HarvesterEventObserverType /*aHEObserverType*/,
|
|
661 |
HarvesterEventState /*aHarvesterEventState*/,
|
|
662 |
TInt /*aItemsLeft*/ )
|
|
663 |
{
|
|
664 |
_LIT( KMsg1, "CallBck HarvestingUpdated" );
|
|
665 |
iLog->Log( KMsg1 );
|
|
666 |
RDebug::Print( KMsg1 );
|
|
667 |
}
|
|
668 |
|
|
669 |
// -----------------------------------------------------------------------------
|
|
670 |
// CHarvesterClientTest::HarvestingComplete
|
|
671 |
// -----------------------------------------------------------------------------
|
|
672 |
//
|
|
673 |
void CHarvesterClientTestScripter::HarvestingComplete( TDesC& aURI, TInt aError )
|
|
674 |
{
|
|
675 |
_LIT( KMsg, "CallBck HarvestingComplete - Error code : %d" );
|
|
676 |
TBuf <100> msg;
|
|
677 |
msg.Format(KMsg, aError);
|
|
678 |
iLog->Log( msg );
|
|
679 |
RDebug::Print( msg );
|
|
680 |
|
|
681 |
if( MdsUtils::Compare( aURI, iUri ) == 0 )
|
|
682 |
{
|
|
683 |
if( iObjectNotification )
|
|
684 |
{
|
|
685 |
iHarvestingComplete = ETrue;
|
|
686 |
// session event
|
|
687 |
TEventIf event( TEventIf::ESetEvent, _L("Continue") );
|
|
688 |
TestModuleIf().Event( event );
|
|
689 |
}
|
|
690 |
else
|
|
691 |
{
|
|
692 |
iHarvestingComplete = ETrue;
|
|
693 |
}
|
|
694 |
}
|
|
695 |
}
|
|
696 |
|
|
697 |
// -----------------------------------------------------------------------------
|
|
698 |
// CHarvesterClientTest::HandleSessionOpened
|
|
699 |
// -----------------------------------------------------------------------------
|
|
700 |
//
|
|
701 |
void CHarvesterClientTestScripter::HandleSessionOpened( CMdESession& /* aSession */, TInt aError )
|
|
702 |
{
|
|
703 |
_LIT( KMsg, "CallBck HandleSessionOpened - Error code : %d" );
|
|
704 |
TBuf <100> msg;
|
|
705 |
msg.Format(KMsg, aError);
|
|
706 |
iLog->Log( msg );
|
|
707 |
RDebug::Print( msg );
|
|
708 |
|
|
709 |
// session event
|
|
710 |
TEventIf event( TEventIf::ESetEvent, _L("Session") );
|
|
711 |
TestModuleIf().Event( event );
|
|
712 |
}
|
|
713 |
|
|
714 |
// -----------------------------------------------------------------------------
|
|
715 |
// CHarvesterClientTest::HandleSessionError
|
|
716 |
// -----------------------------------------------------------------------------
|
|
717 |
//
|
|
718 |
void CHarvesterClientTestScripter::HandleSessionError( CMdESession& /* aSession */, TInt aError )
|
|
719 |
{
|
|
720 |
_LIT( KMsg, "CallBck HandleSessionError - Error code : %d" );
|
|
721 |
TBuf <100> msg;
|
|
722 |
msg.Format(KMsg, aError);
|
|
723 |
iLog->Log( msg );
|
|
724 |
RDebug::Print( msg );
|
|
725 |
|
|
726 |
// session event
|
|
727 |
TEventIf event( TEventIf::ESetEvent, _L("Session") );
|
|
728 |
TestModuleIf().Event( event );
|
|
729 |
}
|
|
730 |
|
|
731 |
// -----------------------------------------------------------------------------
|
|
732 |
// CHarvesterClientTest::HandleObjectNotification
|
|
733 |
// -----------------------------------------------------------------------------
|
|
734 |
//
|
|
735 |
void CHarvesterClientTestScripter::HandleObjectNotification(
|
|
736 |
CMdESession& /* aSession */,
|
|
737 |
TObserverNotificationType aType,
|
|
738 |
const RArray<TItemId>& aObjectIdArray )
|
|
739 |
{
|
|
740 |
_LIT( KMsg1, "CallBck HandleObjectNotification" );
|
|
741 |
iLog->Log( KMsg1 );
|
|
742 |
RDebug::Print( KMsg1 );
|
|
743 |
|
|
744 |
switch( aType )
|
|
745 |
{
|
|
746 |
case ENotifyAdd:
|
|
747 |
{
|
|
748 |
iPlaceholderComplete = ETrue;
|
|
749 |
break;
|
|
750 |
}
|
|
751 |
case ENotifyModify:
|
|
752 |
{
|
|
753 |
iNewObjectComplete = ETrue;
|
|
754 |
break;
|
|
755 |
}
|
|
756 |
case ENotifyRemove:
|
|
757 |
{
|
|
758 |
break;
|
|
759 |
}
|
|
760 |
}
|
|
761 |
|
|
762 |
CMdEObject* temp = NULL;
|
|
763 |
TRAP_IGNORE( temp = iMdeSession->GetObjectL( iUri ) );
|
|
764 |
if( temp && iHarvestingComplete )
|
|
765 |
{
|
|
766 |
for ( TInt i = 0; i < aObjectIdArray.Count(); ++i )
|
|
767 |
{
|
|
768 |
iObjectIdArray.Append( aObjectIdArray[i] );
|
|
769 |
}
|
|
770 |
// session event
|
|
771 |
TEventIf event( TEventIf::ESetEvent, _L("Continue") );
|
|
772 |
TestModuleIf().Event( event );
|
|
773 |
iObjectNotification = ETrue;
|
|
774 |
}
|
|
775 |
else if( temp )
|
|
776 |
{
|
|
777 |
for ( TInt i = 0; i < aObjectIdArray.Count(); ++i )
|
|
778 |
{
|
|
779 |
iObjectIdArray.Append( aObjectIdArray[i] );
|
|
780 |
}
|
|
781 |
iObjectNotification = ETrue;
|
|
782 |
}
|
|
783 |
}
|
|
784 |
|
|
785 |
// -----------------------------------------------------------------------------
|
|
786 |
// CHarvesterClientTest::HandleQueryNewResults
|
|
787 |
// -----------------------------------------------------------------------------
|
|
788 |
//
|
|
789 |
void CHarvesterClientTestScripter::HandleQueryNewResults( CMdEQuery& /* aQuery */,
|
|
790 |
TInt /* aFirstNewItemIndex */,
|
|
791 |
TInt /* aNewItemCount */ )
|
|
792 |
{
|
|
793 |
_LIT( KMsg1, "CallBck HandleQueryNewResults" );
|
|
794 |
iLog->Log( KMsg1 );
|
|
795 |
RDebug::Print( KMsg1 );
|
|
796 |
}
|
|
797 |
|
|
798 |
// -----------------------------------------------------------------------------
|
|
799 |
// CHarvesterClientTest::HandleQueryCompleted
|
|
800 |
// -----------------------------------------------------------------------------
|
|
801 |
//
|
|
802 |
void CHarvesterClientTestScripter::HandleQueryCompleted( CMdEQuery& aQuery, TInt aError)
|
|
803 |
{
|
|
804 |
_LIT( KMsg, "CallBck HandleQueryCompleted - Error code : %d" );
|
|
805 |
TBuf <100> msg;
|
|
806 |
msg.Format(KMsg, aError);
|
|
807 |
iLog->Log( msg );
|
|
808 |
RDebug::Print( msg );
|
|
809 |
|
|
810 |
if( iQuery && iQuery == &aQuery )
|
|
811 |
{
|
|
812 |
for( TInt i = 0; i < aQuery.Count(); i++ )
|
|
813 |
{
|
|
814 |
TInt id = aQuery.ResultItem( i ).Id();
|
|
815 |
CMdEObject* temp = NULL;
|
|
816 |
TRAP_IGNORE( temp = iMdeSession->GetFullObjectL( id ) );
|
|
817 |
if( MdsUtils::Compare( temp->Uri(), iUri ) == 0 )
|
|
818 |
{
|
|
819 |
iQuerySuccess = ETrue;
|
|
820 |
break;
|
|
821 |
}
|
|
822 |
}
|
|
823 |
}
|
|
824 |
|
|
825 |
if( iQuerySuccess )
|
|
826 |
{
|
|
827 |
// session event
|
|
828 |
TEventIf event( TEventIf::ESetEvent, _L("Query") );
|
|
829 |
TestModuleIf().Event( event );
|
|
830 |
}
|
|
831 |
}
|
|
832 |
|
|
833 |
// End of File
|