|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @test |
|
19 @internalComponent - Internal Symbian test code |
|
20 */ |
|
21 |
|
22 #include <e32std.h> |
|
23 #include <e32base.h> |
|
24 #include <f32file.h> |
|
25 #include <apgcli.h> |
|
26 #include <apmrec.h> |
|
27 #include <apaid.h> |
|
28 #include "testableapalssession.h" |
|
29 #include <apgicnfl.h> |
|
30 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
31 #include <apaidpartner.h> |
|
32 #include <apgicnflpartner.h> |
|
33 //#include <apgicnflinternal.h> |
|
34 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS |
|
35 #include <apmstd.h> |
|
36 #include <apacmdln.h> |
|
37 #include <e32property.h> |
|
38 #include <apgnotif.h> |
|
39 |
|
40 #include "../tef/TNonNative/TNNApp1.h" |
|
41 #include "T_NonNativeAppsStep.h" |
|
42 #include "appfwk_test.h" |
|
43 |
|
44 |
|
45 const TUint KApplicationType=0x10207f90; |
|
46 const TUint KApplicationA=0x10207f91; |
|
47 TUint KApplicationB = 0x2002237C; |
|
48 const TUint KMySID=0x101F289C; // apparctestserver UID |
|
49 const TUint KPropertyCategory=KMySID; |
|
50 const TUint KPropertyKey=0; |
|
51 const TUint KBytesToRead=100; |
|
52 |
|
53 _LIT8(KLit8_DataType_Gif, "x-epoc/nna-gif"); |
|
54 _LIT8(KLit8_DataType_Html, "x-epoc/nna-html"); |
|
55 _LIT8(KLit8_DataType_Vcard, "x-epoc/nna-vcf"); |
|
56 _LIT8(KLit8_DataType_plainText, "x-epoc/nna-txt"); |
|
57 |
|
58 _LIT(KLitLogicalExecutableA, "c:\\A.NNAPP2"); // this file never actually needs to exist |
|
59 _LIT(KLitApplicationCaptionA, "Caption NNA A"); |
|
60 _LIT(KLitDocumentName1, "nnapp2:1"); |
|
61 _LIT(KLitDocumentName2, "nnapp2:2"); |
|
62 _LIT(KLitDocumentName3, "nnapp2:3"); |
|
63 _LIT(KLitNativeExecutable, "z:\\sys\\bin\\TNNAPP2.EXE"); |
|
64 _LIT8(KLitMimeTypeA, "x-epoc/a-nnapp2"); |
|
65 _LIT8(KLitMimeTypeB, "x-epoc/dummy"); |
|
66 |
|
67 |
|
68 LOCAL_C void DeregisterNonNativeL(TAny* aApparcServer) |
|
69 { |
|
70 RApaLsSession& apparcServer=*STATIC_CAST(RApaLsSession*, aApparcServer); |
|
71 apparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
72 apparcServer.DeregisterNonNativeApplicationL(TUid::Uid(KApplicationA)); |
|
73 apparcServer.CommitNonNativeApplicationsUpdatesL(); |
|
74 apparcServer.DeregisterNonNativeApplicationTypeL(TUid::Uid(KApplicationType)); |
|
75 } |
|
76 |
|
77 |
|
78 // RTstFileArray |
|
79 |
|
80 RTstFileArray::RTstFileArray(TInt aGranularity) |
|
81 :iFileArray(aGranularity) |
|
82 { |
|
83 } |
|
84 |
|
85 void RTstFileArray::Close() |
|
86 { |
|
87 for (TInt i=iFileArray.Count()-1; i>=0; --i) |
|
88 { |
|
89 const SFile& file=iFileArray[i]; |
|
90 delete file.iFullFileName; |
|
91 delete file.iExpectedDataType; |
|
92 } |
|
93 iFileArray.Close(); |
|
94 } |
|
95 |
|
96 void RTstFileArray::AppendL(const TDesC& aFullFileName, const TDesC8& aExpectedDataType) |
|
97 { |
|
98 SFile file; |
|
99 file.iFullFileName=aFullFileName.AllocLC(); |
|
100 file.iExpectedDataType=aExpectedDataType.AllocLC(); |
|
101 iFileArray.AppendL(file); |
|
102 CleanupStack::Pop(2, file.iFullFileName); |
|
103 } |
|
104 |
|
105 void RTstFileArray::Get(TPtrC& aFullFileName, TPtrC8& aExpectedDataType, TInt aIndex) const |
|
106 { |
|
107 const SFile& file=iFileArray[aIndex]; |
|
108 aFullFileName.Set(*file.iFullFileName); |
|
109 aExpectedDataType.Set(*file.iExpectedDataType); |
|
110 } |
|
111 |
|
112 |
|
113 // RTstAppService |
|
114 |
|
115 TInt RTstAppService::DoTestL(TUid aServiceUid, TBool aPassingFileByHandle, const TDesC& aFileNameWithoutDriveOrPath) |
|
116 { // static |
|
117 RTstAppService appService(aServiceUid); |
|
118 CleanupClosePushL(appService); |
|
119 |
|
120 TInt error=KErrNone; |
|
121 |
|
122 //Try maximum 6 times to connect to server application |
|
123 for(TInt loopCount=0; loopCount<6; loopCount++) |
|
124 { |
|
125 TRAP(error, appService.ConnectL()); |
|
126 if(error==KErrNone) |
|
127 break; |
|
128 |
|
129 if(error!=KErrNotFound) |
|
130 User::Leave(error); |
|
131 |
|
132 User::After(1000000); //wait till one second before trying again |
|
133 } |
|
134 |
|
135 User::LeaveIfError(error); |
|
136 |
|
137 TRequestStatus requestStatus; |
|
138 appService.ReceiveTestResult(requestStatus, aPassingFileByHandle, aFileNameWithoutDriveOrPath); |
|
139 User::WaitForRequest(requestStatus); |
|
140 const TInt result=User::LeaveIfError(requestStatus.Int()); |
|
141 CleanupStack::PopAndDestroy(&appService); |
|
142 User::After(5 * 1000000); //Wait 5sec for Apparc update due to paging |
|
143 return result; |
|
144 } |
|
145 |
|
146 RTstAppService::RTstAppService(TUid aServiceUid) |
|
147 :iServiceUid(aServiceUid) |
|
148 { |
|
149 } |
|
150 |
|
151 void RTstAppService::ConnectL() |
|
152 { |
|
153 ConnectExistingByNameL(KLitServerName); |
|
154 } |
|
155 |
|
156 void RTstAppService::ReceiveTestResult(TRequestStatus& aRequestStatus, TBool aPassingFileByHandle, const TDesC& aFileNameWithoutDriveOrPath) |
|
157 { |
|
158 SendReceive(EOpcode_receiveTestResult, TIpcArgs(aPassingFileByHandle, &aFileNameWithoutDriveOrPath), aRequestStatus); |
|
159 } |
|
160 |
|
161 TUid RTstAppService::ServiceUid() const |
|
162 { |
|
163 return iServiceUid; |
|
164 } |
|
165 |
|
166 |
|
167 // top-level functions |
|
168 |
|
169 HBufC8* CT_NonNativeAppsStep::OpenFileAndReadBufferLC(RApaLsSession& aApparcServer, RFs& aFileServer, const TDesC& aFullFileName) |
|
170 { |
|
171 TInt preferredBufSize=0; |
|
172 User::LeaveIfError(aApparcServer.GetPreferredBufSize(preferredBufSize)); |
|
173 HBufC8* const buffer=HBufC8::NewLC(preferredBufSize); |
|
174 RFile file; |
|
175 CleanupClosePushL(file); |
|
176 User::LeaveIfError(file.Open(aFileServer, aFullFileName, EFileShareReadersOnly|EFileStream|EFileRead)); |
|
177 {TPtr8 buffer_asWritable(buffer->Des()); |
|
178 User::LeaveIfError(file.Read(buffer_asWritable));} |
|
179 CleanupStack::PopAndDestroy(&file); |
|
180 return buffer; |
|
181 } |
|
182 |
|
183 void CT_NonNativeAppsStep::OpenFileAndSetFilePositionToSomewhereUnusualLC(RFile& aFile, TInt& aFilePosition, RFs& aFileServer, const TDesC& aFullFileName) |
|
184 { |
|
185 CleanupClosePushL(aFile); |
|
186 User::LeaveIfError(aFile.Open(aFileServer, aFullFileName, EFileShareReadersOnly|EFileStream|EFileRead)); |
|
187 aFilePosition=0; |
|
188 User::LeaveIfError(aFile.Seek(ESeekEnd, aFilePosition)); |
|
189 aFilePosition=(aFilePosition*83)/100; // set it to somewhere "random" in the middle of the file (83% of the way through) |
|
190 User::LeaveIfError(aFile.Seek(ESeekStart, aFilePosition)); |
|
191 } |
|
192 |
|
193 void CT_NonNativeAppsStep::TestFilePosition(RFile& aFile, TInt aFilePosition) |
|
194 { |
|
195 TInt filePosition=0; |
|
196 TEST(aFile.Seek(ESeekCurrent, filePosition) == KErrNone); |
|
197 TEST(filePosition==aFilePosition); |
|
198 } |
|
199 |
|
200 /** |
|
201 @SYMTestCaseID T_NonNativeAppsStep-TestAppForDocument |
|
202 |
|
203 @SYMDEF DEF065742 |
|
204 |
|
205 @SYMTestCaseDesc Tests AppForDocument API for non native applications. |
|
206 |
|
207 @SYMTestPriority High |
|
208 |
|
209 @SYMTestStatus Implemented |
|
210 |
|
211 @SYMTestActions Call AppForDocument, first with the file name, and then with the file data, with a series of different known files. |
|
212 API Calls:\n |
|
213 RApaLsSession::AppForDocument(const TDesC &aFileName, TUid &aAppUid, TDataType &aDataType) const;\n |
|
214 RApaLsSession::AppForDocument(RFile &aFile, TUid &aAppUid, TDataType &aDataType) const;\n |
|
215 |
|
216 @SYMTestExpectedResults Test checks MIME type and UIDs obtained match the expected ones. |
|
217 */ |
|
218 void CT_NonNativeAppsStep::TestAppForDocumentL(RApaLsSession& aApparcServer, RFs& aFileServer, const RTstFileArray& aFileArray) |
|
219 { |
|
220 INFO_PRINTF1(_L("Testing AppForDocumentL()...")); |
|
221 for (TInt i=aFileArray.Count()-1; i>=0; --i) |
|
222 { |
|
223 TPtrC fullFileName; |
|
224 TPtrC8 expectedDataType; |
|
225 aFileArray.Get(fullFileName, expectedDataType, i); |
|
226 |
|
227 TPtrC fileNameWithoutDriveOrPath(TParsePtrC(fullFileName).NameAndExt()); |
|
228 INFO_PRINTF2(_L("..using following file: '%S'"), &fileNameWithoutDriveOrPath); |
|
229 |
|
230 { |
|
231 TDataType dataType; |
|
232 TUid appUid; |
|
233 //due to access of file in private folder |
|
234 APPFWK_EXPECTED_PLATSEC_START; |
|
235 User::LeaveIfError(aApparcServer.AppForDocument(fullFileName, appUid, dataType)); |
|
236 RDebug::Print(_L("The Full FileName is '%S' "),&fullFileName); |
|
237 APPFWK_EXPECTED_PLATSEC_FINISH; |
|
238 TEST(dataType.Des8().CompareF(expectedDataType)==0); |
|
239 TEST(appUid.iUid==0x10207f92); |
|
240 } |
|
241 |
|
242 RFile file; |
|
243 TInt originalFilePosition=0; |
|
244 OpenFileAndSetFilePositionToSomewhereUnusualLC(file, originalFilePosition, aFileServer, fullFileName); |
|
245 |
|
246 { |
|
247 TDataType dataType; |
|
248 TUid appUid; |
|
249 User::LeaveIfError(aApparcServer.AppForDocument(file, appUid, dataType)); |
|
250 TEST(dataType.Des8().CompareF(expectedDataType)==0); |
|
251 TEST(appUid.iUid==0x10207f92); |
|
252 |
|
253 TestFilePosition(file, originalFilePosition); |
|
254 CleanupStack::PopAndDestroy(&file); |
|
255 } |
|
256 } |
|
257 } |
|
258 |
|
259 void CT_NonNativeAppsStep::TestResultsOfAppForDocumentAndServiceL(TUid aServiceUid, TInt aError, |
|
260 const TUid& aAppUid, // aAppUid needs to be passed by reference (rather than by value) because of the way that this function is called, namely the aAppUid parameter seems to be put into the stack before the expression passed to the aError parameter has executed, the latter having the side-effect of changing the app-UID |
|
261 const TDataType& aDataType, const TDesC8& aExpectedDataType) |
|
262 { |
|
263 if (aServiceUid.iUid==0x10207f99) |
|
264 { |
|
265 User::LeaveIfError(aError); |
|
266 TEST(aDataType.Des8().CompareF(aExpectedDataType)==0); |
|
267 (aDataType.Des8().CompareF(KLit8_DataType_Gif)==0) ? TEST(aAppUid.iUid==0x10207f94) : TEST(aAppUid.iUid==0); |
|
268 } |
|
269 else |
|
270 { |
|
271 User::LeaveIfError(aError); |
|
272 TEST(aDataType.Des8().CompareF(aExpectedDataType)==0); |
|
273 TEST(aAppUid.iUid==0x10207f92); |
|
274 } |
|
275 } |
|
276 |
|
277 /** |
|
278 @SYMTestCaseID T_NonNativeAppsStep-TestAppForDocumentAndServiceL |
|
279 |
|
280 @SYMDEF DEF065742 |
|
281 |
|
282 @SYMTestCaseDesc Tests AppForDocumentAndService API for non native applications. |
|
283 |
|
284 @SYMTestPriority High |
|
285 |
|
286 @SYMTestStatus Implemented |
|
287 |
|
288 @SYMTestActions Call AppForDocumentAndService, first with the file name, and then with the file data, with a series of different known files and serviceUIDs. |
|
289 Note the following: |
|
290 - TNNAPP1 defines in the datatype_list the 4 datatypes, while in the service_list, only 1 datatype is defined. |
|
291 - TNNAPP2 defines no datatype_list, while it just contains 1 datatype in the service_list. |
|
292 - The datatype of the file to be opened is searched in the service_list corresponding to the serviceUID. If not found, |
|
293 the datatype_list of the same reg file is searched. If not found there, it returns a KNullUid as the app. |
|
294 - It means that the service_list has 'priority' over the datatype_list in the same reg file. |
|
295 API Calls:\n |
|
296 RApaLsSession::AppForDocumentAndService(const TDesC &aFileName, TUid aServiceUid, TUid &aAppUid, TDataType &aDataType) const;\n |
|
297 RApaLsSession::AppForDocumentAndService(RFile &aFile, TUid aServiceUid, TUid &aAppUid, TDataType &aDataType) const;\n |
|
298 |
|
299 @SYMTestExpectedResults Test checks MIME type and UIDs obtained match the expected ones. |
|
300 */ |
|
301 void CT_NonNativeAppsStep::TestAppForDocumentAndServiceL(RApaLsSession& aApparcServer, RFs& aFileServer, const RTstFileArray& aFileArray) |
|
302 { |
|
303 INFO_PRINTF1(_L("Testing AppForDocumentAndServiceL()...")); |
|
304 for (TInt i=aFileArray.Count()-1; i>=0; --i) |
|
305 { |
|
306 TPtrC fullFileName; |
|
307 TPtrC8 expectedDataType; |
|
308 aFileArray.Get(fullFileName, expectedDataType, i); |
|
309 |
|
310 TPtrC fileNameWithoutDriveOrPath(TParsePtrC(fullFileName).NameAndExt()); |
|
311 INFO_PRINTF2(_L("..using following file: '%S'"), &fileNameWithoutDriveOrPath); |
|
312 |
|
313 { |
|
314 TDataType dataType; |
|
315 TUid appUid; |
|
316 TUid serviceUid(TUid::Uid(0x10207f99)); |
|
317 //due to access of file in private folder |
|
318 APPFWK_EXPECTED_PLATSEC_START; |
|
319 TestResultsOfAppForDocumentAndServiceL(serviceUid, aApparcServer.AppForDocumentAndService(fullFileName, serviceUid, appUid, dataType), appUid, dataType, expectedDataType); |
|
320 APPFWK_EXPECTED_PLATSEC_FINISH; |
|
321 serviceUid.iUid=0x10207f93; |
|
322 //due to access of file in private folder |
|
323 APPFWK_EXPECTED_PLATSEC_START; |
|
324 TestResultsOfAppForDocumentAndServiceL(serviceUid, aApparcServer.AppForDocumentAndService(fullFileName, serviceUid, appUid, dataType), appUid, dataType, expectedDataType); |
|
325 APPFWK_EXPECTED_PLATSEC_FINISH; |
|
326 } |
|
327 |
|
328 { |
|
329 RFile file; |
|
330 TInt originalFilePosition=0; |
|
331 OpenFileAndSetFilePositionToSomewhereUnusualLC(file, originalFilePosition, aFileServer, fullFileName); |
|
332 |
|
333 TDataType dataType; |
|
334 TUid appUid; |
|
335 TUid serviceUid(TUid::Uid(0x10207f99)); |
|
336 TestResultsOfAppForDocumentAndServiceL(serviceUid, aApparcServer.AppForDocumentAndService(file, serviceUid, appUid, dataType), appUid, dataType, expectedDataType); |
|
337 serviceUid.iUid=0x10207f93; |
|
338 TestResultsOfAppForDocumentAndServiceL(serviceUid, aApparcServer.AppForDocumentAndService(file, serviceUid, appUid, dataType), appUid, dataType, expectedDataType); |
|
339 |
|
340 TestFilePosition(file, originalFilePosition); |
|
341 CleanupStack::PopAndDestroy(&file); |
|
342 } |
|
343 } |
|
344 } |
|
345 |
|
346 /** |
|
347 @SYMTestCaseID T_NonNativeAppsStep-TestRecognizingL |
|
348 |
|
349 @SYMDEF DEF065742 |
|
350 |
|
351 @SYMTestCaseDesc Tests RecognizeData API for non native applications. |
|
352 |
|
353 @SYMTestPriority High |
|
354 |
|
355 @SYMTestStatus Implemented |
|
356 |
|
357 @SYMTestActions Call RecognizeData, first with the file name, and then with the file data, with a series of different known files. |
|
358 API Calls:\n |
|
359 RApaLsSession::RecognizeData(const TDesC &aName, const TDesC8 &aBuffer, TDataRecognitionResult &aDataType) const;\n |
|
360 RApaLsSession::RecognizeData(RFile &aFile, TDataRecognitionResult &aDataType) const;\n |
|
361 |
|
362 @SYMTestExpectedResults Test checks MIME type and conficence obtained match the expected ones. |
|
363 */ |
|
364 void CT_NonNativeAppsStep::TestRecognizingL(RApaLsSession& aApparcServer, RFs& aFileServer, const RTstFileArray& aFileArray) |
|
365 { |
|
366 INFO_PRINTF1(_L("Testing RecognizingL()...")); |
|
367 for (TInt i=aFileArray.Count()-1; i>=0; --i) |
|
368 { |
|
369 TPtrC fullFileName; |
|
370 TPtrC8 expectedDataType; |
|
371 aFileArray.Get(fullFileName, expectedDataType, i); |
|
372 |
|
373 TPtrC fileNameWithoutDriveOrPath(TParsePtrC(fullFileName).NameAndExt()); |
|
374 INFO_PRINTF2(_L("..using following file: '%S'"), &fileNameWithoutDriveOrPath); |
|
375 |
|
376 { |
|
377 RFile file; |
|
378 TInt originalFilePosition=0; |
|
379 OpenFileAndSetFilePositionToSomewhereUnusualLC(file, originalFilePosition, aFileServer, fullFileName); |
|
380 |
|
381 TDataRecognitionResult dataRecognitionResult; |
|
382 dataRecognitionResult.Reset(); |
|
383 User::LeaveIfError(aApparcServer.RecognizeData(file, dataRecognitionResult)); |
|
384 TEST(dataRecognitionResult.iConfidence>=CApaDataRecognizerType::EProbable); |
|
385 TEST(dataRecognitionResult.iDataType.Des8().CompareF(expectedDataType)==0); |
|
386 |
|
387 TestFilePosition(file, originalFilePosition); |
|
388 CleanupStack::PopAndDestroy(&file); |
|
389 } |
|
390 |
|
391 { |
|
392 RFile file; |
|
393 TInt originalFilePosition=0; |
|
394 OpenFileAndSetFilePositionToSomewhereUnusualLC(file, originalFilePosition, aFileServer, fullFileName); |
|
395 |
|
396 TBool result=EFalse; |
|
397 User::LeaveIfError(aApparcServer.RecognizeSpecificData(file, TDataType(expectedDataType), result)); |
|
398 TEST(result); |
|
399 |
|
400 TestFilePosition(file, originalFilePosition); |
|
401 CleanupStack::PopAndDestroy(&file); |
|
402 } |
|
403 |
|
404 { |
|
405 HBufC8* const buffer=OpenFileAndReadBufferLC(aApparcServer, aFileServer, fullFileName); |
|
406 |
|
407 TDataRecognitionResult dataRecognitionResult; |
|
408 dataRecognitionResult.Reset(); |
|
409 APPFWK_EXPECTED_PLATSEC_START; |
|
410 User::LeaveIfError(aApparcServer.RecognizeData(fullFileName, *buffer, dataRecognitionResult)); |
|
411 APPFWK_EXPECTED_PLATSEC_FINISH; |
|
412 TEST(dataRecognitionResult.iConfidence>=CApaDataRecognizerType::EProbable); |
|
413 TEST(dataRecognitionResult.iDataType.Des8().CompareF(expectedDataType)==0); |
|
414 |
|
415 CleanupStack::PopAndDestroy(buffer); |
|
416 } |
|
417 |
|
418 { |
|
419 HBufC8* const buffer=OpenFileAndReadBufferLC(aApparcServer, aFileServer, fullFileName); |
|
420 |
|
421 TBool result=EFalse; |
|
422 User::LeaveIfError(aApparcServer.RecognizeSpecificData(fullFileName, *buffer, TDataType(expectedDataType), result)); |
|
423 TEST(result); |
|
424 |
|
425 CleanupStack::PopAndDestroy(buffer); |
|
426 } |
|
427 } |
|
428 } |
|
429 |
|
430 /** |
|
431 @SYMTestCaseID T_NonNativeAppsStep-TestStartDocumentL |
|
432 |
|
433 @SYMDEF DEF065742 |
|
434 |
|
435 @SYMTestCaseDesc Tests StartDocument API for non native applications. |
|
436 |
|
437 @SYMTestPriority High |
|
438 |
|
439 @SYMTestStatus Implemented |
|
440 |
|
441 @SYMTestActions Call StartDocument, either with the file name as a parameter or a file handle. The test presupposes that when |
|
442 the file is passed by name, it can't be oppened as it's in a private folder (since the app doesn't have AllFiles capability). |
|
443 These provokes few negative platsec errors in the epocwind.out file. |
|
444 On the other hand, when the file is passed by handle, there are no problems opening the file. No platsec errors should be reported. |
|
445 API Calls:\n |
|
446 RApaLsSession::StartDocument(const TDesC &aFileName, TThreadId &aThreadId, TLaunchType aLaunchType=ELaunchNewApp);\n |
|
447 RApaLsSession::StartDocument(RFile &aFile, TThreadId &aThreadId, TRequestStatus *aRequestStatusForRendezvous=0);\n |
|
448 RApaLsSession::StartDocument(const TDesC &aFileName, const TDataType &aDataType, TThreadId &aThreadId, TLaunchType aLaunchType=ELaunchNewApp);\n |
|
449 RApaLsSession::StartDocument(RFile &aFile, const TDataType &aDataType, TThreadId &aThreadId, TRequestStatus *aRequestStatusForRendezvous=0);\n |
|
450 |
|
451 @SYMTestExpectedResults Test the requeststatus obtained match the expected one. |
|
452 */ |
|
453 void CT_NonNativeAppsStep::TestStartDocumentL(RApaLsSession& aApparcServer, RFs& aFileServer, const RTstFileArray& aFileArray) |
|
454 { |
|
455 INFO_PRINTF1(_L("Testing StartDocumentL()...")); |
|
456 for (TInt i=aFileArray.Count()-1; i>=0; --i) |
|
457 { |
|
458 TPtrC fullFileName; |
|
459 TPtrC8 expectedDataType; |
|
460 aFileArray.Get(fullFileName, expectedDataType, i); |
|
461 |
|
462 TPtrC fileNameWithoutDriveOrPath(TParsePtrC(fullFileName).NameAndExt()); |
|
463 INFO_PRINTF2(_L("..using following file: '%S'"), &fileNameWithoutDriveOrPath); |
|
464 |
|
465 for (TInt j=0; j<2; ++j) |
|
466 { |
|
467 const TUid serviceUid=(j==0)? KTstServiceUid_nonSecure: KTstServiceUid_secure; |
|
468 { |
|
469 RFile file; |
|
470 TInt originalFilePosition=0; |
|
471 OpenFileAndSetFilePositionToSomewhereUnusualLC(file, originalFilePosition, aFileServer, fullFileName); |
|
472 |
|
473 TThreadId threadId; |
|
474 TRequestStatus requestStatusForRendezvous; |
|
475 User::LeaveIfError(aApparcServer.StartDocument(file, threadId, &requestStatusForRendezvous)); |
|
476 User::WaitForRequest(requestStatusForRendezvous); |
|
477 TEST(RTstAppService::DoTestL(serviceUid, ETrue, fileNameWithoutDriveOrPath) == KCheckPass); |
|
478 |
|
479 TestFilePosition(file, originalFilePosition); |
|
480 CleanupStack::PopAndDestroy(&file); |
|
481 } |
|
482 |
|
483 { |
|
484 RFile file; |
|
485 TInt originalFilePosition=0; |
|
486 OpenFileAndSetFilePositionToSomewhereUnusualLC(file, originalFilePosition, aFileServer, fullFileName); |
|
487 |
|
488 TThreadId threadId; |
|
489 TRequestStatus requestStatusForRendezvous; |
|
490 User::LeaveIfError(aApparcServer.StartDocument(file, TDataType(expectedDataType), threadId, &requestStatusForRendezvous)); |
|
491 User::WaitForRequest(requestStatusForRendezvous); |
|
492 TEST(RTstAppService::DoTestL(serviceUid, ETrue, fileNameWithoutDriveOrPath) == KCheckPass); |
|
493 |
|
494 TestFilePosition(file, originalFilePosition); |
|
495 CleanupStack::PopAndDestroy(&file); |
|
496 } |
|
497 |
|
498 { |
|
499 RFile file; |
|
500 TInt originalFilePosition=0; |
|
501 OpenFileAndSetFilePositionToSomewhereUnusualLC(file, originalFilePosition, aFileServer, fullFileName); |
|
502 |
|
503 TThreadId threadId; |
|
504 TRequestStatus requestStatusForRendezvous; |
|
505 User::LeaveIfError(aApparcServer.StartDocument(file, TUid::Uid(0x10207f92), threadId, &requestStatusForRendezvous)); |
|
506 User::WaitForRequest(requestStatusForRendezvous); |
|
507 TEST(RTstAppService::DoTestL(serviceUid, ETrue, fileNameWithoutDriveOrPath) == KCheckPass); |
|
508 |
|
509 TestFilePosition(file, originalFilePosition); |
|
510 CleanupStack::PopAndDestroy(&file); |
|
511 } |
|
512 |
|
513 { |
|
514 TThreadId threadId; |
|
515 //due to access of file in private folder |
|
516 APPFWK_EXPECTED_PLATSEC_START; |
|
517 User::LeaveIfError(aApparcServer.StartDocument(fullFileName, threadId)); |
|
518 APPFWK_EXPECTED_PLATSEC_FINISH; |
|
519 TEST(RTstAppService::DoTestL(serviceUid, EFalse, fileNameWithoutDriveOrPath) == KCheckPass); |
|
520 } |
|
521 |
|
522 { |
|
523 TThreadId threadId; |
|
524 User::LeaveIfError(aApparcServer.StartDocument(fullFileName, TDataType(expectedDataType), threadId)); |
|
525 TEST(RTstAppService::DoTestL(serviceUid, EFalse, fileNameWithoutDriveOrPath) == KCheckPass); |
|
526 } |
|
527 |
|
528 { |
|
529 TThreadId threadId; |
|
530 User::LeaveIfError(aApparcServer.StartDocument(fullFileName, TUid::Uid(0x10207f92), threadId)); |
|
531 TEST(RTstAppService::DoTestL(serviceUid, EFalse, fileNameWithoutDriveOrPath) == KCheckPass); |
|
532 } |
|
533 } |
|
534 } |
|
535 //avoid race conditions |
|
536 User::After(1500000); |
|
537 } |
|
538 |
|
539 void CT_NonNativeAppsStep::CheckPropertyUpdateAndResetL(const TDesC& aExpectedNewValue) |
|
540 { |
|
541 __ASSERT_ALWAYS(aExpectedNewValue.Length()>0, User::Invariant()); |
|
542 RProperty property; |
|
543 CleanupClosePushL(property); |
|
544 User::LeaveIfError(property.Attach(TUid::Uid(KPropertyCategory), KPropertyKey)); |
|
545 TRequestStatus requestStatus; |
|
546 property.Subscribe(requestStatus); |
|
547 TBuf<50> propertyValue; |
|
548 User::LeaveIfError(property.Get(propertyValue)); |
|
549 if (propertyValue.Length()>0) |
|
550 { |
|
551 property.Cancel(); |
|
552 } |
|
553 User::WaitForRequest(requestStatus); |
|
554 if (propertyValue.Length()==0) |
|
555 { |
|
556 User::LeaveIfError(property.Get(propertyValue)); |
|
557 } |
|
558 TEST(propertyValue.CompareF(aExpectedNewValue)==0); |
|
559 User::LeaveIfError(property.Set(KNullDesC)); // reset it to an empty descriptor |
|
560 CleanupStack::PopAndDestroy(&property); |
|
561 } |
|
562 |
|
563 void CT_NonNativeAppsStep::CheckApplicationLaunchesOkayL(RApaLsSession& aApparcServer, const CApaCommandLine& aCommandLine, TOption aOption) |
|
564 { |
|
565 TThreadId notUsed; |
|
566 switch(aOption) |
|
567 { |
|
568 case EAppA: |
|
569 INFO_PRINTF1(_L("..Checking ApplicationLaunchesOkayL for app 'A'..")); |
|
570 User::LeaveIfError(aApparcServer.StartDocument(KLitDocumentName1, TDataType(KLitMimeTypeA), notUsed)); |
|
571 CheckPropertyUpdateAndResetL(KLitDocumentName1); |
|
572 User::LeaveIfError(aApparcServer.StartApp(aCommandLine)); |
|
573 CheckPropertyUpdateAndResetL(KLitDocumentName2); |
|
574 break; |
|
575 case EAppB: |
|
576 INFO_PRINTF1(_L("..Checking ApplicationLaunchesOkayL for app 'B'..")); |
|
577 TEST( aApparcServer.StartDocument(KLitDocumentName3, TDataType(KLitMimeTypeB), notUsed) == KErrNone); |
|
578 CheckPropertyUpdateAndResetL(KLitDocumentName3); |
|
579 break; |
|
580 default: |
|
581 break; |
|
582 } |
|
583 } |
|
584 |
|
585 void CT_NonNativeAppsStep::CheckApplicationFailsToLaunchL(RApaLsSession& aApparcServer, const CApaCommandLine& aCommandLine, TOption aOption) |
|
586 { |
|
587 TThreadId notUsed; |
|
588 switch(aOption) |
|
589 { |
|
590 case EAppA: |
|
591 INFO_PRINTF1(_L("..Checking ApplicationFailsToLaunchL for app 'A'..")); |
|
592 TEST(aApparcServer.StartDocument(KLitDocumentName1, TDataType(KLitMimeTypeA), notUsed) != KErrNone); |
|
593 TEST(aApparcServer.StartApp(aCommandLine)!=KErrNone); |
|
594 break; |
|
595 case EAppB: |
|
596 INFO_PRINTF1(_L("..Checking ApplicationFailsToLaunchL for app 'B'..")); |
|
597 TEST( aApparcServer.StartDocument(KLitDocumentName3, TDataType(KLitMimeTypeB), notUsed) != KErrNone); |
|
598 break; |
|
599 default: |
|
600 break; |
|
601 } |
|
602 } |
|
603 |
|
604 /** |
|
605 @SYMTestCaseID T_NonNativeAppsStep-TestRegisterNonNativeApplicationL |
|
606 |
|
607 @SYMDEF DEF065742 |
|
608 |
|
609 @SYMTestCaseDesc Tests RegisterNonNativeApplicationL and DeregisterNonNativeApplicationL API for non native applications. |
|
610 |
|
611 @SYMTestPriority High |
|
612 |
|
613 @SYMTestStatus Implemented |
|
614 |
|
615 @SYMTestActions Call RegisterNonNativeApplicationL and try to launch the app. Then call |
|
616 DeregisterNonNativeApplicationL and try to launch the app again. This is repeated with |
|
617 localisable resource files, etc., etc.. |
|
618 API Calls:\n |
|
619 RApaLsSession::RegisterNonNativeApplicationL(TUid aApplicationType, const TDriveUnit& aDrive, CApaRegistrationResourceFileWriter& aRegistrationResourceFile, CApaLocalisableResourceFileWriter* aLocalisableResourceFile, RFile* aIconFile); \n |
|
620 RApaLsSession::DeregisterNonNativeApplicationL(TUid aApplication);\n |
|
621 RApaLsSession::GetAppIcon(TUid aAppUid, RFile& aFile) const; \n |
|
622 |
|
623 @SYMTestExpectedResults Test checks if app is registered (and launches ok) and deregistered (and fails to launch). |
|
624 */ |
|
625 void CT_NonNativeAppsStep::TestRegisterNonNativeApplicationL(RApaLsSession& aApparcServer, RFs& aFileServer ) |
|
626 { |
|
627 INFO_PRINTF1(_L("Testing RegisterNonNativeApplicationL()...")); |
|
628 |
|
629 RProcess().SetPriority(EPriorityLow); // so that we're pre-empted by the Apparc server when it does its scan |
|
630 |
|
631 CApaCommandLine* commandLine=NULL; |
|
632 User::LeaveIfError(CApaCommandLine::GetCommandLineFromProcessEnvironment(commandLine)); |
|
633 CleanupStack::PushL(commandLine); |
|
634 const TPtrC executableName(commandLine->ExecutableName()); |
|
635 |
|
636 _LIT_SECURITY_POLICY_S0(readSecurityPolicy, KMySID); |
|
637 _LIT_SECURITY_POLICY_PASS(writeSecurityPolicy); |
|
638 const TInt error=RProperty::Define(KPropertyKey, RProperty::EText, readSecurityPolicy, writeSecurityPolicy); |
|
639 if (error!=KErrAlreadyExists) |
|
640 { |
|
641 User::LeaveIfError(error); |
|
642 } |
|
643 User::LeaveIfError(RProperty::Set(TUid::Uid(KPropertyCategory), KPropertyKey, KNullDesC)); |
|
644 |
|
645 // make sure we're starting from a clean sheet |
|
646 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
647 aApparcServer.DeregisterNonNativeApplicationL(TUid::Uid(KApplicationA)); |
|
648 aApparcServer.CommitNonNativeApplicationsUpdatesL(); |
|
649 aApparcServer.DeregisterNonNativeApplicationTypeL(TUid::Uid(KApplicationType)); |
|
650 CleanupStack::PushL(TCleanupItem(DeregisterNonNativeL, &aApparcServer)); |
|
651 |
|
652 aApparcServer.RegisterNonNativeApplicationTypeL(TUid::Uid(KApplicationType), KLitNativeExecutable); |
|
653 |
|
654 CApaRegistrationResourceFileWriter* const registrationResourceFileWriter=CApaRegistrationResourceFileWriter::NewL(TUid::Uid(KApplicationA), KLitLogicalExecutableA, TApaAppCapability::ENonNative); |
|
655 CleanupStack::PushL(registrationResourceFileWriter); |
|
656 registrationResourceFileWriter->AddDataTypeL(KDataTypePriorityNormal, KLitMimeTypeA); |
|
657 |
|
658 CApaCommandLine* const nextCommandLine=CApaCommandLine::NewLC(); |
|
659 nextCommandLine->SetDocumentNameL(KLitDocumentName2); |
|
660 nextCommandLine->SetExecutableNameL(KLitLogicalExecutableA); |
|
661 |
|
662 INFO_PRINTF1(_L("..registering app using RegisterNonNativeApplicationL() ")); |
|
663 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
664 aApparcServer.RegisterNonNativeApplicationL(TUid::Uid(KApplicationType), EDriveC, *registrationResourceFileWriter, NULL, NULL); |
|
665 aApparcServer.CommitNonNativeApplicationsUpdatesL(); |
|
666 CheckApplicationLaunchesOkayL(aApparcServer, *nextCommandLine, EAppA); |
|
667 //Check if there is no problem in registering same app again(basically simulating an upgrade) |
|
668 INFO_PRINTF1(_L("..registering same app again using RegisterNonNativeApplicationL() ")); |
|
669 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
670 aApparcServer.RegisterNonNativeApplicationL(TUid::Uid(KApplicationType), EDriveC, *registrationResourceFileWriter, NULL, NULL); |
|
671 aApparcServer.CommitNonNativeApplicationsUpdatesL(); |
|
672 CheckApplicationLaunchesOkayL(aApparcServer, *nextCommandLine, EAppA); |
|
673 |
|
674 INFO_PRINTF1(_L("..deregistering app using DeregisterNonNativeApplicationL() ")); |
|
675 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
676 aApparcServer.DeregisterNonNativeApplicationL(TUid::Uid(KApplicationA)); |
|
677 aApparcServer.CommitNonNativeApplicationsUpdatesL(); |
|
678 CheckApplicationFailsToLaunchL(aApparcServer, *nextCommandLine, EAppA); |
|
679 |
|
680 _LIT8(KLitOpData, "opaquedata"); |
|
681 registrationResourceFileWriter->SetOpaqueDataL(KLitOpData); |
|
682 |
|
683 CApaLocalisableResourceFileWriter* const localisableResourceFileWriter_noIcons=CApaLocalisableResourceFileWriter::NewL(KNullDesC, KLitApplicationCaptionA, 0, KNullDesC); |
|
684 CleanupStack::PushL(localisableResourceFileWriter_noIcons); |
|
685 INFO_PRINTF1(_L("..registering app using RegisterNonNativeApplicationL() with localisableResourceFileWriter_noIcons")); |
|
686 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
687 aApparcServer.RegisterNonNativeApplicationL(TUid::Uid(KApplicationType), EDriveC, *registrationResourceFileWriter, localisableResourceFileWriter_noIcons, NULL); |
|
688 aApparcServer.CommitNonNativeApplicationsUpdatesL(); |
|
689 CleanupStack::PopAndDestroy(localisableResourceFileWriter_noIcons); |
|
690 CheckApplicationLaunchesOkayL(aApparcServer, *nextCommandLine, EAppA); |
|
691 |
|
692 //Testing with OpaqueData |
|
693 TPtrC8 opData =nextCommandLine->OpaqueData(); |
|
694 TInt tst=opData.CompareF(KLitOpData); |
|
695 TEST(opData.CompareF(KLitOpData)==0); |
|
696 |
|
697 INFO_PRINTF1(_L("..deregistering app using DeregisterNonNativeApplicationL() with localisableResourceFileWriter_noIcons")); |
|
698 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
699 aApparcServer.DeregisterNonNativeApplicationL(TUid::Uid(KApplicationA)); |
|
700 aApparcServer.CommitNonNativeApplicationsUpdatesL(); |
|
701 CheckApplicationFailsToLaunchL(aApparcServer, *nextCommandLine, EAppA); |
|
702 |
|
703 //Testing with IconFile |
|
704 CApaLocalisableResourceFileWriter* const localisableResourceFileWriter_withIcons=CApaLocalisableResourceFileWriter::NewL(KNullDesC, KLitApplicationCaptionA, 2, KNullDesC); |
|
705 CleanupStack::PushL(localisableResourceFileWriter_withIcons); |
|
706 INFO_PRINTF1(_L("..registering app using RegisterNonNativeApplicationL() with localisableResourceFileWriter_withIcons")); |
|
707 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
708 |
|
709 RFile iconFile; |
|
710 CleanupClosePushL(iconFile); |
|
711 _LIT(KIconFullFileName, "z:\\resource\\apps\\tstapp.mbm"); |
|
712 User::LeaveIfError(iconFile.Open(aFileServer, KIconFullFileName, EFileRead)); |
|
713 aApparcServer.RegisterNonNativeApplicationL(TUid::Uid(KApplicationType), EDriveC, *registrationResourceFileWriter, localisableResourceFileWriter_withIcons, &iconFile); |
|
714 iconFile.Close(); |
|
715 CleanupStack::PopAndDestroy(&iconFile); |
|
716 |
|
717 aApparcServer.CommitNonNativeApplicationsUpdatesL(); |
|
718 CheckApplicationLaunchesOkayL(aApparcServer, *nextCommandLine, EAppA); |
|
719 |
|
720 HBufC* iconFileName = NULL; |
|
721 TInt err = aApparcServer.GetAppIcon(TUid::Uid(KApplicationA),iconFileName); |
|
722 TEST(err == KErrNone); |
|
723 _LIT(KIconFileName, "tstapp.mbm"); |
|
724 TEST(iconFileName != NULL); |
|
725 if(iconFileName != NULL) |
|
726 { |
|
727 TEST(iconFileName->Des().Find(KIconFileName) >= 0); |
|
728 delete iconFileName; |
|
729 } |
|
730 |
|
731 //Test other overload of GetAppIcon for MBM icon file. |
|
732 RFile mbmIconFile; |
|
733 CleanupClosePushL(mbmIconFile); |
|
734 INFO_PRINTF1(_L("..testing GetAppIcon for non-native app to retrieve an open file handle to an MBM icon file")); |
|
735 err = aApparcServer.GetAppIcon(TUid::Uid(KApplicationA), mbmIconFile); |
|
736 TEST(err == KErrNone); |
|
737 |
|
738 TBuf<KMaxFileName> mbmIconFileName; |
|
739 mbmIconFile.FullName(mbmIconFileName); |
|
740 TEST(mbmIconFileName.Length() != 0); |
|
741 |
|
742 //Try to write into the MBM icon file whose handle was returned. |
|
743 INFO_PRINTF1(_L("..writing into the MBM icon file whose handle was returned.")); |
|
744 _LIT8(KSomeText, "It would not be written into the file"); |
|
745 err = mbmIconFile.Write(KSomeText); |
|
746 TEST(err == KErrAccessDenied); |
|
747 |
|
748 //Try to read from the MBM icon file whose handle was returned. |
|
749 INFO_PRINTF1(_L("..reading from the MBM icon file whose handle was returned.")); |
|
750 TBuf8<KBytesToRead> buffer; //buffer to read first KBytesToRead bytes of the mbm icon file. |
|
751 err = mbmIconFile.Read(buffer); |
|
752 TEST(err == KErrNone); |
|
753 |
|
754 //First KBytesToRead bytes of the icon file, this should be same as in mbm file. |
|
755 RFile tempFile; |
|
756 CleanupClosePushL(tempFile); |
|
757 err = tempFile.Open(aFileServer, KIconFullFileName, EFileRead); |
|
758 TEST(err == KErrNone); |
|
759 TBuf8<KBytesToRead> buffer1; |
|
760 err = tempFile.Read(buffer1); |
|
761 TEST(err == KErrNone); |
|
762 TEST(buffer == buffer1); |
|
763 |
|
764 //Close icon files. |
|
765 CleanupStack::PopAndDestroy(2, &mbmIconFile); |
|
766 |
|
767 INFO_PRINTF1(_L("..deregistering app using DeregisterNonNativeApplicationL() with localisableResourceFileWriter_withIcons")); |
|
768 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
769 aApparcServer.DeregisterNonNativeApplicationL(TUid::Uid(KApplicationA)); |
|
770 aApparcServer.CommitNonNativeApplicationsUpdatesL(); |
|
771 CheckApplicationFailsToLaunchL(aApparcServer, *nextCommandLine, EAppA); |
|
772 |
|
773 //Testing GetAppIcon API for non-native application with SVG icon. |
|
774 TestGetAppIconForNonNativeL(aApparcServer,aFileServer, registrationResourceFileWriter, localisableResourceFileWriter_withIcons); |
|
775 |
|
776 // clean-up |
|
777 CleanupStack::PopAndDestroy(5, commandLine); |
|
778 } |
|
779 |
|
780 /** |
|
781 @SYMTestCaseID APPFWK-APPARC-0072 |
|
782 |
|
783 @SYMDEF INC098717: support for scalable midlet icons is missing |
|
784 |
|
785 @SYMTestCaseDesc Tests GetAppIcon API for non native applications with SVG icon file. |
|
786 |
|
787 @SYMTestPriority High |
|
788 |
|
789 @SYMTestStatus Implemented |
|
790 |
|
791 @SYMTestActions Register a non-native app with a SVG icon file, Call GetAppIcon API, |
|
792 deregister the app. Again register the same app without the icon file, call GetAppIcon |
|
793 API, deregister the app. Call GetAppIcon with an invalid app uid. |
|
794 |
|
795 @SYMTestExpectedResults RApaLsSession::GetAppIcon should return KErrNotFound when |
|
796 an invalid app uid is passed, KErrNotFound when application does not have an icon |
|
797 file, KErrNone and an open file handle to the application's icon file if app has icon file. |
|
798 */ |
|
799 void CT_NonNativeAppsStep::TestGetAppIconForNonNativeL(RApaLsSession& aApparcServer, |
|
800 RFs& aFileServer, |
|
801 CApaRegistrationResourceFileWriter* const aRegistrationResourceFileWriter, |
|
802 CApaLocalisableResourceFileWriter* const aLocalisableResourceFileWriter) |
|
803 { |
|
804 //Testing GetAppIcon for non-native app having SVG icon file |
|
805 INFO_PRINTF1(_L("..registering app using RegisterNonNativeApplicationL() with localisableResourceFileWriter_withIcons")); |
|
806 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
807 |
|
808 RFile iconFile; |
|
809 CleanupClosePushL(iconFile); |
|
810 _LIT(KSVGIconSourceFile, "z:\\resource\\apps\\svg_icon.svg"); |
|
811 User::LeaveIfError(iconFile.Open(aFileServer, KSVGIconSourceFile, EFileRead)); |
|
812 aApparcServer.RegisterNonNativeApplicationL(TUid::Uid(KApplicationType), EDriveC, *aRegistrationResourceFileWriter, aLocalisableResourceFileWriter, &iconFile); |
|
813 CleanupStack::PopAndDestroy(&iconFile); |
|
814 |
|
815 aApparcServer.CommitNonNativeApplicationsUpdatesL(); |
|
816 |
|
817 RFile svgIconFile; |
|
818 CleanupClosePushL(svgIconFile); |
|
819 INFO_PRINTF1(_L("..testing GetAppIcon for non-native app to retrieve an open file handle to an SVG icon file")); |
|
820 TInt err = aApparcServer.GetAppIcon(TUid::Uid(KApplicationA),svgIconFile); |
|
821 TEST(err == KErrNone); |
|
822 |
|
823 _LIT(KSVGIconFileName, "c:\\private\\10003a3f\\import\\apps\\nonnative\\resource\\svg_icon.svg"); |
|
824 TBuf<KMaxFileName> iconFileName; |
|
825 //Get the name of the icon file |
|
826 svgIconFile.FullName(iconFileName); |
|
827 TEST(iconFileName.Length() != 0); |
|
828 if (iconFileName.Length() != 0) |
|
829 { |
|
830 INFO_PRINTF1(_L("..testing if the SVG icon file for non-native app gets installed in apparc's data cage")); |
|
831 iconFileName.LowerCase(); |
|
832 TEST(iconFileName.Compare(KSVGIconFileName) == 0); |
|
833 } |
|
834 |
|
835 //Try to write into the icon file whose handle was returned. |
|
836 INFO_PRINTF1(_L("..writing into the SVG icon file whose handle was returned.")); |
|
837 _LIT8(KSomeText, "It would not be written into the file"); |
|
838 err = svgIconFile.Write(KSomeText); |
|
839 TEST(err == KErrAccessDenied); |
|
840 |
|
841 //Try to read from the icon file whose handle was returned. |
|
842 INFO_PRINTF1(_L("..reading from the SVG icon file whose handle was returned.")); |
|
843 TBuf8<KBytesToRead> buffer; //buffer to read first KBytesToRead bytes of the icon file. |
|
844 err = svgIconFile.Read(buffer); |
|
845 TEST(err == KErrNone); |
|
846 |
|
847 //First KBytesToRead bytes of the icon file, this should be same as in svg file. |
|
848 RFile tempFile; |
|
849 CleanupClosePushL(tempFile); |
|
850 err = tempFile.Open(aFileServer, KSVGIconSourceFile, EFileRead); |
|
851 TEST(err == KErrNone); |
|
852 TBuf8<KBytesToRead> buffer1; |
|
853 err = tempFile.Read(buffer1); |
|
854 TEST(err == KErrNone); |
|
855 TEST(buffer == buffer1); |
|
856 |
|
857 //Close icon files |
|
858 CleanupStack::PopAndDestroy(2, &svgIconFile); |
|
859 |
|
860 INFO_PRINTF1(_L("..deregistering app using DeregisterNonNativeApplicationL() with localisableResourceFileWriter_withIcons")); |
|
861 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
862 aApparcServer.DeregisterNonNativeApplicationL(TUid::Uid(KApplicationA)); |
|
863 aApparcServer.CommitNonNativeApplicationsUpdatesL(); |
|
864 |
|
865 //Testing GetAppIcon for non-native app without SVG Icon file. |
|
866 INFO_PRINTF1(_L("..registering app using RegisterNonNativeApplicationL() with localisableResourceFileWriter_withIcons")); |
|
867 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
868 aApparcServer.RegisterNonNativeApplicationL(TUid::Uid(KApplicationType), EDriveC, *aRegistrationResourceFileWriter, aLocalisableResourceFileWriter, NULL); |
|
869 aApparcServer.CommitNonNativeApplicationsUpdatesL(); |
|
870 |
|
871 INFO_PRINTF1(_L("..testing GetAppIcon for non-native app that does not have an icon file")); |
|
872 RFile iconFile1; |
|
873 CleanupClosePushL(iconFile1); |
|
874 err = aApparcServer.GetAppIcon(TUid::Uid(KApplicationA),iconFile1); |
|
875 TEST(err == KErrNotFound); |
|
876 |
|
877 INFO_PRINTF1(_L("..deregistering app using DeregisterNonNativeApplicationL() with localisableResourceFileWriter_withIcons")); |
|
878 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
879 aApparcServer.DeregisterNonNativeApplicationL(TUid::Uid(KApplicationA)); |
|
880 aApparcServer.CommitNonNativeApplicationsUpdatesL(); |
|
881 |
|
882 //Testing GetAppIcon with an invalid app UID. |
|
883 INFO_PRINTF1(_L("..testing GetAppIcon, if an invalid app UID is passed")); |
|
884 err = aApparcServer.GetAppIcon(TUid::Uid(KApplicationA),iconFile1); |
|
885 TEST(err == KErrNotFound); |
|
886 |
|
887 //Close icon file |
|
888 CleanupStack::PopAndDestroy(&iconFile1); |
|
889 } |
|
890 |
|
891 |
|
892 |
|
893 /** |
|
894 @SYMTestCaseID APPFWK-APPARC-0099 |
|
895 |
|
896 @SYMDEF PDEF129467 |
|
897 |
|
898 @SYMTestCaseDesc Tests ForceCommitNonNativeApplicationsUpdatesL() API. |
|
899 |
|
900 @SYMTestPriority High |
|
901 |
|
902 @SYMTestStatus Implemented |
|
903 |
|
904 @SYMTestActions Call RegisterNonNativeApplicationL and try to launch the app. Then call |
|
905 DeregisterNonNativeApplicationL and try to launch the app again. ForceCommitNonNativeApplicationsUpdatesL |
|
906 API is used to commit the non-native application updates. |
|
907 |
|
908 @SYMTestExpectedResults Test checks ForceCommitNonNativeApplicationsUpdatesL behaviour and completed with success. |
|
909 */ |
|
910 void CT_NonNativeAppsStep::TestCommitNNAppUpdatesL(RApaLsSession& aApparcServer) |
|
911 { |
|
912 INFO_PRINTF1(_L("Testing ForceCommitNonNativeApplicationsUpdatesL API...")); |
|
913 |
|
914 RProcess().SetPriority(EPriorityLow); // so that we're pre-empted by the Apparc server when it does its scan |
|
915 |
|
916 CApaCommandLine* commandLine=NULL; |
|
917 User::LeaveIfError(CApaCommandLine::GetCommandLineFromProcessEnvironment(commandLine)); |
|
918 CleanupStack::PushL(commandLine); |
|
919 const TPtrC executableName(commandLine->ExecutableName()); |
|
920 |
|
921 _LIT_SECURITY_POLICY_S0(readSecurityPolicy, KMySID); |
|
922 _LIT_SECURITY_POLICY_PASS(writeSecurityPolicy); |
|
923 |
|
924 //TNNAPP2.exe sets the document name passed as part of the command line to this property. |
|
925 const TInt error=RProperty::Define(KPropertyKey, RProperty::EText, readSecurityPolicy, writeSecurityPolicy); |
|
926 if (error!=KErrAlreadyExists) |
|
927 { |
|
928 User::LeaveIfError(error); |
|
929 } |
|
930 User::LeaveIfError(RProperty::Set(TUid::Uid(KPropertyCategory), KPropertyKey, KNullDesC)); |
|
931 |
|
932 // make sure we're starting from a clean sheet |
|
933 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
934 aApparcServer.DeregisterNonNativeApplicationL(TUid::Uid(KApplicationA)); |
|
935 aApparcServer.CommitNonNativeApplicationsUpdatesL(); |
|
936 aApparcServer.DeregisterNonNativeApplicationTypeL(TUid::Uid(KApplicationType)); |
|
937 CleanupStack::PushL(TCleanupItem(DeregisterNonNativeL, &aApparcServer)); |
|
938 |
|
939 aApparcServer.RegisterNonNativeApplicationTypeL(TUid::Uid(KApplicationType), KLitNativeExecutable); |
|
940 |
|
941 CApaRegistrationResourceFileWriter* const registrationResourceFileWriter=CApaRegistrationResourceFileWriter::NewL(TUid::Uid(KApplicationA), KLitLogicalExecutableA, TApaAppCapability::ENonNative); |
|
942 CleanupStack::PushL(registrationResourceFileWriter); |
|
943 registrationResourceFileWriter->AddDataTypeL(KDataTypePriorityNormal, KLitMimeTypeA); |
|
944 |
|
945 CApaCommandLine* const nextCommandLine=CApaCommandLine::NewLC(); |
|
946 nextCommandLine->SetDocumentNameL(KLitDocumentName2); |
|
947 nextCommandLine->SetExecutableNameL(KLitLogicalExecutableA); |
|
948 |
|
949 |
|
950 INFO_PRINTF1(_L("..registering app using RegisterNonNativeApplicationL() ")); |
|
951 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
952 aApparcServer.RegisterNonNativeApplicationL(TUid::Uid(KApplicationType), EDriveC, *registrationResourceFileWriter, NULL, NULL); |
|
953 TTime startTime,endTime; |
|
954 TTimeIntervalMicroSeconds timeTakenToCommitRegistration; |
|
955 INFO_PRINTF1(_L("..start commiting the registration with CommitNonNativeApplicationsUpdatesL")); |
|
956 startTime.HomeTime(); |
|
957 aApparcServer.CommitNonNativeApplicationsUpdatesL(); |
|
958 endTime.HomeTime(); |
|
959 INFO_PRINTF1(_L("..commiting the registration is done")); |
|
960 timeTakenToCommitRegistration=endTime.MicroSecondsFrom(startTime); |
|
961 |
|
962 TInt64 value = timeTakenToCommitRegistration.Int64(); |
|
963 INFO_PRINTF2(_L("..Time taken for registration of application by CommitNonNativeApplicationsUpdatesL is %d micro seconds"), value); |
|
964 CheckApplicationLaunchesOkayL(aApparcServer, *nextCommandLine, EAppA); |
|
965 |
|
966 INFO_PRINTF1(_L("..deregistering app using DeregisterNonNativeApplicationL() ")); |
|
967 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
968 aApparcServer.DeregisterNonNativeApplicationL(TUid::Uid(KApplicationA)); |
|
969 TTimeIntervalMicroSeconds timeTakenToCommitDeregistration; |
|
970 INFO_PRINTF1(_L("..start commiting the deregistration with CommitNonNativeApplicationsUpdatesL")); |
|
971 startTime.HomeTime(); |
|
972 aApparcServer.CommitNonNativeApplicationsUpdatesL(); |
|
973 endTime.HomeTime(); |
|
974 INFO_PRINTF1(_L("..commiting the deregistration is done")); |
|
975 timeTakenToCommitDeregistration=endTime.MicroSecondsFrom(startTime); |
|
976 value = timeTakenToCommitDeregistration.Int64(); |
|
977 INFO_PRINTF2(_L("..Time taken for deregistration of application by CommitNonNativeApplicationsUpdatesL is %d micro seconds"), value); |
|
978 CheckApplicationFailsToLaunchL(aApparcServer, *nextCommandLine, EAppA); |
|
979 |
|
980 |
|
981 INFO_PRINTF1(_L("..registering app using RegisterNonNativeApplicationL() ")); |
|
982 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
983 aApparcServer.RegisterNonNativeApplicationL(TUid::Uid(KApplicationType), EDriveC, *registrationResourceFileWriter, NULL, NULL); |
|
984 TTimeIntervalMicroSeconds timeTakenToForceCommitRegistration; |
|
985 INFO_PRINTF1(_L("..start commiting the registration with ForceCommitNonNativeApplicationsUpdatesL")); |
|
986 startTime.HomeTime(); |
|
987 aApparcServer.ForceCommitNonNativeApplicationsUpdatesL(); |
|
988 endTime.HomeTime(); |
|
989 INFO_PRINTF1(_L("..commiting the registration is done")); |
|
990 timeTakenToForceCommitRegistration=endTime.MicroSecondsFrom(startTime); |
|
991 value = timeTakenToForceCommitRegistration.Int64(); |
|
992 INFO_PRINTF2(_L("..Time taken for registration of application by ForceCommitNonNativeApplicationsUpdatesL is %d micro seconds"), value); |
|
993 TRequestStatus appScanCompleted=KRequestPending; |
|
994 aApparcServer.SetNotify(EFalse,appScanCompleted); |
|
995 User::WaitForRequest(appScanCompleted); |
|
996 TEST(appScanCompleted.Int()==MApaAppListServObserver::EAppListChanged); |
|
997 CheckApplicationLaunchesOkayL(aApparcServer, *nextCommandLine, EAppA); |
|
998 |
|
999 INFO_PRINTF1(_L("..deregistering app using DeregisterNonNativeApplicationL() ")); |
|
1000 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
1001 aApparcServer.DeregisterNonNativeApplicationL(TUid::Uid(KApplicationA)); |
|
1002 TTimeIntervalMicroSeconds timeTakenToForceCommitDeregistration; |
|
1003 INFO_PRINTF1(_L("..start commiting the deregistration with ForceCommitNonNativeApplicationsUpdatesL")); |
|
1004 startTime.HomeTime(); |
|
1005 aApparcServer.ForceCommitNonNativeApplicationsUpdatesL(); |
|
1006 endTime.HomeTime(); |
|
1007 INFO_PRINTF1(_L("..commiting the deregistration is done")); |
|
1008 timeTakenToForceCommitDeregistration=endTime.MicroSecondsFrom(startTime); |
|
1009 value = timeTakenToForceCommitDeregistration.Int64(); |
|
1010 INFO_PRINTF2(_L("..Time taken for deregistration of application by ForceCommitNonNativeApplicationsUpdatesL is %d micro seconds"), value); |
|
1011 appScanCompleted=KRequestPending; |
|
1012 aApparcServer.SetNotify(EFalse,appScanCompleted); |
|
1013 User::WaitForRequest(appScanCompleted); |
|
1014 TEST(appScanCompleted.Int()==MApaAppListServObserver::EAppListChanged); |
|
1015 CheckApplicationFailsToLaunchL(aApparcServer, *nextCommandLine, EAppA); |
|
1016 TEST(timeTakenToForceCommitRegistration<timeTakenToCommitRegistration); |
|
1017 TEST(timeTakenToForceCommitDeregistration<timeTakenToCommitDeregistration); |
|
1018 |
|
1019 CleanupStack::PopAndDestroy(4, commandLine); |
|
1020 } |
|
1021 |
|
1022 /** |
|
1023 @SYMTestCaseID APPFWK-APPARC-0103 |
|
1024 |
|
1025 @SYMDEF PDEF135324 |
|
1026 |
|
1027 @SYMTestCaseDesc Tests ForceCommitNonNativeApplicationsUpdatesL() API. |
|
1028 |
|
1029 @SYMTestPriority High |
|
1030 |
|
1031 @SYMTestStatus Implemented |
|
1032 |
|
1033 @SYMTestActions Make back to back installations of apps and notice that the app in not updated to the applist |
|
1034 immediately. All apps are updated only after the last ForceCommitNonNativeApplicationsUpdatesL. |
|
1035 Note that previous ForceCommitNonNativeApplicationsUpdatesL actions are updates in applist |
|
1036 when RollbackNonNativeApplicationsUpdates is called. |
|
1037 |
|
1038 @SYMTestExpectedResults Test checks ForceCommitNonNativeApplicationsUpdatesL and RollbackNonNativeApplicationsUpdates behaviour and completed with success. |
|
1039 */ |
|
1040 void CT_NonNativeAppsStep::TestForceCommitNNAppUpdatesL(RApaLsSession& aApparcServer) |
|
1041 { |
|
1042 INFO_PRINTF1(_L("Testing ForceCommitNonNativeApplicationsUpdatesL API...")); |
|
1043 |
|
1044 RProcess().SetPriority(EPriorityLow); // so that we're pre-empted by the Apparc server when it does its scan |
|
1045 |
|
1046 CApaCommandLine* commandLine=NULL; |
|
1047 User::LeaveIfError(CApaCommandLine::GetCommandLineFromProcessEnvironment(commandLine)); |
|
1048 CleanupStack::PushL(commandLine); |
|
1049 const TPtrC executableName(commandLine->ExecutableName()); |
|
1050 |
|
1051 |
|
1052 _LIT_SECURITY_POLICY_S0(readSecurityPolicy, KMySID); |
|
1053 _LIT_SECURITY_POLICY_PASS(writeSecurityPolicy); |
|
1054 |
|
1055 //TNNAPP2.exe sets the document name passed as part of the command line to this property. |
|
1056 const TInt error=RProperty::Define(KPropertyKey, RProperty::EText, readSecurityPolicy, writeSecurityPolicy); |
|
1057 if (error!=KErrAlreadyExists) |
|
1058 { |
|
1059 User::LeaveIfError(error); |
|
1060 } |
|
1061 User::LeaveIfError(RProperty::Set(TUid::Uid(KPropertyCategory), KPropertyKey, KNullDesC)); |
|
1062 |
|
1063 // make sure we're starting from a clean sheet |
|
1064 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
1065 aApparcServer.DeregisterNonNativeApplicationL(TUid::Uid(KApplicationA)); |
|
1066 aApparcServer.CommitNonNativeApplicationsUpdatesL(); |
|
1067 aApparcServer.DeregisterNonNativeApplicationTypeL(TUid::Uid(KApplicationType)); |
|
1068 CleanupStack::PushL(TCleanupItem(DeregisterNonNativeL, &aApparcServer)); |
|
1069 |
|
1070 INFO_PRINTF1(_L("..Registering type KApplicationType using RegisterNonNativeApplicationTypeL() ")); |
|
1071 aApparcServer.RegisterNonNativeApplicationTypeL(TUid::Uid(KApplicationType), KLitNativeExecutable); |
|
1072 |
|
1073 CApaRegistrationResourceFileWriter* const registrationResourceFileWriter=CApaRegistrationResourceFileWriter::NewL(TUid::Uid(KApplicationA), KLitLogicalExecutableA, TApaAppCapability::ENonNative); |
|
1074 CleanupStack::PushL(registrationResourceFileWriter); |
|
1075 INFO_PRINTF1(_L("..Add datatype to app 'A'")); |
|
1076 registrationResourceFileWriter->AddDataTypeL(KDataTypePriorityNormal, KLitMimeTypeA); |
|
1077 |
|
1078 CApaCommandLine* const nextCommandLine=CApaCommandLine::NewLC(); |
|
1079 nextCommandLine->SetDocumentNameL(KLitDocumentName2); |
|
1080 nextCommandLine->SetExecutableNameL(KLitLogicalExecutableA); |
|
1081 |
|
1082 TApaAppInfo info; |
|
1083 CApaRegistrationResourceFileWriter* const registrationResourceFileWriterB=CApaRegistrationResourceFileWriter::NewL(TUid::Uid(KApplicationB), KLitLogicalExecutableA, TApaAppCapability::ENonNative); |
|
1084 CleanupStack::PushL(registrationResourceFileWriterB); |
|
1085 registrationResourceFileWriterB->AddDataTypeL(KDataTypePriorityNormal, KLitMimeTypeB); |
|
1086 |
|
1087 TestForceCommitL(aApparcServer, *registrationResourceFileWriter, *registrationResourceFileWriterB, *nextCommandLine); |
|
1088 TestRollbackRegistrationL(aApparcServer, *registrationResourceFileWriter, *registrationResourceFileWriterB, *nextCommandLine); |
|
1089 TestRollbackDeregistrationL(aApparcServer, *registrationResourceFileWriter, *registrationResourceFileWriterB, *nextCommandLine); |
|
1090 |
|
1091 CleanupStack::PopAndDestroy(5, commandLine); |
|
1092 } |
|
1093 |
|
1094 void CT_NonNativeAppsStep::WaitForApplistUpdate(RApaLsSession& aApparcServer) |
|
1095 { |
|
1096 INFO_PRINTF1(_L("..waiting for applist to be updated ")); |
|
1097 TRequestStatus appScanCompleted=KRequestPending; |
|
1098 aApparcServer.SetNotify(EFalse,appScanCompleted); |
|
1099 User::WaitForRequest(appScanCompleted); |
|
1100 TEST(appScanCompleted.Int()==MApaAppListServObserver::EAppListChanged); |
|
1101 } |
|
1102 |
|
1103 void CT_NonNativeAppsStep::TestForceCommitL(RApaLsSession& aApparcServer, CApaRegistrationResourceFileWriter& aRegistrationResourceFileWriter, CApaRegistrationResourceFileWriter& aRegistrationResourceFileWriterB, CApaCommandLine& aNextCommandLine) |
|
1104 { |
|
1105 INFO_PRINTF1(_L("..Start Testing TestForceCommitL API...")); |
|
1106 |
|
1107 //Register app A and ForceCommitNNAUpdate |
|
1108 INFO_PRINTF1(_L("..registering app 'A' using RegisterNonNativeApplicationL() ")); |
|
1109 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
1110 aApparcServer.RegisterNonNativeApplicationL(TUid::Uid(KApplicationType), EDriveC, aRegistrationResourceFileWriter, NULL, NULL); |
|
1111 aApparcServer.ForceCommitNonNativeApplicationsUpdatesL(); |
|
1112 CheckApplicationFailsToLaunchL(aApparcServer, aNextCommandLine, EAppA);//Since applist update has not yet completed |
|
1113 |
|
1114 //Register app B and ForceCommitNNAUpdate |
|
1115 INFO_PRINTF1(_L("..registering app 'B' using RegisterNonNativeApplicationL() ")); |
|
1116 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
1117 aApparcServer.RegisterNonNativeApplicationL(TUid::Uid(KApplicationType), EDriveC, aRegistrationResourceFileWriterB, NULL, NULL); |
|
1118 aApparcServer.ForceCommitNonNativeApplicationsUpdatesL(); |
|
1119 TThreadId notUsed2; |
|
1120 CheckApplicationFailsToLaunchL(aApparcServer, aNextCommandLine, EAppB); |
|
1121 |
|
1122 //Wait for applist to be updated |
|
1123 WaitForApplistUpdate(aApparcServer); |
|
1124 CheckApplicationLaunchesOkayL(aApparcServer, aNextCommandLine, EAppA);//Check if app A launches since applist update is complete now |
|
1125 CheckApplicationLaunchesOkayL(aApparcServer, aNextCommandLine, EAppB);//Similarly check if app B launches |
|
1126 |
|
1127 //DeRegister app B and ForceCommitNNAUpdate |
|
1128 INFO_PRINTF1(_L("..deregistering app 'B' using DeregisterNonNativeApplicationL() ")); |
|
1129 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
1130 aApparcServer.DeregisterNonNativeApplicationL(TUid::Uid(KApplicationB)); |
|
1131 aApparcServer.ForceCommitNonNativeApplicationsUpdatesL(); |
|
1132 //Since applist update has not yet completed, both apps should launch |
|
1133 CheckApplicationLaunchesOkayL(aApparcServer, aNextCommandLine, EAppA); |
|
1134 CheckApplicationLaunchesOkayL(aApparcServer, aNextCommandLine, EAppB); |
|
1135 |
|
1136 //Wait for applist to be updated |
|
1137 WaitForApplistUpdate(aApparcServer); |
|
1138 CheckApplicationLaunchesOkayL(aApparcServer, aNextCommandLine, EAppA); |
|
1139 //Check if app B fails to launches Since applist update is complete now |
|
1140 CheckApplicationFailsToLaunchL(aApparcServer, aNextCommandLine, EAppB); |
|
1141 |
|
1142 //Deregister app A and ForceCommitNNAUpdate |
|
1143 INFO_PRINTF1(_L("..deregistering app 'A' using RegisterNonNativeApplicationL() ")); |
|
1144 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
1145 aApparcServer.DeregisterNonNativeApplicationL(TUid::Uid(KApplicationA)); |
|
1146 aApparcServer.ForceCommitNonNativeApplicationsUpdatesL(); |
|
1147 WaitForApplistUpdate(aApparcServer); |
|
1148 //Both apps fail to launch since they are deregistered |
|
1149 CheckApplicationFailsToLaunchL(aApparcServer, aNextCommandLine, EAppA); |
|
1150 CheckApplicationFailsToLaunchL(aApparcServer, aNextCommandLine, EAppB); |
|
1151 |
|
1152 INFO_PRINTF1(_L("..End Testing TestForceCommitL API...")); |
|
1153 } |
|
1154 |
|
1155 void CT_NonNativeAppsStep::TestRollbackRegistrationL(RApaLsSession& aApparcServer, CApaRegistrationResourceFileWriter& aRegistrationResourceFileWriter, CApaRegistrationResourceFileWriter& aRegistrationResourceFileWriterB, CApaCommandLine& aNextCommandLine) |
|
1156 { |
|
1157 INFO_PRINTF1(_L("..Start Testing TestRollbackRegistrationL API...")); |
|
1158 |
|
1159 //Register app A and ForceCommitNNAUpdate |
|
1160 INFO_PRINTF1(_L("..registering app 'A' using RegisterNonNativeApplicationL() ")); |
|
1161 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
1162 aApparcServer.RegisterNonNativeApplicationL(TUid::Uid(KApplicationType), EDriveC, aRegistrationResourceFileWriter, NULL, NULL); |
|
1163 aApparcServer.ForceCommitNonNativeApplicationsUpdatesL(); |
|
1164 CheckApplicationFailsToLaunchL(aApparcServer, aNextCommandLine, EAppA);//Since applist update has not yet completed |
|
1165 |
|
1166 //Register app B and RollbackNNAUpdates |
|
1167 INFO_PRINTF1(_L("..registering app 'B' using RegisterNonNativeApplicationL() ")); |
|
1168 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
1169 aApparcServer.RegisterNonNativeApplicationL(TUid::Uid(KApplicationType), EDriveC, aRegistrationResourceFileWriterB, NULL, NULL); |
|
1170 aApparcServer.RollbackNonNativeApplicationsUpdates(); |
|
1171 |
|
1172 //Wait for applist to be updated |
|
1173 WaitForApplistUpdate(aApparcServer); |
|
1174 CheckApplicationLaunchesOkayL(aApparcServer, aNextCommandLine, EAppA);//Check if app A launches |
|
1175 //App B's registration was rolled back, so cannot launch it |
|
1176 CheckApplicationFailsToLaunchL(aApparcServer, aNextCommandLine, EAppB); |
|
1177 |
|
1178 //DeRegister app A and ForceCommitNNAUpdate |
|
1179 INFO_PRINTF1(_L("..deregistering app 'A' using DeregisterNonNativeApplicationL() ")); |
|
1180 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
1181 aApparcServer.DeregisterNonNativeApplicationL(TUid::Uid(KApplicationA)); |
|
1182 aApparcServer.ForceCommitNonNativeApplicationsUpdatesL(); |
|
1183 //Since applist update has not yet completed, app A should launch |
|
1184 CheckApplicationLaunchesOkayL(aApparcServer, aNextCommandLine, EAppA); |
|
1185 |
|
1186 //Wait for applist to be updated |
|
1187 WaitForApplistUpdate(aApparcServer); |
|
1188 //Both apps fail to launch |
|
1189 CheckApplicationFailsToLaunchL(aApparcServer, aNextCommandLine, EAppA); |
|
1190 CheckApplicationFailsToLaunchL(aApparcServer, aNextCommandLine, EAppB); |
|
1191 |
|
1192 INFO_PRINTF1(_L("..End Testing TestRollbackRegistrationL API...")); |
|
1193 } |
|
1194 |
|
1195 void CT_NonNativeAppsStep::TestRollbackDeregistrationL(RApaLsSession& aApparcServer, CApaRegistrationResourceFileWriter& aRegistrationResourceFileWriter, CApaRegistrationResourceFileWriter& aRegistrationResourceFileWriterB, CApaCommandLine& aNextCommandLine) |
|
1196 { |
|
1197 INFO_PRINTF1(_L("..Start Testing TestRollbackDeregistrationL API...")); |
|
1198 |
|
1199 //Register app A and ForceCommitNNAUpdate |
|
1200 INFO_PRINTF1(_L("..registering app 'A' using RegisterNonNativeApplicationL() ")); |
|
1201 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
1202 aApparcServer.RegisterNonNativeApplicationL(TUid::Uid(KApplicationType), EDriveC, aRegistrationResourceFileWriter, NULL, NULL); |
|
1203 aApparcServer.ForceCommitNonNativeApplicationsUpdatesL(); |
|
1204 CheckApplicationFailsToLaunchL(aApparcServer, aNextCommandLine, EAppA);//Since applist update has not yet completed |
|
1205 |
|
1206 //Register app B and ForceCommitNNAUpdate |
|
1207 INFO_PRINTF1(_L("..registering app 'B' using RegisterNonNativeApplicationL() ")); |
|
1208 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
1209 aApparcServer.RegisterNonNativeApplicationL(TUid::Uid(KApplicationType), EDriveC, aRegistrationResourceFileWriterB, NULL, NULL); |
|
1210 aApparcServer.ForceCommitNonNativeApplicationsUpdatesL(); |
|
1211 CheckApplicationFailsToLaunchL(aApparcServer, aNextCommandLine, EAppB); |
|
1212 |
|
1213 //Wait for applist to be updated |
|
1214 WaitForApplistUpdate(aApparcServer); |
|
1215 //Check if both apps launches since applist update is complete now |
|
1216 CheckApplicationLaunchesOkayL(aApparcServer, aNextCommandLine, EAppA); |
|
1217 CheckApplicationLaunchesOkayL(aApparcServer, aNextCommandLine, EAppB); |
|
1218 |
|
1219 //DeRegister app B and ForceCommitNNAUpdate |
|
1220 INFO_PRINTF1(_L("..deregistering app 'B' using DeregisterNonNativeApplicationL() ")); |
|
1221 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
1222 aApparcServer.DeregisterNonNativeApplicationL(TUid::Uid(KApplicationB)); |
|
1223 aApparcServer.ForceCommitNonNativeApplicationsUpdatesL(); |
|
1224 |
|
1225 //DeRegister app A and ForceCommitNNAUpdate |
|
1226 INFO_PRINTF1(_L("..deregistering app 'A' using DeregisterNonNativeApplicationL() ")); |
|
1227 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
1228 aApparcServer.DeregisterNonNativeApplicationL(TUid::Uid(KApplicationA)); |
|
1229 aApparcServer.RollbackNonNativeApplicationsUpdates(); |
|
1230 |
|
1231 //Wait for applist to be updated |
|
1232 WaitForApplistUpdate(aApparcServer); |
|
1233 //Since deregistration of app A was rolled back it still launches |
|
1234 CheckApplicationLaunchesOkayL(aApparcServer, aNextCommandLine, EAppA); |
|
1235 CheckApplicationFailsToLaunchL(aApparcServer, aNextCommandLine, EAppB); |
|
1236 |
|
1237 INFO_PRINTF1(_L("..deregistering app 'A' using DeregisterNonNativeApplicationL() ")); |
|
1238 aApparcServer.PrepareNonNativeApplicationsUpdatesL(); |
|
1239 aApparcServer.DeregisterNonNativeApplicationL(TUid::Uid(KApplicationA)); |
|
1240 aApparcServer.ForceCommitNonNativeApplicationsUpdatesL(); |
|
1241 |
|
1242 //Wait for applist to be updated |
|
1243 WaitForApplistUpdate(aApparcServer); |
|
1244 //Both apps fail to launch |
|
1245 CheckApplicationFailsToLaunchL(aApparcServer, aNextCommandLine, EAppA); |
|
1246 CheckApplicationFailsToLaunchL(aApparcServer, aNextCommandLine, EAppB); |
|
1247 |
|
1248 INFO_PRINTF1(_L("..End Testing TestRollbackDeregistrationL API...")); |
|
1249 } |
|
1250 |
|
1251 // CTestStep derived functions |
|
1252 |
|
1253 CT_NonNativeAppsStep::~CT_NonNativeAppsStep() |
|
1254 { |
|
1255 } |
|
1256 |
|
1257 CT_NonNativeAppsStep::CT_NonNativeAppsStep() |
|
1258 { |
|
1259 SetTestStepName(KT_NonNativeAppsStep); |
|
1260 } |
|
1261 |
|
1262 TVerdict CT_NonNativeAppsStep::doTestStepPreambleL() |
|
1263 { |
|
1264 SetTestStepResult(EPass); |
|
1265 return TestStepResult(); |
|
1266 } |
|
1267 |
|
1268 TVerdict CT_NonNativeAppsStep::doTestStepPostambleL() |
|
1269 { |
|
1270 return TestStepResult(); |
|
1271 } |
|
1272 |
|
1273 TVerdict CT_NonNativeAppsStep::doTestStepL() |
|
1274 { |
|
1275 INFO_PRINTF1(_L("Test NonNativeApps starting....\n")); |
|
1276 |
|
1277 RTstFileArray fileArray(2); |
|
1278 CleanupClosePushL(fileArray); |
|
1279 fileArray.AppendL(_L("z:\\private\\101F289C\\GIF.NNA1"), KLit8_DataType_Gif); |
|
1280 fileArray.AppendL(_L("z:\\private\\101F289C\\HTML.NNA2"), KLit8_DataType_Html); |
|
1281 fileArray.AppendL(_L("z:\\private\\101F289C\\CONTACT.NNA3"), KLit8_DataType_Vcard); |
|
1282 fileArray.AppendL(_L("z:\\private\\101F289C\\TXT.NNA4"), KLit8_DataType_plainText); |
|
1283 |
|
1284 RTestableApaLsSession apparcServer; |
|
1285 CleanupClosePushL(apparcServer); |
|
1286 User::LeaveIfError(apparcServer.Connect()); |
|
1287 |
|
1288 RFs fileServer; |
|
1289 CleanupClosePushL(fileServer); |
|
1290 User::LeaveIfError(fileServer.Connect()); |
|
1291 User::LeaveIfError(fileServer.ShareProtected()); |
|
1292 |
|
1293 apparcServer.FlushRecognitionCache(); |
|
1294 HEAP_TEST_LS_SESSION(apparcServer, 0, 0, TestAppForDocumentL(apparcServer, fileServer, fileArray), apparcServer.FlushRecognitionCache()); |
|
1295 HEAP_TEST_LS_SESSION(apparcServer, 0, 0, TestAppForDocumentAndServiceL(apparcServer, fileServer, fileArray), apparcServer.FlushRecognitionCache()); |
|
1296 HEAP_TEST_LS_SESSION(apparcServer, 0, 0, TestRecognizingL(apparcServer, fileServer, fileArray), apparcServer.FlushRecognitionCache()); |
|
1297 |
|
1298 //avoid race conditions |
|
1299 User::After(1500000); |
|
1300 //DONT_CHECK Skips the heap check at server side. This heap imbalance happens intermittently,with no known reason (See PDEF111975). |
|
1301 HEAP_TEST_LS_SESSION(apparcServer, 0, DONT_CHECK, TestStartDocumentL(apparcServer, fileServer, fileArray), apparcServer.FlushRecognitionCache()); |
|
1302 //DONT_CHECK due to file system changes |
|
1303 HEAP_TEST_LS_SESSION(apparcServer, 0, DONT_CHECK, TestRegisterNonNativeApplicationL(apparcServer,fileServer), NO_CLEANUP); |
|
1304 |
|
1305 //INC127734: Test case is added to test ForceCommitNonNativeApplicationsUpdatesL API |
|
1306 //DONT_CHECK due to file system changes |
|
1307 HEAP_TEST_LS_SESSION(apparcServer, 0, DONT_CHECK, TestCommitNNAppUpdatesL(apparcServer), NO_CLEANUP); |
|
1308 //DONT_CHECK due to file system changes |
|
1309 HEAP_TEST_LS_SESSION(apparcServer, 0, DONT_CHECK, TestForceCommitNNAppUpdatesL(apparcServer), NO_CLEANUP); |
|
1310 |
|
1311 CleanupStack::PopAndDestroy(3, &fileArray); |
|
1312 |
|
1313 INFO_PRINTF1(_L("....Test NonNativeApps completed!")); |
|
1314 return TestStepResult(); |
|
1315 } |
|
1316 |
|
1317 |