1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: AppMngr2 Runtime API STIF test module |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "appmngr2runtimeapitest.h" // CRuntimeApiTest |
|
20 #include "appmngr2testcommand.h" // CAppMngr2TestCommand |
|
21 #include <StifLogger.h> // CStifLogger |
|
22 #include <SettingServerClient.h> // RSettingServer |
|
23 #include <ecom/ecom.h> // REComSession |
|
24 #include <appmngr2runtime.h> // AppMngr2 Runtime API |
|
25 #include <appmngr2appinfo.h> // AppMngr2 Runtime API |
|
26 #include <appmngr2packageinfo.h> // AppMngr2 Runtime API |
|
27 #include <appmngr2recognizedfile.h> // AppMngr2 Runtime API |
|
28 #include <appmngr2driveutils.h> // AppMngr2 Runtime API |
|
29 #include <appmngr2common.hrh> // AppMngr2 Runtime API |
|
30 #include <appmngr2cleanuputils.h> // CleanupResetAndDestroyPushL |
|
31 #include <apmstd.h> // TDataType |
|
32 #include <caf/caf.h> // ContentAccess |
|
33 #include <bautils.h> // BaflUtils |
|
34 #include <AknIconArray.h> // CAknIconArray |
|
35 #include <gulicon.h> // CGulIcon |
|
36 #include <data_caging_path_literals.hrh> // KDC_APP_RESOURCE_DIR |
|
37 |
|
38 const TInt KMaxLineLength = 256; |
|
39 const TInt KGranularity = 8; |
|
40 |
|
41 _LIT( KSWInstCommonUIResourceFileName, "SWInstCommonUI.rsc" ); |
|
42 _LIT( KAppMngr2UIResourceFileName, "appmngr2.rsc" ); |
|
43 _LIT( KAppRscFormat, "z:%S%S" ); |
|
44 |
|
45 _LIT( KAppMngr2Tag, "AppMngr2" ); |
|
46 _LIT( KTestStartFormat, "%S: start" ); |
|
47 _LIT( KTestDoneFormat, "%S: done (error %d)" ); |
|
48 _LIT( KResultFormat, "%S: %S, result %d" ); |
|
49 _LIT( KNotFoundFormat, "%S: %S not found" ); |
|
50 |
|
51 |
|
52 // ======== MEMBER FUNCTIONS ======== |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CAppMngr2RuntimeApiTest::NewL() |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CAppMngr2RuntimeApiTest* CAppMngr2RuntimeApiTest::NewL( CTestModuleIf& aTestModuleIf ) |
|
59 { |
|
60 CAppMngr2RuntimeApiTest* self = new (ELeave) CAppMngr2RuntimeApiTest( aTestModuleIf ); |
|
61 CleanupStack::PushL( self ); |
|
62 self->ConstructL(); |
|
63 CleanupStack::Pop(); |
|
64 return self; |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CAppMngr2RuntimeApiTest::~CAppMngr2RuntimeApiTest() |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 CAppMngr2RuntimeApiTest::~CAppMngr2RuntimeApiTest() |
|
72 { |
|
73 delete iInstallCommand; |
|
74 delete iUninstallCommand; |
|
75 delete iShowDetailsCommand; |
|
76 iInstalledApps.ResetAndDestroy(); |
|
77 iInstallationPackages.ResetAndDestroy(); |
|
78 iPlugins.ResetAndDestroy(); |
|
79 |
|
80 CCoeEnv* coeEnv = CCoeEnv::Static(); |
|
81 if( coeEnv ) |
|
82 { |
|
83 if( iSWInstCommonResourceFileOffset ) |
|
84 { |
|
85 coeEnv->DeleteResourceFile( iSWInstCommonResourceFileOffset ); |
|
86 } |
|
87 if( iAppMngr2ResourceFileOffset ) |
|
88 { |
|
89 coeEnv->DeleteResourceFile( iAppMngr2ResourceFileOffset ); |
|
90 } |
|
91 } |
|
92 |
|
93 delete iLog; |
|
94 iFs.Close(); |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CAppMngr2RuntimeApiTest::RunMethodL() |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 TInt CAppMngr2RuntimeApiTest::RunMethodL( CStifItemParser& aItem ) |
|
102 { |
|
103 static TStifFunctionInfo const KFunctions[] = |
|
104 { |
|
105 ENTRY( "CheckFilesExist", CAppMngr2RuntimeApiTest::CheckFilesExistL ), |
|
106 ENTRY( "LoadAllPlugins", CAppMngr2RuntimeApiTest::LoadAllPluginsL ), |
|
107 ENTRY( "LoadPlugin", CAppMngr2RuntimeApiTest::LoadPluginL ), |
|
108 ENTRY( "CheckPluginsLoaded", CAppMngr2RuntimeApiTest::CheckPluginsLoadedL ), |
|
109 ENTRY( "LoadIcons", CAppMngr2RuntimeApiTest::LoadIconsL ), |
|
110 ENTRY( "GetAdditionalDirsToScan", CAppMngr2RuntimeApiTest::GetAdditionalDirsToScanL ), |
|
111 ENTRY( "GetInstallationFiles", CAppMngr2RuntimeApiTest::GetInstallationFilesL ), |
|
112 ENTRY( "CheckInstallationFiles", CAppMngr2RuntimeApiTest::CheckInstallationFilesL ), |
|
113 ENTRY( "ShowInstallationFileDetails", CAppMngr2RuntimeApiTest::ShowInstallationFileDetailsL ), |
|
114 ENTRY( "CheckShowDetailsEnded", CAppMngr2RuntimeApiTest::CheckShowDetailsEndedL ), |
|
115 ENTRY( "CheckNoInstallationFiles", CAppMngr2RuntimeApiTest::CheckNoInstallationFilesL ), |
|
116 ENTRY( "StartInstallFile", CAppMngr2RuntimeApiTest::StartInstallFileL ), |
|
117 ENTRY( "CheckInstallEnded", CAppMngr2RuntimeApiTest::CheckInstallEndedL ), |
|
118 ENTRY( "GetInstalledApps", CAppMngr2RuntimeApiTest::GetInstalledAppsL ), |
|
119 ENTRY( "CheckAppInstalled", CAppMngr2RuntimeApiTest::CheckAppInstalledL ), |
|
120 ENTRY( "ShowInstalledDetails", CAppMngr2RuntimeApiTest::ShowInstalledDetailsL ), |
|
121 ENTRY( "CheckNoAppsInstalled", CAppMngr2RuntimeApiTest::CheckNoAppsInstalledL ), |
|
122 ENTRY( "StartUninstallApp", CAppMngr2RuntimeApiTest::StartUninstallAppL ), |
|
123 ENTRY( "CheckUninstallEnded", CAppMngr2RuntimeApiTest::CheckUninstallEndedL ) |
|
124 }; |
|
125 |
|
126 const TInt count = sizeof( KFunctions ) / sizeof( TStifFunctionInfo ); |
|
127 return RunInternalL( KFunctions, count, aItem ); |
|
128 } |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // CAppMngr2RuntimeApiTest::RefreshInstalledApps() |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 void CAppMngr2RuntimeApiTest::RefreshInstalledApps() |
|
135 { |
|
136 _LIT( KFunctionName, "RefreshInstalledApps()" ); |
|
137 Print( KFunctionName ); |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CAppMngr2RuntimeApiTest::RefreshInstallationFiles() |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 void CAppMngr2RuntimeApiTest::RefreshInstallationFiles() |
|
145 { |
|
146 _LIT( KFunctionName, "RefreshInstallationFiles()" ); |
|
147 Print( KFunctionName ); |
|
148 } |
|
149 |
|
150 // ----------------------------------------------------------------------------- |
|
151 // CAppMngr2RuntimeApiTest::CommandResult() |
|
152 // ----------------------------------------------------------------------------- |
|
153 // |
|
154 void CAppMngr2RuntimeApiTest::CommandResult( CAppMngr2TestCommand& aCommand, |
|
155 TInt aCompletionCode ) |
|
156 { |
|
157 _LIT( KCommandResultFormat, "async command completed (%S), result %d" ); |
|
158 if( &aCommand == iInstallCommand ) |
|
159 { |
|
160 _LIT( KCommandName, "install" ); |
|
161 Print( KCommandResultFormat, &KCommandName, aCompletionCode ); |
|
162 } |
|
163 else if( &aCommand == iUninstallCommand ) |
|
164 { |
|
165 _LIT( KCommandName, "uninstall" ); |
|
166 Print( KCommandResultFormat, &KCommandName, aCompletionCode ); |
|
167 } |
|
168 else |
|
169 { |
|
170 _LIT( KCommandName, "UNKNOWN" ); |
|
171 Print( KCommandResultFormat, &KCommandName, aCompletionCode ); |
|
172 } |
|
173 Signal(); // releases "waittestclass" command in cfg file |
|
174 } |
|
175 |
|
176 // ----------------------------------------------------------------------------- |
|
177 // CAppMngr2RuntimeApiTest::CAppMngr2RuntimeApiTest() |
|
178 // ----------------------------------------------------------------------------- |
|
179 // |
|
180 CAppMngr2RuntimeApiTest::CAppMngr2RuntimeApiTest( CTestModuleIf& aTestModuleIf ) |
|
181 : CScriptBase( aTestModuleIf ) |
|
182 { |
|
183 } |
|
184 |
|
185 // ----------------------------------------------------------------------------- |
|
186 // CAppMngr2RuntimeApiTest::ConstructL() |
|
187 // ----------------------------------------------------------------------------- |
|
188 // |
|
189 void CAppMngr2RuntimeApiTest::ConstructL() |
|
190 { |
|
191 // Logger settings define if test case name must be appended to log file name |
|
192 RSettingServer settingServer; |
|
193 User::LeaveIfError( settingServer.Connect() ); |
|
194 CleanupClosePushL( settingServer ); |
|
195 TLoggerSettings loggerSettings; |
|
196 User::LeaveIfError( settingServer.GetLoggerSettings( loggerSettings ) ); |
|
197 CleanupStack::PopAndDestroy( &settingServer ); |
|
198 |
|
199 User::LeaveIfError( iFs.Connect() ); |
|
200 |
|
201 TFileName logFileName; |
|
202 if( loggerSettings.iAddTestCaseTitle ) |
|
203 { |
|
204 TName title; |
|
205 TestModuleIf().GetTestCaseTitleL( title ); |
|
206 logFileName.Format( KAppMngr2RuntimeApiTestLogFileWithTitle, &title ); |
|
207 } |
|
208 else |
|
209 { |
|
210 logFileName.Copy( KAppMngr2RuntimeApiTestLogFile ); |
|
211 } |
|
212 |
|
213 iLog = CStifLogger::NewL( KAppMngr2RuntimeApiTestLogPath, logFileName, |
|
214 CStifLogger::ETxt, CStifLogger::EFile, EFalse ); |
|
215 |
|
216 SendTestClassVersion(); |
|
217 |
|
218 _LIT( KRuntimeApiTest, "CAppMngr2RuntimeApiTest::ConstructL()" ); |
|
219 Print( KTestStartFormat, &KRuntimeApiTest ); |
|
220 |
|
221 // Ensure that CCoeEnv exists, RuntimeAPI needs it |
|
222 CCoeEnv* coeEnv = CCoeEnv::Static(); |
|
223 _LIT( KRuntimeApiTestCoeEnvFormat, "%S: coeEnv = 0x%08x"); |
|
224 Print( KRuntimeApiTestCoeEnvFormat, &KRuntimeApiTest, coeEnv ); |
|
225 User::LeaveIfNull( coeEnv ); |
|
226 |
|
227 // Load resource files used by AppMngr2 Runtime API and plug-ins |
|
228 TFileName* fullName = TAppMngr2DriveUtils::NearestResourceFileLC( |
|
229 KSWInstCommonUIResourceFileName, iFs ); |
|
230 _LIT( KRuntimeApiTestResourceFileFormat, "%S: resource file %S"); |
|
231 Print( KRuntimeApiTestResourceFileFormat, &KRuntimeApiTest, fullName ); |
|
232 iSWInstCommonResourceFileOffset = coeEnv->AddResourceFileL( *fullName ); |
|
233 CleanupStack::PopAndDestroy( fullName ); |
|
234 |
|
235 fullName = new (ELeave) TFileName; |
|
236 CleanupStack::PushL( fullName ); |
|
237 fullName->Format( KAppRscFormat, &KDC_APP_RESOURCE_DIR, &KAppMngr2UIResourceFileName ); |
|
238 BaflUtils::NearestLanguageFile( iFs, *fullName ); |
|
239 Print( KRuntimeApiTestResourceFileFormat, &KRuntimeApiTest, fullName ); |
|
240 iAppMngr2ResourceFileOffset = coeEnv->AddResourceFileL( *fullName ); |
|
241 CleanupStack::PopAndDestroy( fullName ); |
|
242 |
|
243 _LIT( KCompleteFormat, "%S: complete"); |
|
244 Print( KCompleteFormat, &KRuntimeApiTest ); |
|
245 } |
|
246 |
|
247 //----------------------------------------------------------------------------- |
|
248 // CAppMngr2RuntimeApiTest::SendTestClassVersion() |
|
249 //----------------------------------------------------------------------------- |
|
250 // |
|
251 void CAppMngr2RuntimeApiTest::SendTestClassVersion() |
|
252 { |
|
253 TVersion moduleVersion; |
|
254 moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR; |
|
255 moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR; |
|
256 moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD; |
|
257 |
|
258 TFileName moduleName; |
|
259 moduleName = KAppMngr2RuntimeApiTestModuleName; |
|
260 |
|
261 TBool newVersionOfMethod = ETrue; |
|
262 TestModuleIf().SendTestModuleVersion( moduleVersion, moduleName, newVersionOfMethod ); |
|
263 } |
|
264 |
|
265 // ----------------------------------------------------------------------------- |
|
266 // CAppMngr2RuntimeApiTest::Print() |
|
267 // ----------------------------------------------------------------------------- |
|
268 // |
|
269 void CAppMngr2RuntimeApiTest::Print( TRefByValue<const TDesC> aFmt, ... ) |
|
270 { |
|
271 VA_LIST list; |
|
272 VA_START( list, aFmt ); |
|
273 TBuf<KMaxLineLength> buf; |
|
274 buf.FormatList( aFmt, list ); |
|
275 TestModuleIf().Printf( 0, KAppMngr2Tag, buf ); |
|
276 iLog->Log( buf ); |
|
277 } |
|
278 |
|
279 // ----------------------------------------------------------------------------- |
|
280 // CAppMngr2RuntimeApiTest::GetUidFromStringL() |
|
281 // ----------------------------------------------------------------------------- |
|
282 // |
|
283 void CAppMngr2RuntimeApiTest::GetUidFromStringL( const TDesC& aString, TUid& aUid ) |
|
284 { |
|
285 TUint32 uidValue; |
|
286 TLex lex( aString ); |
|
287 User::LeaveIfError( lex.Val( uidValue, EHex ) ); |
|
288 aUid.iUid = uidValue; |
|
289 } |
|
290 |
|
291 // ----------------------------------------------------------------------------- |
|
292 // CAppMngr2RuntimeApiTest::FindInstallationPackage() |
|
293 // ----------------------------------------------------------------------------- |
|
294 // |
|
295 CAppMngr2PackageInfo* CAppMngr2RuntimeApiTest::FindInstallationPackage( |
|
296 const TDesC& aName ) |
|
297 { |
|
298 TInt count = iInstallationPackages.Count(); |
|
299 for( TInt index = 0; index < count; index++ ) |
|
300 { |
|
301 if( iInstallationPackages[ index ]->Name().CompareC( aName ) == 0 ) |
|
302 { |
|
303 return iInstallationPackages[ index ]; |
|
304 } |
|
305 } |
|
306 return NULL; |
|
307 } |
|
308 |
|
309 // ----------------------------------------------------------------------------- |
|
310 // CAppMngr2RuntimeApiTest::FindInstalledApp() |
|
311 // ----------------------------------------------------------------------------- |
|
312 // |
|
313 CAppMngr2AppInfo* CAppMngr2RuntimeApiTest::FindInstalledApp( |
|
314 const TDesC& aName ) |
|
315 { |
|
316 TInt count = iInstalledApps.Count(); |
|
317 for( TInt index = 0; index < count; index++ ) |
|
318 { |
|
319 if( iInstalledApps[ index ]->Name().CompareC( aName ) == 0 ) |
|
320 { |
|
321 return iInstalledApps[ index ]; |
|
322 } |
|
323 } |
|
324 return NULL; |
|
325 } |
|
326 |
|
327 // ----------------------------------------------------------------------------- |
|
328 // CAppMngr2RuntimeApiTest::CallInfoBaseFunctionsL() |
|
329 // ----------------------------------------------------------------------------- |
|
330 // |
|
331 void CAppMngr2RuntimeApiTest::CallInfoBaseFunctionsL( CAppMngr2InfoBase& aInfo, |
|
332 const TDesC& aTestName ) |
|
333 { |
|
334 // Call CAppMngr2InfoBase and CAppMngr2Runtime members to get better code coverage. |
|
335 CAppMngr2Runtime& runtime( aInfo.Runtime() ); |
|
336 MAppMngr2RuntimeObserver& runtimeObserver( runtime.Observer() ); |
|
337 TInt testResult = KErrNone; |
|
338 |
|
339 RPointerArray<CEikMenuPaneItem::SData> menuPaneData; |
|
340 CleanupResetAndDestroyPushL( menuPaneData ); |
|
341 TRAP( testResult, aInfo.GetMenuItemsL( menuPaneData ) ); |
|
342 _LIT( KGetMenuItemsFormat, "%S: GetMenuItemsL, count %d, result %d" ); |
|
343 Print( KGetMenuItemsFormat, &aTestName, menuPaneData.Count(), testResult ); |
|
344 User::LeaveIfError( testResult ); |
|
345 CleanupStack::PopAndDestroy( &menuPaneData ); |
|
346 |
|
347 TBool isDetailsSupported = aInfo.SupportsGenericCommand( EAppMngr2CmdViewDetails ); |
|
348 _LIT( KIsDetailsSupportedFormat, "%S: SupportsGenericCommand returned %d" ); |
|
349 Print( KIsDetailsSupportedFormat, &aTestName, isDetailsSupported ); |
|
350 |
|
351 TInt resourceId; |
|
352 TInt commandId; |
|
353 TRAP( testResult, aInfo.GetMiddleSoftkeyCommandL( resourceId, commandId ) ); |
|
354 _LIT( KGetMiddleSoftkeyCmdFormat, "%S: GetMiddleSoftkeyCommandL, result %d" ); |
|
355 Print( KGetMiddleSoftkeyCmdFormat, &aTestName, testResult ); |
|
356 User::LeaveIfError( testResult ); |
|
357 |
|
358 TBool isShowOnTop = aInfo.IsShowOnTop(); |
|
359 _LIT( KIsShowOnTopFormat, "%S: IsShowOnTop returned %d" ); |
|
360 Print( KIsShowOnTopFormat, &aTestName, isShowOnTop ); |
|
361 |
|
362 TInt iconIndex = aInfo.IconIndex(); |
|
363 _LIT( KIconIndexFormat, "%S: IconIndex returned %d" ); |
|
364 Print( KIconIndexFormat, &aTestName, iconIndex ); |
|
365 |
|
366 CGulIcon* icon = NULL; |
|
367 TRAP( testResult, icon = aInfo.SpecificIconL() ); |
|
368 delete icon; |
|
369 icon = NULL; |
|
370 _LIT( KSpecificIconFormat, "%S: SpecificIcon, result %d" ); |
|
371 Print( KSpecificIconFormat, &aTestName, testResult ); |
|
372 if( testResult != KErrNone && testResult != KErrNotSupported ) |
|
373 { |
|
374 User::Leave( testResult ); |
|
375 } |
|
376 |
|
377 TInt indIconIndex = aInfo.IndicatorIconIndex(); |
|
378 _LIT( KIndIconIndexFormat, "%S: IndicatorIconIndex returned %d" ); |
|
379 Print( KIndIconIndexFormat, &aTestName, indIconIndex ); |
|
380 |
|
381 TRAP( testResult, icon = aInfo.SpecificIndicatorIconL() ); |
|
382 delete icon; |
|
383 icon = NULL; |
|
384 _LIT( KSpecificIndIconFormat, "%S: SpecificIndicatorIcon, result %d" ); |
|
385 Print( KSpecificIndIconFormat, &aTestName, testResult ); |
|
386 if( testResult != KErrNone && testResult != KErrNotSupported ) |
|
387 { |
|
388 User::Leave( testResult ); |
|
389 } |
|
390 |
|
391 TAppMngr2Location location = aInfo.Location(); |
|
392 _LIT( KLocationFormat, "%S: Location returned %d" ); |
|
393 Print( KLocationFormat, &aTestName, location ); |
|
394 |
|
395 TDriveUnit driveUnit = aInfo.LocationDrive(); |
|
396 _LIT( KLocationDriveFormat, "%S: LocationDrive returned %S" ); |
|
397 TDriveName driveName( driveUnit.Name() ); |
|
398 Print( KLocationDriveFormat, &aTestName, &driveName ); |
|
399 } |
|
400 |
|
401 // ----------------------------------------------------------------------------- |
|
402 // CAppMngr2RuntimeApiTest::CheckFilesExistL() |
|
403 // ----------------------------------------------------------------------------- |
|
404 // |
|
405 TInt CAppMngr2RuntimeApiTest::CheckFilesExistL( CStifItemParser& aItem ) |
|
406 { |
|
407 _LIT( KTestName, "CheckFilesExist" ); |
|
408 Print( KTestStartFormat, &KTestName ); |
|
409 TInt testResult = KErrNone; |
|
410 |
|
411 TPtrC dirName; |
|
412 User::LeaveIfError( aItem.GetNextString( dirName ) ); |
|
413 |
|
414 TPtrC fileName; |
|
415 while( aItem.GetNextString( fileName ) == KErrNone ) |
|
416 { |
|
417 TParse parse; |
|
418 User::LeaveIfError( parse.SetNoWild( fileName, &dirName, NULL ) ); |
|
419 TPtrC fullName = parse.FullName(); |
|
420 TEntry entry; |
|
421 testResult = iFs.Entry( fullName, entry ); |
|
422 Print( KResultFormat, &KTestName, &fileName, testResult ); |
|
423 } |
|
424 |
|
425 Print( KTestDoneFormat, &KTestName, testResult ); |
|
426 return testResult; |
|
427 } |
|
428 |
|
429 // ----------------------------------------------------------------------------- |
|
430 // CAppMngr2RuntimeApiTest::LoadAllPluginsL() |
|
431 // ----------------------------------------------------------------------------- |
|
432 // |
|
433 TInt CAppMngr2RuntimeApiTest::LoadAllPluginsL( CStifItemParser& /*aItem*/ ) |
|
434 { |
|
435 _LIT( KTestName, "LoadAllPlugins" ); |
|
436 Print( KTestStartFormat, &KTestName ); |
|
437 TInt testResult = KErrNone; |
|
438 iPlugins.ResetAndDestroy(); |
|
439 |
|
440 RImplInfoPtrArray implInfoArray; |
|
441 CleanupResetAndDestroyPushL( implInfoArray ); |
|
442 REComSession::ListImplementationsL( KAppMngr2PluginInterface, implInfoArray ); |
|
443 |
|
444 TInt count = implInfoArray.Count(); |
|
445 _LIT( KPluginCountFormat, "%S: %d plugins found" ); |
|
446 Print( KPluginCountFormat, &KTestName, count ); |
|
447 |
|
448 for( TInt index = 0; index < count; index++ ) |
|
449 { |
|
450 CImplementationInformation* implInfo = implInfoArray[ index ]; |
|
451 CAppMngr2Runtime* plugin = NULL; |
|
452 TPtrC pluginName = implInfo->DisplayName(); |
|
453 TUid pluginUid = implInfo->ImplementationUid(); |
|
454 TRAP( testResult, plugin = CAppMngr2Runtime::NewL( pluginUid, *this ) ); |
|
455 _LIT( KLoadingFormat, "%S: index %d, loading %S (0x%08x), result %d" ); |
|
456 Print( KLoadingFormat, &KTestName, index, &pluginName, pluginUid.iUid, testResult ); |
|
457 if( testResult == KErrNone ) |
|
458 { |
|
459 CleanupStack::PushL( plugin ); |
|
460 iPlugins.AppendL( plugin ); |
|
461 CleanupStack::Pop( plugin ); |
|
462 } |
|
463 } |
|
464 |
|
465 CleanupStack::PopAndDestroy( &implInfoArray ); |
|
466 REComSession::FinalClose(); |
|
467 |
|
468 Print( KTestDoneFormat, &KTestName, testResult ); |
|
469 return testResult; |
|
470 } |
|
471 |
|
472 // ----------------------------------------------------------------------------- |
|
473 // CAppMngr2RuntimeApiTest::LoadPluginL() |
|
474 // ----------------------------------------------------------------------------- |
|
475 // |
|
476 TInt CAppMngr2RuntimeApiTest::LoadPluginL( CStifItemParser& aItem ) |
|
477 { |
|
478 _LIT( KTestName, "LoadPlugin" ); |
|
479 Print( KTestStartFormat, &KTestName ); |
|
480 TInt testResult = KErrNone; |
|
481 |
|
482 TPtrC string; |
|
483 User::LeaveIfError( aItem.GetNextString ( string ) ); |
|
484 TUid uid; |
|
485 GetUidFromStringL( string, uid ); |
|
486 _LIT( KPluginCountFormat, "%S: plugin UID 0x%08x" ); |
|
487 Print( KPluginCountFormat, &KTestName, uid.iUid ); |
|
488 |
|
489 RImplInfoPtrArray implInfoArray; |
|
490 CleanupResetAndDestroyPushL( implInfoArray ); |
|
491 REComSession::ListImplementationsL( KAppMngr2PluginInterface, implInfoArray ); |
|
492 |
|
493 CImplementationInformation* implInfo; |
|
494 TInt count = implInfoArray.Count(); |
|
495 TBool found = EFalse; |
|
496 for( TInt index = 0; index < count && !found; index++ ) |
|
497 { |
|
498 implInfo = implInfoArray[ index ]; |
|
499 if( implInfo->ImplementationUid() == uid ) |
|
500 { |
|
501 CAppMngr2Runtime* plugin = NULL; |
|
502 found = ETrue; |
|
503 |
|
504 _LIT( KLoadingFormat, "%S: loading %S" ); |
|
505 Print( KLoadingFormat, &KTestName, &( implInfo->DisplayName() ) ); |
|
506 TRAP( testResult, plugin = CAppMngr2Runtime::NewL( |
|
507 implInfo->ImplementationUid(), *this ) ); |
|
508 if( testResult == KErrNone ) |
|
509 { |
|
510 CleanupStack::PushL( plugin ); |
|
511 iPlugins.AppendL( plugin ); |
|
512 CleanupStack::Pop( plugin ); |
|
513 } |
|
514 } |
|
515 } |
|
516 if( !found ) |
|
517 { |
|
518 _LIT( KPluginNotFound, "%S: plugin not found" ); |
|
519 Print( KPluginNotFound, &KTestName ); |
|
520 testResult = KErrNotFound; |
|
521 } |
|
522 |
|
523 CleanupStack::PopAndDestroy( &implInfoArray ); |
|
524 REComSession::FinalClose(); |
|
525 |
|
526 Print( KTestDoneFormat, &KTestName, testResult ); |
|
527 return testResult; |
|
528 } |
|
529 |
|
530 // ----------------------------------------------------------------------------- |
|
531 // CAppMngr2RuntimeApiTest::CheckPluginsLoadedL() |
|
532 // ----------------------------------------------------------------------------- |
|
533 // |
|
534 TInt CAppMngr2RuntimeApiTest::CheckPluginsLoadedL( CStifItemParser& aItem ) |
|
535 { |
|
536 _LIT( KTestName, "CheckPluginsLoaded" ); |
|
537 Print( KTestStartFormat, &KTestName ); |
|
538 TInt testResult = KErrNone; |
|
539 |
|
540 TPtrC pluginUidString; |
|
541 while( aItem.GetNextString( pluginUidString ) == KErrNone ) |
|
542 { |
|
543 TUid uid; |
|
544 GetUidFromStringL( pluginUidString, uid ); |
|
545 |
|
546 TBool found = EFalse; |
|
547 for( TInt index = 0; index < iPlugins.Count() && !found; index++ ) |
|
548 { |
|
549 found = ( iPlugins[ index ]->RuntimeUid() == uid ); |
|
550 } |
|
551 |
|
552 _LIT( KCheckPluginsLoadedFormat, "%S: 0x%08x, result %d" ); |
|
553 Print( KCheckPluginsLoadedFormat, &KTestName, uid.iUid, found ); |
|
554 if( !found ) |
|
555 { |
|
556 testResult = KErrNotFound; |
|
557 } |
|
558 } |
|
559 |
|
560 Print( KTestDoneFormat, &KTestName, testResult ); |
|
561 return testResult; |
|
562 } |
|
563 |
|
564 // ----------------------------------------------------------------------------- |
|
565 // CAppMngr2RuntimeApiTest::LoadIconsL() |
|
566 // ----------------------------------------------------------------------------- |
|
567 // |
|
568 TInt CAppMngr2RuntimeApiTest::LoadIconsL( CStifItemParser& /*aItem*/ ) |
|
569 { |
|
570 _LIT( KTestName, "LoadIcons" ); |
|
571 Print( KTestStartFormat, &KTestName ); |
|
572 TInt testResult = KErrNone; |
|
573 |
|
574 for( TInt pluginIndex = 0; pluginIndex < iPlugins.Count(); pluginIndex++ ) |
|
575 { |
|
576 CAppMngr2Runtime* plugin = iPlugins[ pluginIndex ]; |
|
577 TInt pluginId = plugin->RuntimeUid().iUid; |
|
578 |
|
579 CAknIconArray* iconArray = new (ELeave) CAknIconArray( KGranularity ); |
|
580 CleanupStack::PushL( iconArray ); |
|
581 TRAP( testResult, plugin->LoadIconsL( *iconArray ) ); |
|
582 _LIT( KLoadIconsFormat, "%S: plugin 0x%08x, icons count %d, error %d" ); |
|
583 Print( KLoadIconsFormat, &KTestName, pluginId, iconArray->Count(), testResult ); |
|
584 CleanupStack::PopAndDestroy( iconArray ); |
|
585 } |
|
586 |
|
587 Print( KTestDoneFormat, &KTestName, testResult ); |
|
588 return testResult; |
|
589 } |
|
590 |
|
591 // ----------------------------------------------------------------------------- |
|
592 // CAppMngr2RuntimeApiTest::GetAdditionalDirsToScanL() |
|
593 // ----------------------------------------------------------------------------- |
|
594 // |
|
595 TInt CAppMngr2RuntimeApiTest::GetAdditionalDirsToScanL( CStifItemParser& /*aItem*/ ) |
|
596 { |
|
597 _LIT( KTestName, "GetAdditionalDirsToScan" ); |
|
598 Print( KTestStartFormat, &KTestName ); |
|
599 TInt testResult = KErrNone; |
|
600 |
|
601 for( TInt pluginIndex = 0; pluginIndex < iPlugins.Count(); pluginIndex++ ) |
|
602 { |
|
603 CAppMngr2Runtime* plugin = iPlugins[ pluginIndex ]; |
|
604 TInt pluginId = plugin->RuntimeUid().iUid; |
|
605 |
|
606 RPointerArray<HBufC> dirs; |
|
607 CleanupResetAndDestroyPushL( dirs ); |
|
608 TRAP( testResult, plugin->GetAdditionalDirsToScanL( iFs, dirs ) ); |
|
609 _LIT( KDirsToScanFormat, "%S: plugin 0x%08x, additional dirs, count %d, error %d" ); |
|
610 Print( KDirsToScanFormat, &KTestName, pluginId, dirs.Count(), testResult ); |
|
611 if( testResult == KErrNone ) |
|
612 { |
|
613 for( TInt dirIndex = 0; dirIndex < dirs.Count(); dirIndex++ ) |
|
614 { |
|
615 _LIT( KScanDirFormat, "%S: plugin 0x%08x, dir %S" ); |
|
616 Print( KScanDirFormat, &KTestName, pluginId, dirs[ dirIndex ] ); |
|
617 } |
|
618 } |
|
619 CleanupStack::PopAndDestroy( &dirs ); |
|
620 } |
|
621 |
|
622 Print( KTestDoneFormat, &KTestName, testResult ); |
|
623 return testResult; |
|
624 } |
|
625 |
|
626 // ----------------------------------------------------------------------------- |
|
627 // CAppMngr2RuntimeApiTest::GetInstallationFilesL() |
|
628 // ----------------------------------------------------------------------------- |
|
629 // |
|
630 TInt CAppMngr2RuntimeApiTest::GetInstallationFilesL( CStifItemParser& aItem ) |
|
631 { |
|
632 _LIT( KTestName, "GetInstallationFiles" ); |
|
633 Print( KTestStartFormat, &KTestName ); |
|
634 TInt testResult = KErrNone; |
|
635 iInstallationPackages.ResetAndDestroy(); |
|
636 |
|
637 TPtrC dirName; |
|
638 User::LeaveIfError( aItem.GetNextString( dirName ) ); |
|
639 _LIT( KParameterFormat, "%S: dir %S" ); |
|
640 Print( KParameterFormat, &KTestName, &dirName ); |
|
641 |
|
642 RPointerArray<CAppMngr2RecognizedFile> fileArray; |
|
643 CleanupResetAndDestroyPushL( fileArray ); |
|
644 |
|
645 // recognize files in given directory |
|
646 CDir* dir = NULL; |
|
647 User::LeaveIfError( iFs.GetDir( dirName, KEntryAttNormal, ESortNone, dir ) ); |
|
648 CleanupStack::PushL( dir ); |
|
649 TInt dirCount = dir->Count(); |
|
650 for( TInt dirIndex = 0; dirIndex < dirCount; dirIndex++ ) |
|
651 { |
|
652 const TChar KBackslash = '\\'; |
|
653 const TInt KBackslashLen = 1; |
|
654 |
|
655 const TEntry& file = ( *dir )[ dirIndex ]; |
|
656 |
|
657 // full file name |
|
658 HBufC* fullName = HBufC::NewLC( dirName.Length() + KBackslashLen + file.iName.Length() ); |
|
659 TPtr namePtr( fullName->Des() ); |
|
660 namePtr.Copy( dirName ); |
|
661 if( dirName.LocateReverse( KBackslash ) != ( dirName.Length() - 1 ) ) |
|
662 { |
|
663 namePtr.Append( KBackslash ); |
|
664 } |
|
665 namePtr.Append( file.iName ); |
|
666 |
|
667 // data type |
|
668 HBufC* mimeType = HBufC::NewLC( KMaxDataTypeLength ); |
|
669 ContentAccess::CContent* content = ContentAccess::CContent::NewLC( *fullName, |
|
670 ContentAccess::EContentShareReadWrite ); |
|
671 TPtr mimePtr( mimeType->Des() ); |
|
672 content->GetStringAttribute( ContentAccess::EMimeType, mimePtr ); |
|
673 |
|
674 _LIT( KFileTypeFormat, "%S: file %S, type %S" ); |
|
675 Print( KFileTypeFormat, &KTestName, fullName, mimeType ); |
|
676 |
|
677 // create new recognized file |
|
678 CAppMngr2RecognizedFile* recFile = CAppMngr2RecognizedFile::NewL( fullName, mimeType ); |
|
679 CleanupStack::PopAndDestroy( content ); |
|
680 CleanupStack::Pop( 2, fullName ); // mimeType and fullName now owned by recFile |
|
681 |
|
682 // append it into array |
|
683 CleanupStack::PushL( recFile ); |
|
684 fileArray.AppendL( recFile ); |
|
685 CleanupStack::Pop( recFile ); |
|
686 } |
|
687 CleanupStack::PopAndDestroy( dir ); |
|
688 dir = NULL; |
|
689 |
|
690 for( TInt pluginIndex = 0; pluginIndex < iPlugins.Count(); pluginIndex++ ) |
|
691 { |
|
692 CAppMngr2Runtime* plugin = iPlugins[ pluginIndex ]; |
|
693 TInt pluginId = plugin->RuntimeUid().iUid; |
|
694 |
|
695 CDataTypeArray* dataTypeArray = new (ELeave) CDataTypeArray( KGranularity ); |
|
696 CleanupStack::PushL( dataTypeArray ); |
|
697 TRAP( testResult, plugin->GetSupportedDataTypesL( *dataTypeArray ) ); |
|
698 _LIT( KSuppDataTypeFormat, "%S: plugin 0x%08x, data type count %d, error %d" ); |
|
699 Print( KSuppDataTypeFormat, &KTestName, pluginId, dataTypeArray->Count(), testResult ); |
|
700 if( testResult == KErrNone ) |
|
701 { |
|
702 // copy those recognized files that matches plugin data types in pluginFiles |
|
703 RPointerArray<CAppMngr2RecognizedFile> pluginFiles; |
|
704 CleanupResetAndDestroyPushL( pluginFiles ); |
|
705 for( TInt dataTypeIndex = 0; dataTypeIndex < dataTypeArray->Count(); dataTypeIndex++ ) |
|
706 { |
|
707 for( TInt fileIndex = 0; fileIndex < fileArray.Count(); fileIndex++ ) |
|
708 { |
|
709 if( fileArray[ fileIndex ]->DataType() == (*dataTypeArray)[ dataTypeIndex ] ) |
|
710 { |
|
711 _LIT( KPluginGetsFileFormat, "%S: plugin 0x%08x, matching file %S" ); |
|
712 Print( KPluginGetsFileFormat, &KTestName, pluginId, |
|
713 &( fileArray[ fileIndex ]->FileName() ) ); |
|
714 |
|
715 CAppMngr2RecognizedFile* recFile = CAppMngr2RecognizedFile::NewL( |
|
716 fileArray[ fileIndex ]->FileName(), |
|
717 fileArray[ fileIndex ]->DataType() ); |
|
718 CleanupStack::PushL( recFile ); |
|
719 pluginFiles.Append( recFile ); |
|
720 CleanupStack::Pop( recFile ); |
|
721 } |
|
722 } |
|
723 } |
|
724 _LIT( KPluginFilesFormat, "%S: plugin 0x%08x, total %d files" ); |
|
725 Print( KPluginFilesFormat, &KTestName, pluginId, pluginFiles.Count() ); |
|
726 |
|
727 // get installation files from plugin |
|
728 RPointerArray<CAppMngr2PackageInfo> packageArray; |
|
729 CleanupResetAndDestroyPushL( packageArray ); |
|
730 TRequestStatus status; |
|
731 TRAP( testResult, plugin->GetInstallationFilesL( packageArray, pluginFiles, iFs, status ) ); |
|
732 _LIT( KInstFilesReqFormat, "%S: plugin 0x%08x, inst files req, error %d, status %d" ); |
|
733 Print( KInstFilesReqFormat, &KTestName, pluginId, testResult, status.Int() ); |
|
734 if( testResult == KErrNone ) |
|
735 { |
|
736 User::WaitForRequest( status ); |
|
737 _LIT( KInstFilesCompleteFormat, "%S: plugin 0x%08x, package count %d, status %d" ); |
|
738 Print( KInstFilesCompleteFormat, &KTestName, pluginId, packageArray.Count(), |
|
739 status.Int() ); |
|
740 |
|
741 // move items to iInstallationPackages array |
|
742 for( TInt i = packageArray.Count() - 1; i >= 0; i-- ) |
|
743 { |
|
744 CAppMngr2PackageInfo* packageInfo = packageArray[ i ]; |
|
745 packageArray.Remove( i ); |
|
746 CleanupStack::PushL( packageInfo ); |
|
747 iInstallationPackages.AppendL( packageInfo ); |
|
748 CleanupStack::Pop( packageInfo ); |
|
749 } |
|
750 _LIT( KTotalInstFileCountFormat, "%S: total package count %d" ); |
|
751 Print( KTotalInstFileCountFormat, &KTestName, iInstallationPackages.Count() ); |
|
752 |
|
753 if( status.Int() ) |
|
754 { |
|
755 testResult = status.Int(); |
|
756 } |
|
757 } |
|
758 |
|
759 CleanupStack::PopAndDestroy( &packageArray ); |
|
760 CleanupStack::PopAndDestroy( &pluginFiles ); |
|
761 } |
|
762 |
|
763 CleanupStack::PopAndDestroy( dataTypeArray ); |
|
764 } |
|
765 |
|
766 CleanupStack::PopAndDestroy( &fileArray ); |
|
767 |
|
768 Print( KTestDoneFormat, &KTestName, testResult ); |
|
769 return testResult; |
|
770 } |
|
771 |
|
772 // ----------------------------------------------------------------------------- |
|
773 // CAppMngr2RuntimeApiTest::CheckInstallationFilesL() |
|
774 // ----------------------------------------------------------------------------- |
|
775 // |
|
776 TInt CAppMngr2RuntimeApiTest::CheckInstallationFilesL( CStifItemParser& aItem ) |
|
777 { |
|
778 _LIT( KTestName, "CheckInstallationFiles" ); |
|
779 Print( KTestStartFormat, &KTestName ); |
|
780 TInt testResult = KErrNone; |
|
781 |
|
782 TPtrC nameString; |
|
783 while( aItem.GetNextString( nameString ) == KErrNone ) |
|
784 { |
|
785 CAppMngr2PackageInfo* info = FindInstallationPackage( nameString ); |
|
786 TBool found = ( info != NULL ); |
|
787 |
|
788 _LIT( KCheckInstFileFormat, "%S: file %S, result %d" ); |
|
789 Print( KCheckInstFileFormat, &KTestName, &nameString, found ); |
|
790 if( found ) |
|
791 { |
|
792 CallInfoBaseFunctionsL( *info, KTestName ); |
|
793 } |
|
794 else |
|
795 { |
|
796 Print( KNotFoundFormat, &KTestName, &nameString ); |
|
797 testResult = KErrNotFound; |
|
798 } |
|
799 } |
|
800 |
|
801 Print( KTestDoneFormat, &KTestName, testResult ); |
|
802 return testResult; |
|
803 } |
|
804 |
|
805 // ----------------------------------------------------------------------------- |
|
806 // CAppMngr2RuntimeApiTest::ShowInstallationFileDetailsL() |
|
807 // ----------------------------------------------------------------------------- |
|
808 // |
|
809 TInt CAppMngr2RuntimeApiTest::ShowInstallationFileDetailsL( CStifItemParser& aItem ) |
|
810 { |
|
811 _LIT( KTestName, "ShowInstallationFileDetails" ); |
|
812 Print( KTestStartFormat, &KTestName ); |
|
813 TInt testResult = KErrNone; |
|
814 |
|
815 if( iShowDetailsCommand ) |
|
816 { |
|
817 User::Leave( KErrInUse ); |
|
818 } |
|
819 |
|
820 TPtrC nameString; |
|
821 while( aItem.GetNextString( nameString ) == KErrNone ) |
|
822 { |
|
823 CAppMngr2PackageInfo* info = FindInstallationPackage( nameString ); |
|
824 if( info ) |
|
825 { |
|
826 iShowDetailsCommand = CAppMngr2TestCommand::NewL( *info, *this ); |
|
827 TRAP( testResult, iShowDetailsCommand->HandleCommandL( EAppMngr2CmdViewDetails ) ); |
|
828 _LIT( KShowInstFileDetailsFormat, "%S: show details request %S, result %d" ); |
|
829 Print( KShowInstFileDetailsFormat, &KTestName, &nameString, testResult ); |
|
830 } |
|
831 else |
|
832 { |
|
833 Print( KNotFoundFormat, &KTestName, &nameString ); |
|
834 testResult = KErrNotFound; |
|
835 } |
|
836 } |
|
837 |
|
838 Print( KTestDoneFormat, &KTestName, testResult ); |
|
839 return testResult; |
|
840 } |
|
841 |
|
842 // ----------------------------------------------------------------------------- |
|
843 // CAppMngr2RuntimeApiTest::CheckShowDetailsEndedL() |
|
844 // ----------------------------------------------------------------------------- |
|
845 // |
|
846 TInt CAppMngr2RuntimeApiTest::CheckShowDetailsEndedL( CStifItemParser& /*aItem*/ ) |
|
847 { |
|
848 _LIT( KTestName, "CheckShowDetailsEnded" ); |
|
849 Print( KTestStartFormat, &KTestName ); |
|
850 TInt testResult = KErrNone; |
|
851 |
|
852 if( !iShowDetailsCommand ) |
|
853 { |
|
854 User::Leave( KErrNotFound ); |
|
855 } |
|
856 |
|
857 if( iShowDetailsCommand->IsActive() ) |
|
858 { |
|
859 User::Leave( KErrNotReady ); |
|
860 } |
|
861 testResult = iShowDetailsCommand->iStatus.Int(); |
|
862 _LIT( KCheckShowDetailsEndedFormat, "%S: show details completed, status %d" ); |
|
863 Print( KCheckShowDetailsEndedFormat, &KTestName, testResult ); |
|
864 |
|
865 delete iShowDetailsCommand; |
|
866 iShowDetailsCommand = NULL; |
|
867 |
|
868 Print( KTestDoneFormat, &KTestName, testResult ); |
|
869 return testResult; |
|
870 } |
|
871 |
|
872 // ----------------------------------------------------------------------------- |
|
873 // CAppMngr2RuntimeApiTest::CheckNoInstallationFilesL() |
|
874 // ----------------------------------------------------------------------------- |
|
875 // |
|
876 TInt CAppMngr2RuntimeApiTest::CheckNoInstallationFilesL( CStifItemParser& /*aItem*/ ) |
|
877 { |
|
878 _LIT( KTestName, "CheckNoInstallationFiles" ); |
|
879 Print( KTestStartFormat, &KTestName ); |
|
880 TInt testResult = KErrNone; |
|
881 |
|
882 TInt count = iInstallationPackages.Count(); |
|
883 if( count != 0 ) |
|
884 { |
|
885 testResult = KErrTooBig; |
|
886 } |
|
887 _LIT( KInstallationFilesEmptyFormat, "%S: file count %d" ); |
|
888 Print( KInstallationFilesEmptyFormat, &KTestName, count ); |
|
889 |
|
890 Print( KTestDoneFormat, &KTestName, testResult ); |
|
891 return testResult; |
|
892 } |
|
893 |
|
894 // ----------------------------------------------------------------------------- |
|
895 // CAppMngr2RuntimeApiTest::StartInstallFileL() |
|
896 // ----------------------------------------------------------------------------- |
|
897 // |
|
898 TInt CAppMngr2RuntimeApiTest::StartInstallFileL( CStifItemParser& aItem ) |
|
899 { |
|
900 _LIT( KTestName, "StartInstallFile" ); |
|
901 Print( KTestStartFormat, &KTestName ); |
|
902 TInt testResult = KErrNone; |
|
903 |
|
904 if( iInstallCommand ) |
|
905 { |
|
906 User::Leave( KErrInUse ); |
|
907 } |
|
908 |
|
909 TPtrC nameString; |
|
910 while( aItem.GetNextString( nameString ) == KErrNone ) |
|
911 { |
|
912 CAppMngr2PackageInfo* info = FindInstallationPackage( nameString ); |
|
913 if( info ) |
|
914 { |
|
915 iInstallCommand = CAppMngr2TestCommand::NewL( *info, *this ); |
|
916 TRAP( testResult, iInstallCommand->HandleCommandL( EAppMngr2CmdInstall ) ); |
|
917 _LIT( KInstallFileFormat, "%S: install request %S, result %d" ); |
|
918 Print( KInstallFileFormat, &KTestName, &nameString, testResult ); |
|
919 } |
|
920 else |
|
921 { |
|
922 Print( KNotFoundFormat, &KTestName, &nameString ); |
|
923 testResult = KErrNotFound; |
|
924 } |
|
925 } |
|
926 |
|
927 Print( KTestDoneFormat, &KTestName, testResult ); |
|
928 return testResult; |
|
929 } |
|
930 |
|
931 // ----------------------------------------------------------------------------- |
|
932 // CAppMngr2RuntimeApiTest::CheckInstallEndedL() |
|
933 // ----------------------------------------------------------------------------- |
|
934 // |
|
935 TInt CAppMngr2RuntimeApiTest::CheckInstallEndedL( CStifItemParser& /*aItem*/ ) |
|
936 { |
|
937 _LIT( KTestName, "CheckInstallEnded" ); |
|
938 Print( KTestStartFormat, &KTestName ); |
|
939 TInt testResult = KErrNone; |
|
940 |
|
941 if( !iInstallCommand ) |
|
942 { |
|
943 User::Leave( KErrNotFound ); |
|
944 } |
|
945 |
|
946 if( iInstallCommand->IsActive() ) |
|
947 { |
|
948 User::Leave( KErrNotReady ); |
|
949 } |
|
950 testResult = iInstallCommand->iStatus.Int(); |
|
951 _LIT( KCheckInstallEndedFormat, "%S: install completed, status %d" ); |
|
952 Print( KCheckInstallEndedFormat, &KTestName, testResult ); |
|
953 |
|
954 delete iInstallCommand; |
|
955 iInstallCommand = NULL; |
|
956 |
|
957 Print( KTestDoneFormat, &KTestName, testResult ); |
|
958 return testResult; |
|
959 } |
|
960 |
|
961 // ----------------------------------------------------------------------------- |
|
962 // CAppMngr2RuntimeApiTest::GetInstalledAppsL() |
|
963 // ----------------------------------------------------------------------------- |
|
964 // |
|
965 TInt CAppMngr2RuntimeApiTest::GetInstalledAppsL( CStifItemParser& /*aItem*/ ) |
|
966 { |
|
967 _LIT( KTestName, "GetInstalledApps" ); |
|
968 Print( KTestStartFormat, &KTestName ); |
|
969 TInt testResult = KErrNone; |
|
970 iInstalledApps.ResetAndDestroy(); |
|
971 |
|
972 TInt count = iPlugins.Count(); |
|
973 for( TInt index = 0; index < count; index++ ) |
|
974 { |
|
975 CAppMngr2Runtime* plugin = iPlugins[ index ]; |
|
976 TInt pluginId = plugin->RuntimeUid().iUid; |
|
977 |
|
978 RPointerArray<CAppMngr2AppInfo> appArray; |
|
979 CleanupResetAndDestroyPushL( appArray ); |
|
980 |
|
981 TRequestStatus status; |
|
982 TRAP( testResult, plugin->GetInstalledAppsL( appArray, iFs, status ) ); |
|
983 _LIT( KRequestedFormat, "%S: plugin 0x%08x, apps requested, error %d, status %d" ); |
|
984 Print( KRequestedFormat, &KTestName, pluginId, testResult, status.Int() ); |
|
985 if( testResult == KErrNone ) |
|
986 { |
|
987 User::WaitForRequest( status ); |
|
988 _LIT( KLoadedFormat, "%S: plugin 0x%08x, apps count %d, status %d" ); |
|
989 TInt count = appArray.Count(); |
|
990 Print( KLoadedFormat, &KTestName, pluginId, count, status.Int() ); |
|
991 |
|
992 // move items to iInstalledApps array |
|
993 for( TInt i = count - 1; i >= 0; i-- ) |
|
994 { |
|
995 CAppMngr2AppInfo* appInfo = appArray[ i ]; |
|
996 appArray.Remove( i ); |
|
997 CleanupStack::PushL( appInfo ); |
|
998 iInstalledApps.AppendL( appInfo ); |
|
999 CleanupStack::Pop( appInfo ); |
|
1000 } |
|
1001 _LIT( KTotalInstAppCountFormat, "%S: total installed apps count %d" ); |
|
1002 Print( KTotalInstAppCountFormat, &KTestName, iInstalledApps.Count() ); |
|
1003 |
|
1004 if( status.Int() ) |
|
1005 { |
|
1006 testResult = status.Int(); |
|
1007 } |
|
1008 } |
|
1009 |
|
1010 CleanupStack::PopAndDestroy( &appArray ); |
|
1011 } |
|
1012 |
|
1013 Print( KTestDoneFormat, &KTestName, testResult ); |
|
1014 return testResult; |
|
1015 } |
|
1016 |
|
1017 // ----------------------------------------------------------------------------- |
|
1018 // CAppMngr2RuntimeApiTest::CheckAppInstalledL() |
|
1019 // ----------------------------------------------------------------------------- |
|
1020 // |
|
1021 TInt CAppMngr2RuntimeApiTest::CheckAppInstalledL( CStifItemParser& aItem ) |
|
1022 { |
|
1023 _LIT( KTestName, "CheckAppInstalled" ); |
|
1024 Print( KTestStartFormat, &KTestName ); |
|
1025 TInt testResult = KErrNone; |
|
1026 |
|
1027 TPtrC nameString; |
|
1028 while( aItem.GetNextString( nameString ) == KErrNone ) |
|
1029 { |
|
1030 CAppMngr2AppInfo* info = FindInstalledApp( nameString ); |
|
1031 TBool found = ( info != NULL ); |
|
1032 |
|
1033 Print( KResultFormat, &KTestName, &nameString, found ); |
|
1034 if( found ) |
|
1035 { |
|
1036 CallInfoBaseFunctionsL( *info, KTestName ); |
|
1037 } |
|
1038 else |
|
1039 { |
|
1040 Print( KNotFoundFormat, &KTestName, &nameString ); |
|
1041 testResult = KErrNotFound; |
|
1042 } |
|
1043 } |
|
1044 |
|
1045 Print( KTestDoneFormat, &KTestName, testResult ); |
|
1046 return testResult; |
|
1047 } |
|
1048 |
|
1049 // ----------------------------------------------------------------------------- |
|
1050 // CAppMngr2RuntimeApiTest::ShowInstalledDetailsL() |
|
1051 // ----------------------------------------------------------------------------- |
|
1052 // |
|
1053 TInt CAppMngr2RuntimeApiTest::ShowInstalledDetailsL( CStifItemParser& aItem ) |
|
1054 { |
|
1055 _LIT( KTestName, "ShowInstalledDetails" ); |
|
1056 Print( KTestStartFormat, &KTestName ); |
|
1057 TInt testResult = KErrNone; |
|
1058 |
|
1059 if( iShowDetailsCommand ) |
|
1060 { |
|
1061 User::Leave( KErrInUse ); |
|
1062 } |
|
1063 |
|
1064 TPtrC nameString; |
|
1065 while( aItem.GetNextString( nameString ) == KErrNone ) |
|
1066 { |
|
1067 CAppMngr2AppInfo* info = FindInstalledApp( nameString ); |
|
1068 if( info ) |
|
1069 { |
|
1070 iShowDetailsCommand = CAppMngr2TestCommand::NewL( *info, *this ); |
|
1071 TRAP( testResult, iShowDetailsCommand->HandleCommandL( EAppMngr2CmdViewDetails ) ); |
|
1072 _LIT( KShowInstalledDetailsFormat, "%S: show details request %S, result %d" ); |
|
1073 Print( KShowInstalledDetailsFormat, &KTestName, &nameString, testResult ); |
|
1074 } |
|
1075 else |
|
1076 { |
|
1077 Print( KNotFoundFormat, &KTestName, &nameString ); |
|
1078 testResult = KErrNotFound; |
|
1079 } |
|
1080 } |
|
1081 |
|
1082 Print( KTestDoneFormat, &KTestName, testResult ); |
|
1083 return testResult; |
|
1084 } |
|
1085 |
|
1086 // ----------------------------------------------------------------------------- |
|
1087 // CAppMngr2RuntimeApiTest::CheckNoAppsInstalledL() |
|
1088 // ----------------------------------------------------------------------------- |
|
1089 // |
|
1090 TInt CAppMngr2RuntimeApiTest::CheckNoAppsInstalledL( CStifItemParser& /*aItem*/ ) |
|
1091 { |
|
1092 _LIT( KTestName, "CheckNoAppsInstalled" ); |
|
1093 Print( KTestStartFormat, &KTestName ); |
|
1094 TInt testResult = KErrNone; |
|
1095 |
|
1096 TInt count = iInstalledApps.Count(); |
|
1097 if( count != 0 ) |
|
1098 { |
|
1099 testResult = KErrTooBig; |
|
1100 } |
|
1101 _LIT( KInstalledAppsEmptyFormat, "%S: app count %d" ); |
|
1102 Print( KInstalledAppsEmptyFormat, &KTestName, count ); |
|
1103 |
|
1104 Print( KTestDoneFormat, &KTestName, testResult ); |
|
1105 return testResult; |
|
1106 } |
|
1107 |
|
1108 // ----------------------------------------------------------------------------- |
|
1109 // CAppMngr2RuntimeApiTest::StartUninstallAppL() |
|
1110 // ----------------------------------------------------------------------------- |
|
1111 // |
|
1112 TInt CAppMngr2RuntimeApiTest::StartUninstallAppL( CStifItemParser& aItem ) |
|
1113 { |
|
1114 _LIT( KTestName, "StartUninstallApp" ); |
|
1115 Print( KTestStartFormat, &KTestName ); |
|
1116 TInt testResult = KErrNone; |
|
1117 |
|
1118 if( iUninstallCommand ) |
|
1119 { |
|
1120 User::Leave( KErrInUse ); |
|
1121 } |
|
1122 |
|
1123 TPtrC nameString; |
|
1124 while( aItem.GetNextString( nameString ) == KErrNone ) |
|
1125 { |
|
1126 CAppMngr2AppInfo* info = FindInstalledApp( nameString ); |
|
1127 if( info ) |
|
1128 { |
|
1129 iUninstallCommand = CAppMngr2TestCommand::NewL( *info, *this ); |
|
1130 TRAP( testResult, iUninstallCommand->HandleCommandL( EAppMngr2CmdUninstall ) ); |
|
1131 _LIT( KUninstallAppFormat, "%S: uninstall request %S, result %d" ); |
|
1132 Print( KUninstallAppFormat, &KTestName, &nameString, testResult ); |
|
1133 } |
|
1134 else |
|
1135 { |
|
1136 Print( KNotFoundFormat, &KTestName, &nameString ); |
|
1137 testResult = KErrNotFound; |
|
1138 } |
|
1139 } |
|
1140 |
|
1141 Print( KTestDoneFormat, &KTestName, testResult ); |
|
1142 return testResult; |
|
1143 } |
|
1144 |
|
1145 // ----------------------------------------------------------------------------- |
|
1146 // CAppMngr2RuntimeApiTest::CheckUninstallEndedL() |
|
1147 // ----------------------------------------------------------------------------- |
|
1148 // |
|
1149 TInt CAppMngr2RuntimeApiTest::CheckUninstallEndedL( CStifItemParser& /*aItem*/ ) |
|
1150 { |
|
1151 _LIT( KTestName, "CheckUninstallEnded" ); |
|
1152 Print( KTestStartFormat, &KTestName ); |
|
1153 TInt testResult = KErrNone; |
|
1154 |
|
1155 if( !iUninstallCommand ) |
|
1156 { |
|
1157 User::Leave( KErrNotFound ); |
|
1158 } |
|
1159 |
|
1160 if( iUninstallCommand->IsActive() ) |
|
1161 { |
|
1162 User::Leave( KErrNotReady ); |
|
1163 } |
|
1164 testResult = iUninstallCommand->iStatus.Int(); |
|
1165 _LIT( KCheckUninstallEndedFormat, "%S: uninstall completed, status %d" ); |
|
1166 Print( KCheckUninstallEndedFormat, &KTestName, testResult ); |
|
1167 |
|
1168 delete iUninstallCommand; |
|
1169 iUninstallCommand = NULL; |
|
1170 |
|
1171 Print( KTestDoneFormat, &KTestName, testResult ); |
|
1172 return testResult; |
|
1173 } |
|
1174 |
|