os/ossrv/lowlevellibsandfws/apputils/initLocale/test/T_LocaleFlexiNewLocaleModel.cpp
Update contrib.
1 // Copyright (c) 2005-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.
14 // This file contains RTest based tests which check flexibility of Locale.
15 // That are, 1. Selectable from Multiple traditional locale 2. Loaded all from a single traditional locale.
27 #include <centralrepository.h>
28 #include "LocaleRepository.h"
29 #include "InitialiseLocale.h"
30 #include "T_CheckLocale.h"
33 _LIT(KInitPersistLocaleExeName, "InitialiseLocale.exe");
35 LOCAL_D RTest test(_L("T_LocaleFlexiNewLocaleModel"));
39 @SYMTestCaseID SYSLIB-BAFL-CIT-0140
40 @SYMTestCaseDesc Check that locale settings can be selected from several traditional locale
42 @SYMTestActions Ensure that locales are selected, system set and persisted
43 @SYMTestExpectedResults The test must not fail.
46 LOCAL_D void ChangeLocaleNewCombination()
48 test.Start(_L(" @SYMTestCaseID:SYSLIB-BAFL-CIT-0140 \nTest to demonstrate Locale settings by multiple traditional locale "));
50 TExtendedLocale myExtendedLocale;
51 myExtendedLocale.LoadSystemSettings();
53 TBuf<KMaxFullName> languageDllName(KUSLanguage);
54 TBuf<KMaxFullName> regionDllName(KCNRegion);
55 TBuf<KMaxFullName> collationDllName(KGECollation);
57 test( KErrNone == myExtendedLocale.LoadLocaleAspect(languageDllName));
58 test( KErrNone == myExtendedLocale.LoadLocaleAspect(regionDllName));
59 test( KErrNone ==myExtendedLocale.LoadLocaleAspect(collationDllName));
61 test( KErrNone ==myExtendedLocale.SaveSystemSettings());
64 User::After(10000000);
66 TUid LocaleRepositoryUid ;
67 LocaleRepositoryUid.iUid = KLocalePersistRepositoryUid ;
69 CRepository* repository = CRepository::NewLC(LocaleRepositoryUid);
71 // To get names of DLLs to be loaded
72 TBuf<KMaxFullName> aDllName ;
74 // Test for the language settings
75 TInt err = repository->Get(KLocaleLanguageDll, aDllName);
78 // Failed to read DLL name, bail out!
79 CleanupStack::PopAndDestroy(repository) ;
83 test.Printf(_L("\nThe lagnuage DLL names in CRepository is: %S"), &aDllName);
84 test( KErrNotFound != aDllName.Find(languageDllName));
86 err = repository->Get(KLocaleCollationDll, aDllName);
89 // Failed to read DLL name, bail out!
90 CleanupStack::PopAndDestroy(repository) ;
94 test.Printf(_L("\nThe collation DLL names in CRepository is: %S"), &aDllName);
95 test( KErrNotFound != aDllName.Find(collationDllName));
98 err = repository->Get(KLocaleLocaleDll, aDllName);
101 // Failed to read DLL name, bail out!
102 CleanupStack::PopAndDestroy(repository) ;
106 test.Printf(_L("\nThe Region DLL names in CRepository is: %S"), &aDllName);
107 test( KErrNotFound != aDllName.Find(regionDllName));
109 // Free the central repository object
110 CleanupStack::PopAndDestroy (repository);
113 //becasue we check whether locale content can be persisted is the system in this code block , we mark this test case here.
114 test.Start(_L(" @SYMTestCaseID:TI18N-INITLOCALE-CT-4005 persist system locale content"));
119 @SYMTestCaseID SYSLIB-BAFL-CIT-0141
120 @SYMTestCaseDesc Check that locale settings can be selected from single traditional locale. Also prepare the data for T_RebootNewLocaleModel
121 @SYMTestPriority High
122 @SYMTestActions Ensure that all settings are loaded from a DLL, system set and persisted
123 @SYMTestExpectedResults The test must not fail.
126 LOCAL_D void ChangeLocaleExistedCombination()
128 test.Start(_L(" @SYMTestCaseID:SYSLIB-BAFL-CIT-0141 Test to demonstrate change of Locale from one traditional locale "));
130 TExtendedLocale myExtendedLocale;
131 myExtendedLocale.LoadSystemSettings() ;
133 TBuf<KMaxFullName> languageDllName(KCNLanguage);
134 TBuf<KMaxFullName> regionDllName(KCNRegion);
135 TBuf<KMaxFullName> collationDllName(KCNCollation);
137 test.Printf(_L("Changing all 3 Locale aspects to Chinese"));
139 // Change the locale to Chinese Locale, all settings from single Dll
140 myExtendedLocale.LoadLocale(languageDllName, regionDllName, collationDllName);
142 // Save the changes to system settings
143 myExtendedLocale.SaveSystemSettings();
146 User::After(10000000);
148 TUid LocaleRepositoryUid ;
149 LocaleRepositoryUid.iUid = KLocalePersistRepositoryUid;
150 CRepository* repository = CRepository::NewLC(LocaleRepositoryUid) ;
152 // To get names of DLLs to be loaded
153 TBuf<KMaxFullName> aDllName ;
155 // Test for the language settings
156 TInt err = repository->Get(KLocaleLanguageDll, aDllName);
159 // Failed to read DLL name, bail out!
160 CleanupStack::PopAndDestroy(repository) ;
164 test( KErrNotFound != aDllName.Find(languageDllName));
166 err = repository->Get(KLocaleCollationDll, aDllName);
169 // Failed to read DLL name, bail out!
170 CleanupStack::PopAndDestroy(repository) ;
174 test( KErrNotFound != aDllName.Find(collationDllName));
177 err = repository->Get(KLocaleLocaleDll, aDllName);
180 // Failed to read DLL name, bail out!
181 CleanupStack::PopAndDestroy(repository) ;
185 test( KErrNotFound != aDllName.Find(regionDllName));
189 CleanupStack::PopAndDestroy (repository);
192 //prepare for the reboot test
193 void Prepare4forRebootTest()
195 TExtendedLocale myExtendedLocale;
196 myExtendedLocale.LoadSystemSettings();
197 test( KErrNone == myExtendedLocale.LoadLocale(KCNLanguage(), KCNRegion(), KCNCollation() ));
198 test( KErrNone == myExtendedLocale.SaveSystemSettings());
199 User::After(10000000);
202 // Call the tests that test flexibility of Locale
203 void TestLocaleFlexibility()
208 // Kick-in InitialiseLocale.exe, This will be done as part of system start in actual
210 TInt r = process.Create(KInitPersistLocaleExeName, KNullDesC);
213 process.Resume(); // Start the process going
214 User::After(1000000);
216 ChangeLocaleNewCombination();
217 ChangeLocaleExistedCombination();
219 User::After(1000000);
220 Prepare4forRebootTest();
221 User::After(1000000);
223 User::After(1000000);
232 CTrapCleanup* cleanup = CTrapCleanup::New();
233 test(cleanup != NULL);
236 test.Start(_L("Test to demonstrate Locale flexibility in new locale model"));
239 TRAPD(err, ::TestLocaleFlexibility());
241 test(err == KErrNone);