19
|
1 |
/*
|
|
2 |
* Copyright (c) 2006-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 the License "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: ?Description
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
#include <e32svr.h>
|
|
22 |
#include <StifParser.h>
|
|
23 |
#include <Stiftestinterface.h>
|
|
24 |
#include <LiwServiceHandler.h>
|
|
25 |
#include <Liwbufferextension.h>
|
|
26 |
#include "tappmgrprovider.h"
|
|
27 |
#include "appmanagerservice.h"
|
|
28 |
#include "appmanagercommon.h"
|
|
29 |
#include <f32file.h>
|
|
30 |
#include <e32des16.h>
|
|
31 |
#include <e32base.h>
|
|
32 |
|
|
33 |
#include "testappobserver.h"
|
|
34 |
|
|
35 |
_LIT8(KContent,"Type");
|
|
36 |
_LIT8(KDocumentPath,"DocumentPath");
|
|
37 |
_LIT8(KMimeType,"MimeType");
|
|
38 |
_LIT8(KMode,"Mode");
|
|
39 |
_LIT8(KPostion,"Position");
|
|
40 |
_LIT8(KHandle,"Handle");
|
|
41 |
_LIT8(KDocument,"Document");
|
|
42 |
_LIT(KNull,"NULL");
|
|
43 |
|
|
44 |
_LIT8(KService, "Service.AppManager");
|
|
45 |
_LIT8(KIAppManager,"IAppManager");
|
|
46 |
_LIT8(KTransactionID,"TransactionID");
|
|
47 |
_LIT8(KCmdLine,"CmdLine");
|
|
48 |
|
|
49 |
_LIT8(KApplicationID,"ApplicationID");
|
|
50 |
_LIT8(KDocumentName,"DocumentName");
|
|
51 |
|
|
52 |
//Supported Operation
|
|
53 |
_LIT8(KGetList, "GetList");
|
|
54 |
_LIT8(KLaunchApp,"LaunchApp");
|
|
55 |
_LIT8(KLaunchDoc,"LaunchDoc");
|
|
56 |
_LIT8(KResponse,"ReturnValue");
|
|
57 |
_LIT8(KErrorCode,"ErrorCode");
|
|
58 |
_LIT8(KOptions,"Options");
|
|
59 |
|
|
60 |
// Filter Map
|
|
61 |
_LIT8(KFilter,"Filter");
|
|
62 |
|
|
63 |
const TInt KDocMaxDigitsInHexString = 8; // 32 bits.
|
|
64 |
|
|
65 |
|
|
66 |
// EXTERNAL DATA STRUCTURES
|
|
67 |
//extern ?external_data;
|
|
68 |
|
|
69 |
// EXTERNAL FUNCTION PROTOTYPES
|
|
70 |
//extern ?external_function( ?arg_type,?arg_type );
|
|
71 |
|
|
72 |
// CONSTANTS
|
|
73 |
//const ?type ?constant_var = ?constant;
|
|
74 |
|
|
75 |
// MACROS
|
|
76 |
//#define ?macro ?macro_def
|
|
77 |
|
|
78 |
// LOCAL CONSTANTS AND MACROS
|
|
79 |
//const ?type ?constant_var = ?constant;
|
|
80 |
//#define ?macro_name ?macro_def
|
|
81 |
|
|
82 |
// MODULE DATA STRUCTURES
|
|
83 |
//enum ?declaration
|
|
84 |
//typedef ?declaration
|
|
85 |
|
|
86 |
// LOCAL FUNCTION PROTOTYPES
|
|
87 |
//?type ?function_name( ?arg_type, ?arg_type );
|
|
88 |
|
|
89 |
// FORWARD DECLARATIONS
|
|
90 |
//class ?FORWARD_CLASSNAME;
|
|
91 |
|
|
92 |
// ============================= LOCAL FUNCTIONS ===============================
|
|
93 |
|
|
94 |
// -----------------------------------------------------------------------------
|
|
95 |
// ?function_name ?description.
|
|
96 |
// ?description
|
|
97 |
// Returns: ?value_1: ?description
|
|
98 |
// ?value_n: ?description_line1
|
|
99 |
// ?description_line2
|
|
100 |
// -----------------------------------------------------------------------------
|
|
101 |
//
|
|
102 |
/*
|
|
103 |
?type ?function_name(
|
|
104 |
?arg_type arg, // ?description
|
|
105 |
?arg_type arg) // ?description
|
|
106 |
{
|
|
107 |
|
|
108 |
?code // ?comment
|
|
109 |
|
|
110 |
// ?comment
|
|
111 |
?code
|
|
112 |
}
|
|
113 |
*/
|
|
114 |
|
|
115 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
116 |
|
|
117 |
// -----------------------------------------------------------------------------
|
|
118 |
// Csapi_getheader:Delete
|
|
119 |
// Delete here all resources allocated and opened from test methods.
|
|
120 |
// Called from destructor.
|
|
121 |
// -----------------------------------------------------------------------------
|
|
122 |
//
|
|
123 |
void CAppManagerTest::Delete()
|
|
124 |
{
|
|
125 |
|
|
126 |
}
|
|
127 |
|
|
128 |
// -----------------------------------------------------------------------------
|
|
129 |
// Csapi_getheader:RunMethodL
|
|
130 |
// Run specified method. Contains also table of test mothods and their names.
|
|
131 |
// -----------------------------------------------------------------------------
|
|
132 |
//
|
|
133 |
TInt CAppManagerTest::RunMethodL(
|
|
134 |
CStifItemParser& aItem )
|
|
135 |
{
|
|
136 |
|
|
137 |
static TStifFunctionInfo const KFunctions[] =
|
|
138 |
{
|
|
139 |
ENTRY( "getlisttest", CAppManagerTest::getlisttestL ),
|
|
140 |
ENTRY( "getlistnegativetestL", CAppManagerTest::getlistnegativetestL ),
|
|
141 |
ENTRY( "launchApp", CAppManagerTest::launchAppL ),
|
|
142 |
ENTRY( "launchDoc", CAppManagerTest::launchDocL ),
|
|
143 |
ENTRY( "cancellaunchDoc", CAppManagerTest::CancellaunchDocL ),
|
|
144 |
// ENTRY( "getlistnegativetestL", CAppManagerTest::getlistnegativetestL ),
|
|
145 |
};
|
|
146 |
|
|
147 |
const TInt count = sizeof( KFunctions ) /
|
|
148 |
sizeof( TStifFunctionInfo );
|
|
149 |
|
|
150 |
return RunInternalL( KFunctions, count, aItem );
|
|
151 |
|
|
152 |
}
|
|
153 |
|
|
154 |
// -----------------------------------------------------------------------------
|
|
155 |
// CAppManagerTest:getlistapplication1_testL
|
|
156 |
// Example test method function.
|
|
157 |
// (other items were commented in a header).
|
|
158 |
// -----------------------------------------------------------------------------
|
|
159 |
//
|
|
160 |
TInt CAppManagerTest::getlisttestL( CStifItemParser& aItem )
|
|
161 |
{
|
|
162 |
|
|
163 |
__UHEAP_MARK;
|
|
164 |
TPtrC16 content;
|
|
165 |
TPtrC16 docname;
|
|
166 |
TPtrC16 mimetype16;
|
|
167 |
TInt expected;
|
|
168 |
TInt noOfmaps;
|
|
169 |
TPtrC16 filename;
|
|
170 |
TInt result =KErrNone ;// KErrGeneral; // 0 means pass and -1 means Fail
|
|
171 |
|
|
172 |
aItem.GetNextString(content);
|
|
173 |
aItem.GetNextString(docname);
|
|
174 |
aItem.GetNextString(mimetype16);
|
|
175 |
aItem.GetNextInt(expected);
|
|
176 |
aItem.GetNextString(filename);
|
|
177 |
aItem.GetNextInt(noOfmaps);
|
|
178 |
|
|
179 |
iLog->Log(_L("read varibale "));
|
|
180 |
|
|
181 |
/*-------------------------------------------------------------------------------------------*/
|
|
182 |
|
|
183 |
|
|
184 |
CLiwServiceHandler* iServiceHandler = CLiwServiceHandler::NewL();
|
|
185 |
CleanupStack::PushL(iServiceHandler);//1
|
|
186 |
|
|
187 |
if ( iServiceHandler )
|
|
188 |
iLog->Log(_L("Got Service Handler "));
|
|
189 |
else
|
|
190 |
iLog->Log(_L("Didn't get service handler"));
|
|
191 |
|
|
192 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1,KIAppManager,KService);
|
|
193 |
iLog->Log(_L("Create criterai Item"));
|
|
194 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase));
|
|
195 |
CleanupStack::PushL(crit);//2
|
|
196 |
|
|
197 |
|
|
198 |
RCriteriaArray critArray;
|
|
199 |
iLog->Log(_L("Append in Crit"));
|
|
200 |
critArray.AppendL(crit);
|
|
201 |
CleanupClosePushL(critArray);//3
|
|
202 |
|
|
203 |
iServiceHandler->AttachL(critArray);
|
|
204 |
//critArray.Reset();
|
|
205 |
//critArray.Close();
|
|
206 |
|
|
207 |
iLog->Log(_L("Creating Output"));
|
|
208 |
|
|
209 |
CLiwGenericParamList* output = CLiwGenericParamList::NewL();
|
|
210 |
CleanupStack::PushL(output);//4
|
|
211 |
CLiwGenericParamList* input = CLiwGenericParamList::NewL();
|
|
212 |
CleanupStack::PushL(input);//5
|
|
213 |
|
|
214 |
iLog->Log(_L("call Service cmd L"));
|
|
215 |
|
|
216 |
iServiceHandler->ExecuteServiceCmdL(*crit, *input, *output);
|
|
217 |
|
|
218 |
iLog->Log(_L("Service cmdl is over"));
|
|
219 |
|
|
220 |
// Create the Instance of SAPI class and the Input Param and output Param
|
|
221 |
TInt pos = 0;
|
|
222 |
MLiwInterface* Interface = NULL;
|
|
223 |
output->FindFirst(pos,KIAppManager );
|
|
224 |
if(pos != KErrNotFound)
|
|
225 |
{
|
|
226 |
Interface = (*output)[pos].Value().AsInterface();
|
|
227 |
}
|
|
228 |
output->Reset();
|
|
229 |
|
|
230 |
|
|
231 |
|
|
232 |
CleanupClosePushL(*Interface);//6
|
|
233 |
|
|
234 |
|
|
235 |
iLog->Log(_L("got Interface"));
|
|
236 |
|
|
237 |
|
|
238 |
input->Reset();
|
|
239 |
|
|
240 |
//Inserting content
|
|
241 |
if( 0 != content.CompareF(KNull) )
|
|
242 |
{
|
|
243 |
TLiwVariant dsName;
|
|
244 |
dsName.Set(content);
|
|
245 |
TLiwGenericParam dsNameParam(KContent, content);
|
|
246 |
input->AppendL(dsNameParam);
|
|
247 |
}
|
|
248 |
|
|
249 |
|
|
250 |
|
|
251 |
|
|
252 |
|
|
253 |
CLiwDefaultMap *filterMap = NULL;
|
|
254 |
|
|
255 |
if(docname.CompareF(_L("NULL")) != 0 )
|
|
256 |
{
|
|
257 |
filterMap = CLiwDefaultMap::NewL();
|
|
258 |
//CleanupStack::PushL( filterMap );//7
|
|
259 |
filterMap->InsertL(KDocumentPath,TLiwVariant(docname));
|
|
260 |
TLiwGenericParam iFilterParam(KFilter, TLiwVariant(filterMap));
|
|
261 |
input->AppendL(iFilterParam);
|
|
262 |
|
|
263 |
filterMap->DecRef();
|
|
264 |
}
|
|
265 |
|
|
266 |
|
|
267 |
if(mimetype16.CompareF(_L("NULL")) != 0)
|
|
268 |
{
|
|
269 |
if( !filterMap )
|
|
270 |
{
|
|
271 |
filterMap = CLiwDefaultMap::NewL();
|
|
272 |
//CleanupStack::PushL( filterMap );//7
|
|
273 |
TLiwGenericParam iFilterParam(KFilter, TLiwVariant(filterMap));
|
|
274 |
input->AppendL(iFilterParam);
|
|
275 |
filterMap->DecRef();
|
|
276 |
}
|
|
277 |
|
|
278 |
filterMap->InsertL(KMimeType,TLiwVariant(mimetype16));
|
|
279 |
}
|
|
280 |
|
|
281 |
if( Interface != NULL)
|
|
282 |
{
|
|
283 |
iLog->Log(_L("got Interface"));
|
|
284 |
Interface->ExecuteCmdL(KGetList,*input,*output);
|
|
285 |
iLog->Log(_L("SAPI called"));
|
|
286 |
}
|
|
287 |
else
|
|
288 |
{
|
|
289 |
iLog->Log(_L("Didn't get interface"));
|
|
290 |
return KErrGeneral;
|
|
291 |
}
|
|
292 |
|
|
293 |
|
|
294 |
const TLiwGenericParam* p= NULL;
|
|
295 |
CLiwIterable* iter;
|
|
296 |
TLiwVariant Map;
|
|
297 |
const CLiwMap* infomap;
|
|
298 |
TInt err= 0;
|
|
299 |
pos = 0;
|
|
300 |
TInt retcode;
|
|
301 |
p = output->FindFirst(pos, KErrorCode); // Finding Error Code
|
|
302 |
if(p)
|
|
303 |
{
|
|
304 |
|
|
305 |
err = p->Value().AsTInt32();
|
|
306 |
iLog->Log(_L("Got Error Code "));
|
|
307 |
}
|
|
308 |
|
|
309 |
pos = 0;
|
|
310 |
p = output->FindFirst(pos, KResponse);// Finding out the response of Media Management
|
|
311 |
if(!p)
|
|
312 |
{
|
|
313 |
if( err == KErrNone )
|
|
314 |
err = KErrGeneral;
|
|
315 |
}
|
|
316 |
else
|
|
317 |
{
|
|
318 |
iter = p->Value().AsIterable();// returning Iterator as Response
|
|
319 |
}
|
|
320 |
|
|
321 |
|
|
322 |
|
|
323 |
|
|
324 |
/*---------------------------------------------------------------------------------------------*/
|
|
325 |
|
|
326 |
if(noOfmaps > 0)
|
|
327 |
{
|
|
328 |
RArray<TInt> uidArray;
|
|
329 |
TInt matchedOutput =0;
|
|
330 |
TInt32 appuid;
|
|
331 |
TInt index;
|
|
332 |
TPtrC16 appuidstring;
|
|
333 |
for(TInt i =0 ;i < noOfmaps; i++ )
|
|
334 |
{
|
|
335 |
aItem.GetNextString( appuidstring );
|
|
336 |
ConvertHexStringToInt32(appuidstring,appuid );
|
|
337 |
uidArray.Append(appuid);
|
|
338 |
}
|
|
339 |
|
|
340 |
_LIT8(UidKey,"Uid");// Key In The Map
|
|
341 |
TPtrC KeyValue;// value of that key
|
|
342 |
TLiwVariant val;//just for extracting the value
|
|
343 |
|
|
344 |
while( (uidArray.Count()>0) && iter->NextL(Map) )
|
|
345 |
{
|
|
346 |
infomap = Map.AsMap();
|
|
347 |
infomap->FindL(UidKey, val);
|
|
348 |
val.Get(KeyValue);
|
|
349 |
ConvertHexStringToInt32(KeyValue,appuid );
|
|
350 |
|
|
351 |
if( ( index = uidArray.Find( appuid ) )!= KErrNotFound)
|
|
352 |
{
|
|
353 |
matchedOutput++;
|
|
354 |
uidArray.Remove(index);
|
|
355 |
uidArray.Compress();
|
|
356 |
}
|
|
357 |
|
|
358 |
infomap = NULL;
|
|
359 |
Map.Reset();
|
|
360 |
}
|
|
361 |
|
|
362 |
//iter->Reset(); has to implement by lokesh
|
|
363 |
if( matchedOutput != noOfmaps )
|
|
364 |
{
|
|
365 |
//Test case failed
|
|
366 |
err = KErrGeneral;
|
|
367 |
}
|
|
368 |
uidArray.Reset();
|
|
369 |
uidArray.Close();
|
|
370 |
}
|
|
371 |
|
|
372 |
|
|
373 |
/*------------------------------------Output For Manual Testing ---------------------------------*/
|
|
374 |
RFs fs;
|
|
375 |
TEntry entry;
|
|
376 |
TInt dir_ret=0;
|
|
377 |
|
|
378 |
//Check for directory.
|
|
379 |
User::LeaveIfError(fs.Connect());
|
|
380 |
CleanupClosePushL(fs);
|
|
381 |
dir_ret=fs.Entry(_L("c:\\Data\\AppManager\\"),entry);
|
|
382 |
|
|
383 |
|
|
384 |
//Write the output only if the directory is present.Means Manual testing mode
|
|
385 |
if(KErrNone==dir_ret)
|
|
386 |
{
|
|
387 |
if(filename.CompareF(_L("NULL"))!= 0)
|
|
388 |
{
|
|
389 |
|
|
390 |
// Convert 16 Bit values into 8 bit as SAPI accept 8 bit Des
|
|
391 |
TBuf8<30> content8 ;
|
|
392 |
content8.Copy(content);
|
|
393 |
RFile file;
|
|
394 |
TInt errfile=0;
|
|
395 |
|
|
396 |
/* Show the output
|
|
397 |
//RFs fs;
|
|
398 |
|
|
399 |
//User::LeaveIfError(fs.Connect());
|
|
400 |
//CleanupClosePushL(fs);//8
|
|
401 |
|
|
402 |
TEntry entry;
|
|
403 |
if( fs.Entry(_L("c:\\Data\\AppManager\\"),entry) != KErrNone)
|
|
404 |
{
|
|
405 |
TInt ret = fs.MkDir(_L("c:\\Data\\AppManager\\"));
|
|
406 |
}*/
|
|
407 |
|
|
408 |
TBuf<100> flname(_L("c:\\Data\\AppManager\\"));
|
|
409 |
|
|
410 |
flname.Append(filename);
|
|
411 |
flname.Append(_L(".txt"));
|
|
412 |
|
|
413 |
errfile =file.Replace(fs,flname, EFileWrite | EFileStreamText);
|
|
414 |
CleanupClosePushL(file);//9
|
|
415 |
|
|
416 |
TBuf8<100> filebuf;
|
|
417 |
TInt index =0 ;
|
|
418 |
TBuf8<15> Key;// Key In The Map
|
|
419 |
TPtrC16 KeyValue;// value of that key
|
|
420 |
|
|
421 |
filebuf.Append(_L8("TestCase \n"));
|
|
422 |
filebuf.Append(_L8("Content = "));
|
|
423 |
filebuf.Append(content8);
|
|
424 |
filebuf.Append(_L8(","));
|
|
425 |
|
|
426 |
filebuf.Append(_L8("docname = "));
|
|
427 |
filebuf.Append(docname);
|
|
428 |
filebuf.Append(_L8(","));
|
|
429 |
|
|
430 |
filebuf.Append(_L8("mimetype16 = "));
|
|
431 |
filebuf.Append(mimetype16);
|
|
432 |
filebuf.Append(_L8("\n"));
|
|
433 |
|
|
434 |
file.Write(filebuf);
|
|
435 |
filebuf.Zero();
|
|
436 |
|
|
437 |
TInt count =1;
|
|
438 |
TLiwVariant val;//just for extracting the value
|
|
439 |
while(iter->NextL(Map))
|
|
440 |
{
|
|
441 |
infomap = Map.AsMap();
|
|
442 |
filebuf.Append(_L8(" :- "));
|
|
443 |
filebuf.AppendNum(count);
|
|
444 |
file.Write(content8);
|
|
445 |
file.Write(filebuf);
|
|
446 |
file.Write(_L8("\n"));
|
|
447 |
filebuf.Zero();
|
|
448 |
file.Write(_L8("----------------------------------------------------\n"));
|
|
449 |
|
|
450 |
for(index =0 ;index <infomap->Count(); index++ )
|
|
451 |
{
|
|
452 |
infomap->AtL(index,Key);
|
|
453 |
infomap->FindL(Key, val);
|
|
454 |
val.Get(KeyValue);
|
|
455 |
file.Write(Key);
|
|
456 |
file.Write(_L8("\t"));
|
|
457 |
filebuf.Copy(KeyValue);
|
|
458 |
file.Write(filebuf);
|
|
459 |
file.Write(_L8("\n"));
|
|
460 |
filebuf.Zero();
|
|
461 |
}// Map
|
|
462 |
|
|
463 |
//delete infomap;
|
|
464 |
infomap = NULL;
|
|
465 |
Map.Reset();
|
|
466 |
file.Write(_L8("----------------------------------------------------\n\n"));
|
|
467 |
|
|
468 |
count++;
|
|
469 |
}//Iterator
|
|
470 |
|
|
471 |
CleanupStack::PopAndDestroy();//File 9
|
|
472 |
|
|
473 |
|
|
474 |
}
|
|
475 |
}
|
|
476 |
CleanupStack::PopAndDestroy();//File Session 8
|
|
477 |
|
|
478 |
/*------------------------------------Output For Manual Testing ---------------------------------*/
|
|
479 |
|
|
480 |
iter->DecRef();
|
|
481 |
|
|
482 |
|
|
483 |
|
|
484 |
if(!expected)
|
|
485 |
{
|
|
486 |
//Postive Test Case
|
|
487 |
if(err != KErrNone)
|
|
488 |
{
|
|
489 |
result = KErrGeneral;
|
|
490 |
}
|
|
491 |
|
|
492 |
}
|
|
493 |
else
|
|
494 |
{
|
|
495 |
if (err == KErrNone)
|
|
496 |
{
|
|
497 |
result = KErrGeneral;
|
|
498 |
}
|
|
499 |
//Neagative Test Case
|
|
500 |
}
|
|
501 |
|
|
502 |
output->Reset();
|
|
503 |
input->Reset();
|
|
504 |
|
|
505 |
//if(filterMap)
|
|
506 |
//CleanupStack::PopAndDestroy();//Filter Parameter 7
|
|
507 |
|
|
508 |
CleanupStack::PopAndDestroy( );
|
|
509 |
CleanupStack::PopAndDestroy( );
|
|
510 |
CleanupStack::PopAndDestroy( );
|
|
511 |
CleanupStack::PopAndDestroy( );
|
|
512 |
CleanupStack::PopAndDestroy( );
|
|
513 |
CleanupStack::PopAndDestroy( );
|
|
514 |
//Interface->Close();
|
|
515 |
__UHEAP_MARKEND;
|
|
516 |
return result;
|
|
517 |
|
|
518 |
|
|
519 |
}
|
|
520 |
|
|
521 |
|
|
522 |
// -----------------------------------------------------------------------------
|
|
523 |
// CAppManagerTest:launchAppL
|
|
524 |
// Example test method function.
|
|
525 |
// (other items were commented in a header).
|
|
526 |
// -----------------------------------------------------------------------------
|
|
527 |
//
|
|
528 |
|
|
529 |
TInt CAppManagerTest::launchAppL( CStifItemParser& aItem )
|
|
530 |
{
|
|
531 |
__UHEAP_MARK;
|
|
532 |
|
|
533 |
CLiwServiceHandler* iServiceHandler = CLiwServiceHandler::NewL();
|
|
534 |
CleanupStack::PushL(iServiceHandler);//1
|
|
535 |
|
|
536 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1,KIAppManager,KService);
|
|
537 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase));
|
|
538 |
CleanupStack::PushL(crit);//2
|
|
539 |
|
|
540 |
|
|
541 |
RCriteriaArray critArray;
|
|
542 |
critArray.AppendL(crit);
|
|
543 |
CleanupClosePushL(critArray);//3
|
|
544 |
|
|
545 |
iServiceHandler->AttachL(critArray);
|
|
546 |
|
|
547 |
|
|
548 |
|
|
549 |
CLiwGenericParamList* output = CLiwGenericParamList::NewL();
|
|
550 |
CleanupStack::PushL(output);//4
|
|
551 |
CLiwGenericParamList* input = CLiwGenericParamList::NewL();
|
|
552 |
CleanupStack::PushL(input);//5
|
|
553 |
|
|
554 |
iServiceHandler->ExecuteServiceCmdL(*crit, *input, *output);
|
|
555 |
|
|
556 |
|
|
557 |
// Create the Instance of SAPI class and the Input Param and output Param
|
|
558 |
TInt pos = 0;
|
|
559 |
MLiwInterface* Interface = NULL;
|
|
560 |
output->FindFirst(pos,KIAppManager );
|
|
561 |
if(pos != KErrNotFound)
|
|
562 |
{
|
|
563 |
Interface = (*output)[pos].Value().AsInterface();
|
|
564 |
}
|
|
565 |
output->Reset();
|
|
566 |
|
|
567 |
|
|
568 |
|
|
569 |
//MLiwInterface* Interface = CMgDataSourceInterface::NewL();
|
|
570 |
CleanupClosePushL(*Interface);//6
|
|
571 |
|
|
572 |
/*--------Test Logic Starts-----------*/
|
|
573 |
TOptions options;
|
|
574 |
TInt expected;
|
|
575 |
TPtrC16 temp;
|
|
576 |
TBuf<30> appId;
|
|
577 |
TPtrC16 cmdLine16;
|
|
578 |
TPtrC16 document;
|
|
579 |
TPtrC16 mode;
|
|
580 |
TPtrC16 postion;
|
|
581 |
TPtrC16 callback;
|
|
582 |
TInt err;
|
|
583 |
TInt result =KErrNone ;// KErrGeneral; // 0 means pass and -1 means Fail
|
|
584 |
|
|
585 |
aItem.GetNextString( temp );
|
|
586 |
appId.Append( temp );
|
|
587 |
appId.Append(_L("//"));
|
|
588 |
aItem.GetNextString( temp );
|
|
589 |
appId.Append( temp );
|
|
590 |
|
|
591 |
|
|
592 |
aItem.GetNextString(cmdLine16);
|
|
593 |
aItem.GetNextString(document);
|
|
594 |
aItem.GetNextString(mode);
|
|
595 |
aItem.GetNextString(postion);
|
|
596 |
aItem.GetNextString(callback);
|
|
597 |
aItem.GetNextInt(expected);
|
|
598 |
|
|
599 |
input->Reset();
|
|
600 |
|
|
601 |
//Inserting ApplicationID
|
|
602 |
if( 0 != appId.CompareF(KNull) )
|
|
603 |
{
|
|
604 |
TLiwVariant id;
|
|
605 |
id.Set(appId);
|
|
606 |
TLiwGenericParam idParam(KApplicationID, id);
|
|
607 |
input->AppendL(idParam);
|
|
608 |
}
|
|
609 |
|
|
610 |
|
|
611 |
|
|
612 |
|
|
613 |
//Inserting cmdLine
|
|
614 |
if( 0 != cmdLine16.CompareF(KNull) )
|
|
615 |
{
|
|
616 |
TLiwVariant cmdline;
|
|
617 |
cmdline.Set(cmdLine16);
|
|
618 |
TLiwGenericParam cmdlineParam(KCmdLine, cmdline);
|
|
619 |
input->AppendL(cmdlineParam);
|
|
620 |
}
|
|
621 |
|
|
622 |
|
|
623 |
|
|
624 |
|
|
625 |
CLiwDefaultMap *filterMap = NULL;
|
|
626 |
|
|
627 |
if( document.CompareF(_L("NULL")) != 0 )
|
|
628 |
{
|
|
629 |
filterMap = CLiwDefaultMap::NewL();
|
|
630 |
//CleanupStack::PushL( filterMap );//7
|
|
631 |
filterMap->InsertL(KDocumentPath,TLiwVariant(document));
|
|
632 |
TLiwGenericParam iFilterParam(KOptions, TLiwVariant(filterMap));
|
|
633 |
input->AppendL(iFilterParam);
|
|
634 |
filterMap->DecRef();
|
|
635 |
}
|
|
636 |
|
|
637 |
|
|
638 |
if( mode.CompareF(_L("NULL") ) != 0)
|
|
639 |
{
|
|
640 |
if( !filterMap )
|
|
641 |
{
|
|
642 |
filterMap = CLiwDefaultMap::NewL();
|
|
643 |
CleanupStack::PushL( filterMap );//7
|
|
644 |
TLiwGenericParam iFilterParam(KOptions, TLiwVariant(filterMap));
|
|
645 |
input->AppendL(iFilterParam);
|
|
646 |
filterMap->DecRef();
|
|
647 |
}
|
|
648 |
|
|
649 |
filterMap->InsertL(KMode,TLiwVariant(mode));
|
|
650 |
}
|
|
651 |
|
|
652 |
if( postion.CompareF(_L("NULL") ) != 0)
|
|
653 |
{
|
|
654 |
if( !filterMap )
|
|
655 |
{
|
|
656 |
filterMap = CLiwDefaultMap::NewL();
|
|
657 |
//CleanupStack::PushL( filterMap );//7
|
|
658 |
TLiwGenericParam iFilterParam(KOptions, TLiwVariant(filterMap));
|
|
659 |
input->AppendL(iFilterParam);
|
|
660 |
filterMap->DecRef();
|
|
661 |
}
|
|
662 |
|
|
663 |
filterMap->InsertL(KPostion,TLiwVariant( postion ));
|
|
664 |
}
|
|
665 |
|
|
666 |
|
|
667 |
|
|
668 |
|
|
669 |
if( callback.CompareF(_L("NULL")) != 0 )
|
|
670 |
{
|
|
671 |
//Aysnch Call;
|
|
672 |
CActiveSchedulerWait *wait = new CActiveSchedulerWait();
|
|
673 |
CleanupStack::PushL( wait);
|
|
674 |
CAppObserver* callback = CAppObserver::NewL(wait);
|
|
675 |
CleanupStack::PushL( callback);
|
|
676 |
Interface->ExecuteCmdL(KLaunchApp,*input,*output,KLiwOptASyncronous,callback);
|
|
677 |
const TLiwGenericParam* p= NULL;
|
|
678 |
pos = 0;
|
|
679 |
|
|
680 |
p = output->FindFirst(pos, KErrorCode); // Finding Error Code
|
|
681 |
if(p)
|
|
682 |
{
|
|
683 |
err = p->Value().AsTInt32();
|
|
684 |
}
|
|
685 |
else
|
|
686 |
{
|
|
687 |
err = KErrGeneral;
|
|
688 |
}
|
|
689 |
|
|
690 |
if ( err == KErrNone)
|
|
691 |
{
|
|
692 |
// Asynch request properly accepted
|
|
693 |
wait->Start();
|
|
694 |
err = callback->iErrorReturn;
|
|
695 |
if ( callback->iReason > 0 )
|
|
696 |
{
|
|
697 |
//but we didn't get notifaction
|
|
698 |
//Reason of failure can be either 0 or some negative value which incates
|
|
699 |
//error but it cant be greater than 0
|
|
700 |
err = KErrGeneral;
|
|
701 |
}
|
|
702 |
|
|
703 |
}
|
|
704 |
|
|
705 |
CleanupStack::PopAndDestroy();//Callback
|
|
706 |
CleanupStack::PopAndDestroy();//Active Wait Scheduler
|
|
707 |
}
|
|
708 |
else
|
|
709 |
{
|
|
710 |
//Synch call
|
|
711 |
if( Interface != NULL)
|
|
712 |
{
|
|
713 |
_LIT8(KLaunchApp,"LaunchApp");
|
|
714 |
Interface->ExecuteCmdL(KLaunchApp,*input,*output);
|
|
715 |
}
|
|
716 |
else
|
|
717 |
{
|
|
718 |
//Didn't get the interface
|
|
719 |
return KErrGeneral;
|
|
720 |
}
|
|
721 |
|
|
722 |
|
|
723 |
const TLiwGenericParam* p= NULL;
|
|
724 |
pos = 0;
|
|
725 |
p = output->FindFirst(pos, KErrorCode); // Finding Error Code
|
|
726 |
if(p)
|
|
727 |
{
|
|
728 |
err = p->Value().AsTInt32();
|
|
729 |
}
|
|
730 |
else
|
|
731 |
{
|
|
732 |
err = KErrGeneral;
|
|
733 |
}
|
|
734 |
}
|
|
735 |
|
|
736 |
|
|
737 |
if(!expected)
|
|
738 |
{
|
|
739 |
//Postive Test Case
|
|
740 |
if(err != KErrNone)
|
|
741 |
{
|
|
742 |
result = KErrGeneral;
|
|
743 |
}
|
|
744 |
|
|
745 |
}
|
|
746 |
else
|
|
747 |
{
|
|
748 |
if (err == KErrNone)
|
|
749 |
{
|
|
750 |
result = KErrGeneral;
|
|
751 |
}
|
|
752 |
//Neagative Test Case
|
|
753 |
}
|
|
754 |
|
|
755 |
|
|
756 |
/*--------Test Logic Ends -----------*/
|
|
757 |
if(err == KErrNone)
|
|
758 |
{
|
|
759 |
TBuf<30> uidsearch;
|
|
760 |
TPtrC internaluid;
|
|
761 |
|
|
762 |
//Format it!
|
|
763 |
uidsearch.Append(_L("*["));
|
|
764 |
internaluid.Set(appId.Mid(11)); //Stripping first11 chars.
|
|
765 |
uidsearch.Append(internaluid);
|
|
766 |
uidsearch.Append(_L("]*"));
|
|
767 |
|
|
768 |
killapp(uidsearch);
|
|
769 |
}
|
|
770 |
|
|
771 |
//if(filterMap)
|
|
772 |
//CleanupStack::PopAndDestroy();//Filter Parameter 7
|
|
773 |
|
|
774 |
CleanupStack::PopAndDestroy( );
|
|
775 |
CleanupStack::PopAndDestroy( );
|
|
776 |
CleanupStack::PopAndDestroy( );
|
|
777 |
CleanupStack::PopAndDestroy( );
|
|
778 |
CleanupStack::PopAndDestroy( );
|
|
779 |
CleanupStack::PopAndDestroy( );
|
|
780 |
__UHEAP_MARK;
|
|
781 |
return result;
|
|
782 |
|
|
783 |
}
|
|
784 |
|
|
785 |
|
|
786 |
// -----------------------------------------------------------------------------
|
|
787 |
// CAppManagerTest:launchDocL
|
|
788 |
// Example test method function.
|
|
789 |
// (other items were commented in a header).
|
|
790 |
// -----------------------------------------------------------------------------
|
|
791 |
//
|
|
792 |
|
|
793 |
TInt CAppManagerTest::launchDocL( CStifItemParser& aItem )
|
|
794 |
{
|
|
795 |
|
|
796 |
|
|
797 |
__UHEAP_MARK;
|
|
798 |
|
|
799 |
|
|
800 |
CLiwServiceHandler* iServiceHandler = CLiwServiceHandler::NewL();
|
|
801 |
CleanupStack::PushL(iServiceHandler);//1
|
|
802 |
|
|
803 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1,KIAppManager,KService);
|
|
804 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase));
|
|
805 |
CleanupStack::PushL(crit);//2
|
|
806 |
|
|
807 |
|
|
808 |
RCriteriaArray critArray;
|
|
809 |
critArray.AppendL(crit);
|
|
810 |
CleanupClosePushL(critArray);//3
|
|
811 |
|
|
812 |
iServiceHandler->AttachL(critArray);
|
|
813 |
|
|
814 |
|
|
815 |
|
|
816 |
CLiwGenericParamList* output = CLiwGenericParamList::NewL();
|
|
817 |
CleanupStack::PushL(output);//4
|
|
818 |
CLiwGenericParamList* input = CLiwGenericParamList::NewL();
|
|
819 |
CleanupStack::PushL(input);//5
|
|
820 |
|
|
821 |
iServiceHandler->ExecuteServiceCmdL(*crit, *input, *output);
|
|
822 |
|
|
823 |
|
|
824 |
// Create the Instance of SAPI class and the Input Param and output Param
|
|
825 |
TInt pos = 0;
|
|
826 |
MLiwInterface* Interface = NULL;
|
|
827 |
output->FindFirst(pos,KIAppManager );
|
|
828 |
if(pos != KErrNotFound)
|
|
829 |
{
|
|
830 |
Interface = (*output)[pos].Value().AsInterface();
|
|
831 |
}
|
|
832 |
output->Reset();
|
|
833 |
|
|
834 |
|
|
835 |
|
|
836 |
//MLiwInterface* Interface = CMgDataSourceInterface::NewL();
|
|
837 |
CleanupClosePushL(*Interface);//6
|
|
838 |
|
|
839 |
/*--------Test Logic Starts-----------*/
|
|
840 |
TOptions options;
|
|
841 |
TDocument criteria;
|
|
842 |
TInt expected;
|
|
843 |
TBuf<30> filename;
|
|
844 |
TPtrC16 path;
|
|
845 |
TPtrC16 handle;
|
|
846 |
TPtrC16 mimetype16;
|
|
847 |
TPtrC16 mode;
|
|
848 |
TPtrC16 callback;
|
|
849 |
TInt err;
|
|
850 |
TInt result =KErrNone ;// KErrGeneral; // 0 means pass and -1 means Fail
|
|
851 |
|
|
852 |
|
|
853 |
aItem.GetNextString(path);
|
|
854 |
aItem.GetNextString(handle);
|
|
855 |
aItem.GetNextString(mimetype16);
|
|
856 |
aItem.GetNextString(mode);
|
|
857 |
aItem.GetNextString(callback);
|
|
858 |
aItem.GetNextInt(expected);
|
|
859 |
|
|
860 |
/*------------------------------------------------------------------*/
|
|
861 |
|
|
862 |
input->Reset();
|
|
863 |
|
|
864 |
//Inserting Document
|
|
865 |
|
|
866 |
|
|
867 |
CLiwDefaultMap *documentMap = NULL;
|
|
868 |
|
|
869 |
if( path.CompareF(_L("NULL")) != 0 )
|
|
870 |
{
|
|
871 |
documentMap = CLiwDefaultMap::NewL();
|
|
872 |
documentMap->InsertL(KDocumentPath,TLiwVariant(path));
|
|
873 |
TLiwGenericParam iFilterParam( KDocument, TLiwVariant(documentMap));
|
|
874 |
input->AppendL(iFilterParam);
|
|
875 |
documentMap->DecRef();
|
|
876 |
}
|
|
877 |
|
|
878 |
|
|
879 |
if( handle.CompareF(_L("NULL") ) != 0)
|
|
880 |
{
|
|
881 |
if( !documentMap )
|
|
882 |
{
|
|
883 |
documentMap = CLiwDefaultMap::NewL();
|
|
884 |
TLiwGenericParam iFilterParam(KDocument, TLiwVariant(documentMap));
|
|
885 |
input->AppendL(iFilterParam);
|
|
886 |
documentMap->DecRef();
|
|
887 |
}
|
|
888 |
|
|
889 |
RFs fileSession;
|
|
890 |
User::LeaveIfError(fileSession.Connect());
|
|
891 |
RFile file;
|
|
892 |
User::LeaveIfError(fileSession.ShareProtected());
|
|
893 |
file.Open(fileSession,handle,EFileShareReadersOnly);
|
|
894 |
//CLiwDefaultFileBuffer* filebuffer = CLiwFileBuffer::NewL();
|
|
895 |
documentMap->InsertL(KHandle,TLiwVariant(file));
|
|
896 |
}
|
|
897 |
|
|
898 |
|
|
899 |
|
|
900 |
|
|
901 |
//Inserting MimeType
|
|
902 |
if( 0 != mimetype16.CompareF(KNull) )
|
|
903 |
{
|
|
904 |
TLiwVariant mimetype;
|
|
905 |
mimetype.Set(mimetype16);
|
|
906 |
TLiwGenericParam mimetypeParam(KMimeType, mimetype);
|
|
907 |
input->AppendL(mimetypeParam);
|
|
908 |
}
|
|
909 |
|
|
910 |
|
|
911 |
|
|
912 |
|
|
913 |
if( mode.CompareF(_L("NULL")) != 0 )
|
|
914 |
{
|
|
915 |
CLiwDefaultMap *filterMap = CLiwDefaultMap::NewL();
|
|
916 |
filterMap->InsertL(KMode,TLiwVariant(mode));
|
|
917 |
TLiwGenericParam iFilterParam(KOptions, TLiwVariant(filterMap));
|
|
918 |
input->AppendL(iFilterParam);
|
|
919 |
filterMap->DecRef();
|
|
920 |
}
|
|
921 |
|
|
922 |
|
|
923 |
|
|
924 |
if( callback.CompareF(_L("NULL")) != 0 )
|
|
925 |
{
|
|
926 |
//Aysnch Call;
|
|
927 |
CActiveSchedulerWait *wait = new CActiveSchedulerWait();
|
|
928 |
CleanupStack::PushL( wait);
|
|
929 |
CAppObserver* callback = CAppObserver::NewL(wait);
|
|
930 |
CleanupStack::PushL( callback);
|
|
931 |
Interface->ExecuteCmdL(KLaunchDoc,*input,*output,KLiwOptASyncronous,callback);
|
|
932 |
const TLiwGenericParam* p= NULL;
|
|
933 |
pos = 0;
|
|
934 |
|
|
935 |
p = output->FindFirst(pos, KErrorCode); // Finding Error Code
|
|
936 |
if(p)
|
|
937 |
{
|
|
938 |
err = p->Value().AsTInt32();
|
|
939 |
}
|
|
940 |
else
|
|
941 |
{
|
|
942 |
err = KErrGeneral;
|
|
943 |
}
|
|
944 |
|
|
945 |
if ( err == KErrNone)
|
|
946 |
{
|
|
947 |
// Asynch request properly accepted
|
|
948 |
|
|
949 |
wait->Start();
|
|
950 |
err = callback->iErrorReturn;
|
|
951 |
if ( callback->iReason > 0 )
|
|
952 |
{
|
|
953 |
//but we didn't get notifaction
|
|
954 |
//Reason of failure can be either 0 or some negative value which incates
|
|
955 |
//error but it cant be greater than 0
|
|
956 |
err = KErrGeneral;
|
|
957 |
}
|
|
958 |
|
|
959 |
}
|
|
960 |
|
|
961 |
CleanupStack::PopAndDestroy();//Callback
|
|
962 |
CleanupStack::PopAndDestroy();//Active Wait Scheduler
|
|
963 |
}
|
|
964 |
else
|
|
965 |
{
|
|
966 |
//Synch call
|
|
967 |
if( Interface != NULL)
|
|
968 |
{
|
|
969 |
_LIT8(KLaunchApp,"LaunchApp");
|
|
970 |
Interface->ExecuteCmdL(KLaunchDoc,*input,*output);
|
|
971 |
}
|
|
972 |
else
|
|
973 |
{
|
|
974 |
//Didn't get the interface
|
|
975 |
return KErrGeneral;
|
|
976 |
}
|
|
977 |
|
|
978 |
|
|
979 |
const TLiwGenericParam* p= NULL;
|
|
980 |
pos = 0;
|
|
981 |
p = output->FindFirst(pos, KErrorCode); // Finding Error Code
|
|
982 |
if(p)
|
|
983 |
{
|
|
984 |
err = p->Value().AsTInt32();
|
|
985 |
}
|
|
986 |
else
|
|
987 |
{
|
|
988 |
err = KErrGeneral;
|
|
989 |
}
|
|
990 |
|
|
991 |
p= NULL;
|
|
992 |
pos = 0;
|
|
993 |
p = output->FindFirst(pos, KDocumentName); // Finding Error Code
|
|
994 |
if(p)
|
|
995 |
{
|
|
996 |
TPtrC filname ;
|
|
997 |
p->Value().Get(filname);
|
|
998 |
}
|
|
999 |
|
|
1000 |
}
|
|
1001 |
|
|
1002 |
|
|
1003 |
if(!expected)
|
|
1004 |
{
|
|
1005 |
//Postive Test Case
|
|
1006 |
if(err != KErrNone)
|
|
1007 |
{
|
|
1008 |
result = KErrGeneral;
|
|
1009 |
}
|
|
1010 |
|
|
1011 |
}
|
|
1012 |
else
|
|
1013 |
{
|
|
1014 |
if (err == KErrNone)
|
|
1015 |
{
|
|
1016 |
result = KErrGeneral;
|
|
1017 |
}
|
|
1018 |
//Neagative Test Case
|
|
1019 |
}
|
|
1020 |
|
|
1021 |
if (err == KErrNone)
|
|
1022 |
{
|
|
1023 |
RApaLsSession bdApaLsSession;
|
|
1024 |
User::LeaveIfError(bdApaLsSession.Connect());
|
|
1025 |
|
|
1026 |
TUid anuid;
|
|
1027 |
TBuf8<30> mimetype ;
|
|
1028 |
mimetype.Copy(mimetype16);
|
|
1029 |
TDataType ada(mimetype);
|
|
1030 |
bdApaLsSession.AppForDocument(criteria.iPath,anuid, ada);
|
|
1031 |
killapp(anuid.Name());
|
|
1032 |
bdApaLsSession.Close();
|
|
1033 |
}
|
|
1034 |
|
|
1035 |
|
|
1036 |
|
|
1037 |
/*--------Test Logic Ends -----------*/
|
|
1038 |
|
|
1039 |
|
|
1040 |
CleanupStack::PopAndDestroy( );
|
|
1041 |
CleanupStack::PopAndDestroy( );
|
|
1042 |
CleanupStack::PopAndDestroy( );
|
|
1043 |
CleanupStack::PopAndDestroy( );
|
|
1044 |
CleanupStack::PopAndDestroy( );
|
|
1045 |
CleanupStack::PopAndDestroy( );
|
|
1046 |
__UHEAP_MARK;
|
|
1047 |
return result;
|
|
1048 |
}
|
|
1049 |
|
|
1050 |
|
|
1051 |
|
|
1052 |
|
|
1053 |
// -----------------------------------------------------------------------------
|
|
1054 |
// CAppManagerTest:launchDocL
|
|
1055 |
// Example test method function.
|
|
1056 |
// (other items were commented in a header).
|
|
1057 |
// -----------------------------------------------------------------------------
|
|
1058 |
//
|
|
1059 |
|
|
1060 |
TInt CAppManagerTest::CancellaunchDocL( CStifItemParser& aItem )
|
|
1061 |
{
|
|
1062 |
|
|
1063 |
|
|
1064 |
__UHEAP_MARK;
|
|
1065 |
|
|
1066 |
|
|
1067 |
CLiwServiceHandler* iServiceHandler = CLiwServiceHandler::NewL();
|
|
1068 |
CleanupStack::PushL(iServiceHandler);//1
|
|
1069 |
|
|
1070 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1,KIAppManager,KService);
|
|
1071 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase));
|
|
1072 |
CleanupStack::PushL(crit);//2
|
|
1073 |
|
|
1074 |
|
|
1075 |
RCriteriaArray critArray;
|
|
1076 |
critArray.AppendL(crit);
|
|
1077 |
CleanupClosePushL(critArray);//3
|
|
1078 |
|
|
1079 |
iServiceHandler->AttachL(critArray);
|
|
1080 |
|
|
1081 |
|
|
1082 |
|
|
1083 |
CLiwGenericParamList* output = CLiwGenericParamList::NewL();
|
|
1084 |
CleanupStack::PushL(output);//4
|
|
1085 |
CLiwGenericParamList* input = CLiwGenericParamList::NewL();
|
|
1086 |
CleanupStack::PushL(input);//5
|
|
1087 |
|
|
1088 |
iServiceHandler->ExecuteServiceCmdL(*crit, *input, *output);
|
|
1089 |
|
|
1090 |
|
|
1091 |
// Create the Instance of SAPI class and the Input Param and output Param
|
|
1092 |
TInt pos = 0;
|
|
1093 |
MLiwInterface* Interface = NULL;
|
|
1094 |
output->FindFirst(pos,KIAppManager );
|
|
1095 |
if(pos != KErrNotFound)
|
|
1096 |
{
|
|
1097 |
Interface = (*output)[pos].Value().AsInterface();
|
|
1098 |
}
|
|
1099 |
output->Reset();
|
|
1100 |
|
|
1101 |
|
|
1102 |
|
|
1103 |
//MLiwInterface* Interface = CMgDataSourceInterface::NewL();
|
|
1104 |
CleanupClosePushL(*Interface);//6
|
|
1105 |
|
|
1106 |
/*--------Test Logic Starts-----------*/
|
|
1107 |
TOptions options;
|
|
1108 |
TDocument criteria;
|
|
1109 |
TInt expected;
|
|
1110 |
TBuf<30> filename;
|
|
1111 |
TPtrC16 path;
|
|
1112 |
TPtrC16 handle;
|
|
1113 |
TPtrC16 mimetype16;
|
|
1114 |
TPtrC16 mode;
|
|
1115 |
TPtrC16 callback;
|
|
1116 |
TInt err;
|
|
1117 |
TInt result =KErrNone ;// KErrGeneral; // 0 means pass and -1 means Fail
|
|
1118 |
|
|
1119 |
|
|
1120 |
aItem.GetNextString(path);
|
|
1121 |
aItem.GetNextString(handle);
|
|
1122 |
aItem.GetNextString(mimetype16);
|
|
1123 |
aItem.GetNextString(mode);
|
|
1124 |
aItem.GetNextString(callback);
|
|
1125 |
aItem.GetNextInt(expected);
|
|
1126 |
|
|
1127 |
/*------------------------------------------------------------------*/
|
|
1128 |
|
|
1129 |
|
|
1130 |
//Inserting Document
|
|
1131 |
input->Reset();
|
|
1132 |
|
|
1133 |
CLiwDefaultMap *documentMap = NULL;
|
|
1134 |
|
|
1135 |
if( path.CompareF(_L("NULL")) != 0 )
|
|
1136 |
{
|
|
1137 |
documentMap = CLiwDefaultMap::NewL();
|
|
1138 |
documentMap->InsertL(KDocumentPath,TLiwVariant(path));
|
|
1139 |
TLiwGenericParam iFilterParam( KDocument, TLiwVariant(documentMap));
|
|
1140 |
input->AppendL(iFilterParam);
|
|
1141 |
documentMap->DecRef();
|
|
1142 |
}
|
|
1143 |
|
|
1144 |
|
|
1145 |
if( handle.CompareF(_L("NULL") ) != 0)
|
|
1146 |
{
|
|
1147 |
if( !documentMap )
|
|
1148 |
{
|
|
1149 |
documentMap = CLiwDefaultMap::NewL();
|
|
1150 |
TLiwGenericParam iFilterParam(KDocument, TLiwVariant(documentMap));
|
|
1151 |
input->AppendL(iFilterParam);
|
|
1152 |
documentMap->DecRef();
|
|
1153 |
}
|
|
1154 |
|
|
1155 |
RFs fileSession;
|
|
1156 |
User::LeaveIfError(fileSession.Connect());
|
|
1157 |
RFile file;
|
|
1158 |
User::LeaveIfError(fileSession.ShareProtected());
|
|
1159 |
file.Open(fileSession,handle,EFileShareReadersOnly);
|
|
1160 |
//criteria.iHandle.Duplicate(file);
|
|
1161 |
documentMap->InsertL(KHandle,TLiwVariant(file));
|
|
1162 |
}
|
|
1163 |
|
|
1164 |
|
|
1165 |
|
|
1166 |
|
|
1167 |
//Inserting MimeType
|
|
1168 |
if( 0 != mimetype16.CompareF(KNull) )
|
|
1169 |
{
|
|
1170 |
TLiwVariant mimetype;
|
|
1171 |
mimetype.Set(mimetype16);
|
|
1172 |
TLiwGenericParam mimetypeParam(KMimeType, mimetype);
|
|
1173 |
input->AppendL(mimetypeParam);
|
|
1174 |
}
|
|
1175 |
|
|
1176 |
|
|
1177 |
|
|
1178 |
|
|
1179 |
if( mode.CompareF(_L("NULL")) != 0 )
|
|
1180 |
{
|
|
1181 |
CLiwDefaultMap *filterMap = CLiwDefaultMap::NewL();
|
|
1182 |
filterMap->InsertL(KMode,TLiwVariant(mode));
|
|
1183 |
TLiwGenericParam iFilterParam(KOptions, TLiwVariant(filterMap));
|
|
1184 |
input->AppendL(iFilterParam);
|
|
1185 |
filterMap->DecRef();
|
|
1186 |
}
|
|
1187 |
|
|
1188 |
|
|
1189 |
|
|
1190 |
if( callback.CompareF(_L("NULL")) != 0 )
|
|
1191 |
{
|
|
1192 |
//Aysnch Call;
|
|
1193 |
CActiveSchedulerWait *wait = new CActiveSchedulerWait();
|
|
1194 |
CleanupStack::PushL( wait);
|
|
1195 |
CAppObserver* callback = CAppObserver::NewL(wait);
|
|
1196 |
CleanupStack::PushL( callback);
|
|
1197 |
Interface->ExecuteCmdL(KLaunchDoc,*input,*output,KLiwOptASyncronous,callback);
|
|
1198 |
const TLiwGenericParam* p= NULL;
|
|
1199 |
pos = 0;
|
|
1200 |
|
|
1201 |
p = output->FindFirst(pos, KErrorCode); // Finding Error Code
|
|
1202 |
if(p)
|
|
1203 |
{
|
|
1204 |
err = p->Value().AsTInt32();
|
|
1205 |
}
|
|
1206 |
else
|
|
1207 |
{
|
|
1208 |
err = KErrGeneral;
|
|
1209 |
}
|
|
1210 |
|
|
1211 |
if ( err == KErrNone)
|
|
1212 |
{
|
|
1213 |
pos = 0;
|
|
1214 |
p = output->FindFirst(pos, KTransactionID);
|
|
1215 |
input->Reset();
|
|
1216 |
|
|
1217 |
input->AppendL( TLiwGenericParam (KTransactionID, TLiwVariant ( p->Value().AsTInt32() ) ) );
|
|
1218 |
Interface->ExecuteCmdL(_L8("Cancel"),*input,*output,KLiwOptCancel,callback);
|
|
1219 |
//wait->Start();
|
|
1220 |
|
|
1221 |
if(callback->iCancel)
|
|
1222 |
{
|
|
1223 |
err = KErrNone;
|
|
1224 |
}
|
|
1225 |
else
|
|
1226 |
{
|
|
1227 |
err = KErrGeneral;
|
|
1228 |
}
|
|
1229 |
|
|
1230 |
}
|
|
1231 |
|
|
1232 |
CleanupStack::PopAndDestroy();//Callback
|
|
1233 |
CleanupStack::PopAndDestroy();//Active Wait Scheduler
|
|
1234 |
}
|
|
1235 |
else
|
|
1236 |
{
|
|
1237 |
//Synch call
|
|
1238 |
err = KErrGeneral;
|
|
1239 |
}
|
|
1240 |
|
|
1241 |
|
|
1242 |
if(!expected)
|
|
1243 |
{
|
|
1244 |
//Postive Test Case
|
|
1245 |
if(err != KErrNone)
|
|
1246 |
{
|
|
1247 |
result = KErrGeneral;
|
|
1248 |
}
|
|
1249 |
|
|
1250 |
}
|
|
1251 |
else
|
|
1252 |
{
|
|
1253 |
if (err == KErrNone)
|
|
1254 |
{
|
|
1255 |
result = KErrGeneral;
|
|
1256 |
}
|
|
1257 |
//Neagative Test Case
|
|
1258 |
}
|
|
1259 |
|
|
1260 |
|
|
1261 |
/*--------Test Logic Ends -----------*/
|
|
1262 |
|
|
1263 |
|
|
1264 |
CleanupStack::PopAndDestroy( );
|
|
1265 |
CleanupStack::PopAndDestroy( );
|
|
1266 |
CleanupStack::PopAndDestroy( );
|
|
1267 |
CleanupStack::PopAndDestroy( );
|
|
1268 |
CleanupStack::PopAndDestroy( );
|
|
1269 |
CleanupStack::PopAndDestroy( );
|
|
1270 |
__UHEAP_MARK;
|
|
1271 |
return result;
|
|
1272 |
}
|
|
1273 |
|
|
1274 |
|
|
1275 |
|
|
1276 |
|
|
1277 |
// -----------------------------------------------------------------------------
|
|
1278 |
// CAppManagerTest:getListneagtive Test case
|
|
1279 |
// Example test method function.
|
|
1280 |
// (other items were commented in a header).
|
|
1281 |
// -----------------------------------------------------------------------------
|
|
1282 |
//
|
|
1283 |
TInt CAppManagerTest::getlistnegativetestL( CStifItemParser& aItem )
|
|
1284 |
{
|
|
1285 |
TPtrC16 content;
|
|
1286 |
TPtrC16 docname;
|
|
1287 |
TPtrC16 mimetype16;
|
|
1288 |
TInt expected;
|
|
1289 |
TInt ind;
|
|
1290 |
TPtrC16 testCaseType;
|
|
1291 |
TInt result =KErrNone ;// KErrGeneral; // 0 means pass and -1 means Fail
|
|
1292 |
|
|
1293 |
aItem.GetNextString(content); // 1
|
|
1294 |
aItem.GetNextString(docname); // 2
|
|
1295 |
aItem.GetNextString(mimetype16);// 3
|
|
1296 |
aItem.GetNextString(testCaseType);//5 TestCaseType
|
|
1297 |
aItem.GetNextInt(ind);// 6
|
|
1298 |
|
|
1299 |
iLog->Log(_L("read varibale "));
|
|
1300 |
|
|
1301 |
/*-------------------------------------------------------------------------------------------*/
|
|
1302 |
|
|
1303 |
|
|
1304 |
CLiwServiceHandler* iServiceHandler = CLiwServiceHandler::NewL();
|
|
1305 |
CleanupStack::PushL(iServiceHandler);//1
|
|
1306 |
|
|
1307 |
if ( iServiceHandler )
|
|
1308 |
iLog->Log(_L("Got Service Handler "));
|
|
1309 |
else
|
|
1310 |
iLog->Log(_L("Didn't get service handler"));
|
|
1311 |
|
|
1312 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1,KIAppManager,KService);
|
|
1313 |
iLog->Log(_L("Create criterai Item"));
|
|
1314 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase));
|
|
1315 |
CleanupStack::PushL(crit);//2
|
|
1316 |
|
|
1317 |
|
|
1318 |
RCriteriaArray critArray;
|
|
1319 |
iLog->Log(_L("Append in Crit"));
|
|
1320 |
critArray.AppendL(crit);
|
|
1321 |
CleanupClosePushL(critArray);//3
|
|
1322 |
|
|
1323 |
iServiceHandler->AttachL(critArray);
|
|
1324 |
//critArray.Reset();
|
|
1325 |
//critArray.Close();
|
|
1326 |
|
|
1327 |
iLog->Log(_L("Creating Output"));
|
|
1328 |
|
|
1329 |
CLiwGenericParamList* output = CLiwGenericParamList::NewL();
|
|
1330 |
CleanupStack::PushL(output);//4
|
|
1331 |
CLiwGenericParamList* input = CLiwGenericParamList::NewL();
|
|
1332 |
CleanupStack::PushL(input);//5
|
|
1333 |
|
|
1334 |
iLog->Log(_L("call Service cmd L"));
|
|
1335 |
|
|
1336 |
iServiceHandler->ExecuteServiceCmdL(*crit, *input, *output);
|
|
1337 |
|
|
1338 |
iLog->Log(_L("Service cmdl is over"));
|
|
1339 |
|
|
1340 |
// Create the Instance of SAPI class and the Input Param and output Param
|
|
1341 |
TInt pos = 0;
|
|
1342 |
MLiwInterface* Interface = NULL;
|
|
1343 |
output->FindFirst(pos,KIAppManager );
|
|
1344 |
if(pos != KErrNotFound)
|
|
1345 |
{
|
|
1346 |
Interface = (*output)[pos].Value().AsInterface();
|
|
1347 |
}
|
|
1348 |
output->Reset();
|
|
1349 |
|
|
1350 |
|
|
1351 |
|
|
1352 |
CleanupClosePushL(*Interface);//6
|
|
1353 |
|
|
1354 |
|
|
1355 |
iLog->Log(_L("got Interface"));
|
|
1356 |
|
|
1357 |
|
|
1358 |
//Inserting content
|
|
1359 |
if( 0 != content.CompareF(KNull) )
|
|
1360 |
{
|
|
1361 |
TLiwVariant dsName;
|
|
1362 |
dsName.Set(content);
|
|
1363 |
TLiwGenericParam dsNameParam(KContent, content);
|
|
1364 |
input->AppendL(dsNameParam);
|
|
1365 |
}
|
|
1366 |
|
|
1367 |
|
|
1368 |
|
|
1369 |
|
|
1370 |
|
|
1371 |
CLiwDefaultMap *filterMap = NULL;
|
|
1372 |
|
|
1373 |
if(docname.CompareF(_L("NULL")) != 0 )
|
|
1374 |
{
|
|
1375 |
filterMap = CLiwDefaultMap::NewL();
|
|
1376 |
//CleanupStack::PushL( filterMap );//7
|
|
1377 |
filterMap->InsertL(KDocumentPath,TLiwVariant(docname));
|
|
1378 |
TLiwGenericParam iFilterParam(KFilter, TLiwVariant(filterMap));
|
|
1379 |
input->AppendL(iFilterParam);
|
|
1380 |
|
|
1381 |
filterMap->DecRef();
|
|
1382 |
}
|
|
1383 |
|
|
1384 |
|
|
1385 |
if(mimetype16.CompareF(_L("NULL")) != 0)
|
|
1386 |
{
|
|
1387 |
if( !filterMap )
|
|
1388 |
{
|
|
1389 |
filterMap = CLiwDefaultMap::NewL();
|
|
1390 |
//CleanupStack::PushL( filterMap );//7
|
|
1391 |
TLiwGenericParam iFilterParam(KFilter, TLiwVariant(filterMap));
|
|
1392 |
input->AppendL(iFilterParam);
|
|
1393 |
filterMap->DecRef();
|
|
1394 |
}
|
|
1395 |
|
|
1396 |
filterMap->InsertL(KMimeType,TLiwVariant(mimetype16));
|
|
1397 |
}
|
|
1398 |
|
|
1399 |
if( Interface != NULL)
|
|
1400 |
{
|
|
1401 |
iLog->Log(_L("got Interface"));
|
|
1402 |
Interface->ExecuteCmdL(KGetList,*input,*output);
|
|
1403 |
iLog->Log(_L("SAPI called"));
|
|
1404 |
}
|
|
1405 |
else
|
|
1406 |
{
|
|
1407 |
iLog->Log(_L("Didn't get interface"));
|
|
1408 |
return KErrGeneral;
|
|
1409 |
}
|
|
1410 |
|
|
1411 |
|
|
1412 |
const TLiwGenericParam* p= NULL;
|
|
1413 |
CLiwIterable* iter;
|
|
1414 |
TLiwVariant Map;
|
|
1415 |
const CLiwMap* infomap;
|
|
1416 |
TInt err= 0;
|
|
1417 |
pos = 0;
|
|
1418 |
TInt retcode;
|
|
1419 |
p = output->FindFirst(pos, KErrorCode); // Finding Error Code
|
|
1420 |
if(p)
|
|
1421 |
{
|
|
1422 |
|
|
1423 |
err = p->Value().AsTInt32();
|
|
1424 |
iLog->Log(_L("Got Error Code "));
|
|
1425 |
}
|
|
1426 |
|
|
1427 |
pos = 0;
|
|
1428 |
p = output->FindFirst(pos, KResponse);// Finding out the response of Media Management
|
|
1429 |
if(!p)
|
|
1430 |
{
|
|
1431 |
if( err == KErrNone )
|
|
1432 |
err = KErrGeneral;
|
|
1433 |
}
|
|
1434 |
else
|
|
1435 |
{
|
|
1436 |
iter = p->Value().AsIterable();// returning Iterator as Response
|
|
1437 |
}
|
|
1438 |
|
|
1439 |
|
|
1440 |
|
|
1441 |
|
|
1442 |
TLiwVariant val;//just for extracting the value
|
|
1443 |
TPtrC KeyValue;// value of that key
|
|
1444 |
TPtrC FirstKeyValue;// value of that key
|
|
1445 |
TBuf8<30> Key;
|
|
1446 |
if( testCaseType.CompareF(_L("Index"))==KErrNone )
|
|
1447 |
{
|
|
1448 |
|
|
1449 |
iter->NextL(Map);
|
|
1450 |
infomap = Map.AsMap();
|
|
1451 |
if (infomap->AtL(ind,Key) == EFalse )
|
|
1452 |
result = KErrNone;
|
|
1453 |
else
|
|
1454 |
result = KErrGeneral ;
|
|
1455 |
//delete infomap;
|
|
1456 |
infomap = NULL;
|
|
1457 |
Map.Reset();
|
|
1458 |
|
|
1459 |
}
|
|
1460 |
else if( testCaseType.CompareF(_L("Key"))==KErrNone )
|
|
1461 |
{
|
|
1462 |
iter->NextL(Map);
|
|
1463 |
infomap = Map.AsMap();
|
|
1464 |
if (infomap->FindL(_L8("WrongKey"), val) == EFalse )
|
|
1465 |
result = KErrNone;
|
|
1466 |
else
|
|
1467 |
result = KErrGeneral ;
|
|
1468 |
|
|
1469 |
//delete infomap;
|
|
1470 |
infomap = NULL;
|
|
1471 |
Map.Reset();
|
|
1472 |
|
|
1473 |
}
|
|
1474 |
|
|
1475 |
else if( testCaseType.CompareF(_L("Reset"))==KErrNone )
|
|
1476 |
{
|
|
1477 |
TInt count =0 ;
|
|
1478 |
while(iter->NextL(Map))
|
|
1479 |
{
|
|
1480 |
if(count == 0 )
|
|
1481 |
{
|
|
1482 |
infomap = Map.AsMap();
|
|
1483 |
infomap->FindL(_L8("UID"), val);
|
|
1484 |
val.Get(FirstKeyValue);
|
|
1485 |
|
|
1486 |
//delete infomap;
|
|
1487 |
infomap = NULL;
|
|
1488 |
Map.Reset();
|
|
1489 |
count++ ;
|
|
1490 |
}
|
|
1491 |
|
|
1492 |
}
|
|
1493 |
iter->Reset();
|
|
1494 |
iter->NextL(Map);
|
|
1495 |
infomap = Map.AsMap();
|
|
1496 |
infomap->FindL(_L8("UID"), val);
|
|
1497 |
val.Get(KeyValue);
|
|
1498 |
|
|
1499 |
if(KeyValue.CompareF(FirstKeyValue)== KErrNone )
|
|
1500 |
result = KErrNone;
|
|
1501 |
else
|
|
1502 |
result = KErrGeneral ;
|
|
1503 |
//delete infomap;
|
|
1504 |
infomap = NULL;
|
|
1505 |
Map.Reset();
|
|
1506 |
}
|
|
1507 |
|
|
1508 |
else
|
|
1509 |
{
|
|
1510 |
result = KErrGeneral ;
|
|
1511 |
}
|
|
1512 |
|
|
1513 |
|
|
1514 |
|
|
1515 |
|
|
1516 |
|
|
1517 |
CleanupStack::PopAndDestroy( );
|
|
1518 |
CleanupStack::PopAndDestroy( );
|
|
1519 |
CleanupStack::PopAndDestroy( );
|
|
1520 |
CleanupStack::PopAndDestroy( );
|
|
1521 |
CleanupStack::PopAndDestroy( );
|
|
1522 |
CleanupStack::PopAndDestroy( );
|
|
1523 |
|
|
1524 |
|
|
1525 |
return result;
|
|
1526 |
|
|
1527 |
|
|
1528 |
|
|
1529 |
}
|
|
1530 |
|
|
1531 |
|
|
1532 |
|
|
1533 |
|
|
1534 |
|
|
1535 |
|
|
1536 |
|
|
1537 |
|
|
1538 |
|
|
1539 |
//Helper Function
|
|
1540 |
|
|
1541 |
TInt CAppManagerTest::ConvertHexStringToInt32(const TDesC& aHexString,TInt32& aInt32 )
|
|
1542 |
{
|
|
1543 |
aInt32 = 0;
|
|
1544 |
|
|
1545 |
TInt pos = aHexString.LocateF( 'x' );
|
|
1546 |
if ( pos == KErrNotFound )
|
|
1547 |
{
|
|
1548 |
pos = 0;
|
|
1549 |
}
|
|
1550 |
else
|
|
1551 |
{
|
|
1552 |
pos++;
|
|
1553 |
}
|
|
1554 |
|
|
1555 |
if( ( aHexString.Length() - pos ) > KDocMaxDigitsInHexString )
|
|
1556 |
{
|
|
1557 |
return KErrArgument; // Error: value too big.
|
|
1558 |
}
|
|
1559 |
TPtrC aHexStringPtr( aHexString.Mid( pos ) );
|
|
1560 |
|
|
1561 |
TInt64 value64;
|
|
1562 |
if ( TLex( aHexStringPtr ).Val( value64, EHex ) != KErrNone )
|
|
1563 |
{
|
|
1564 |
return KErrArgument; // Error: conversion failed.
|
|
1565 |
}
|
|
1566 |
aInt32 = value64;
|
|
1567 |
|
|
1568 |
return KErrNone;
|
|
1569 |
}
|
|
1570 |
|
|
1571 |
void CAppManagerTest::killapp(TBuf<30> appId) //appId in format [101f4d90]
|
|
1572 |
{
|
|
1573 |
|
|
1574 |
RFs FileSession;
|
|
1575 |
RFile Applist;
|
|
1576 |
TInt ret;
|
|
1577 |
|
|
1578 |
|
|
1579 |
FileSession.Connect();
|
|
1580 |
CleanupClosePushL(FileSession);
|
|
1581 |
|
|
1582 |
TBuf<100> flname(_L("c:\\data\\AppManager\\AppList.txt"));
|
|
1583 |
ret=Applist.Open(FileSession, flname,EFileWrite | EFileStreamText);
|
|
1584 |
CleanupClosePushL(Applist);
|
|
1585 |
|
|
1586 |
|
|
1587 |
if(ret==KErrNone) //The file is for debug purposes only.Create it if neeeded
|
|
1588 |
{
|
|
1589 |
TInt SeekPos=0;
|
|
1590 |
TBuf8<100> filebuf;
|
|
1591 |
Applist.Seek(ESeekEnd,SeekPos);
|
|
1592 |
|
|
1593 |
|
|
1594 |
filebuf.Append(appId);
|
|
1595 |
filebuf.Append(_L8("-------- \n "));
|
|
1596 |
Applist.Write(SeekPos,filebuf);
|
|
1597 |
filebuf.Zero();
|
|
1598 |
}
|
|
1599 |
|
|
1600 |
|
|
1601 |
TFindProcess findProcess(appId);
|
|
1602 |
TFullName procresult;
|
|
1603 |
while (findProcess.Next(procresult) == KErrNone)
|
|
1604 |
{
|
|
1605 |
RProcess p;
|
|
1606 |
CleanupClosePushL(p);
|
|
1607 |
|
|
1608 |
//filebuf.Append(procresult);
|
|
1609 |
|
|
1610 |
if (p.Open(findProcess, EOwnerThread) == KErrNone)
|
|
1611 |
{
|
|
1612 |
p.Kill(0);
|
|
1613 |
p.Close();
|
|
1614 |
//filebuf.Append(KKill);
|
|
1615 |
}
|
|
1616 |
CleanupStack::PopAndDestroy();
|
|
1617 |
}
|
|
1618 |
|
|
1619 |
CleanupStack::PopAndDestroy();//File
|
|
1620 |
CleanupStack::PopAndDestroy();//File Session
|
|
1621 |
|
|
1622 |
}
|
|
1623 |
|
|
1624 |
|
|
1625 |
|
|
1626 |
// ========================== OTHER EXPORTED FUNCTIONS =========================
|
|
1627 |
// None
|
|
1628 |
|
|
1629 |
// End of File
|