sl@0: // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include "..\EcomTestUtils\EcomTestUtils.h" sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: TUid KUidMultipeImageInterface = { 0x10282307 }; sl@0: static RFs TheFs; sl@0: static RTest TheTest(_L("t_multipleImageTest.exe")); sl@0: sl@0: #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL sl@0: _LIT(KEnglishLocale, "elocl.01"); sl@0: _LIT(KFrenchLocale, "elocl.02"); sl@0: _LIT(KGermanLocale, "elocl.03"); sl@0: #else sl@0: // refer base/os/kernelhwsrv/kernel/eka/euser/locmapping.cpp sl@0: // Language sl@0: _LIT(KEComEnglishLang,"elocl_lan.001"); sl@0: _LIT(KEComFrenchLang,"elocl_lan.002"); sl@0: _LIT(KEComGermanLang,"elocl_lan.003"); sl@0: // Region sl@0: _LIT(KEComEnglishReg,"elocl_reg.826"); sl@0: _LIT(KEComFrenchReg,"elocl_reg.250"); sl@0: _LIT(KEComGermanReg,"elocl_reg.276"); sl@0: // Collation sl@0: _LIT(KEComEnglishColl,"elocl_col.001"); sl@0: _LIT(KEComFrenchColl,"elocl_col.002"); sl@0: _LIT(KEComGermanColl,"elocl_col.003"); sl@0: #endif sl@0: sl@0: // Test Macroes and Functions sl@0: static void Check(TInt aValue, TInt aLine) sl@0: { sl@0: if(!aValue) sl@0: { sl@0: TheTest(EFalse, aLine); sl@0: } sl@0: } sl@0: sl@0: static void Check(TInt aValue, TInt aExpected, TInt aLine) sl@0: { sl@0: if(aValue != aExpected) sl@0: { sl@0: RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue); sl@0: TheTest(EFalse, aLine); sl@0: } sl@0: } sl@0: #define TEST(arg) ::Check((arg), __LINE__) sl@0: #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__) sl@0: sl@0: // Type definition for test functions. sl@0: // Used in calling t_multipleImageTest functions. sl@0: typedef void (*FuncPtrL) (TLanguage* , TPtrC* ); sl@0: sl@0: void KillEComServerL() sl@0: { sl@0: //Need to ensure that the EComServer process is killed before even starting this test by using sl@0: //the EComTestUtils library sl@0: _LIT(KEComServerProcessName,"ecomserver"); sl@0: TRAPD(error, EComTestUtils::KillProcessL(KEComServerProcessName)); sl@0: TEST2(error, KErrNone); sl@0: } sl@0: sl@0: void SetLanguageDowngradeL(TLanguage* aLanguages) sl@0: { sl@0: TLocale locale; sl@0: sl@0: TInt i=0; sl@0: RArray languageArray; sl@0: sl@0: TLanguage lang = User::Language(); sl@0: sl@0: if(lang != aLanguages[0]) sl@0: { sl@0: TExtendedLocale extendedLocale; sl@0: extendedLocale.LoadSystemSettings(); sl@0: sl@0: if(aLanguages[0] == ELangEnglish) sl@0: { sl@0: #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL sl@0: extendedLocale.LoadLocale(KEnglishLocale); sl@0: #else sl@0: extendedLocale.LoadLocale(KEComEnglishLang,KEComEnglishReg,KEComEnglishColl); sl@0: #endif sl@0: } sl@0: else if(aLanguages[0] == ELangFrench) sl@0: { sl@0: #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL sl@0: extendedLocale.LoadLocale(KFrenchLocale); sl@0: #else sl@0: extendedLocale.LoadLocale(KEComFrenchLang,KEComFrenchReg,KEComFrenchColl); sl@0: #endif sl@0: } sl@0: else if(aLanguages[0] == ELangGerman) sl@0: { sl@0: #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL sl@0: extendedLocale.LoadLocale(KGermanLocale); sl@0: #else sl@0: extendedLocale.LoadLocale(KEComGermanLang,KEComGermanReg,KEComGermanColl); sl@0: #endif sl@0: } sl@0: else sl@0: { sl@0: __ASSERT_ALWAYS(EFalse, User::Leave(KErrNotSupported)); //Unexpected test language sl@0: } sl@0: sl@0: // Save the changes to system settings sl@0: extendedLocale.SaveSystemSettings(); sl@0: sl@0: TEST(User::Language() == aLanguages[0]); sl@0: } sl@0: sl@0: for(i=1; aLanguages[i] != ELangNone && i < KMaxDowngradeLanguages; i++) sl@0: { sl@0: locale.SetLanguageDowngrade(i, aLanguages[i]); sl@0: } sl@0: sl@0: locale.Set(); sl@0: sl@0: BaflUtils::GetDowngradePathL(TheFs, aLanguages[0], languageArray); sl@0: sl@0: for(i = languageArray.Count() - 1; i >= 0; i--) sl@0: { sl@0: TLanguage language = languageArray[i]; sl@0: TheTest.Printf(_L("Updated language downgrade[%d]: %d\n"), i, language); sl@0: TEST2(languageArray[i], aLanguages[i]); sl@0: } sl@0: sl@0: languageArray.Close(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-ECOM-CT-1694 sl@0: @SYMTestCaseDesc Test that ECOM lists the expected plugins under different language downgrade path settings sl@0: @SYMTestPriority High sl@0: @SYMTestActions Set the language downgrade path.Kill ECOM server to ensure ECOM uses the new downgrade path sl@0: next time it starts. List implementations. Check that the list contains the expected plugins. sl@0: @SYMTestExpectedResults The test must not fail. sl@0: @SYMREQ CR0759 sl@0: */ sl@0: void ListImplementationsL(TLanguage* aLanguageDowngradePath, TPtrC* aExpectedImplementations) sl@0: { sl@0: //set the language downgrade path sl@0: SetLanguageDowngradeL(aLanguageDowngradePath); sl@0: //kill ecom server to ensure the use of updated language downgrade path sl@0: KillEComServerL(); sl@0: sl@0: RImplInfoPtrArray implementations; sl@0: TRAPD(err, REComSession::ListImplementationsL(KUidMultipeImageInterface, implementations)); sl@0: TEST2(err, KErrNone); sl@0: sl@0: const TInt implementationCount = implementations.Count(); sl@0: TheTest.Printf(_L("Found %d implementations.\n"), implementationCount); sl@0: sl@0: for (TInt i=0; iImplementationUid()).iUid, &(info->DisplayName())) ; sl@0: TEST(info->DisplayName() == aExpectedImplementations[i]); sl@0: } sl@0: sl@0: // Empty the array of implementations to avoid leaks sl@0: implementations.ResetAndDestroy(); sl@0: //close the ecom session to avoid leaks sl@0: REComSession::FinalClose(); sl@0: } sl@0: sl@0: sl@0: LOCAL_C void DoBasicTestL(FuncPtrL testFuncL, TLanguage* aLanguageDowngradePath, TPtrC* aExpectedImplementations, const TDesC& aTestDesc) sl@0: { sl@0: TheTest.Next(aTestDesc); sl@0: sl@0: __UHEAP_MARK; sl@0: // find out the number of open handles sl@0: TInt startProcessHandleCount; sl@0: TInt startThreadHandleCount; sl@0: RThread().HandleCount(startProcessHandleCount, startThreadHandleCount); sl@0: sl@0: testFuncL(aLanguageDowngradePath, aExpectedImplementations); sl@0: sl@0: // check that no handles have leaked sl@0: TInt endProcessHandleCount; sl@0: TInt endThreadHandleCount; sl@0: RThread().HandleCount(endProcessHandleCount, endThreadHandleCount); sl@0: sl@0: TEST(startProcessHandleCount == endProcessHandleCount); sl@0: TEST(startThreadHandleCount == endThreadHandleCount); sl@0: sl@0: __UHEAP_MARKEND; sl@0: } sl@0: sl@0: sl@0: LOCAL_C void DoTestsL() sl@0: { sl@0: const TLanguage languageDowngradePath[][7] = sl@0: { sl@0: {ELangEnglish, ELangFrench, ELangGerman, ELangNone}, sl@0: {ELangFrench, ELangGerman, ELangEnglish, ELangNone}, sl@0: {ELangGerman, ELangFrench, ELangEnglish, ELangNone}, sl@0: {ELangFrench, ELangGerman, ELangNone, ELangNone}, sl@0: {ELangGerman, ELangFrench, ELangNone, ELangNone}, sl@0: {ELangFrench, ELangNone, ELangNone, ELangNone}, sl@0: {ELangGerman, ELangNone, ELangNone, ELangNone} sl@0: }; sl@0: sl@0: const TPtrC pluginResolution[][16] = sl@0: { sl@0: { sl@0: _L("Example B Image 2 Language 01 UK English"), sl@0: _L("Example C Image 2 Language 01 UK English"), sl@0: _L("Example E Image 2 Language 02 French"), sl@0: _L("Example F Image 2 Language 02 French"), sl@0: _L("Example G Image 1 Language 02 French"), sl@0: _L("Example H Image 1 Language 03 German"), sl@0: _L("Example I Image 1 Language 02 French"), sl@0: _L("Example J Image 1 Language 03 German"), sl@0: _L("Example K Image 2 Language 02 French"), sl@0: _L("Example L Image 2 Language 03 German"), sl@0: _L("Example M Image 2 Language 02 French"), sl@0: _L("Example N Image 2 Language 03 German"), sl@0: _L("Example O Image 2 Language 02 French"), sl@0: _L("Example P Image 2 Language 03 German"), sl@0: _L("Example Q Image 2 Language 02 French"), sl@0: _L("Example S Image 1 Language 02 French") sl@0: }, sl@0: { sl@0: _L("Example B Image 2 Language 01 UK English"), sl@0: _L("Example C Image 2 Language 01 UK English"), sl@0: _L("Example E Image 2 Language 02 French"), sl@0: _L("Example F Image 2 Language 02 French"), sl@0: _L("Example G Image 1 Language 02 French"), sl@0: _L("Example H Image 1 Language 03 German"), sl@0: _L("Example I Image 1 Language 02 French"), sl@0: _L("Example J Image 1 Language 03 German"), sl@0: _L("Example K Image 2 Language 02 French"), sl@0: _L("Example L Image 2 Language 03 German"), sl@0: _L("Example M Image 2 Language 02 French"), sl@0: _L("Example N Image 2 Language 03 German"), sl@0: _L("Example O Image 2 Language 02 French"), sl@0: _L("Example P Image 2 Language 03 German"), sl@0: _L("Example Q Image 2 Language 02 French"), sl@0: _L("Example S Image 1 Language 02 French") sl@0: }, sl@0: { sl@0: _L("Example B Image 2 Language 01 UK English"), sl@0: _L("Example C Image 2 Language 01 UK English"), sl@0: _L("Example E Image 2 Language 02 French"), sl@0: _L("Example F Image 2 Language 02 French"), sl@0: _L("Example G Image 1 Language 03 German"), sl@0: _L("Example H Image 1 Language 03 German"), sl@0: _L("Example I Image 1 Language 03 German"), sl@0: _L("Example J Image 1 Language 03 German"), sl@0: _L("Example K Image 2 Language 03 German"), sl@0: _L("Example L Image 2 Language 03 German"), sl@0: _L("Example M Image 2 Language 03 German"), sl@0: _L("Example N Image 2 Language 03 German"), sl@0: _L("Example O Image 2 Language 03 German"), sl@0: _L("Example P Image 2 Language 03 German"), sl@0: _L("Example Q Image 2 Language 03 German"), sl@0: _L("Example S Image 2 Language 03 German") sl@0: }, sl@0: { sl@0: _L("Example B Image 2 Language 01 UK English"), sl@0: _L("Example C Image 2 Language 01 UK English"), sl@0: _L("Example E Image 2 Language 02 French"), sl@0: _L("Example F Image 2 Language 02 French"), sl@0: _L("Example G Image 1 Language 02 French"), sl@0: _L("Example H Image 1 Language 03 German"), sl@0: _L("Example I Image 1 Language 02 French"), sl@0: _L("Example J Image 1 Language 03 German"), sl@0: _L("Example K Image 2 Language 02 French"), sl@0: _L("Example L Image 2 Language 03 German"), sl@0: _L("Example M Image 2 Language 02 French"), sl@0: _L("Example N Image 2 Language 03 German"), sl@0: _L("Example O Image 2 Language 02 French"), sl@0: _L("Example P Image 2 Language 03 German"), sl@0: _L("Example Q Image 2 Language 02 French"), sl@0: _L("Example S Image 1 Language 02 French") sl@0: }, sl@0: { sl@0: _L("Example B Image 2 Language 01 UK English"), sl@0: _L("Example C Image 2 Language 01 UK English"), sl@0: _L("Example E Image 2 Language 02 French"), sl@0: _L("Example F Image 2 Language 02 French"), sl@0: _L("Example G Image 1 Language 03 German"), sl@0: _L("Example H Image 1 Language 03 German"), sl@0: _L("Example I Image 1 Language 03 German"), sl@0: _L("Example J Image 1 Language 03 German"), sl@0: _L("Example K Image 2 Language 03 German"), sl@0: _L("Example L Image 2 Language 03 German"), sl@0: _L("Example M Image 2 Language 03 German"), sl@0: _L("Example N Image 2 Language 03 German"), sl@0: _L("Example O Image 2 Language 03 German"), sl@0: _L("Example P Image 2 Language 03 German"), sl@0: _L("Example Q Image 2 Language 03 German"), sl@0: _L("Example S Image 2 Language 03 German") sl@0: }, sl@0: { sl@0: _L("Example B Image 2 Language 01 UK English"), sl@0: _L("Example C Image 2 Language 01 UK English"), sl@0: _L("Example E Image 2 Language 02 French"), sl@0: _L("Example F Image 2 Language 02 French"), sl@0: _L("Example G Image 1 Language 02 French"), sl@0: _L("Example H Image 1 Language 01 UK English"), sl@0: _L("Example I Image 1 Language 02 French"), sl@0: _L("Example K Image 2 Language 02 French"), sl@0: _L("Example L Image 2 Language 01 UK English"), sl@0: _L("Example M Image 2 Language 02 French"), sl@0: _L("Example O Image 2 Language 02 French"), sl@0: _L("Example P Image 2 Language 01 UK English"), sl@0: _L("Example Q Image 2 Language 02 French"), sl@0: _L("Example S Image 1 Language 02 French"), sl@0: _L("Dummy"), sl@0: _L("Dummy") sl@0: }, sl@0: { sl@0: _L("Example B Image 2 Language 01 UK English"), sl@0: _L("Example C Image 2 Language 01 UK English"), sl@0: _L("Example G Image 1 Language 03 German"), sl@0: _L("Example H Image 1 Language 03 German"), sl@0: _L("Example I Image 1 Language 03 German"), sl@0: _L("Example J Image 1 Language 03 German"), sl@0: _L("Example K Image 2 Language 03 German"), sl@0: _L("Example L Image 2 Language 03 German"), sl@0: _L("Example M Image 2 Language 03 German"), sl@0: _L("Example N Image 2 Language 03 German"), sl@0: _L("Example O Image 2 Language 03 German"), sl@0: _L("Example P Image 2 Language 03 German"), sl@0: _L("Example Q Image 2 Language 03 German"), sl@0: _L("Example S Image 2 Language 03 German"), sl@0: _L("Dummy"), sl@0: _L("Dummy") sl@0: } sl@0: }; sl@0: sl@0: //make a copy of the current locale sl@0: TLocale oldLocale; sl@0: sl@0: TRAPD(err, sl@0: { sl@0: DoBasicTestL(&ListImplementationsL, sl@0: (TLanguage*)languageDowngradePath[0], sl@0: (TPtrC*)pluginResolution[0], sl@0: _L("Check Installed Plugins for Downgrade Path English-French-German")); sl@0: sl@0: oldLocale.Set(); sl@0: sl@0: DoBasicTestL(&ListImplementationsL, sl@0: (TLanguage*)languageDowngradePath[1], sl@0: (TPtrC*)pluginResolution[1], sl@0: _L("Check Installed Plugins for Downgrade Path French-German-English")); sl@0: sl@0: oldLocale.Set(); sl@0: sl@0: DoBasicTestL(&ListImplementationsL, sl@0: (TLanguage*)languageDowngradePath[2], sl@0: (TPtrC*)pluginResolution[2], sl@0: _L("Check Installed Plugins for Downgrade Path German-French-English")); sl@0: sl@0: oldLocale.Set(); sl@0: sl@0: DoBasicTestL(&ListImplementationsL, sl@0: (TLanguage*)languageDowngradePath[3], sl@0: (TPtrC*)pluginResolution[3], sl@0: _L("Check Installed Plugins for Downgrade Path French-German")); sl@0: sl@0: oldLocale.Set(); sl@0: sl@0: DoBasicTestL(&ListImplementationsL, sl@0: (TLanguage*)languageDowngradePath[4], sl@0: (TPtrC*)pluginResolution[4], sl@0: _L("Check Installed Plugins for Downgrade Path German-French")); sl@0: sl@0: oldLocale.Set(); sl@0: sl@0: DoBasicTestL(&ListImplementationsL, sl@0: (TLanguage*)languageDowngradePath[5], sl@0: (TPtrC*)pluginResolution[5], sl@0: _L("Check Installed Plugins for Downgrade Path French")); sl@0: sl@0: oldLocale.Set(); sl@0: sl@0: DoBasicTestL(&ListImplementationsL, sl@0: (TLanguage*)languageDowngradePath[6], sl@0: (TPtrC*)pluginResolution[6], sl@0: _L("Check Installed Plugins for Downgrade Path German")); sl@0: } sl@0: ); sl@0: TExtendedLocale extendedLocale; sl@0: extendedLocale.LoadSystemSettings(); sl@0: #ifndef SYMBIAN_DISTINCT_LOCALE_MODEL sl@0: // Change the locale to Default Locale, all settings from single Dll sl@0: extendedLocale.LoadLocale(KEnglishLocale); sl@0: #else sl@0: extendedLocale.LoadLocale(KEComEnglishLang,KEComEnglishReg,KEComEnglishColl); sl@0: #endif sl@0: sl@0: // Save the changes to system settings sl@0: extendedLocale.SaveSystemSettings(); sl@0: sl@0: //reset locale sl@0: oldLocale.Set(); sl@0: sl@0: if(err != KErrNone) sl@0: { sl@0: User::Leave(err); sl@0: } sl@0: } sl@0: sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: __UHEAP_MARK; sl@0: TheTest.Printf(_L("\n")); sl@0: TheTest.Title(); sl@0: TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-1694 MultipleImageTests ")); sl@0: sl@0: TEST2(TheFs.Connect(), KErrNone); sl@0: sl@0: // get clean-up stack sl@0: CTrapCleanup* cleanup = CTrapCleanup::New(); sl@0: // Construct and install the Active Scheduler. The Active Scheduler is needed sl@0: // by components used by this test as they are ActiveObjects. sl@0: CActiveScheduler* activeScheduler = new(ELeave)CActiveScheduler; sl@0: CActiveScheduler::Install(activeScheduler); sl@0: sl@0: TRAPD(err,DoTestsL()); sl@0: TEST2(err, KErrNone); sl@0: sl@0: //delete scheduler; sl@0: delete activeScheduler; sl@0: delete cleanup; sl@0: sl@0: TheFs.Close(); sl@0: sl@0: TheTest.End(); sl@0: TheTest.Close(); sl@0: sl@0: __UHEAP_MARKEND; sl@0: sl@0: User::Heap().Check(); sl@0: sl@0: return KErrNone; sl@0: } sl@0: sl@0: