os/ossrv/lowlevellibsandfws/pluginfw/Framework/MultipleImageTest/t_multipleImageTest.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/lowlevellibsandfws/pluginfw/Framework/MultipleImageTest/t_multipleImageTest.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,462 @@
1.4 +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include "..\EcomTestUtils\EcomTestUtils.h"
1.20 +#include <e32test.h>
1.21 +#include <Ecom\ECom.h>
1.22 +#include <Ecom\ImplementationInformation.h>
1.23 +#include <hal.h>
1.24 +#include <bautils.h>
1.25 +
1.26 +TUid KUidMultipeImageInterface = { 0x10282307 };
1.27 +static RFs TheFs;
1.28 +static RTest TheTest(_L("t_multipleImageTest.exe"));
1.29 +
1.30 +#ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
1.31 + _LIT(KEnglishLocale, "elocl.01");
1.32 + _LIT(KFrenchLocale, "elocl.02");
1.33 + _LIT(KGermanLocale, "elocl.03");
1.34 +#else
1.35 + // refer base/os/kernelhwsrv/kernel/eka/euser/locmapping.cpp
1.36 + // Language
1.37 + _LIT(KEComEnglishLang,"elocl_lan.001");
1.38 + _LIT(KEComFrenchLang,"elocl_lan.002");
1.39 + _LIT(KEComGermanLang,"elocl_lan.003");
1.40 + // Region
1.41 + _LIT(KEComEnglishReg,"elocl_reg.826");
1.42 + _LIT(KEComFrenchReg,"elocl_reg.250");
1.43 + _LIT(KEComGermanReg,"elocl_reg.276");
1.44 + // Collation
1.45 + _LIT(KEComEnglishColl,"elocl_col.001");
1.46 + _LIT(KEComFrenchColl,"elocl_col.002");
1.47 + _LIT(KEComGermanColl,"elocl_col.003");
1.48 +#endif
1.49 +
1.50 +// Test Macroes and Functions
1.51 +static void Check(TInt aValue, TInt aLine)
1.52 + {
1.53 + if(!aValue)
1.54 + {
1.55 + TheTest(EFalse, aLine);
1.56 + }
1.57 + }
1.58 +
1.59 +static void Check(TInt aValue, TInt aExpected, TInt aLine)
1.60 + {
1.61 + if(aValue != aExpected)
1.62 + {
1.63 + RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
1.64 + TheTest(EFalse, aLine);
1.65 + }
1.66 + }
1.67 +#define TEST(arg) ::Check((arg), __LINE__)
1.68 +#define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
1.69 +
1.70 +// Type definition for test functions.
1.71 +// Used in calling t_multipleImageTest functions.
1.72 +typedef void (*FuncPtrL) (TLanguage* , TPtrC* );
1.73 +
1.74 +void KillEComServerL()
1.75 + {
1.76 + //Need to ensure that the EComServer process is killed before even starting this test by using
1.77 + //the EComTestUtils library
1.78 + _LIT(KEComServerProcessName,"ecomserver");
1.79 + TRAPD(error, EComTestUtils::KillProcessL(KEComServerProcessName));
1.80 + TEST2(error, KErrNone);
1.81 + }
1.82 +
1.83 +void SetLanguageDowngradeL(TLanguage* aLanguages)
1.84 + {
1.85 + TLocale locale;
1.86 +
1.87 + TInt i=0;
1.88 + RArray<TLanguage> languageArray;
1.89 +
1.90 + TLanguage lang = User::Language();
1.91 +
1.92 + if(lang != aLanguages[0])
1.93 + {
1.94 + TExtendedLocale extendedLocale;
1.95 + extendedLocale.LoadSystemSettings();
1.96 +
1.97 + if(aLanguages[0] == ELangEnglish)
1.98 + {
1.99 + #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
1.100 + extendedLocale.LoadLocale(KEnglishLocale);
1.101 + #else
1.102 + extendedLocale.LoadLocale(KEComEnglishLang,KEComEnglishReg,KEComEnglishColl);
1.103 + #endif
1.104 + }
1.105 + else if(aLanguages[0] == ELangFrench)
1.106 + {
1.107 + #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
1.108 + extendedLocale.LoadLocale(KFrenchLocale);
1.109 + #else
1.110 + extendedLocale.LoadLocale(KEComFrenchLang,KEComFrenchReg,KEComFrenchColl);
1.111 + #endif
1.112 + }
1.113 + else if(aLanguages[0] == ELangGerman)
1.114 + {
1.115 + #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
1.116 + extendedLocale.LoadLocale(KGermanLocale);
1.117 + #else
1.118 + extendedLocale.LoadLocale(KEComGermanLang,KEComGermanReg,KEComGermanColl);
1.119 + #endif
1.120 + }
1.121 + else
1.122 + {
1.123 + __ASSERT_ALWAYS(EFalse, User::Leave(KErrNotSupported)); //Unexpected test language
1.124 + }
1.125 +
1.126 + // Save the changes to system settings
1.127 + extendedLocale.SaveSystemSettings();
1.128 +
1.129 + TEST(User::Language() == aLanguages[0]);
1.130 + }
1.131 +
1.132 + for(i=1; aLanguages[i] != ELangNone && i < KMaxDowngradeLanguages; i++)
1.133 + {
1.134 + locale.SetLanguageDowngrade(i, aLanguages[i]);
1.135 + }
1.136 +
1.137 + locale.Set();
1.138 +
1.139 + BaflUtils::GetDowngradePathL(TheFs, aLanguages[0], languageArray);
1.140 +
1.141 + for(i = languageArray.Count() - 1; i >= 0; i--)
1.142 + {
1.143 + TLanguage language = languageArray[i];
1.144 + TheTest.Printf(_L("Updated language downgrade[%d]: %d\n"), i, language);
1.145 + TEST2(languageArray[i], aLanguages[i]);
1.146 + }
1.147 +
1.148 + languageArray.Close();
1.149 + }
1.150 +
1.151 +/**
1.152 +@SYMTestCaseID SYSLIB-ECOM-CT-1694
1.153 +@SYMTestCaseDesc Test that ECOM lists the expected plugins under different language downgrade path settings
1.154 +@SYMTestPriority High
1.155 +@SYMTestActions Set the language downgrade path.Kill ECOM server to ensure ECOM uses the new downgrade path
1.156 +next time it starts. List implementations. Check that the list contains the expected plugins.
1.157 +@SYMTestExpectedResults The test must not fail.
1.158 +@SYMREQ CR0759
1.159 +*/
1.160 +void ListImplementationsL(TLanguage* aLanguageDowngradePath, TPtrC* aExpectedImplementations)
1.161 + {
1.162 + //set the language downgrade path
1.163 + SetLanguageDowngradeL(aLanguageDowngradePath);
1.164 + //kill ecom server to ensure the use of updated language downgrade path
1.165 + KillEComServerL();
1.166 +
1.167 + RImplInfoPtrArray implementations;
1.168 + TRAPD(err, REComSession::ListImplementationsL(KUidMultipeImageInterface, implementations));
1.169 + TEST2(err, KErrNone);
1.170 +
1.171 + const TInt implementationCount = implementations.Count();
1.172 + TheTest.Printf(_L("Found %d implementations.\n"), implementationCount);
1.173 +
1.174 + for (TInt i=0; i<implementationCount; i++)
1.175 + {
1.176 + const CImplementationInformation* info = implementations[i];
1.177 + TheTest.Printf(_L("Implementation[%d]: UID=0x%x DisplayName=\"%S\"\n"), i, (info->ImplementationUid()).iUid, &(info->DisplayName())) ;
1.178 + TEST(info->DisplayName() == aExpectedImplementations[i]);
1.179 + }
1.180 +
1.181 + // Empty the array of implementations to avoid leaks
1.182 + implementations.ResetAndDestroy();
1.183 + //close the ecom session to avoid leaks
1.184 + REComSession::FinalClose();
1.185 + }
1.186 +
1.187 +
1.188 +LOCAL_C void DoBasicTestL(FuncPtrL testFuncL, TLanguage* aLanguageDowngradePath, TPtrC* aExpectedImplementations, const TDesC& aTestDesc)
1.189 + {
1.190 + TheTest.Next(aTestDesc);
1.191 +
1.192 + __UHEAP_MARK;
1.193 + // find out the number of open handles
1.194 + TInt startProcessHandleCount;
1.195 + TInt startThreadHandleCount;
1.196 + RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
1.197 +
1.198 + testFuncL(aLanguageDowngradePath, aExpectedImplementations);
1.199 +
1.200 + // check that no handles have leaked
1.201 + TInt endProcessHandleCount;
1.202 + TInt endThreadHandleCount;
1.203 + RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
1.204 +
1.205 + TEST(startProcessHandleCount == endProcessHandleCount);
1.206 + TEST(startThreadHandleCount == endThreadHandleCount);
1.207 +
1.208 + __UHEAP_MARKEND;
1.209 + }
1.210 +
1.211 +
1.212 +LOCAL_C void DoTestsL()
1.213 + {
1.214 + const TLanguage languageDowngradePath[][7] =
1.215 + {
1.216 + {ELangEnglish, ELangFrench, ELangGerman, ELangNone},
1.217 + {ELangFrench, ELangGerman, ELangEnglish, ELangNone},
1.218 + {ELangGerman, ELangFrench, ELangEnglish, ELangNone},
1.219 + {ELangFrench, ELangGerman, ELangNone, ELangNone},
1.220 + {ELangGerman, ELangFrench, ELangNone, ELangNone},
1.221 + {ELangFrench, ELangNone, ELangNone, ELangNone},
1.222 + {ELangGerman, ELangNone, ELangNone, ELangNone}
1.223 + };
1.224 +
1.225 + const TPtrC pluginResolution[][16] =
1.226 + {
1.227 + {
1.228 + _L("Example B Image 2 Language 01 UK English"),
1.229 + _L("Example C Image 2 Language 01 UK English"),
1.230 + _L("Example E Image 2 Language 02 French"),
1.231 + _L("Example F Image 2 Language 02 French"),
1.232 + _L("Example G Image 1 Language 02 French"),
1.233 + _L("Example H Image 1 Language 03 German"),
1.234 + _L("Example I Image 1 Language 02 French"),
1.235 + _L("Example J Image 1 Language 03 German"),
1.236 + _L("Example K Image 2 Language 02 French"),
1.237 + _L("Example L Image 2 Language 03 German"),
1.238 + _L("Example M Image 2 Language 02 French"),
1.239 + _L("Example N Image 2 Language 03 German"),
1.240 + _L("Example O Image 2 Language 02 French"),
1.241 + _L("Example P Image 2 Language 03 German"),
1.242 + _L("Example Q Image 2 Language 02 French"),
1.243 + _L("Example S Image 1 Language 02 French")
1.244 + },
1.245 + {
1.246 + _L("Example B Image 2 Language 01 UK English"),
1.247 + _L("Example C Image 2 Language 01 UK English"),
1.248 + _L("Example E Image 2 Language 02 French"),
1.249 + _L("Example F Image 2 Language 02 French"),
1.250 + _L("Example G Image 1 Language 02 French"),
1.251 + _L("Example H Image 1 Language 03 German"),
1.252 + _L("Example I Image 1 Language 02 French"),
1.253 + _L("Example J Image 1 Language 03 German"),
1.254 + _L("Example K Image 2 Language 02 French"),
1.255 + _L("Example L Image 2 Language 03 German"),
1.256 + _L("Example M Image 2 Language 02 French"),
1.257 + _L("Example N Image 2 Language 03 German"),
1.258 + _L("Example O Image 2 Language 02 French"),
1.259 + _L("Example P Image 2 Language 03 German"),
1.260 + _L("Example Q Image 2 Language 02 French"),
1.261 + _L("Example S Image 1 Language 02 French")
1.262 + },
1.263 + {
1.264 + _L("Example B Image 2 Language 01 UK English"),
1.265 + _L("Example C Image 2 Language 01 UK English"),
1.266 + _L("Example E Image 2 Language 02 French"),
1.267 + _L("Example F Image 2 Language 02 French"),
1.268 + _L("Example G Image 1 Language 03 German"),
1.269 + _L("Example H Image 1 Language 03 German"),
1.270 + _L("Example I Image 1 Language 03 German"),
1.271 + _L("Example J Image 1 Language 03 German"),
1.272 + _L("Example K Image 2 Language 03 German"),
1.273 + _L("Example L Image 2 Language 03 German"),
1.274 + _L("Example M Image 2 Language 03 German"),
1.275 + _L("Example N Image 2 Language 03 German"),
1.276 + _L("Example O Image 2 Language 03 German"),
1.277 + _L("Example P Image 2 Language 03 German"),
1.278 + _L("Example Q Image 2 Language 03 German"),
1.279 + _L("Example S Image 2 Language 03 German")
1.280 + },
1.281 + {
1.282 + _L("Example B Image 2 Language 01 UK English"),
1.283 + _L("Example C Image 2 Language 01 UK English"),
1.284 + _L("Example E Image 2 Language 02 French"),
1.285 + _L("Example F Image 2 Language 02 French"),
1.286 + _L("Example G Image 1 Language 02 French"),
1.287 + _L("Example H Image 1 Language 03 German"),
1.288 + _L("Example I Image 1 Language 02 French"),
1.289 + _L("Example J Image 1 Language 03 German"),
1.290 + _L("Example K Image 2 Language 02 French"),
1.291 + _L("Example L Image 2 Language 03 German"),
1.292 + _L("Example M Image 2 Language 02 French"),
1.293 + _L("Example N Image 2 Language 03 German"),
1.294 + _L("Example O Image 2 Language 02 French"),
1.295 + _L("Example P Image 2 Language 03 German"),
1.296 + _L("Example Q Image 2 Language 02 French"),
1.297 + _L("Example S Image 1 Language 02 French")
1.298 + },
1.299 + {
1.300 + _L("Example B Image 2 Language 01 UK English"),
1.301 + _L("Example C Image 2 Language 01 UK English"),
1.302 + _L("Example E Image 2 Language 02 French"),
1.303 + _L("Example F Image 2 Language 02 French"),
1.304 + _L("Example G Image 1 Language 03 German"),
1.305 + _L("Example H Image 1 Language 03 German"),
1.306 + _L("Example I Image 1 Language 03 German"),
1.307 + _L("Example J Image 1 Language 03 German"),
1.308 + _L("Example K Image 2 Language 03 German"),
1.309 + _L("Example L Image 2 Language 03 German"),
1.310 + _L("Example M Image 2 Language 03 German"),
1.311 + _L("Example N Image 2 Language 03 German"),
1.312 + _L("Example O Image 2 Language 03 German"),
1.313 + _L("Example P Image 2 Language 03 German"),
1.314 + _L("Example Q Image 2 Language 03 German"),
1.315 + _L("Example S Image 2 Language 03 German")
1.316 + },
1.317 + {
1.318 + _L("Example B Image 2 Language 01 UK English"),
1.319 + _L("Example C Image 2 Language 01 UK English"),
1.320 + _L("Example E Image 2 Language 02 French"),
1.321 + _L("Example F Image 2 Language 02 French"),
1.322 + _L("Example G Image 1 Language 02 French"),
1.323 + _L("Example H Image 1 Language 01 UK English"),
1.324 + _L("Example I Image 1 Language 02 French"),
1.325 + _L("Example K Image 2 Language 02 French"),
1.326 + _L("Example L Image 2 Language 01 UK English"),
1.327 + _L("Example M Image 2 Language 02 French"),
1.328 + _L("Example O Image 2 Language 02 French"),
1.329 + _L("Example P Image 2 Language 01 UK English"),
1.330 + _L("Example Q Image 2 Language 02 French"),
1.331 + _L("Example S Image 1 Language 02 French"),
1.332 + _L("Dummy"),
1.333 + _L("Dummy")
1.334 + },
1.335 + {
1.336 + _L("Example B Image 2 Language 01 UK English"),
1.337 + _L("Example C Image 2 Language 01 UK English"),
1.338 + _L("Example G Image 1 Language 03 German"),
1.339 + _L("Example H Image 1 Language 03 German"),
1.340 + _L("Example I Image 1 Language 03 German"),
1.341 + _L("Example J Image 1 Language 03 German"),
1.342 + _L("Example K Image 2 Language 03 German"),
1.343 + _L("Example L Image 2 Language 03 German"),
1.344 + _L("Example M Image 2 Language 03 German"),
1.345 + _L("Example N Image 2 Language 03 German"),
1.346 + _L("Example O Image 2 Language 03 German"),
1.347 + _L("Example P Image 2 Language 03 German"),
1.348 + _L("Example Q Image 2 Language 03 German"),
1.349 + _L("Example S Image 2 Language 03 German"),
1.350 + _L("Dummy"),
1.351 + _L("Dummy")
1.352 + }
1.353 + };
1.354 +
1.355 + //make a copy of the current locale
1.356 + TLocale oldLocale;
1.357 +
1.358 + TRAPD(err,
1.359 + {
1.360 + DoBasicTestL(&ListImplementationsL,
1.361 + (TLanguage*)languageDowngradePath[0],
1.362 + (TPtrC*)pluginResolution[0],
1.363 + _L("Check Installed Plugins for Downgrade Path English-French-German"));
1.364 +
1.365 + oldLocale.Set();
1.366 +
1.367 + DoBasicTestL(&ListImplementationsL,
1.368 + (TLanguage*)languageDowngradePath[1],
1.369 + (TPtrC*)pluginResolution[1],
1.370 + _L("Check Installed Plugins for Downgrade Path French-German-English"));
1.371 +
1.372 + oldLocale.Set();
1.373 +
1.374 + DoBasicTestL(&ListImplementationsL,
1.375 + (TLanguage*)languageDowngradePath[2],
1.376 + (TPtrC*)pluginResolution[2],
1.377 + _L("Check Installed Plugins for Downgrade Path German-French-English"));
1.378 +
1.379 + oldLocale.Set();
1.380 +
1.381 + DoBasicTestL(&ListImplementationsL,
1.382 + (TLanguage*)languageDowngradePath[3],
1.383 + (TPtrC*)pluginResolution[3],
1.384 + _L("Check Installed Plugins for Downgrade Path French-German"));
1.385 +
1.386 + oldLocale.Set();
1.387 +
1.388 + DoBasicTestL(&ListImplementationsL,
1.389 + (TLanguage*)languageDowngradePath[4],
1.390 + (TPtrC*)pluginResolution[4],
1.391 + _L("Check Installed Plugins for Downgrade Path German-French"));
1.392 +
1.393 + oldLocale.Set();
1.394 +
1.395 + DoBasicTestL(&ListImplementationsL,
1.396 + (TLanguage*)languageDowngradePath[5],
1.397 + (TPtrC*)pluginResolution[5],
1.398 + _L("Check Installed Plugins for Downgrade Path French"));
1.399 +
1.400 + oldLocale.Set();
1.401 +
1.402 + DoBasicTestL(&ListImplementationsL,
1.403 + (TLanguage*)languageDowngradePath[6],
1.404 + (TPtrC*)pluginResolution[6],
1.405 + _L("Check Installed Plugins for Downgrade Path German"));
1.406 + }
1.407 + );
1.408 + TExtendedLocale extendedLocale;
1.409 + extendedLocale.LoadSystemSettings();
1.410 +#ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
1.411 + // Change the locale to Default Locale, all settings from single Dll
1.412 + extendedLocale.LoadLocale(KEnglishLocale);
1.413 +#else
1.414 + extendedLocale.LoadLocale(KEComEnglishLang,KEComEnglishReg,KEComEnglishColl);
1.415 +#endif
1.416 +
1.417 + // Save the changes to system settings
1.418 + extendedLocale.SaveSystemSettings();
1.419 +
1.420 + //reset locale
1.421 + oldLocale.Set();
1.422 +
1.423 + if(err != KErrNone)
1.424 + {
1.425 + User::Leave(err);
1.426 + }
1.427 + }
1.428 +
1.429 +
1.430 +GLDEF_C TInt E32Main()
1.431 + {
1.432 + __UHEAP_MARK;
1.433 + TheTest.Printf(_L("\n"));
1.434 + TheTest.Title();
1.435 + TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-1694 MultipleImageTests "));
1.436 +
1.437 + TEST2(TheFs.Connect(), KErrNone);
1.438 +
1.439 + // get clean-up stack
1.440 + CTrapCleanup* cleanup = CTrapCleanup::New();
1.441 + // Construct and install the Active Scheduler. The Active Scheduler is needed
1.442 + // by components used by this test as they are ActiveObjects.
1.443 + CActiveScheduler* activeScheduler = new(ELeave)CActiveScheduler;
1.444 + CActiveScheduler::Install(activeScheduler);
1.445 +
1.446 + TRAPD(err,DoTestsL());
1.447 + TEST2(err, KErrNone);
1.448 +
1.449 + //delete scheduler;
1.450 + delete activeScheduler;
1.451 + delete cleanup;
1.452 +
1.453 + TheFs.Close();
1.454 +
1.455 + TheTest.End();
1.456 + TheTest.Close();
1.457 +
1.458 + __UHEAP_MARKEND;
1.459 +
1.460 + User::Heap().Check();
1.461 +
1.462 + return KErrNone;
1.463 + }
1.464 +
1.465 +