os/ossrv/lowlevellibsandfws/pluginfw/Framework/MultipleImageTest/t_multipleImageTest.cpp
Update contrib.
1 // Copyright (c) 2006-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include "..\EcomTestUtils\EcomTestUtils.h"
18 #include <Ecom\ECom.h>
19 #include <Ecom\ImplementationInformation.h>
23 TUid KUidMultipeImageInterface = { 0x10282307 };
25 static RTest TheTest(_L("t_multipleImageTest.exe"));
27 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
28 _LIT(KEnglishLocale, "elocl.01");
29 _LIT(KFrenchLocale, "elocl.02");
30 _LIT(KGermanLocale, "elocl.03");
32 // refer base/os/kernelhwsrv/kernel/eka/euser/locmapping.cpp
34 _LIT(KEComEnglishLang,"elocl_lan.001");
35 _LIT(KEComFrenchLang,"elocl_lan.002");
36 _LIT(KEComGermanLang,"elocl_lan.003");
38 _LIT(KEComEnglishReg,"elocl_reg.826");
39 _LIT(KEComFrenchReg,"elocl_reg.250");
40 _LIT(KEComGermanReg,"elocl_reg.276");
42 _LIT(KEComEnglishColl,"elocl_col.001");
43 _LIT(KEComFrenchColl,"elocl_col.002");
44 _LIT(KEComGermanColl,"elocl_col.003");
47 // Test Macroes and Functions
48 static void Check(TInt aValue, TInt aLine)
52 TheTest(EFalse, aLine);
56 static void Check(TInt aValue, TInt aExpected, TInt aLine)
58 if(aValue != aExpected)
60 RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
61 TheTest(EFalse, aLine);
64 #define TEST(arg) ::Check((arg), __LINE__)
65 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
67 // Type definition for test functions.
68 // Used in calling t_multipleImageTest functions.
69 typedef void (*FuncPtrL) (TLanguage* , TPtrC* );
71 void KillEComServerL()
73 //Need to ensure that the EComServer process is killed before even starting this test by using
74 //the EComTestUtils library
75 _LIT(KEComServerProcessName,"ecomserver");
76 TRAPD(error, EComTestUtils::KillProcessL(KEComServerProcessName));
77 TEST2(error, KErrNone);
80 void SetLanguageDowngradeL(TLanguage* aLanguages)
85 RArray<TLanguage> languageArray;
87 TLanguage lang = User::Language();
89 if(lang != aLanguages[0])
91 TExtendedLocale extendedLocale;
92 extendedLocale.LoadSystemSettings();
94 if(aLanguages[0] == ELangEnglish)
96 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
97 extendedLocale.LoadLocale(KEnglishLocale);
99 extendedLocale.LoadLocale(KEComEnglishLang,KEComEnglishReg,KEComEnglishColl);
102 else if(aLanguages[0] == ELangFrench)
104 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
105 extendedLocale.LoadLocale(KFrenchLocale);
107 extendedLocale.LoadLocale(KEComFrenchLang,KEComFrenchReg,KEComFrenchColl);
110 else if(aLanguages[0] == ELangGerman)
112 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
113 extendedLocale.LoadLocale(KGermanLocale);
115 extendedLocale.LoadLocale(KEComGermanLang,KEComGermanReg,KEComGermanColl);
120 __ASSERT_ALWAYS(EFalse, User::Leave(KErrNotSupported)); //Unexpected test language
123 // Save the changes to system settings
124 extendedLocale.SaveSystemSettings();
126 TEST(User::Language() == aLanguages[0]);
129 for(i=1; aLanguages[i] != ELangNone && i < KMaxDowngradeLanguages; i++)
131 locale.SetLanguageDowngrade(i, aLanguages[i]);
136 BaflUtils::GetDowngradePathL(TheFs, aLanguages[0], languageArray);
138 for(i = languageArray.Count() - 1; i >= 0; i--)
140 TLanguage language = languageArray[i];
141 TheTest.Printf(_L("Updated language downgrade[%d]: %d\n"), i, language);
142 TEST2(languageArray[i], aLanguages[i]);
145 languageArray.Close();
149 @SYMTestCaseID SYSLIB-ECOM-CT-1694
150 @SYMTestCaseDesc Test that ECOM lists the expected plugins under different language downgrade path settings
151 @SYMTestPriority High
152 @SYMTestActions Set the language downgrade path.Kill ECOM server to ensure ECOM uses the new downgrade path
153 next time it starts. List implementations. Check that the list contains the expected plugins.
154 @SYMTestExpectedResults The test must not fail.
157 void ListImplementationsL(TLanguage* aLanguageDowngradePath, TPtrC* aExpectedImplementations)
159 //set the language downgrade path
160 SetLanguageDowngradeL(aLanguageDowngradePath);
161 //kill ecom server to ensure the use of updated language downgrade path
164 RImplInfoPtrArray implementations;
165 TRAPD(err, REComSession::ListImplementationsL(KUidMultipeImageInterface, implementations));
166 TEST2(err, KErrNone);
168 const TInt implementationCount = implementations.Count();
169 TheTest.Printf(_L("Found %d implementations.\n"), implementationCount);
171 for (TInt i=0; i<implementationCount; i++)
173 const CImplementationInformation* info = implementations[i];
174 TheTest.Printf(_L("Implementation[%d]: UID=0x%x DisplayName=\"%S\"\n"), i, (info->ImplementationUid()).iUid, &(info->DisplayName())) ;
175 TEST(info->DisplayName() == aExpectedImplementations[i]);
178 // Empty the array of implementations to avoid leaks
179 implementations.ResetAndDestroy();
180 //close the ecom session to avoid leaks
181 REComSession::FinalClose();
185 LOCAL_C void DoBasicTestL(FuncPtrL testFuncL, TLanguage* aLanguageDowngradePath, TPtrC* aExpectedImplementations, const TDesC& aTestDesc)
187 TheTest.Next(aTestDesc);
190 // find out the number of open handles
191 TInt startProcessHandleCount;
192 TInt startThreadHandleCount;
193 RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
195 testFuncL(aLanguageDowngradePath, aExpectedImplementations);
197 // check that no handles have leaked
198 TInt endProcessHandleCount;
199 TInt endThreadHandleCount;
200 RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
202 TEST(startProcessHandleCount == endProcessHandleCount);
203 TEST(startThreadHandleCount == endThreadHandleCount);
209 LOCAL_C void DoTestsL()
211 const TLanguage languageDowngradePath[][7] =
213 {ELangEnglish, ELangFrench, ELangGerman, ELangNone},
214 {ELangFrench, ELangGerman, ELangEnglish, ELangNone},
215 {ELangGerman, ELangFrench, ELangEnglish, ELangNone},
216 {ELangFrench, ELangGerman, ELangNone, ELangNone},
217 {ELangGerman, ELangFrench, ELangNone, ELangNone},
218 {ELangFrench, ELangNone, ELangNone, ELangNone},
219 {ELangGerman, ELangNone, ELangNone, ELangNone}
222 const TPtrC pluginResolution[][16] =
225 _L("Example B Image 2 Language 01 UK English"),
226 _L("Example C Image 2 Language 01 UK English"),
227 _L("Example E Image 2 Language 02 French"),
228 _L("Example F Image 2 Language 02 French"),
229 _L("Example G Image 1 Language 02 French"),
230 _L("Example H Image 1 Language 03 German"),
231 _L("Example I Image 1 Language 02 French"),
232 _L("Example J Image 1 Language 03 German"),
233 _L("Example K Image 2 Language 02 French"),
234 _L("Example L Image 2 Language 03 German"),
235 _L("Example M Image 2 Language 02 French"),
236 _L("Example N Image 2 Language 03 German"),
237 _L("Example O Image 2 Language 02 French"),
238 _L("Example P Image 2 Language 03 German"),
239 _L("Example Q Image 2 Language 02 French"),
240 _L("Example S Image 1 Language 02 French")
243 _L("Example B Image 2 Language 01 UK English"),
244 _L("Example C Image 2 Language 01 UK English"),
245 _L("Example E Image 2 Language 02 French"),
246 _L("Example F Image 2 Language 02 French"),
247 _L("Example G Image 1 Language 02 French"),
248 _L("Example H Image 1 Language 03 German"),
249 _L("Example I Image 1 Language 02 French"),
250 _L("Example J Image 1 Language 03 German"),
251 _L("Example K Image 2 Language 02 French"),
252 _L("Example L Image 2 Language 03 German"),
253 _L("Example M Image 2 Language 02 French"),
254 _L("Example N Image 2 Language 03 German"),
255 _L("Example O Image 2 Language 02 French"),
256 _L("Example P Image 2 Language 03 German"),
257 _L("Example Q Image 2 Language 02 French"),
258 _L("Example S Image 1 Language 02 French")
261 _L("Example B Image 2 Language 01 UK English"),
262 _L("Example C Image 2 Language 01 UK English"),
263 _L("Example E Image 2 Language 02 French"),
264 _L("Example F Image 2 Language 02 French"),
265 _L("Example G Image 1 Language 03 German"),
266 _L("Example H Image 1 Language 03 German"),
267 _L("Example I Image 1 Language 03 German"),
268 _L("Example J Image 1 Language 03 German"),
269 _L("Example K Image 2 Language 03 German"),
270 _L("Example L Image 2 Language 03 German"),
271 _L("Example M Image 2 Language 03 German"),
272 _L("Example N Image 2 Language 03 German"),
273 _L("Example O Image 2 Language 03 German"),
274 _L("Example P Image 2 Language 03 German"),
275 _L("Example Q Image 2 Language 03 German"),
276 _L("Example S Image 2 Language 03 German")
279 _L("Example B Image 2 Language 01 UK English"),
280 _L("Example C Image 2 Language 01 UK English"),
281 _L("Example E Image 2 Language 02 French"),
282 _L("Example F Image 2 Language 02 French"),
283 _L("Example G Image 1 Language 02 French"),
284 _L("Example H Image 1 Language 03 German"),
285 _L("Example I Image 1 Language 02 French"),
286 _L("Example J Image 1 Language 03 German"),
287 _L("Example K Image 2 Language 02 French"),
288 _L("Example L Image 2 Language 03 German"),
289 _L("Example M Image 2 Language 02 French"),
290 _L("Example N Image 2 Language 03 German"),
291 _L("Example O Image 2 Language 02 French"),
292 _L("Example P Image 2 Language 03 German"),
293 _L("Example Q Image 2 Language 02 French"),
294 _L("Example S Image 1 Language 02 French")
297 _L("Example B Image 2 Language 01 UK English"),
298 _L("Example C Image 2 Language 01 UK English"),
299 _L("Example E Image 2 Language 02 French"),
300 _L("Example F Image 2 Language 02 French"),
301 _L("Example G Image 1 Language 03 German"),
302 _L("Example H Image 1 Language 03 German"),
303 _L("Example I Image 1 Language 03 German"),
304 _L("Example J Image 1 Language 03 German"),
305 _L("Example K Image 2 Language 03 German"),
306 _L("Example L Image 2 Language 03 German"),
307 _L("Example M Image 2 Language 03 German"),
308 _L("Example N Image 2 Language 03 German"),
309 _L("Example O Image 2 Language 03 German"),
310 _L("Example P Image 2 Language 03 German"),
311 _L("Example Q Image 2 Language 03 German"),
312 _L("Example S Image 2 Language 03 German")
315 _L("Example B Image 2 Language 01 UK English"),
316 _L("Example C Image 2 Language 01 UK English"),
317 _L("Example E Image 2 Language 02 French"),
318 _L("Example F Image 2 Language 02 French"),
319 _L("Example G Image 1 Language 02 French"),
320 _L("Example H Image 1 Language 01 UK English"),
321 _L("Example I Image 1 Language 02 French"),
322 _L("Example K Image 2 Language 02 French"),
323 _L("Example L Image 2 Language 01 UK English"),
324 _L("Example M Image 2 Language 02 French"),
325 _L("Example O Image 2 Language 02 French"),
326 _L("Example P Image 2 Language 01 UK English"),
327 _L("Example Q Image 2 Language 02 French"),
328 _L("Example S Image 1 Language 02 French"),
333 _L("Example B Image 2 Language 01 UK English"),
334 _L("Example C Image 2 Language 01 UK English"),
335 _L("Example G Image 1 Language 03 German"),
336 _L("Example H Image 1 Language 03 German"),
337 _L("Example I Image 1 Language 03 German"),
338 _L("Example J Image 1 Language 03 German"),
339 _L("Example K Image 2 Language 03 German"),
340 _L("Example L Image 2 Language 03 German"),
341 _L("Example M Image 2 Language 03 German"),
342 _L("Example N Image 2 Language 03 German"),
343 _L("Example O Image 2 Language 03 German"),
344 _L("Example P Image 2 Language 03 German"),
345 _L("Example Q Image 2 Language 03 German"),
346 _L("Example S Image 2 Language 03 German"),
352 //make a copy of the current locale
357 DoBasicTestL(&ListImplementationsL,
358 (TLanguage*)languageDowngradePath[0],
359 (TPtrC*)pluginResolution[0],
360 _L("Check Installed Plugins for Downgrade Path English-French-German"));
364 DoBasicTestL(&ListImplementationsL,
365 (TLanguage*)languageDowngradePath[1],
366 (TPtrC*)pluginResolution[1],
367 _L("Check Installed Plugins for Downgrade Path French-German-English"));
371 DoBasicTestL(&ListImplementationsL,
372 (TLanguage*)languageDowngradePath[2],
373 (TPtrC*)pluginResolution[2],
374 _L("Check Installed Plugins for Downgrade Path German-French-English"));
378 DoBasicTestL(&ListImplementationsL,
379 (TLanguage*)languageDowngradePath[3],
380 (TPtrC*)pluginResolution[3],
381 _L("Check Installed Plugins for Downgrade Path French-German"));
385 DoBasicTestL(&ListImplementationsL,
386 (TLanguage*)languageDowngradePath[4],
387 (TPtrC*)pluginResolution[4],
388 _L("Check Installed Plugins for Downgrade Path German-French"));
392 DoBasicTestL(&ListImplementationsL,
393 (TLanguage*)languageDowngradePath[5],
394 (TPtrC*)pluginResolution[5],
395 _L("Check Installed Plugins for Downgrade Path French"));
399 DoBasicTestL(&ListImplementationsL,
400 (TLanguage*)languageDowngradePath[6],
401 (TPtrC*)pluginResolution[6],
402 _L("Check Installed Plugins for Downgrade Path German"));
405 TExtendedLocale extendedLocale;
406 extendedLocale.LoadSystemSettings();
407 #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
408 // Change the locale to Default Locale, all settings from single Dll
409 extendedLocale.LoadLocale(KEnglishLocale);
411 extendedLocale.LoadLocale(KEComEnglishLang,KEComEnglishReg,KEComEnglishColl);
414 // Save the changes to system settings
415 extendedLocale.SaveSystemSettings();
427 GLDEF_C TInt E32Main()
430 TheTest.Printf(_L("\n"));
432 TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-1694 MultipleImageTests "));
434 TEST2(TheFs.Connect(), KErrNone);
436 // get clean-up stack
437 CTrapCleanup* cleanup = CTrapCleanup::New();
438 // Construct and install the Active Scheduler. The Active Scheduler is needed
439 // by components used by this test as they are ActiveObjects.
440 CActiveScheduler* activeScheduler = new(ELeave)CActiveScheduler;
441 CActiveScheduler::Install(activeScheduler);
443 TRAPD(err,DoTestsL());
444 TEST2(err, KErrNone);
447 delete activeScheduler;
457 User::Heap().Check();