author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 24 Nov 2009 08:56:33 +0200 | |
changeset 23 | 50974a8b132e |
parent 5 | 989d2f495d90 |
permissions | -rw-r--r-- |
5 | 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
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
23 |
#include <StifTestInterface.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
24 |
#include <liwservicehandler.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
25 |
#include <liwbufferextension.h> |
5 | 26 |
#include "appmanagertest.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 |
||
57 |
_LIT8(KResponse,"ReturnValue"); |
|
58 |
_LIT8(KErrorCode,"ErrorCode"); |
|
59 |
_LIT8(KOptions,"Options"); |
|
60 |
||
61 |
// Filter Map |
|
62 |
_LIT8(KFilter,"Filter"); |
|
63 |
||
64 |
const TInt KDocMaxDigitsInHexString = 8; // 32 bits. |
|
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( "launchApp", CAppManagerTest::launchAppL ), |
|
141 |
ENTRY( "launchDoc", CAppManagerTest::launchDocL ), |
|
142 |
ENTRY( "cancellaunchDoc", CAppManagerTest::CancellaunchDocL ), |
|
143 |
}; |
|
144 |
||
145 |
const TInt count = sizeof( KFunctions ) / |
|
146 |
sizeof( TStifFunctionInfo ); |
|
147 |
||
148 |
return RunInternalL( KFunctions, count, aItem ); |
|
149 |
||
150 |
} |
|
151 |
||
152 |
// ----------------------------------------------------------------------------- |
|
153 |
// CAppManagerTest:getlistapplication1_testL |
|
154 |
// Example test method function. |
|
155 |
// (other items were commented in a header). |
|
156 |
// ----------------------------------------------------------------------------- |
|
157 |
// |
|
158 |
TInt CAppManagerTest::getlisttestL( CStifItemParser& aItem ) |
|
159 |
{ |
|
160 |
||
161 |
__UHEAP_MARK; |
|
162 |
TPtrC16 content; |
|
163 |
TPtrC16 docname; |
|
164 |
TPtrC16 mimetype16; |
|
165 |
TInt expected; |
|
166 |
TInt noOfmaps; |
|
167 |
TPtrC16 filename; |
|
168 |
TInt result =KErrNone ;// KErrGeneral; // 0 means pass and -1 means Fail |
|
169 |
||
170 |
aItem.GetNextString(content); |
|
171 |
aItem.GetNextString(docname); |
|
172 |
aItem.GetNextString(mimetype16); |
|
173 |
aItem.GetNextInt(expected); |
|
174 |
aItem.GetNextString(filename); |
|
175 |
aItem.GetNextInt(noOfmaps); |
|
176 |
||
177 |
iLog->Log(_L("read varibale ")); |
|
178 |
||
179 |
/*-------------------------------------------------------------------------------------------*/ |
|
180 |
||
181 |
||
182 |
CLiwServiceHandler* iServiceHandler = CLiwServiceHandler::NewL(); |
|
183 |
CleanupStack::PushL(iServiceHandler);//1 |
|
184 |
||
185 |
if ( iServiceHandler ) |
|
186 |
iLog->Log(_L("Got Service Handler ")); |
|
187 |
else |
|
188 |
iLog->Log(_L("Didn't get service handler")); |
|
189 |
||
190 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1,KIAppManager,KService); |
|
191 |
iLog->Log(_L("Create criterai Item")); |
|
192 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
193 |
CleanupStack::PushL(crit);//2 |
|
194 |
||
195 |
||
196 |
RCriteriaArray critArray; |
|
197 |
iLog->Log(_L("Append in Crit")); |
|
198 |
critArray.AppendL(crit); |
|
199 |
CleanupClosePushL(critArray);//3 |
|
200 |
||
201 |
iServiceHandler->AttachL(critArray); |
|
202 |
//critArray.Reset(); |
|
203 |
//critArray.Close(); |
|
204 |
||
205 |
iLog->Log(_L("Creating Output")); |
|
206 |
||
207 |
CLiwGenericParamList* output = CLiwGenericParamList::NewL(); |
|
208 |
CleanupStack::PushL(output);//4 |
|
209 |
CLiwGenericParamList* input = CLiwGenericParamList::NewL(); |
|
210 |
CleanupStack::PushL(input);//5 |
|
211 |
||
212 |
iLog->Log(_L("call Service cmd L")); |
|
213 |
||
214 |
iServiceHandler->ExecuteServiceCmdL(*crit, *input, *output); |
|
215 |
||
216 |
iLog->Log(_L("Service cmdl is over")); |
|
217 |
||
218 |
// Create the Instance of SAPI class and the Input Param and output Param |
|
219 |
TInt pos = 0; |
|
220 |
MLiwInterface* Interface = NULL; |
|
221 |
output->FindFirst(pos,KIAppManager ); |
|
222 |
if(pos != KErrNotFound) |
|
223 |
{ |
|
224 |
Interface = (*output)[pos].Value().AsInterface(); |
|
225 |
} |
|
226 |
output->Reset(); |
|
227 |
||
228 |
||
229 |
||
230 |
CleanupClosePushL(*Interface);//6 |
|
231 |
||
232 |
||
233 |
iLog->Log(_L("got Interface")); |
|
234 |
||
235 |
||
236 |
//Inserting content |
|
237 |
if( 0 != content.CompareF(KNull) ) |
|
238 |
{ |
|
239 |
TLiwVariant dsName; |
|
240 |
dsName.Set(content); |
|
241 |
TLiwGenericParam dsNameParam(KContent, content); |
|
242 |
input->AppendL(dsNameParam); |
|
243 |
} |
|
244 |
||
245 |
||
246 |
||
247 |
||
248 |
||
249 |
CLiwDefaultMap *filterMap = NULL; |
|
250 |
||
251 |
if(docname.CompareF(_L("NULL")) != 0 ) |
|
252 |
{ |
|
253 |
filterMap = CLiwDefaultMap::NewL(); |
|
254 |
//CleanupStack::PushL( filterMap );//7 |
|
255 |
filterMap->InsertL(KDocumentPath,TLiwVariant(docname)); |
|
256 |
TLiwGenericParam iFilterParam(KFilter, TLiwVariant(filterMap)); |
|
257 |
input->AppendL(iFilterParam); |
|
258 |
||
259 |
filterMap->DecRef(); |
|
260 |
} |
|
261 |
||
262 |
||
263 |
if(mimetype16.CompareF(_L("NULL")) != 0) |
|
264 |
{ |
|
265 |
if( !filterMap ) |
|
266 |
{ |
|
267 |
filterMap = CLiwDefaultMap::NewL(); |
|
268 |
//CleanupStack::PushL( filterMap );//7 |
|
269 |
TLiwGenericParam iFilterParam(KFilter, TLiwVariant(filterMap)); |
|
270 |
input->AppendL(iFilterParam); |
|
271 |
filterMap->DecRef(); |
|
272 |
} |
|
273 |
||
274 |
filterMap->InsertL(KMimeType,TLiwVariant(mimetype16)); |
|
275 |
} |
|
276 |
||
277 |
if( Interface != NULL) |
|
278 |
{ |
|
279 |
iLog->Log(_L("got Interface")); |
|
280 |
Interface->ExecuteCmdL(KGetList,*input,*output); |
|
281 |
iLog->Log(_L("SAPI called")); |
|
282 |
} |
|
283 |
else |
|
284 |
{ |
|
285 |
iLog->Log(_L("Didn't get interface")); |
|
286 |
return KErrGeneral; |
|
287 |
} |
|
288 |
||
289 |
||
290 |
const TLiwGenericParam* p= NULL; |
|
291 |
CLiwIterable* iter = NULL; |
|
292 |
TLiwVariant Map; |
|
293 |
const CLiwMap* infomap; |
|
294 |
TInt err= 0; |
|
295 |
pos = 0; |
|
296 |
TInt retcode; |
|
297 |
p = output->FindFirst(pos, KErrorCode); // Finding Error Code |
|
298 |
if(p) |
|
299 |
{ |
|
300 |
||
301 |
err = p->Value().AsTInt32(); |
|
302 |
iLog->Log(_L("Got Error Code ")); |
|
303 |
} |
|
304 |
||
305 |
pos = 0; |
|
306 |
p = output->FindFirst(pos, KResponse);// Finding out the response of Media Management |
|
307 |
if(!p) |
|
308 |
{ |
|
309 |
if( err == KErrNone ) |
|
310 |
err = KErrGeneral; |
|
311 |
} |
|
312 |
else |
|
313 |
{ |
|
314 |
iter = p->Value().AsIterable();// returning Iterator as Response |
|
315 |
} |
|
316 |
||
317 |
||
318 |
||
319 |
||
320 |
/*---------------------------------------------------------------------------------------------*/ |
|
321 |
||
322 |
if(noOfmaps > 0) |
|
323 |
{ |
|
324 |
RArray<TInt> uidArray; |
|
325 |
TInt matchedOutput =0; |
|
326 |
TInt32 appuid; |
|
327 |
TInt index; |
|
328 |
TPtrC16 appuidstring; |
|
329 |
for(TInt i =0 ;i < noOfmaps; i++ ) |
|
330 |
{ |
|
331 |
aItem.GetNextString( appuidstring ); |
|
332 |
ConvertHexStringToInt32(appuidstring,appuid ); |
|
333 |
uidArray.Append(appuid); |
|
334 |
} |
|
335 |
||
336 |
_LIT8(UidKey,"Uid");// Key In The Map |
|
337 |
TPtrC KeyValue;// value of that key |
|
338 |
TLiwVariant val;//just for extracting the value |
|
339 |
||
340 |
while( (uidArray.Count()>0) && iter->NextL(Map) ) |
|
341 |
{ |
|
342 |
infomap = Map.AsMap(); |
|
343 |
infomap->FindL(UidKey, val); |
|
344 |
val.Get(KeyValue); |
|
345 |
ConvertHexStringToInt32(KeyValue,appuid ); |
|
346 |
||
347 |
if( ( index = uidArray.Find( appuid ) )!= KErrNotFound) |
|
348 |
{ |
|
349 |
matchedOutput++; |
|
350 |
uidArray.Remove(index); |
|
351 |
uidArray.Compress(); |
|
352 |
} |
|
353 |
||
354 |
infomap = NULL; |
|
355 |
Map.Reset(); |
|
356 |
} |
|
357 |
||
358 |
//iter->Reset(); has to implement by lokesh |
|
359 |
if( matchedOutput != noOfmaps ) |
|
360 |
{ |
|
361 |
//Test case failed |
|
362 |
err = KErrGeneral; |
|
363 |
} |
|
364 |
uidArray.Reset(); |
|
365 |
uidArray.Close(); |
|
366 |
} |
|
367 |
||
368 |
||
369 |
/*------------------------------------Output For Manual Testing ---------------------------------*/ |
|
370 |
if(filename.CompareF(_L("NULL"))!= 0) |
|
371 |
{ |
|
372 |
||
373 |
// Convert 16 Bit values into 8 bit as SAPI accept 8 bit Des |
|
374 |
TBuf8<30> content8 ; |
|
375 |
content8.Copy(content); |
|
376 |
||
377 |
||
378 |
// Show the output |
|
379 |
RFs fs; |
|
380 |
RFile file; |
|
381 |
User::LeaveIfError(fs.Connect()); |
|
382 |
CleanupClosePushL(fs);//8 |
|
383 |
TInt errfile=0; |
|
384 |
TEntry entry; |
|
385 |
if( fs.Entry(_L("c:\\Data\\AppManager\\"),entry) != KErrNone) |
|
386 |
{ |
|
387 |
TInt ret = fs.MkDir(_L("c:\\Data\\AppManager\\")); |
|
388 |
} |
|
389 |
||
390 |
TBuf<100> flname(_L("c:\\Data\\AppManager\\")); |
|
391 |
||
392 |
flname.Append(filename); |
|
393 |
flname.Append(_L(".txt")); |
|
394 |
||
395 |
errfile =file.Replace(fs,flname, EFileWrite | EFileStreamText); |
|
396 |
CleanupClosePushL(file);//9 |
|
397 |
||
398 |
TBuf8<100> filebuf; |
|
399 |
TInt index =0 ; |
|
400 |
TBuf8<15> Key;// Key In The Map |
|
401 |
TPtrC16 KeyValue;// value of that key |
|
402 |
||
403 |
filebuf.Append(_L8("TestCase \n")); |
|
404 |
filebuf.Append(_L8("Content = ")); |
|
405 |
filebuf.Append(content8); |
|
406 |
filebuf.Append(_L8(",")); |
|
407 |
||
408 |
filebuf.Append(_L8("docname = ")); |
|
409 |
filebuf.Append(docname); |
|
410 |
filebuf.Append(_L8(",")); |
|
411 |
||
412 |
filebuf.Append(_L8("mimetype16 = ")); |
|
413 |
filebuf.Append(mimetype16); |
|
414 |
filebuf.Append(_L8("\n")); |
|
415 |
||
416 |
file.Write(filebuf); |
|
417 |
filebuf.Zero(); |
|
418 |
||
419 |
TInt count =1; |
|
420 |
TLiwVariant val;//just for extracting the value |
|
421 |
while(iter && iter->NextL(Map)) |
|
422 |
{ |
|
423 |
infomap = Map.AsMap(); |
|
424 |
filebuf.Append(_L8(" :- ")); |
|
425 |
filebuf.AppendNum(count); |
|
426 |
file.Write(content8); |
|
427 |
file.Write(filebuf); |
|
428 |
file.Write(_L8("\n")); |
|
429 |
filebuf.Zero(); |
|
430 |
file.Write(_L8("----------------------------------------------------\n")); |
|
431 |
||
432 |
for(index =0 ;index <infomap->Count(); index++ ) |
|
433 |
{ |
|
434 |
infomap->AtL(index,Key); |
|
435 |
infomap->FindL(Key, val); |
|
436 |
val.Get(KeyValue); |
|
437 |
file.Write(Key); |
|
438 |
file.Write(_L8("\t")); |
|
439 |
filebuf.Copy(KeyValue); |
|
440 |
file.Write(filebuf); |
|
441 |
file.Write(_L8("\n")); |
|
442 |
filebuf.Zero(); |
|
443 |
}// Map |
|
444 |
||
445 |
//delete infomap; |
|
446 |
infomap = NULL; |
|
447 |
Map.Reset(); |
|
448 |
file.Write(_L8("----------------------------------------------------\n\n")); |
|
449 |
||
450 |
count++; |
|
451 |
}//Iterator |
|
452 |
||
453 |
CleanupStack::PopAndDestroy();//File 9 |
|
454 |
CleanupStack::PopAndDestroy();//File Session 8 |
|
455 |
||
456 |
} |
|
457 |
||
458 |
/*------------------------------------Output For Manual Testing ---------------------------------*/ |
|
459 |
||
460 |
iter->DecRef(); |
|
461 |
||
462 |
||
463 |
||
464 |
if(!expected) |
|
465 |
{ |
|
466 |
//Postive Test Case |
|
467 |
if(err != KErrNone) |
|
468 |
{ |
|
469 |
result = KErrGeneral; |
|
470 |
} |
|
471 |
||
472 |
} |
|
473 |
else |
|
474 |
{ |
|
475 |
if (err == KErrNone) |
|
476 |
{ |
|
477 |
result = KErrGeneral; |
|
478 |
} |
|
479 |
//Neagative Test Case |
|
480 |
} |
|
481 |
||
482 |
output->Reset(); |
|
483 |
input->Reset(); |
|
484 |
||
485 |
//if(filterMap) |
|
486 |
//CleanupStack::PopAndDestroy();//Filter Parameter 7 |
|
487 |
||
488 |
CleanupStack::PopAndDestroy( ); |
|
489 |
CleanupStack::PopAndDestroy( ); |
|
490 |
CleanupStack::PopAndDestroy( ); |
|
491 |
CleanupStack::PopAndDestroy( ); |
|
492 |
CleanupStack::PopAndDestroy( ); |
|
493 |
CleanupStack::PopAndDestroy( ); |
|
494 |
//Interface->Close(); |
|
495 |
__UHEAP_MARKEND; |
|
496 |
return result; |
|
497 |
||
498 |
||
499 |
} |
|
500 |
||
501 |
||
502 |
// ----------------------------------------------------------------------------- |
|
503 |
// CAppManagerTest:launchAppL |
|
504 |
// Example test method function. |
|
505 |
// (other items were commented in a header). |
|
506 |
// ----------------------------------------------------------------------------- |
|
507 |
// |
|
508 |
||
509 |
TInt CAppManagerTest::launchAppL( CStifItemParser& aItem ) |
|
510 |
{ |
|
511 |
__UHEAP_MARK; |
|
512 |
||
513 |
CLiwServiceHandler* iServiceHandler = CLiwServiceHandler::NewL(); |
|
514 |
CleanupStack::PushL(iServiceHandler);//1 |
|
515 |
||
516 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1,KIAppManager,KService); |
|
517 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
518 |
CleanupStack::PushL(crit);//2 |
|
519 |
||
520 |
||
521 |
RCriteriaArray critArray; |
|
522 |
critArray.AppendL(crit); |
|
523 |
CleanupClosePushL(critArray);//3 |
|
524 |
||
525 |
iServiceHandler->AttachL(critArray); |
|
526 |
||
527 |
||
528 |
||
529 |
CLiwGenericParamList* output = CLiwGenericParamList::NewL(); |
|
530 |
CleanupStack::PushL(output);//4 |
|
531 |
CLiwGenericParamList* input = CLiwGenericParamList::NewL(); |
|
532 |
CleanupStack::PushL(input);//5 |
|
533 |
||
534 |
iServiceHandler->ExecuteServiceCmdL(*crit, *input, *output); |
|
535 |
||
536 |
||
537 |
// Create the Instance of SAPI class and the Input Param and output Param |
|
538 |
TInt pos = 0; |
|
539 |
MLiwInterface* Interface = NULL; |
|
540 |
output->FindFirst(pos,KIAppManager ); |
|
541 |
if(pos != KErrNotFound) |
|
542 |
{ |
|
543 |
Interface = (*output)[pos].Value().AsInterface(); |
|
544 |
} |
|
545 |
output->Reset(); |
|
546 |
||
547 |
||
548 |
||
549 |
//MLiwInterface* Interface = CMgDataSourceInterface::NewL(); |
|
550 |
CleanupClosePushL(*Interface);//6 |
|
551 |
||
552 |
/*--------Test Logic Starts-----------*/ |
|
553 |
TOptions options; |
|
554 |
TInt expected; |
|
555 |
TPtrC16 temp; |
|
556 |
TBuf<30> appId; |
|
557 |
TPtrC16 cmdLine16; |
|
558 |
TPtrC16 document; |
|
559 |
TPtrC16 mode; |
|
560 |
TPtrC16 postion; |
|
561 |
TPtrC16 callback; |
|
562 |
TInt err; |
|
563 |
TInt result =KErrNone ;// KErrGeneral; // 0 means pass and -1 means Fail |
|
564 |
||
565 |
aItem.GetNextString( temp ); |
|
566 |
appId.Append( temp ); |
|
567 |
appId.Append(_L("//")); |
|
568 |
aItem.GetNextString( temp ); |
|
569 |
appId.Append( temp ); |
|
570 |
||
571 |
||
572 |
aItem.GetNextString(cmdLine16); |
|
573 |
aItem.GetNextString(document); |
|
574 |
aItem.GetNextString(mode); |
|
575 |
aItem.GetNextString(postion); |
|
576 |
aItem.GetNextString(callback); |
|
577 |
aItem.GetNextInt(expected); |
|
578 |
||
579 |
||
580 |
//Inserting ApplicationID |
|
581 |
if( 0 != appId.CompareF(KNull) ) |
|
582 |
{ |
|
583 |
TLiwVariant id; |
|
584 |
id.Set(appId); |
|
585 |
TLiwGenericParam idParam(KApplicationID, id); |
|
586 |
input->AppendL(idParam); |
|
587 |
} |
|
588 |
||
589 |
||
590 |
||
591 |
||
592 |
//Inserting cmdLine |
|
593 |
if( 0 != cmdLine16.CompareF(KNull) ) |
|
594 |
{ |
|
595 |
TLiwVariant cmdline; |
|
596 |
cmdline.Set(cmdLine16); |
|
597 |
TLiwGenericParam cmdlineParam(KCmdLine, cmdline); |
|
598 |
input->AppendL(cmdlineParam); |
|
599 |
} |
|
600 |
||
601 |
||
602 |
||
603 |
||
604 |
CLiwDefaultMap *filterMap = NULL; |
|
605 |
||
606 |
if( document.CompareF(_L("NULL")) != 0 ) |
|
607 |
{ |
|
608 |
filterMap = CLiwDefaultMap::NewL(); |
|
609 |
//CleanupStack::PushL( filterMap );//7 |
|
610 |
filterMap->InsertL(KDocumentPath,TLiwVariant(document)); |
|
611 |
TLiwGenericParam iFilterParam(KOptions, TLiwVariant(filterMap)); |
|
612 |
input->AppendL(iFilterParam); |
|
613 |
filterMap->DecRef(); |
|
614 |
} |
|
615 |
||
616 |
||
617 |
if( mode.CompareF(_L("NULL") ) != 0) |
|
618 |
{ |
|
619 |
if( !filterMap ) |
|
620 |
{ |
|
621 |
filterMap = CLiwDefaultMap::NewL(); |
|
622 |
CleanupStack::PushL( filterMap );//7 |
|
623 |
TLiwGenericParam iFilterParam(KOptions, TLiwVariant(filterMap)); |
|
624 |
input->AppendL(iFilterParam); |
|
625 |
filterMap->DecRef(); |
|
626 |
} |
|
627 |
||
628 |
filterMap->InsertL(KMode,TLiwVariant(mode)); |
|
629 |
} |
|
630 |
||
631 |
if( postion.CompareF(_L("NULL") ) != 0) |
|
632 |
{ |
|
633 |
if( !filterMap ) |
|
634 |
{ |
|
635 |
filterMap = CLiwDefaultMap::NewL(); |
|
636 |
//CleanupStack::PushL( filterMap );//7 |
|
637 |
TLiwGenericParam iFilterParam(KOptions, TLiwVariant(filterMap)); |
|
638 |
input->AppendL(iFilterParam); |
|
639 |
filterMap->DecRef(); |
|
640 |
} |
|
641 |
||
642 |
filterMap->InsertL(KPostion,TLiwVariant( postion )); |
|
643 |
} |
|
644 |
||
645 |
||
646 |
||
647 |
||
648 |
if( callback.CompareF(_L("NULL")) != 0 ) |
|
649 |
{ |
|
650 |
//Aysnch Call; |
|
651 |
CActiveSchedulerWait *wait = new CActiveSchedulerWait(); |
|
652 |
CleanupStack::PushL( wait); |
|
653 |
CAppObserver* callback = CAppObserver::NewL(wait); |
|
654 |
CleanupStack::PushL( callback); |
|
655 |
Interface->ExecuteCmdL(KLaunchApp,*input,*output,KLiwOptASyncronous,callback); |
|
656 |
const TLiwGenericParam* p= NULL; |
|
657 |
pos = 0; |
|
658 |
||
659 |
p = output->FindFirst(pos, KErrorCode); // Finding Error Code |
|
660 |
if(p) |
|
661 |
{ |
|
662 |
err = p->Value().AsTInt32(); |
|
663 |
} |
|
664 |
else |
|
665 |
{ |
|
666 |
err = KErrGeneral; |
|
667 |
} |
|
668 |
||
669 |
if ( err == KErrNone) |
|
670 |
{ |
|
671 |
// Asynch request properly accepted |
|
672 |
wait->Start(); |
|
673 |
err = callback->iErrorReturn; |
|
674 |
if ( callback->iReason > 0 ) |
|
675 |
{ |
|
676 |
//but we didn't get notifaction |
|
677 |
//Reason of failure can be either 0 or some negative value which incates |
|
678 |
//error but it cant be greater than 0 |
|
679 |
err = KErrGeneral; |
|
680 |
} |
|
681 |
||
682 |
} |
|
683 |
||
684 |
CleanupStack::PopAndDestroy();//Callback |
|
685 |
CleanupStack::PopAndDestroy();//Active Wait Scheduler |
|
686 |
} |
|
687 |
else |
|
688 |
{ |
|
689 |
//Synch call |
|
690 |
if( Interface != NULL) |
|
691 |
{ |
|
692 |
_LIT8(KLaunchApp,"LaunchApp"); |
|
693 |
Interface->ExecuteCmdL(KLaunchApp,*input,*output); |
|
694 |
} |
|
695 |
else |
|
696 |
{ |
|
697 |
//Didn't get the interface |
|
698 |
return KErrGeneral; |
|
699 |
} |
|
700 |
||
701 |
||
702 |
const TLiwGenericParam* p= NULL; |
|
703 |
pos = 0; |
|
704 |
p = output->FindFirst(pos, KErrorCode); // Finding Error Code |
|
705 |
if(p) |
|
706 |
{ |
|
707 |
err = p->Value().AsTInt32(); |
|
708 |
} |
|
709 |
else |
|
710 |
{ |
|
711 |
err = KErrGeneral; |
|
712 |
} |
|
713 |
} |
|
714 |
||
715 |
||
716 |
if(!expected) |
|
717 |
{ |
|
718 |
//Postive Test Case |
|
719 |
if(err != KErrNone) |
|
720 |
{ |
|
721 |
result = KErrGeneral; |
|
722 |
} |
|
723 |
||
724 |
} |
|
725 |
else |
|
726 |
{ |
|
727 |
if (err == KErrNone) |
|
728 |
{ |
|
729 |
result = KErrGeneral; |
|
730 |
} |
|
731 |
//Neagative Test Case |
|
732 |
} |
|
733 |
||
734 |
||
735 |
/*--------Test Logic Ends -----------*/ |
|
736 |
//if(filterMap) |
|
737 |
//CleanupStack::PopAndDestroy();//Filter Parameter 7 |
|
738 |
||
739 |
CleanupStack::PopAndDestroy( ); |
|
740 |
CleanupStack::PopAndDestroy( ); |
|
741 |
CleanupStack::PopAndDestroy( ); |
|
742 |
CleanupStack::PopAndDestroy( ); |
|
743 |
CleanupStack::PopAndDestroy( ); |
|
744 |
CleanupStack::PopAndDestroy( ); |
|
745 |
__UHEAP_MARK; |
|
746 |
return result; |
|
747 |
||
748 |
} |
|
749 |
||
750 |
||
751 |
// ----------------------------------------------------------------------------- |
|
752 |
// CAppManagerTest:launchDocL |
|
753 |
// Example test method function. |
|
754 |
// (other items were commented in a header). |
|
755 |
// ----------------------------------------------------------------------------- |
|
756 |
// |
|
757 |
||
758 |
TInt CAppManagerTest::launchDocL( CStifItemParser& aItem ) |
|
759 |
{ |
|
760 |
||
761 |
||
762 |
__UHEAP_MARK; |
|
763 |
||
764 |
||
765 |
CLiwServiceHandler* iServiceHandler = CLiwServiceHandler::NewL(); |
|
766 |
CleanupStack::PushL(iServiceHandler);//1 |
|
767 |
||
768 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1,KIAppManager,KService); |
|
769 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
770 |
CleanupStack::PushL(crit);//2 |
|
771 |
||
772 |
||
773 |
RCriteriaArray critArray; |
|
774 |
critArray.AppendL(crit); |
|
775 |
CleanupClosePushL(critArray);//3 |
|
776 |
||
777 |
iServiceHandler->AttachL(critArray); |
|
778 |
||
779 |
||
780 |
||
781 |
CLiwGenericParamList* output = CLiwGenericParamList::NewL(); |
|
782 |
CleanupStack::PushL(output);//4 |
|
783 |
CLiwGenericParamList* input = CLiwGenericParamList::NewL(); |
|
784 |
CleanupStack::PushL(input);//5 |
|
785 |
||
786 |
iServiceHandler->ExecuteServiceCmdL(*crit, *input, *output); |
|
787 |
||
788 |
||
789 |
// Create the Instance of SAPI class and the Input Param and output Param |
|
790 |
TInt pos = 0; |
|
791 |
MLiwInterface* Interface = NULL; |
|
792 |
output->FindFirst(pos,KIAppManager ); |
|
793 |
if(pos != KErrNotFound) |
|
794 |
{ |
|
795 |
Interface = (*output)[pos].Value().AsInterface(); |
|
796 |
} |
|
797 |
output->Reset(); |
|
798 |
||
799 |
||
800 |
||
801 |
//MLiwInterface* Interface = CMgDataSourceInterface::NewL(); |
|
802 |
CleanupClosePushL(*Interface);//6 |
|
803 |
||
804 |
/*--------Test Logic Starts-----------*/ |
|
805 |
TOptions options; |
|
806 |
TDocument criteria; |
|
807 |
TInt expected; |
|
808 |
TBuf<30> filename; |
|
809 |
TPtrC16 path; |
|
810 |
TPtrC16 handle; |
|
811 |
TPtrC16 mimetype16; |
|
812 |
TPtrC16 mode; |
|
813 |
TPtrC16 callback; |
|
814 |
TInt err; |
|
815 |
TInt result =KErrNone ;// KErrGeneral; // 0 means pass and -1 means Fail |
|
816 |
||
817 |
||
818 |
aItem.GetNextString(path); |
|
819 |
aItem.GetNextString(handle); |
|
820 |
aItem.GetNextString(mimetype16); |
|
821 |
aItem.GetNextString(mode); |
|
822 |
aItem.GetNextString(callback); |
|
823 |
aItem.GetNextInt(expected); |
|
824 |
||
825 |
/*------------------------------------------------------------------*/ |
|
826 |
||
827 |
||
828 |
//Inserting Document |
|
829 |
||
830 |
||
831 |
CLiwDefaultMap *documentMap = NULL; |
|
832 |
input->Reset(); |
|
833 |
||
834 |
if( path.CompareF(_L("NULL")) != 0 ) |
|
835 |
{ |
|
836 |
documentMap = CLiwDefaultMap::NewL(); |
|
837 |
documentMap->InsertL(KDocumentPath,TLiwVariant(path)); |
|
838 |
TLiwGenericParam iFilterParam( KDocument, TLiwVariant(documentMap)); |
|
839 |
input->AppendL(iFilterParam); |
|
840 |
documentMap->DecRef(); |
|
841 |
} |
|
842 |
||
843 |
||
844 |
if( handle.CompareF(_L("NULL") ) != 0) |
|
845 |
{ |
|
846 |
if( !documentMap ) |
|
847 |
{ |
|
848 |
documentMap = CLiwDefaultMap::NewL(); |
|
849 |
TLiwGenericParam iFilterParam(KDocument, TLiwVariant(documentMap)); |
|
850 |
input->AppendL(iFilterParam); |
|
851 |
documentMap->DecRef(); |
|
852 |
} |
|
853 |
||
854 |
RFs fileSession; |
|
855 |
User::LeaveIfError(fileSession.Connect()); |
|
856 |
RFile file; |
|
857 |
User::LeaveIfError(fileSession.ShareProtected()); |
|
858 |
file.Open(fileSession,handle,EFileShareReadersOnly); |
|
859 |
//CLiwDefaultFileBuffer* filebuffer = CLiwFileBuffer::NewL(); |
|
860 |
documentMap->InsertL(KHandle,TLiwVariant(file)); |
|
861 |
} |
|
862 |
||
863 |
||
864 |
||
865 |
||
866 |
//Inserting MimeType |
|
867 |
if( 0 != mimetype16.CompareF(KNull) ) |
|
868 |
{ |
|
869 |
TLiwVariant mimetype; |
|
870 |
mimetype.Set(mimetype16); |
|
871 |
TLiwGenericParam mimetypeParam(KMimeType, mimetype); |
|
872 |
input->AppendL(mimetypeParam); |
|
873 |
} |
|
874 |
||
875 |
||
876 |
||
877 |
||
878 |
if( mode.CompareF(_L("NULL")) != 0 ) |
|
879 |
{ |
|
880 |
CLiwDefaultMap *filterMap = CLiwDefaultMap::NewL(); |
|
881 |
filterMap->InsertL(KMode,TLiwVariant(mode)); |
|
882 |
TLiwGenericParam iFilterParam(KOptions, TLiwVariant(filterMap)); |
|
883 |
input->AppendL(iFilterParam); |
|
884 |
filterMap->DecRef(); |
|
885 |
} |
|
886 |
||
887 |
||
888 |
||
889 |
if( callback.CompareF(_L("NULL")) != 0 ) |
|
890 |
{ |
|
891 |
//Aysnch Call; |
|
892 |
CActiveSchedulerWait *wait = new CActiveSchedulerWait(); |
|
893 |
CleanupStack::PushL( wait); |
|
894 |
CAppObserver* callback = CAppObserver::NewL(wait); |
|
895 |
CleanupStack::PushL( callback); |
|
896 |
Interface->ExecuteCmdL(KLaunchDoc,*input,*output,KLiwOptASyncronous,callback); |
|
897 |
const TLiwGenericParam* p= NULL; |
|
898 |
pos = 0; |
|
899 |
||
900 |
p = output->FindFirst(pos, KErrorCode); // Finding Error Code |
|
901 |
if(p) |
|
902 |
{ |
|
903 |
err = p->Value().AsTInt32(); |
|
904 |
} |
|
905 |
else |
|
906 |
{ |
|
907 |
err = KErrGeneral; |
|
908 |
} |
|
909 |
||
910 |
if ( err == KErrNone) |
|
911 |
{ |
|
912 |
// Asynch request properly accepted |
|
913 |
||
914 |
wait->Start(); |
|
915 |
err = callback->iErrorReturn; |
|
916 |
if ( callback->iReason > 0 ) |
|
917 |
{ |
|
918 |
//but we didn't get notifaction |
|
919 |
//Reason of failure can be either 0 or some negative value which incates |
|
920 |
//error but it cant be greater than 0 |
|
921 |
err = KErrGeneral; |
|
922 |
} |
|
923 |
||
924 |
} |
|
925 |
||
926 |
CleanupStack::PopAndDestroy();//Callback |
|
927 |
CleanupStack::PopAndDestroy();//Active Wait Scheduler |
|
928 |
} |
|
929 |
else |
|
930 |
{ |
|
931 |
//Synch call |
|
932 |
if( Interface != NULL) |
|
933 |
{ |
|
934 |
_LIT8(KLaunchApp,"LaunchApp"); |
|
935 |
Interface->ExecuteCmdL(KLaunchDoc,*input,*output); |
|
936 |
} |
|
937 |
else |
|
938 |
{ |
|
939 |
//Didn't get the interface |
|
940 |
return KErrGeneral; |
|
941 |
} |
|
942 |
||
943 |
||
944 |
const TLiwGenericParam* p= NULL; |
|
945 |
pos = 0; |
|
946 |
p = output->FindFirst(pos, KErrorCode); // Finding Error Code |
|
947 |
if(p) |
|
948 |
{ |
|
949 |
err = p->Value().AsTInt32(); |
|
950 |
} |
|
951 |
else |
|
952 |
{ |
|
953 |
err = KErrGeneral; |
|
954 |
} |
|
955 |
||
956 |
p= NULL; |
|
957 |
pos = 0; |
|
958 |
p = output->FindFirst(pos, KDocumentName); // Finding Error Code |
|
959 |
if(p) |
|
960 |
{ |
|
961 |
TPtrC filname ; |
|
962 |
p->Value().Get(filname); |
|
963 |
} |
|
964 |
||
965 |
} |
|
966 |
||
967 |
||
968 |
if(!expected) |
|
969 |
{ |
|
970 |
//Postive Test Case |
|
971 |
if(err != KErrNone) |
|
972 |
{ |
|
973 |
result = err; |
|
974 |
} |
|
975 |
||
976 |
} |
|
977 |
else |
|
978 |
{ |
|
979 |
if (err == KErrNone) |
|
980 |
{ |
|
981 |
result = KErrGeneral; |
|
982 |
} |
|
983 |
//Neagative Test Case |
|
984 |
} |
|
985 |
||
986 |
||
987 |
/*--------Test Logic Ends -----------*/ |
|
988 |
||
989 |
||
990 |
CleanupStack::PopAndDestroy( ); |
|
991 |
CleanupStack::PopAndDestroy( ); |
|
992 |
CleanupStack::PopAndDestroy( ); |
|
993 |
CleanupStack::PopAndDestroy( ); |
|
994 |
CleanupStack::PopAndDestroy( ); |
|
995 |
CleanupStack::PopAndDestroy( ); |
|
996 |
__UHEAP_MARK; |
|
997 |
return result; |
|
998 |
} |
|
999 |
||
1000 |
||
1001 |
||
1002 |
// ----------------------------------------------------------------------------- |
|
1003 |
// CAppManagerTest:launchDocL |
|
1004 |
// Example test method function. |
|
1005 |
// (other items were commented in a header). |
|
1006 |
// ----------------------------------------------------------------------------- |
|
1007 |
// |
|
1008 |
||
1009 |
TInt CAppManagerTest::CancellaunchDocL( CStifItemParser& aItem ) |
|
1010 |
{ |
|
1011 |
||
1012 |
||
1013 |
__UHEAP_MARK; |
|
1014 |
||
1015 |
||
1016 |
CLiwServiceHandler* iServiceHandler = CLiwServiceHandler::NewL(); |
|
1017 |
CleanupStack::PushL(iServiceHandler);//1 |
|
1018 |
||
1019 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1,KIAppManager,KService); |
|
1020 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
1021 |
CleanupStack::PushL(crit);//2 |
|
1022 |
||
1023 |
||
1024 |
RCriteriaArray critArray; |
|
1025 |
critArray.AppendL(crit); |
|
1026 |
CleanupClosePushL(critArray);//3 |
|
1027 |
||
1028 |
iServiceHandler->AttachL(critArray); |
|
1029 |
||
1030 |
||
1031 |
||
1032 |
CLiwGenericParamList* output = CLiwGenericParamList::NewL(); |
|
1033 |
CleanupStack::PushL(output);//4 |
|
1034 |
CLiwGenericParamList* input = CLiwGenericParamList::NewL(); |
|
1035 |
CleanupStack::PushL(input);//5 |
|
1036 |
||
1037 |
iServiceHandler->ExecuteServiceCmdL(*crit, *input, *output); |
|
1038 |
||
1039 |
||
1040 |
// Create the Instance of SAPI class and the Input Param and output Param |
|
1041 |
TInt pos = 0; |
|
1042 |
MLiwInterface* Interface = NULL; |
|
1043 |
output->FindFirst(pos,KIAppManager ); |
|
1044 |
if(pos != KErrNotFound) |
|
1045 |
{ |
|
1046 |
Interface = (*output)[pos].Value().AsInterface(); |
|
1047 |
} |
|
1048 |
output->Reset(); |
|
1049 |
||
1050 |
||
1051 |
||
1052 |
//MLiwInterface* Interface = CMgDataSourceInterface::NewL(); |
|
1053 |
CleanupClosePushL(*Interface);//6 |
|
1054 |
||
1055 |
/*--------Test Logic Starts-----------*/ |
|
1056 |
TOptions options; |
|
1057 |
TDocument criteria; |
|
1058 |
TInt expected; |
|
1059 |
TBuf<30> filename; |
|
1060 |
TPtrC16 path; |
|
1061 |
TPtrC16 handle; |
|
1062 |
TPtrC16 mimetype16; |
|
1063 |
TPtrC16 mode; |
|
1064 |
TPtrC16 callback; |
|
1065 |
TInt err; |
|
1066 |
TInt result =KErrNone ;// KErrGeneral; // 0 means pass and -1 means Fail |
|
1067 |
||
1068 |
||
1069 |
aItem.GetNextString(path); |
|
1070 |
aItem.GetNextString(handle); |
|
1071 |
aItem.GetNextString(mimetype16); |
|
1072 |
aItem.GetNextString(mode); |
|
1073 |
aItem.GetNextString(callback); |
|
1074 |
aItem.GetNextInt(expected); |
|
1075 |
||
1076 |
/*------------------------------------------------------------------*/ |
|
1077 |
||
1078 |
||
1079 |
//Inserting Document |
|
1080 |
||
1081 |
||
1082 |
CLiwDefaultMap *documentMap = NULL; |
|
1083 |
||
1084 |
if( path.CompareF(_L("NULL")) != 0 ) |
|
1085 |
{ |
|
1086 |
documentMap = CLiwDefaultMap::NewL(); |
|
1087 |
documentMap->InsertL(KDocumentPath,TLiwVariant(path)); |
|
1088 |
TLiwGenericParam iFilterParam( KDocument, TLiwVariant(documentMap)); |
|
1089 |
input->AppendL(iFilterParam); |
|
1090 |
documentMap->DecRef(); |
|
1091 |
} |
|
1092 |
||
1093 |
||
1094 |
if( handle.CompareF(_L("NULL") ) != 0) |
|
1095 |
{ |
|
1096 |
if( !documentMap ) |
|
1097 |
{ |
|
1098 |
documentMap = CLiwDefaultMap::NewL(); |
|
1099 |
TLiwGenericParam iFilterParam(KDocument, TLiwVariant(documentMap)); |
|
1100 |
input->AppendL(iFilterParam); |
|
1101 |
documentMap->DecRef(); |
|
1102 |
} |
|
1103 |
||
1104 |
RFs fileSession; |
|
1105 |
User::LeaveIfError(fileSession.Connect()); |
|
1106 |
RFile file; |
|
1107 |
User::LeaveIfError(fileSession.ShareProtected()); |
|
1108 |
file.Open(fileSession,handle,EFileShareReadersOnly); |
|
1109 |
//criteria.iHandle.Duplicate(file); |
|
1110 |
documentMap->InsertL(KHandle,TLiwVariant(file)); |
|
1111 |
} |
|
1112 |
||
1113 |
||
1114 |
||
1115 |
||
1116 |
//Inserting MimeType |
|
1117 |
if( 0 != mimetype16.CompareF(KNull) ) |
|
1118 |
{ |
|
1119 |
TLiwVariant mimetype; |
|
1120 |
mimetype.Set(mimetype16); |
|
1121 |
TLiwGenericParam mimetypeParam(KMimeType, mimetype); |
|
1122 |
input->AppendL(mimetypeParam); |
|
1123 |
} |
|
1124 |
||
1125 |
||
1126 |
||
1127 |
||
1128 |
if( mode.CompareF(_L("NULL")) != 0 ) |
|
1129 |
{ |
|
1130 |
CLiwDefaultMap *filterMap = CLiwDefaultMap::NewL(); |
|
1131 |
filterMap->InsertL(KMode,TLiwVariant(mode)); |
|
1132 |
TLiwGenericParam iFilterParam(KOptions, TLiwVariant(filterMap)); |
|
1133 |
input->AppendL(iFilterParam); |
|
1134 |
filterMap->DecRef(); |
|
1135 |
} |
|
1136 |
||
1137 |
||
1138 |
||
1139 |
if( callback.CompareF(_L("NULL")) != 0 ) |
|
1140 |
{ |
|
1141 |
//Aysnch Call; |
|
1142 |
CActiveSchedulerWait *wait = new CActiveSchedulerWait(); |
|
1143 |
CleanupStack::PushL( wait); |
|
1144 |
CAppObserver* callback = CAppObserver::NewL(wait); |
|
1145 |
CleanupStack::PushL( callback); |
|
1146 |
Interface->ExecuteCmdL(KLaunchDoc,*input,*output,KLiwOptASyncronous,callback); |
|
1147 |
const TLiwGenericParam* p= NULL; |
|
1148 |
pos = 0; |
|
1149 |
||
1150 |
p = output->FindFirst(pos, KErrorCode); // Finding Error Code |
|
1151 |
if(p) |
|
1152 |
{ |
|
1153 |
err = p->Value().AsTInt32(); |
|
1154 |
} |
|
1155 |
else |
|
1156 |
{ |
|
1157 |
err = KErrGeneral; |
|
1158 |
} |
|
1159 |
||
1160 |
if ( err == KErrNone) |
|
1161 |
{ |
|
1162 |
pos = 0; |
|
1163 |
p = output->FindFirst(pos, KTransactionID); |
|
1164 |
input->Reset(); |
|
1165 |
||
1166 |
input->AppendL( TLiwGenericParam (KTransactionID, TLiwVariant ( p->Value().AsTInt32() ) ) ); |
|
1167 |
//Interface->ExecuteCmdL(KLaunchDoc,*input,*output,KLiwOptCancel,callback); |
|
1168 |
//wait->Start(); |
|
1169 |
pos = 0; |
|
1170 |
||
1171 |
p = output->FindFirst(pos, KErrorCode); // Finding Error Code |
|
1172 |
if(p) |
|
1173 |
{ |
|
1174 |
err = p->Value().AsTInt32(); |
|
1175 |
} |
|
1176 |
else |
|
1177 |
{ |
|
1178 |
err = KErrGeneral; |
|
1179 |
} |
|
1180 |
||
1181 |
} |
|
1182 |
||
1183 |
CleanupStack::PopAndDestroy();//Callback |
|
1184 |
CleanupStack::PopAndDestroy();//Active Wait Scheduler |
|
1185 |
} |
|
1186 |
else |
|
1187 |
{ |
|
1188 |
//Synch call |
|
1189 |
if( Interface != NULL) |
|
1190 |
{ |
|
1191 |
_LIT8(KLaunchApp,"LaunchApp"); |
|
1192 |
Interface->ExecuteCmdL(KLaunchDoc,*input,*output); |
|
1193 |
} |
|
1194 |
else |
|
1195 |
{ |
|
1196 |
//Didn't get the interface |
|
1197 |
return KErrGeneral; |
|
1198 |
} |
|
1199 |
||
1200 |
||
1201 |
const TLiwGenericParam* p= NULL; |
|
1202 |
pos = 0; |
|
1203 |
p = output->FindFirst(pos, KErrorCode); // Finding Error Code |
|
1204 |
if(p) |
|
1205 |
{ |
|
1206 |
err = p->Value().AsTInt32(); |
|
1207 |
} |
|
1208 |
else |
|
1209 |
{ |
|
1210 |
err = KErrGeneral; |
|
1211 |
} |
|
1212 |
||
1213 |
p= NULL; |
|
1214 |
pos = 0; |
|
1215 |
p = output->FindFirst(pos, KDocumentName); // Finding Error Code |
|
1216 |
if(p) |
|
1217 |
{ |
|
1218 |
TPtrC filname ; |
|
1219 |
p->Value().Get(filname); |
|
1220 |
} |
|
1221 |
||
1222 |
} |
|
1223 |
||
1224 |
||
1225 |
if(!expected) |
|
1226 |
{ |
|
1227 |
//Postive Test Case |
|
1228 |
if(err != KErrNone) |
|
1229 |
{ |
|
1230 |
result = KErrGeneral; |
|
1231 |
} |
|
1232 |
||
1233 |
} |
|
1234 |
else |
|
1235 |
{ |
|
1236 |
if (err == KErrNone) |
|
1237 |
{ |
|
1238 |
result = KErrGeneral; |
|
1239 |
} |
|
1240 |
//Neagative Test Case |
|
1241 |
} |
|
1242 |
||
1243 |
||
1244 |
/*--------Test Logic Ends -----------*/ |
|
1245 |
||
1246 |
||
1247 |
CleanupStack::PopAndDestroy( ); |
|
1248 |
CleanupStack::PopAndDestroy( ); |
|
1249 |
CleanupStack::PopAndDestroy( ); |
|
1250 |
CleanupStack::PopAndDestroy( ); |
|
1251 |
CleanupStack::PopAndDestroy( ); |
|
1252 |
CleanupStack::PopAndDestroy( ); |
|
1253 |
__UHEAP_MARK; |
|
1254 |
return result; |
|
1255 |
} |
|
1256 |
||
1257 |
//Helper Function |
|
1258 |
||
1259 |
TInt CAppManagerTest::ConvertHexStringToInt32(const TDesC& aHexString,TInt32& aInt32 ) |
|
1260 |
{ |
|
1261 |
aInt32 = 0; |
|
1262 |
||
1263 |
TInt pos = aHexString.LocateF( 'x' ); |
|
1264 |
if ( pos == KErrNotFound ) |
|
1265 |
{ |
|
1266 |
pos = 0; |
|
1267 |
} |
|
1268 |
else |
|
1269 |
{ |
|
1270 |
pos++; |
|
1271 |
} |
|
1272 |
||
1273 |
if( ( aHexString.Length() - pos ) > KDocMaxDigitsInHexString ) |
|
1274 |
{ |
|
1275 |
return KErrArgument; // Error: value too big. |
|
1276 |
} |
|
1277 |
TPtrC aHexStringPtr( aHexString.Mid( pos ) ); |
|
1278 |
||
1279 |
TInt64 value64; |
|
1280 |
if ( TLex( aHexStringPtr ).Val( value64, EHex ) != KErrNone ) |
|
1281 |
{ |
|
1282 |
return KErrArgument; // Error: conversion failed. |
|
1283 |
} |
|
1284 |
aInt32 = value64; |
|
1285 |
||
1286 |
return KErrNone; |
|
1287 |
} |
|
1288 |
||
1289 |
// ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
1290 |
// None |
|
1291 |
||
1292 |
// End of File |