sl@0: // Copyright (c) 2005-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: // This file contains RTest based tests which check flexibility of Locale. sl@0: // That are, 1. Selectable from Multiple traditional locale 2. Loaded all from a single traditional locale. sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "LocaleRepository.h" sl@0: #include "InitialiseLocale.h" sl@0: #include "T_CheckLocale.h" sl@0: sl@0: sl@0: _LIT(KInitPersistLocaleExeName, "InitialiseLocale.exe"); sl@0: sl@0: LOCAL_D RTest test(_L("T_LocaleFlexiNewLocaleModel")); sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CIT-0140 sl@0: @SYMTestCaseDesc Check that locale settings can be selected from several traditional locale sl@0: @SYMTestPriority High sl@0: @SYMTestActions Ensure that locales are selected, system set and persisted sl@0: @SYMTestExpectedResults The test must not fail. sl@0: @SYMREQ PREQ1001 sl@0: */ sl@0: LOCAL_D void ChangeLocaleNewCombination() sl@0: { sl@0: test.Start(_L(" @SYMTestCaseID:SYSLIB-BAFL-CIT-0140 \nTest to demonstrate Locale settings by multiple traditional locale ")); sl@0: sl@0: TExtendedLocale myExtendedLocale; sl@0: myExtendedLocale.LoadSystemSettings(); sl@0: sl@0: TBuf languageDllName(KUSLanguage); sl@0: TBuf regionDllName(KCNRegion); sl@0: TBuf collationDllName(KGECollation); sl@0: sl@0: test( KErrNone == myExtendedLocale.LoadLocaleAspect(languageDllName)); sl@0: test( KErrNone == myExtendedLocale.LoadLocaleAspect(regionDllName)); sl@0: test( KErrNone ==myExtendedLocale.LoadLocaleAspect(collationDllName)); sl@0: sl@0: test( KErrNone ==myExtendedLocale.SaveSystemSettings()); sl@0: sl@0: // Wait sl@0: User::After(10000000); sl@0: sl@0: TUid LocaleRepositoryUid ; sl@0: LocaleRepositoryUid.iUid = KLocalePersistRepositoryUid ; sl@0: sl@0: CRepository* repository = CRepository::NewLC(LocaleRepositoryUid); sl@0: sl@0: // To get names of DLLs to be loaded sl@0: TBuf aDllName ; sl@0: sl@0: // Test for the language settings sl@0: TInt err = repository->Get(KLocaleLanguageDll, aDllName); sl@0: if (err != KErrNone) sl@0: { sl@0: // Failed to read DLL name, bail out! sl@0: CleanupStack::PopAndDestroy(repository) ; sl@0: return ; sl@0: } sl@0: sl@0: test.Printf(_L("\nThe lagnuage DLL names in CRepository is: %S"), &aDllName); sl@0: test( KErrNotFound != aDllName.Find(languageDllName)); sl@0: sl@0: err = repository->Get(KLocaleCollationDll, aDllName); sl@0: if (err != KErrNone) sl@0: { sl@0: // Failed to read DLL name, bail out! sl@0: CleanupStack::PopAndDestroy(repository) ; sl@0: return ; sl@0: } sl@0: sl@0: test.Printf(_L("\nThe collation DLL names in CRepository is: %S"), &aDllName); sl@0: test( KErrNotFound != aDllName.Find(collationDllName)); sl@0: sl@0: sl@0: err = repository->Get(KLocaleLocaleDll, aDllName); sl@0: if (err != KErrNone) sl@0: { sl@0: // Failed to read DLL name, bail out! sl@0: CleanupStack::PopAndDestroy(repository) ; sl@0: return ; sl@0: } sl@0: sl@0: test.Printf(_L("\nThe Region DLL names in CRepository is: %S"), &aDllName); sl@0: test( KErrNotFound != aDllName.Find(regionDllName)); sl@0: sl@0: // Free the central repository object sl@0: CleanupStack::PopAndDestroy (repository); sl@0: test.End() ; sl@0: sl@0: //becasue we check whether locale content can be persisted is the system in this code block , we mark this test case here. sl@0: test.Start(_L(" @SYMTestCaseID:TI18N-INITLOCALE-CT-4005 persist system locale content")); sl@0: test.End(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CIT-0141 sl@0: @SYMTestCaseDesc Check that locale settings can be selected from single traditional locale. Also prepare the data for T_RebootNewLocaleModel sl@0: @SYMTestPriority High sl@0: @SYMTestActions Ensure that all settings are loaded from a DLL, system set and persisted sl@0: @SYMTestExpectedResults The test must not fail. sl@0: @SYMREQ PREQ1001 sl@0: */ sl@0: LOCAL_D void ChangeLocaleExistedCombination() sl@0: { sl@0: test.Start(_L(" @SYMTestCaseID:SYSLIB-BAFL-CIT-0141 Test to demonstrate change of Locale from one traditional locale ")); sl@0: sl@0: TExtendedLocale myExtendedLocale; sl@0: myExtendedLocale.LoadSystemSettings() ; sl@0: sl@0: TBuf languageDllName(KCNLanguage); sl@0: TBuf regionDllName(KCNRegion); sl@0: TBuf collationDllName(KCNCollation); sl@0: sl@0: test.Printf(_L("Changing all 3 Locale aspects to Chinese")); sl@0: sl@0: // Change the locale to Chinese Locale, all settings from single Dll sl@0: myExtendedLocale.LoadLocale(languageDllName, regionDllName, collationDllName); sl@0: sl@0: // Save the changes to system settings sl@0: myExtendedLocale.SaveSystemSettings(); sl@0: sl@0: // Wait sl@0: User::After(10000000); sl@0: sl@0: TUid LocaleRepositoryUid ; sl@0: LocaleRepositoryUid.iUid = KLocalePersistRepositoryUid; sl@0: CRepository* repository = CRepository::NewLC(LocaleRepositoryUid) ; sl@0: sl@0: // To get names of DLLs to be loaded sl@0: TBuf aDllName ; sl@0: sl@0: // Test for the language settings sl@0: TInt err = repository->Get(KLocaleLanguageDll, aDllName); sl@0: if (err != KErrNone) sl@0: { sl@0: // Failed to read DLL name, bail out! sl@0: CleanupStack::PopAndDestroy(repository) ; sl@0: return ; sl@0: } sl@0: sl@0: test( KErrNotFound != aDllName.Find(languageDllName)); sl@0: sl@0: err = repository->Get(KLocaleCollationDll, aDllName); sl@0: if (err != KErrNone) sl@0: { sl@0: // Failed to read DLL name, bail out! sl@0: CleanupStack::PopAndDestroy(repository) ; sl@0: return ; sl@0: } sl@0: sl@0: test( KErrNotFound != aDllName.Find(collationDllName)); sl@0: sl@0: sl@0: err = repository->Get(KLocaleLocaleDll, aDllName); sl@0: if (err != KErrNone) sl@0: { sl@0: // Failed to read DLL name, bail out! sl@0: CleanupStack::PopAndDestroy(repository) ; sl@0: return ; sl@0: } sl@0: sl@0: test( KErrNotFound != aDllName.Find(regionDllName)); sl@0: sl@0: sl@0: sl@0: CleanupStack::PopAndDestroy (repository); sl@0: test.End(); sl@0: } sl@0: //prepare for the reboot test sl@0: void Prepare4forRebootTest() sl@0: { sl@0: TExtendedLocale myExtendedLocale; sl@0: myExtendedLocale.LoadSystemSettings(); sl@0: test( KErrNone == myExtendedLocale.LoadLocale(KCNLanguage(), KCNRegion(), KCNCollation() )); sl@0: test( KErrNone == myExtendedLocale.SaveSystemSettings()); sl@0: User::After(10000000); sl@0: } sl@0: sl@0: // Call the tests that test flexibility of Locale sl@0: void TestLocaleFlexibility() sl@0: { sl@0: sl@0: RProcess process; sl@0: sl@0: // Kick-in InitialiseLocale.exe, This will be done as part of system start in actual sl@0: // release code! sl@0: TInt r = process.Create(KInitPersistLocaleExeName, KNullDesC); sl@0: if(r == KErrNone) sl@0: { sl@0: process.Resume(); // Start the process going sl@0: User::After(1000000); sl@0: sl@0: ChangeLocaleNewCombination(); sl@0: ChangeLocaleExistedCombination(); sl@0: sl@0: User::After(1000000); sl@0: Prepare4forRebootTest(); sl@0: User::After(1000000); sl@0: process.Close(); sl@0: User::After(1000000); sl@0: } sl@0: sl@0: } sl@0: sl@0: sl@0: sl@0: TInt E32Main() sl@0: { sl@0: CTrapCleanup* cleanup = CTrapCleanup::New(); sl@0: test(cleanup != NULL); sl@0: sl@0: __UHEAP_MARK; sl@0: test.Start(_L("Test to demonstrate Locale flexibility in new locale model")); sl@0: test.Title(); sl@0: sl@0: TRAPD(err, ::TestLocaleFlexibility()); sl@0: sl@0: test(err == KErrNone); sl@0: sl@0: test.End(); sl@0: test.Close(); sl@0: sl@0: __UHEAP_MARKEND; sl@0: delete cleanup; sl@0: sl@0: return(KErrNone); sl@0: }