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.
17 #include "T_CheckLocale.h"
20 RTest test(_L("T_NewLocaleModel"));
23 //new locale API should work in the new locale model
24 void TestNewLocaleAPI()
26 TExtendedLocale firstExtendLocale;
28 test.Start(_L(" @SYMTestCaseID:TI18N-EUSER-CT-4022 new LoadLocale() interface"));
29 firstExtendLocale.LoadSystemSettings();
30 test( KErrNone == firstExtendLocale.LoadLocale(KGermanLanguage(), KGERegion(), KGECollation()) );
31 test( KErrNone == firstExtendLocale.SaveSystemSettings() );
32 TestLocaleDLLName(test, KGermanLanguage(), KGERegion(), KGECollation() );
33 TestLocaleContent(test, KGELanguageID, KGECurrencySymbol, KGETCollationMethodID);
34 test( ERegDEU == User::RegionCode() );
36 firstExtendLocale.LoadSystemSettings();
37 test( KErrNone == firstExtendLocale.LoadLocale(KCNLanguage(), KCNRegion(), KCNCollation()) );
38 test( KErrNone == firstExtendLocale.SaveSystemSettings() );
39 TestLocaleDLLName(test, KCNLanguage(), KCNRegion(), KCNCollation() );
40 TestLocaleContent(test, KCNLanguageID, KCNCurrencySymbol, KCNTCollationMethodID);
42 //becasue TestLocaleContent() naturally check the system locale content, we mark this test case here.
43 test.Start(_L(" @SYMTestCaseID:TI18N-EUSER-CT-4025 publish locale content to the system"));
46 firstExtendLocale.LoadSystemSettings();
47 test( KErrNone == firstExtendLocale.LoadLocale(KUSLanguage(), KCNRegion(), KGECollation()) );
48 test( KErrNone == firstExtendLocale.SaveSystemSettings() );
49 TestLocaleDLLName(test, KUSLanguage(), KCNRegion(), KGECollation() );
50 TestLocaleContent(test, KUSLanguageID, KCNCurrencySymbol, KGETCollationMethodID);
53 test.Start(_L(" @SYMTestCaseID:TI18N-EUSER-CT-4023 new LoadLocaleAspect() interface"));
54 firstExtendLocale.LoadSystemSettings();
55 test( KErrNone == firstExtendLocale.LoadLocaleAspect(KCNLanguage));
56 test( KErrNone == firstExtendLocale.LoadLocaleAspect(KUSRegion));
57 test( KErrNone == firstExtendLocale.LoadLocaleAspect(KGECollation));
58 test( KErrNone == firstExtendLocale.SaveSystemSettings() );
59 TestLocaleDLLName(test, KCNLanguage(), KUSRegion(), KGECollation() );
60 TestLocaleContent(test, KCNLanguageID, KUSCurrencySymbol, KGETCollationMethodID);
62 firstExtendLocale.LoadSystemSettings();
63 test( KErrNone == firstExtendLocale.LoadLocaleAspect(KEnglishLanguage));
64 test( KErrNone == firstExtendLocale.LoadLocaleAspect(KUKRegion));
65 test( KErrNone == firstExtendLocale.LoadLocaleAspect(KStandardCollation));
66 test( KErrNone == firstExtendLocale.SaveSystemSettings() );
67 TestLocaleDLLName(test, KEnglishLanguage(), KUKRegion(), KStandardCollation() );
68 TestLocaleContent(test, KEnglishLanguageID, KUKCurrencySymbol, KStandardCollationID);
71 test.Start(_L(" @SYMTestCaseID:TI18N-EUSER-CT-4020 new LoadLocale() should not work with old locale DLL"));
72 firstExtendLocale.LoadSystemSettings();
73 test( KErrNotFound == firstExtendLocale.LoadLocale(KOldUKLocaleName(), KOldUKLocaleName(), KOldUKLocaleName()) );
74 firstExtendLocale.LoadSystemSettings();
75 test( KErrNotFound == firstExtendLocale.LoadLocale(KOldCNLocaleName(), KOldCNLocaleName(), KOldCNLocaleName()) );
76 firstExtendLocale.LoadSystemSettings();
77 test( KErrNotFound == firstExtendLocale.LoadLocale(KOldUKLocaleName(), KOldCNLocaleName(), KOldGELocaleName()) );
80 test.Start(_L(" @SYMTestCaseID:TI18N-EUSER-CT-4021 new LoadLocaleAspect() should not work with old locale DLL"));
81 firstExtendLocale.LoadSystemSettings();
82 test( KErrNotFound == firstExtendLocale.LoadLocaleAspect(KOldUKLocaleName()));
83 firstExtendLocale.LoadSystemSettings();
84 test( KErrNotFound == firstExtendLocale.LoadLocaleAspect(KOldCNLocaleName()));
85 firstExtendLocale.LoadSystemSettings();
86 test( KErrNotFound == firstExtendLocale.LoadLocaleAspect(KOldGELocaleName()));
90 test.Start(_L(" @SYMTestCaseID:TI18N-EUSER-CT-4024 check DLL naming convention"));
91 firstExtendLocale.LoadSystemSettings();
92 test( KErrNotFound == firstExtendLocale.LoadLocale(KInvalidNameLanguage(), KUKRegion(), KGECollation()) );
93 firstExtendLocale.LoadSystemSettings();
94 test( KErrNotFound == firstExtendLocale.LoadLocale(KEnglishLanguage(), KInvalidNameRegion(), KGECollation()) );
95 firstExtendLocale.LoadSystemSettings();
96 test( KErrNotFound == firstExtendLocale.LoadLocale(KEnglishLanguage(), KUKRegion(), KInvalidNameCollation()) );
97 firstExtendLocale.LoadSystemSettings();
98 test( KErrNotFound == firstExtendLocale.LoadLocale(KInvalidNameLanguage(), KInvalidNameRegion(), KInvalidNameCollation()) );
100 firstExtendLocale.LoadSystemSettings();
101 test( KErrNotFound == firstExtendLocale.LoadLocaleAspect(KInvalidNameLanguage()));
102 firstExtendLocale.LoadSystemSettings();
103 test( KErrNotFound == firstExtendLocale.LoadLocaleAspect(KInvalidNameRegion()));
104 firstExtendLocale.LoadSystemSettings();
105 test( KErrNotFound == firstExtendLocale.LoadLocaleAspect(KInvalidNameCollation()));
109 //Old locale API should work with the legacy old locale DLL name in the new locale model
110 void TestOldLocaleAPI()
112 TExtendedLocale firstExtendLocale;
114 test.Start(_L(" @SYMTestCaseID:TI18N-EUSER-CIT-4018 old LoadLocale() API should work with the legacy old locale DLL name in the new locale model"));
115 firstExtendLocale.LoadSystemSettings();
116 test( KErrNone == firstExtendLocale.LoadLocale(KOldUKLocaleName()) );
117 test( KErrNone == firstExtendLocale.SaveSystemSettings() );
118 TestLocaleDLLName(test, KEnglishLanguage(), KUKRegion(), KStandardCollation() );
119 TestLocaleContent(test, KEnglishLanguageID, KUKCurrencySymbol, KStandardCollationID);
121 firstExtendLocale.LoadSystemSettings();
122 test( KErrNone == firstExtendLocale.LoadLocale(KOldCNLocaleName()) );
123 test( KErrNone == firstExtendLocale.SaveSystemSettings() );
124 TestLocaleDLLName(test, KCNLanguage(), KCNRegion(), KCNCollation() );
125 TestLocaleContent(test, KCNLanguageID, KCNCurrencySymbol, KCNTCollationMethodID);
128 test.Start(_L(" @SYMTestCaseID:TI18N-EUSER-CIT-4017 old LoadLocaleAspect() API should work with the legacy old locale DLL name in the new locale model"));
129 firstExtendLocale.LoadSystemSettings();
130 test( KErrNone == firstExtendLocale.LoadLocaleAspect(ELocaleLanguageSettings, KOldGELocaleName()));
131 test( KErrNone == firstExtendLocale.LoadLocaleAspect(ELocaleCollateSetting, KOldGELocaleName()));
132 test( KErrNone == firstExtendLocale.LoadLocaleAspect(ELocaleLocaleSettings, KOldGELocaleName()));
133 test( KErrNone == firstExtendLocale.SaveSystemSettings() );
134 TestLocaleDLLName(test, KGermanLanguage(), KGERegion(), KGECollation() );
135 TestLocaleContent(test, KGELanguageID, KGECurrencySymbol, KGETCollationMethodID);
137 firstExtendLocale.LoadSystemSettings();
138 test( KErrNone == firstExtendLocale.LoadLocaleAspect(ELocaleLanguageSettings, KOldUKLocaleName()));
139 test( KErrNone == firstExtendLocale.LoadLocaleAspect(ELocaleCollateSetting, KOldCNLocaleName()));
140 test( KErrNone == firstExtendLocale.LoadLocaleAspect(ELocaleLocaleSettings, KOldUSLocaleName()));
141 test( KErrNone == firstExtendLocale.SaveSystemSettings() );
142 TestLocaleDLLName(test, KEnglishLanguage(), KUSRegion(), KCNCollation() );
143 TestLocaleContent(test, KEnglishLanguageID, KUSCurrencySymbol, KCNTCollationMethodID);
148 void TestNewLocaleModel()
156 CTrapCleanup* tc = CTrapCleanup::New();
161 test.Start(_L("The test for check old API and new API behavior in new locale model"));
163 TRAPD(err, ::TestNewLocaleModel())
164 test(err == KErrNone);