|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Tests to meet REQ758.2: "Captions localization must be efficient |
|
15 // (i.e. not waste disk space) and extensible (i.e. support non-ROM language packs)"\n |
|
16 // Test for UIKON GT0143 Typhoon Work Series 60 Changes |
|
17 // REQ758.2: Captions localization must be efficient (i.e. not waste disk space) |
|
18 // and extensible (i.e. support non-ROM language packs) |
|
19 // Test for CR0902 - Enable Dynamic Language Switching in APPARC. |
|
20 // Application's localisable information should be updated by apparc on language change event. |
|
21 // |
|
22 // |
|
23 |
|
24 /** |
|
25 @file |
|
26 @internalComponent - Internal Symbian test code |
|
27 */ |
|
28 |
|
29 #include <e32test.h> |
|
30 #include <f32file.h> |
|
31 #include <apgicnfl.h> |
|
32 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
33 #include <apgicnflpartner.h> |
|
34 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS |
|
35 #include <hal.h> |
|
36 #include <apgcli.h> |
|
37 #include "T_LocaleStep.h" |
|
38 |
|
39 const TUid KUidTestApp = { 10 }; //uid of tstapp. |
|
40 const TUid KUidCustomiseDefaultIconApp = {0x10208181}; // uid of CustomiseDefaultIconApp. |
|
41 const TInt KDelayForOnDemand = 20000; //a small delay |
|
42 const TInt KDelay = 4000000; // Most apparc tests have 2.5 secs wait time to let apparc update the app-list, but on safer side let us give 4 secs. |
|
43 const TInt KViewCount = 3; // Total no of views in tstapp |
|
44 |
|
45 |
|
46 /** |
|
47 Auxiliary Fn for Test Case ID T-LocaleStep-TestAllLanguages |
|
48 |
|
49 This method loads the required DLL for the language specified as argument |
|
50 and changes the locale accordingly. |
|
51 |
|
52 */ |
|
53 void CT_LocaleStep::ChangeLocaleL(TLanguage aLanguage) |
|
54 { |
|
55 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL |
|
56 _LIT(KLitLocaleDllNameBase, "elocl_lan"); |
|
57 _LIT(KLitLocaleDllNameExtension, ".loc"); |
|
58 #else |
|
59 _LIT(KLitLocaleDllNameBase, "ELOCL"); |
|
60 _LIT(KLitLocaleDllNameExtension, ".LOC"); |
|
61 #endif |
|
62 RLibrary localeDll; |
|
63 TBuf<16> localeDllName(KLitLocaleDllNameBase); |
|
64 CleanupClosePushL(localeDll); |
|
65 const TUidType uidType(TUid::Uid(0x10000079),TUid::Uid(0x100039e6)); |
|
66 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL |
|
67 _LIT(ThreeDigExt,".%03d"); |
|
68 localeDllName.AppendFormat(ThreeDigExt, aLanguage); |
|
69 #else |
|
70 _LIT(TwoDigExt,".%02d"); |
|
71 localeDllName.AppendFormat(TwoDigExt, aLanguage); |
|
72 #endif |
|
73 |
|
74 TInt error=localeDll.Load(localeDllName, uidType); |
|
75 if (error==KErrNotFound) |
|
76 { |
|
77 localeDllName=KLitLocaleDllNameBase; |
|
78 localeDllName.Append(KLitLocaleDllNameExtension); |
|
79 error=localeDll.Load(localeDllName, uidType); |
|
80 } |
|
81 User::LeaveIfError(error); |
|
82 |
|
83 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL |
|
84 TExtendedLocale myExtendedLocale; |
|
85 User::LeaveIfError(myExtendedLocale.LoadLocaleAspect(localeDllName)); |
|
86 User::LeaveIfError(myExtendedLocale.SaveSystemSettings()); |
|
87 #else |
|
88 User::LeaveIfError(UserSvr::ChangeLocale(localeDllName)); |
|
89 #endif |
|
90 CleanupStack::PopAndDestroy(); // localeDll |
|
91 } |
|
92 |
|
93 // CheckIcons is a function used in testcase TestLocaleDefaultIconL to check the size of the default icons |
|
94 void CT_LocaleStep::CheckIcons(CArrayFixFlat<TSize>* aNewIconSizes,TSize aSmall,TSize aMedium,TSize aLarge, TSize& afstIcon, TSize& asecIcon, TSize& atrdIcon) |
|
95 { |
|
96 afstIcon = (*aNewIconSizes)[0]; |
|
97 asecIcon = (*aNewIconSizes)[1]; |
|
98 atrdIcon = (*aNewIconSizes)[2]; |
|
99 TEST((afstIcon==aSmall) || (afstIcon==aMedium) || (afstIcon==aLarge) && ((afstIcon!=asecIcon) && (afstIcon!=atrdIcon))); |
|
100 TEST((asecIcon==aSmall) || (asecIcon==aMedium) || (asecIcon==aLarge) && ((asecIcon!=afstIcon) && (asecIcon!=atrdIcon))); |
|
101 TEST((atrdIcon==aSmall) || (atrdIcon==aMedium) || (atrdIcon==aLarge) && ((atrdIcon!=afstIcon) && (atrdIcon!=asecIcon))); |
|
102 } |
|
103 |
|
104 /** |
|
105 @SYMTestCaseID APPFWK-APPARC-0070 |
|
106 |
|
107 @SYMPREQ |
|
108 |
|
109 @SYMTestCaseDesc Test whether the default app icons change with respect to the locale/language. |
|
110 This testcase checks whether BaflUtils::NearestLanguageFile is called when the locale has been changed. |
|
111 |
|
112 @SYMTestPriority High |
|
113 |
|
114 @SYMTestStatus Implemented |
|
115 |
|
116 @SYMTestActions Call User::Language() to check that the default locale is English; Call CT_LocaleStep::CheckIcons |
|
117 to check the size of the current default icons; Call UserSvr::ChangeLocale to change the Locale to French; |
|
118 Call CT_LocaleStep::CheckIcons to check the size of the new icons; Restore the file system and the locale |
|
119 and check if the icons are restored. |
|
120 API Calls:\n |
|
121 |
|
122 @SYMTestExpectedResults Returns KErrNone |
|
123 */ |
|
124 void CT_LocaleStep::TestLocaleDefaultIconL() |
|
125 { |
|
126 INFO_PRINTF1(_L("APPFWK-APPARC-0070: TestLocaleDefaultIconL started...")); |
|
127 |
|
128 TInt ret = 0; |
|
129 |
|
130 //first checks that language is not currently set to French (any other language except English since English is the default language |
|
131 TEST(User::Language()!=ELangFrench); |
|
132 |
|
133 // getappiconsizes must be called to check if the icons are the default ones |
|
134 // KUidCustomiseDefaultIconApp - uid of CustomiseDefaultIconApp_reg.RSS; this app has a localisable resource file, CustomiseDefaultIconApp_loc.RSS, that does not define any icon |
|
135 // Hence, the default icons must be picked up when the language changes to French. The default icons for French are defined in default_app_icon.m02 |
|
136 |
|
137 CArrayFixFlat<TSize>* newIconSizes = new(ELeave) CArrayFixFlat<TSize>(3); |
|
138 CleanupStack::PushL(newIconSizes); |
|
139 TRAP(ret,iLs.GetAppIconSizes(KUidCustomiseDefaultIconApp, *newIconSizes)); |
|
140 TEST(ret==KErrNone); |
|
141 TEST(newIconSizes->Count()!=0); |
|
142 // these are the sizes of the default icons |
|
143 TSize small(24,24); |
|
144 TSize medium(32,32); |
|
145 TSize large(48,48); |
|
146 TSize fstIcon; |
|
147 TSize secIcon; |
|
148 TSize trdIcon; |
|
149 CheckIcons(newIconSizes, small, medium,large, fstIcon, secIcon, trdIcon); |
|
150 |
|
151 // Change the locale to French |
|
152 TRAP(ret,ChangeLocaleL(ELangFrench)); |
|
153 TEST(ret==KErrNone); |
|
154 TEST(User::Language()==ELangFrench);//checks that the language has been set to French |
|
155 |
|
156 //Wait for a small period to let apparc receive language change notification |
|
157 User::After(KDelayForOnDemand); |
|
158 //call getappiconsizes to see if the new icons have been changed as as expected |
|
159 // The size of the icons indicates whether the icon corresponding to French Locale has been picked up |
|
160 newIconSizes->Reset(); |
|
161 TRAP(ret,iLs.GetAppIconSizes(KUidCustomiseDefaultIconApp, *newIconSizes)); |
|
162 TEST(ret==KErrNone); |
|
163 TEST(newIconSizes->Count()!=0); |
|
164 small.SetSize(25,25); |
|
165 medium.SetSize(35,35); |
|
166 large.SetSize(50,50); |
|
167 CheckIcons(newIconSizes, small, medium,large, fstIcon, secIcon, trdIcon); |
|
168 |
|
169 //have to restore the locale before exiting the testcase |
|
170 TRAP(ret,ChangeLocaleL(ELangEnglish)); |
|
171 TEST(ret==KErrNone); |
|
172 TEST(User::Language()==ELangEnglish); |
|
173 |
|
174 //Again wait for a small period to let apparc receive language change notification |
|
175 User::After(KDelayForOnDemand); |
|
176 |
|
177 //call getappiconsizes to see if the new icons have been changed as as expected |
|
178 // The size of the icons indicates whether the icon corresponding to English Locale has been picked up |
|
179 newIconSizes->Reset(); |
|
180 TRAP(ret,iLs.GetAppIconSizes(KUidCustomiseDefaultIconApp, *newIconSizes)); |
|
181 TEST(ret==KErrNone); |
|
182 TEST(newIconSizes->Count()!=0); |
|
183 small.SetSize(24,24); |
|
184 medium.SetSize(32,32); |
|
185 large.SetSize(48,48); |
|
186 CheckIcons(newIconSizes, small, medium,large, fstIcon, secIcon, trdIcon); |
|
187 |
|
188 // Icon cleanup |
|
189 CleanupStack::PopAndDestroy(newIconSizes); |
|
190 newIconSizes=NULL; |
|
191 INFO_PRINTF1(_L("APPFWK-APPARC-0070: TestLocaleDefaultIconL finished...")); |
|
192 } |
|
193 |
|
194 /** |
|
195 @SYMTestCaseID APPFWK-APPARC-0061 |
|
196 |
|
197 @SYMPREQ CR0902 - Enable Dynamic Language Switching in APPARC. |
|
198 |
|
199 @SYMTestCaseDesc Test whether caption, short caption and app icon, is updated with respect to the change |
|
200 in locale/language. This test case checks on language change event apparc updates application |
|
201 localisable information for all installed applications, without forcing a change in the part of |
|
202 file system which apparc monitors. |
|
203 This test also tests, on a language change event, application's localisable information is |
|
204 updated immediately, if not yet updated by the re-scan (On demand loading). This is done by not |
|
205 giving enough time to finish rescan of app-list. |
|
206 |
|
207 @SYMTestPriority Critical |
|
208 |
|
209 @SYMTestStatus Implemented |
|
210 |
|
211 @SYMTestActions Check if language is English by calling User::Language(). |
|
212 |
|
213 1. Call GetAppInfo() by passing an application's UID which provides support for multiple languages. |
|
214 Check if the caption and short caption, both are in English. Change locale to French. |
|
215 2. Call GetAppIcon() by passing same application's UID. Check app icons are same as sepcified in |
|
216 app icon file for English locale. |
|
217 |
|
218 Wait for a small period (20 milli seconds) to let apparc receive language change notification. |
|
219 Again - |
|
220 1. Call GetAppInfo() by passing same application's UID and check if the caption and short caption, |
|
221 both are in French. |
|
222 2. Call GetAppIcon() by passing same application's UID. Check app icons are same as sepcified in |
|
223 app icon file for French locale. |
|
224 |
|
225 Restore locale to English and again check - |
|
226 1. If caption and short caption are in English after a call to GetAppInfo() for the same application. |
|
227 2. Call GetAppIcon() by passing same application's UID. Check app icons are same as sepcified in |
|
228 app icon file for English locale. |
|
229 |
|
230 @SYMTestExpectedResults |
|
231 1. GetAppInfo() should fetch caption and short caption in the newly-set language. |
|
232 2. GetAppIcon() should fetch icons from the icon file selected for current locale. |
|
233 */ |
|
234 void CT_LocaleStep::TestLocaleApplicationInfoOnDemandL() |
|
235 { |
|
236 INFO_PRINTF1(_L("APPFWK-APPARC-0061: TestLocaleApplicationInfoOnDemandL started...")); |
|
237 TestAppInfoL(ETrue); |
|
238 INFO_PRINTF1(_L("APPFWK-APPARC-0061: TestLocaleApplicationInfoOnDemandL finished...")); |
|
239 } |
|
240 |
|
241 /** |
|
242 @SYMTestCaseID APPFWK-APPARC-0062 |
|
243 |
|
244 @SYMPREQ CR0902 - Enable Dynamic Language Switching in APPARC. |
|
245 |
|
246 @SYMTestCaseDesc Test whether caption, short caption and app icon, is updated with respect to the change in |
|
247 locale/language. This test case checks on language change event apparc updates application localisable |
|
248 information for all installed applications, without forcing a change in the part of file system which |
|
249 apparc monitors. |
|
250 |
|
251 @SYMTestPriority Critical |
|
252 |
|
253 @SYMTestStatus Implemented |
|
254 |
|
255 @SYMTestActions Check if language is English by calling User::Language(). |
|
256 |
|
257 1. Call GetAppInfo() by passing an application's UID which provides support for multiple languages. |
|
258 Check if the caption and short caption, both are in English. Change locale to French. |
|
259 2. Call GetAppIcon by passing same application's UID. Check app icons are same as sepcified in |
|
260 app icon file for English locale. |
|
261 |
|
262 Change locale to French. Wait for some time (e.g. 4 seconds) to let apparc complete rescanning of app-list. |
|
263 Again - |
|
264 1. Call GetAppInfo() by passing same application's UID and check if the caption and short caption, |
|
265 both are in French. |
|
266 2. Call GetAppIcon() by passing same application's UID. Check app icons are same as sepcified in |
|
267 app icon file for French locale. |
|
268 |
|
269 Restore locale to English and again check - |
|
270 1. If caption and short caption are in English after a call to GetAppInfo() for the same application. |
|
271 2. Call GetAppIcon() by passing same application's UID. Check app icons are same as sepcified in |
|
272 app icon file for English locale. |
|
273 |
|
274 @SYMTestExpectedResults |
|
275 1. GetAppInfo() should fetch caption and short caption in the newly-set language. |
|
276 2. GetAppIcon() should fetch icons from the icon file selected for current locale. |
|
277 */ |
|
278 void CT_LocaleStep::TestLocaleApplicationInfoL() |
|
279 { |
|
280 INFO_PRINTF1(_L("APPFWK-APPARC-0062: TestLocaleApplicationInfoL started...")); |
|
281 TestAppInfoL(EFalse); |
|
282 INFO_PRINTF1(_L("APPFWK-APPARC-0062: TestLocaleApplicationInfoL finished...")); |
|
283 } |
|
284 |
|
285 /** |
|
286 This function performs steps to test application related information (caption, short caption and app icon) |
|
287 on language change event . |
|
288 It is called from TestLocaleApplicationInfoOnDemandL and TestLocaleApplicationInfoL. |
|
289 |
|
290 @param aOnDemand Pass true if on demand loading is required, otherwise false. |
|
291 */ |
|
292 void CT_LocaleStep::TestAppInfoL(TBool aOnDemand) |
|
293 { |
|
294 TInt ret = RFbsSession::Connect(); |
|
295 TEST(ret == KErrNone); |
|
296 |
|
297 // If it is on-demand loading delay would be very less. |
|
298 TInt delay = aOnDemand ? KDelayForOnDemand : KDelay; |
|
299 |
|
300 // Check language is not currently set to French (any other language except English since English is the default language. |
|
301 TEST(User::Language() != ELangFrench); |
|
302 |
|
303 // Caption and Short-caption should be same as defined in English localisable strings file (tstapp01.rls) |
|
304 _LIT(KCaptionEng, "TstCap UK"); |
|
305 _LIT(KShortCaptionEng, "TC UK"); |
|
306 |
|
307 // Call GetAppInfo() by passing KUidTestApp as tstapp's UID. tstapp provides support for multiple languages. |
|
308 TApaAppInfo appInfo; |
|
309 ret = iLs.GetAppInfo(appInfo, KUidTestApp); |
|
310 TEST(ret == KErrNone); |
|
311 |
|
312 // Caption and short-caption should be in English. |
|
313 TEST(appInfo.iCaption == KCaptionEng); |
|
314 TEST(appInfo.iShortCaption == KShortCaptionEng); |
|
315 |
|
316 // Test application's icons, should be same as sepcified in app icon file for English locale. |
|
317 TestAppIconL(TSize(40,55)); |
|
318 |
|
319 // Change the locale to French |
|
320 TRAP(ret, ChangeLocaleL(ELangFrench)); |
|
321 TEST(ret == KErrNone); |
|
322 TEST(User::Language() == ELangFrench);//check language is set to French |
|
323 |
|
324 // Caption and Short-caption should be same as defined in French localisable strings file (tstapp02.rls) |
|
325 _LIT(KCaptionFrench, "TstCap FR"); |
|
326 _LIT(KShortCaptionFrench, "TC FR"); |
|
327 |
|
328 User::After(delay); |
|
329 |
|
330 // Again call GetAppInfo() by passing KUidTestApp as UID. |
|
331 ret = iLs.GetAppInfo(appInfo, KUidTestApp); |
|
332 TEST(ret == KErrNone); |
|
333 |
|
334 // Caption and short-caption should be in French. |
|
335 TEST(appInfo.iCaption == KCaptionFrench); |
|
336 TEST(appInfo.iShortCaption == KShortCaptionFrench); |
|
337 |
|
338 // Test application's icons, should be same as sepcified in app icon file for French locale. |
|
339 TestAppIconL(TSize(50,50)); |
|
340 |
|
341 // Restore locale before exiting the testcase. |
|
342 TRAP(ret, ChangeLocaleL(ELangEnglish)); |
|
343 TEST(ret == KErrNone); |
|
344 TEST(User::Language() == ELangEnglish); |
|
345 |
|
346 User::After(delay); |
|
347 |
|
348 ret = iLs.GetAppInfo(appInfo, KUidTestApp); |
|
349 TEST(ret == KErrNone); |
|
350 |
|
351 // Caption and short-caption should again be in English. |
|
352 TEST(appInfo.iCaption == KCaptionEng); |
|
353 TEST(appInfo.iShortCaption == KShortCaptionEng); |
|
354 |
|
355 // Test application's icons, should be same as sepcified in app icon file for English locale. |
|
356 TestAppIconL(TSize(40,55)); |
|
357 |
|
358 RFbsSession::Disconnect(); |
|
359 } |
|
360 /** |
|
361 This function tests application's icon. It is called from TestAppInfoL function. |
|
362 */ |
|
363 void CT_LocaleStep::TestAppIconL(TSize aSize) |
|
364 { |
|
365 CApaMaskedBitmap* icon = CApaMaskedBitmap::NewLC(); |
|
366 TSize lastSize(0,0); |
|
367 |
|
368 TInt ret = iLs.GetAppIcon(KUidTestApp, aSize, *icon); |
|
369 TEST(ret == KErrNone); |
|
370 // Returned icon size should be exactly same as asked. |
|
371 TEST(icon->SizeInPixels().iWidth * icon->SizeInPixels().iHeight == aSize.iWidth * aSize.iHeight); |
|
372 |
|
373 CleanupStack::PopAndDestroy(icon); |
|
374 } |
|
375 |
|
376 /** |
|
377 @SYMTestCaseID APPFWK-APPARC-0063 |
|
378 |
|
379 @SYMPREQ CR0902 - Enable Dynamic Language Switching in APPARC. |
|
380 |
|
381 @SYMTestCaseDesc Test whether caption and short caption remains same on language change, if application |
|
382 does not provide support for multiple languages. |
|
383 |
|
384 @SYMTestPriority Critical |
|
385 |
|
386 @SYMTestStatus Implemented |
|
387 |
|
388 @SYMTestActions Check if language is English by calling User::Language(). Call GetAppInfo() by passing an |
|
389 application's UID which does not provide support for multiple languages. Check if the caption and short |
|
390 caption, both are in English. Change locale to French.Wait for a small period (20 milli seconds) to let |
|
391 apparc receive language change notification. Again Call GetAppInfo() by passing same application's UID and |
|
392 check if the caption and short caption, both are still in English. Restore locale to English and again check |
|
393 if caption and short caption are in English after a call to GetAppInfo() for the same application. |
|
394 |
|
395 @SYMTestExpectedResults GetAppInfo() should fetch caption and short caption in the same language. |
|
396 */ |
|
397 void CT_LocaleStep::TestLocaleApplicationInfo1L() |
|
398 { |
|
399 INFO_PRINTF1(_L("APPFWK-APPARC-0063: TestLocaleApplicationInfo1L started...")); |
|
400 TInt ret = KErrNotFound; |
|
401 |
|
402 // Check language is not currently set to French (any other language except English since English is the default language. |
|
403 TEST(User::Language() != ELangFrench); |
|
404 |
|
405 // Caption and Short-caption should be same as defined in the localisable resource file. (CustomiseDefaultIconApp_loc.RSS) |
|
406 _LIT(KCaptionEng, "CustomiseDefaultIconAppLong"); |
|
407 _LIT(KShortCaptionEng, "CustomiseDefaultIconApp"); |
|
408 |
|
409 // KUidCustomiseDefaultIconApp - uid of CustomiseDefaultIconApp_reg.RSS; this app does not provide support for multiple languages. |
|
410 |
|
411 // Call GetAppInfo() by passing above UID. |
|
412 TApaAppInfo appInfo; |
|
413 ret = iLs.GetAppInfo(appInfo, KUidCustomiseDefaultIconApp); |
|
414 TEST(ret == KErrNone); |
|
415 |
|
416 // Caption and short-caption should be in English. |
|
417 TEST(appInfo.iCaption == KCaptionEng); |
|
418 TEST(appInfo.iShortCaption == KShortCaptionEng); |
|
419 |
|
420 // Change the locale to French |
|
421 TRAP(ret,ChangeLocaleL(ELangFrench)); |
|
422 TEST(ret == KErrNone); |
|
423 TEST(User::Language() == ELangFrench);//check language is set to French. |
|
424 |
|
425 // Wait for a small period (20 milli seconds) to let apparc receive language change notification. |
|
426 User::After(KDelayForOnDemand); |
|
427 |
|
428 // Again call GetAppInfo() by passing KUidTestApp as UID. |
|
429 ret = iLs.GetAppInfo(appInfo, KUidCustomiseDefaultIconApp); |
|
430 TEST(ret == KErrNone); |
|
431 |
|
432 // Caption and short-caption should be in English. |
|
433 TEST(appInfo.iCaption == KCaptionEng); |
|
434 TEST(appInfo.iShortCaption == KShortCaptionEng); |
|
435 |
|
436 // Restore locale before exiting the testcase. |
|
437 TRAP(ret,ChangeLocaleL(ELangEnglish)); |
|
438 TEST(ret == KErrNone); |
|
439 TEST(User::Language() == ELangEnglish); |
|
440 |
|
441 User::After(KDelayForOnDemand); |
|
442 ret = iLs.GetAppInfo(appInfo, KUidCustomiseDefaultIconApp); |
|
443 TEST(ret == KErrNone); |
|
444 |
|
445 // Caption and short-caption should be in English again. |
|
446 TEST(appInfo.iCaption == KCaptionEng); |
|
447 TEST(appInfo.iShortCaption == KShortCaptionEng); |
|
448 |
|
449 INFO_PRINTF1(_L("APPFWK-APPARC-0063: TestLocaleApplicationInfo1L finished...")); |
|
450 } |
|
451 |
|
452 /** |
|
453 @SYMTestCaseID APPFWK-APPARC-0064 APPFWK-APPARC-0066 APPFWK-APPARC-0068 |
|
454 |
|
455 @SYMPREQ CR0902 - Enable Dynamic Language Switching in APPARC. |
|
456 |
|
457 @SYMTestCaseDesc Test whether |
|
458 1. View's caption is updated with respect to the change in locale/language. |
|
459 2. View's icons is updated with respect to the change in locale/language. |
|
460 3. View's icon file name changes with respect to the change in locale/language. |
|
461 |
|
462 This test case checks apparc updates application localisable information for all installed applications |
|
463 on language change event without forcing a change in the part of file system which apparc monitors. |
|
464 This test also tests, on a language change event, application's localisable information is updated |
|
465 immediately, if not yet updated by the re-scan (On demand loading). This is done by not giving enough |
|
466 time to finish rescan of app-list. |
|
467 |
|
468 @SYMTestPriority High |
|
469 |
|
470 @SYMTestStatus Implemented |
|
471 |
|
472 @SYMTestActions Check if language is English by calling User::Language(). Call GetAppViews() by passing |
|
473 an application's UID which provides support for multiple languages and different size icons for French |
|
474 language. |
|
475 |
|
476 1. Check if all view captions are same as specified in localisable file and in English. |
|
477 2. Call GetAppViewIcon() passing above application's ID. Check view icon size, it should be as |
|
478 specified in English icon file. |
|
479 3. Call overload of GetAppViewIcon() which returns view's icon file, passing above application's ID. |
|
480 |
|
481 Change locale to French.Wait for a small period (20 milli seconds) to let apparc receive language change |
|
482 notification. Again - |
|
483 |
|
484 1. Call GetAppViews() by passing same application's UID and check if the view captions for all views |
|
485 are in French. |
|
486 2. Call GetAppViewIcon() by passing same application's UID.Check view icon size, it should be as specified |
|
487 in French icon file. |
|
488 3. Call GetAppViewIcon() by passing same application's UID. Check view icon file, it should be same as |
|
489 specified in French locale. |
|
490 |
|
491 Restore locale to English and again check |
|
492 1. if view captions are same as specified in English resource file. |
|
493 2. if view icon size is same as specified in English icon file. |
|
494 3. if view icon file is same as specified in English resource file. |
|
495 |
|
496 @SYMTestExpectedResults Following are the expected results. |
|
497 1. GetAppViews() should fetch captions for all views in the newly-set language. |
|
498 2. GetAppViewIcon() should fetch icons specified in the newly-set language. |
|
499 3. GetAppViewIcon() should fetch view's icon file specified in the newly-set language. |
|
500 */ |
|
501 void CT_LocaleStep::TestLocaleViewCaptionAndIconOnDemandL() |
|
502 { |
|
503 INFO_PRINTF1(_L("APPFWK-APPARC-0064: TestLocaleViewCaptionOnDemandL started...")); |
|
504 INFO_PRINTF1(_L("APPFWK-APPARC-0066: TestLocaleViewIconSizeOnDemandL started...")); |
|
505 INFO_PRINTF1(_L("APPFWK-APPARC-0068: TestLocaleViewIconFileOnDemandL started...")); |
|
506 TestViewCaptionAndIconL(ETrue); |
|
507 INFO_PRINTF1(_L("APPFWK-APPARC-0064: TestLocaleViewCaptionOnDemandL finished...")); |
|
508 INFO_PRINTF1(_L("APPFWK-APPARC-0066: TestLocaleViewIconSizeOnDemandL finished...")); |
|
509 INFO_PRINTF1(_L("APPFWK-APPARC-0068: TestLocaleViewIconFileOnDemandL finished...")); |
|
510 } |
|
511 |
|
512 /** |
|
513 @SYMTestCaseID APPFWK-APPARC-0065 APPFWK-APPARC-0067 APPFWK-APPARC-0069 |
|
514 |
|
515 @SYMPREQ CR0902 - Enable Dynamic Language Switching in APPARC. |
|
516 @SYMDEF PDEF113054 - Apparc fails to detect the presence of localized Mbm files |
|
517 |
|
518 @SYMTestCaseDesc Test whether |
|
519 1. View's caption changes with respect to the change in locale/language. |
|
520 2. View's icons is updated with respect to the change in locale/language. |
|
521 3. View's icon file name changes with respect to the change in locale/language. |
|
522 |
|
523 This test case checks apparc updates application localisable information for all installed applications |
|
524 on language change event without forcing a change in the part of file system which apparc monitors. |
|
525 |
|
526 It checks for localized MBM files and MBM icon files with generic extension for an application. |
|
527 @SYMTestPriority High |
|
528 |
|
529 @SYMTestStatus Implemented |
|
530 |
|
531 @SYMTestActions Check if language is English by calling User::Language(). Call GetAppViews() by passing |
|
532 an application's UID which provides support for multiple languages and different size icons for French |
|
533 language. |
|
534 1. Check if all view captions are same as specified in localisable file and in English. |
|
535 2. Call GetAppViewIcon() passing above application's ID. Check view icon size, it should be as |
|
536 specified in English icon file. |
|
537 3. Call overload of GetAppViewIcon() which returns view's icon file, passing above application's ID. |
|
538 |
|
539 Change locale to French. Wait for some time (e.g. 4 seconds) to let apparc complete rescanning of app-list. |
|
540 Again - |
|
541 1. Call GetAppViews() by passing same application's UID and check if the view captions for all views |
|
542 are in French. |
|
543 2. Call GetAppViewIcon() by passing same application's UID.Check view icon size, it should be as specified |
|
544 in French icon file. |
|
545 3. Call GetAppViewIcon() by passing same application's UID. Check view icon file, it should be same as |
|
546 specified in French locale. |
|
547 |
|
548 Restore locale to English and again check - |
|
549 1. if view captions are same as specified in English resource file. |
|
550 2. if view icon size is same as specified in English icon file. |
|
551 3. if view icon file is same as specified in English resource file. |
|
552 |
|
553 @SYMTestExpectedResults Following are the expected results. |
|
554 1. GetAppViews() should fetch captions for all views in the newly-set language. |
|
555 2. GetAppViewIcon() should fetch icons specified in the newly-set language. |
|
556 3. GetAppViewIcon() should fetch view's icon file specified in the newly-set language. |
|
557 */ |
|
558 void CT_LocaleStep::TestLocaleViewCaptionAndIconL() |
|
559 { |
|
560 INFO_PRINTF1(_L("APPFWK-APPARC-0065: TestLocaleViewCaption started...")); |
|
561 INFO_PRINTF1(_L("APPFWK-APPARC-0067: TestLocaleViewIconSizeL started...")); |
|
562 INFO_PRINTF1(_L("APPFWK-APPARC-0069: TestLocaleViewIconFileL started...")); |
|
563 TestViewCaptionAndIconL(EFalse); |
|
564 INFO_PRINTF1(_L("APPFWK-APPARC-0065: TestLocaleViewCaption finished...")); |
|
565 INFO_PRINTF1(_L("APPFWK-APPARC-0067: TestLocaleViewIconSizeL finished...")); |
|
566 INFO_PRINTF1(_L("APPFWK-APPARC-0069: TestLocaleViewIconFileL finished...")); |
|
567 } |
|
568 |
|
569 |
|
570 /** |
|
571 This function performs steps to test view related information (view caption, view icon size and view icon |
|
572 file name) on language change event. |
|
573 and view icon file name. |
|
574 |
|
575 This function is called from following test cases - |
|
576 TestLocaleViewCaptionAndIconOnDemandL, |
|
577 TestLocaleViewCaptionAndIconL |
|
578 |
|
579 @param aTesCaption Pass true if caption test is required, otherwise false for view icon test. |
|
580 @param aOnDemand Pass true if on demand loading is required, otherwise false. |
|
581 */ |
|
582 void CT_LocaleStep::TestViewCaptionAndIconL(TBool aOnDemand) |
|
583 { |
|
584 TInt ret = RFbsSession::Connect(); |
|
585 TEST(ret == KErrNone); |
|
586 |
|
587 // If it is on-demand loading delay would be very less. |
|
588 TInt delay = aOnDemand ? KDelayForOnDemand : KDelay; |
|
589 |
|
590 // Check language is not currently set to French (any other language except English since English is the default language. |
|
591 TEST(User::Language() != ELangFrench); |
|
592 |
|
593 // Create view array to hold views for TstApp. |
|
594 CApaAppViewArray* appViews = new(ELeave) CApaAppViewArray(KViewCount); |
|
595 CleanupStack::PushL(appViews); |
|
596 |
|
597 // Call GetAppViews() by passing tstapp's KUidTestApp as UID. |
|
598 // tstapp provides support for multiple languages. |
|
599 ret = iLs.GetAppViews(*appViews, KUidTestApp); |
|
600 TEST(ret == KErrNone); |
|
601 |
|
602 // Check application's view count. It should have three views.One of them is invalid |
|
603 TInt count = appViews->Count(); |
|
604 TEST(count == KViewCount); |
|
605 |
|
606 // Check application's view's captions or icons. They should be in English |
|
607 CheckViewCaptionAndIconL(ELangEnglish, appViews); |
|
608 CleanupStack::PopAndDestroy(appViews); |
|
609 |
|
610 // Switch locale to French |
|
611 TRAP(ret, ChangeLocaleL(ELangFrench)); |
|
612 TEST(ret == KErrNone); |
|
613 TEST(User::Language() == ELangFrench);//check language is set to French |
|
614 |
|
615 // Wait for a small period to let apparc receive language change notification. |
|
616 User::After(delay); |
|
617 |
|
618 // Create view array to hold views for TstApp. |
|
619 appViews = NULL; |
|
620 appViews = new(ELeave) CApaAppViewArray(KViewCount); |
|
621 CleanupStack::PushL(appViews); |
|
622 |
|
623 ret = iLs.GetAppViews(*appViews, KUidTestApp); |
|
624 TEST(ret == KErrNone); |
|
625 |
|
626 count = appViews->Count(); |
|
627 TEST(count == KViewCount); |
|
628 |
|
629 //Check application's view's captions or icons. They should be in French. |
|
630 CheckViewCaptionAndIconL(ELangFrench, appViews); |
|
631 CleanupStack::PopAndDestroy(appViews); |
|
632 |
|
633 //Restore locale to English before exiting the testcase |
|
634 TRAP(ret, ChangeLocaleL(ELangEnglish)); |
|
635 TEST(ret == KErrNone); |
|
636 TEST(User::Language() == ELangEnglish); |
|
637 |
|
638 User::After(delay); |
|
639 |
|
640 appViews = NULL; |
|
641 appViews = new(ELeave) CApaAppViewArray(KViewCount); |
|
642 CleanupStack::PushL(appViews); |
|
643 ret = iLs.GetAppViews(*appViews, KUidTestApp); |
|
644 |
|
645 TEST(ret == KErrNone); |
|
646 count = appViews->Count(); |
|
647 TEST(count == KViewCount); |
|
648 |
|
649 //check every thing is restored to English. |
|
650 CheckViewCaptionAndIconL(ELangEnglish, appViews); |
|
651 CleanupStack::PopAndDestroy(appViews); |
|
652 RFbsSession::Disconnect(); |
|
653 } |
|
654 |
|
655 /** |
|
656 Tests view's caption and view's icon. |
|
657 It is called from TestViewCaptionAndIconL function. |
|
658 This function is hardcoded to test view captions and icons for two languages - |
|
659 ELangEnglish and ELangFrench, |
|
660 if any other language is passed from any test case, this function will cause the test case to fail. |
|
661 |
|
662 @param aLanguage Language for which to test caption/icon. |
|
663 @param aAppViews application's view array. |
|
664 */ |
|
665 void CT_LocaleStep::CheckViewCaptionAndIconL(TLanguage aLanguage, CApaAppViewArray* aAppViews) |
|
666 { |
|
667 TInt testNumberOfIcons=KViewCount-1; |
|
668 // the for loop will check for all view icons except the last one which is invalid |
|
669 // Hence the upper limit is KViewCount-1 |
|
670 for (TInt ii=0; ii < testNumberOfIcons ; ii++) |
|
671 |
|
672 { |
|
673 const TApaAppViewInfo& viewInfo = (*aAppViews)[ii]; |
|
674 TEST(viewInfo.iViewCaption.Length() > 0); |
|
675 TBuf<256> viewCaption; |
|
676 TBuf<256> viewIconFileName; |
|
677 TSize iconSize; |
|
678 |
|
679 switch(aLanguage) |
|
680 { |
|
681 case ELangEnglish: |
|
682 viewCaption.Format(_L("V%d UK"), ii+1); |
|
683 iconSize.iWidth = 50; |
|
684 iconSize.iHeight = 50; |
|
685 break; |
|
686 |
|
687 case ELangFrench: |
|
688 viewCaption.Format(_L("V%d FR"), ii+1); |
|
689 iconSize.iWidth = 40; |
|
690 iconSize.iHeight = 55; |
|
691 break; |
|
692 |
|
693 default: |
|
694 // This case will cause test case to fail if any other language is passed apart from English and French. |
|
695 break; |
|
696 } |
|
697 |
|
698 // View's captions should be same as defined in language's localisable strings file (tstappXX.rls) |
|
699 TEST(viewInfo.iViewCaption == viewCaption); |
|
700 |
|
701 // View's icon size should be same as defined in icon file for the selected locale/language. |
|
702 CApaMaskedBitmap* viewBitmap = CApaMaskedBitmap::NewLC(); |
|
703 TInt ret = iLs.GetAppViewIcon(KUidTestApp, viewInfo.iUid, iconSize, *viewBitmap); |
|
704 TEST(ret == KErrNone); |
|
705 CleanupStack::PopAndDestroy(viewBitmap); |
|
706 |
|
707 // View's icon file should be same as defined in language's localisable strings file (tstappXX.rls) |
|
708 HBufC* fullFileName = NULL; |
|
709 ret = iLs.GetAppViewIcon(KUidTestApp, viewInfo.iUid, fullFileName); |
|
710 TEST(ret == KErrNone); |
|
711 TEST(fullFileName != NULL); |
|
712 INFO_PRINTF2(_L("View's icon file name is - %S"), fullFileName); |
|
713 TEST(fullFileName->Length() > 0); |
|
714 |
|
715 delete fullFileName; |
|
716 fullFileName = NULL; |
|
717 } //end of for |
|
718 /*The invalid View icon for language French has the file name "tstappview.mbm" This should |
|
719 return KErrNotSupported. Refer to PDEF113054 for details */ |
|
720 if (aLanguage==ELangFrench) |
|
721 { |
|
722 TSize iconSize; |
|
723 const TApaAppViewInfo& viewInfo = (*aAppViews)[2]; |
|
724 CApaMaskedBitmap* viewBitmap = CApaMaskedBitmap::NewLC(); |
|
725 TInt ret = iLs.GetAppViewIcon(KUidTestApp, viewInfo.iUid, iconSize, *viewBitmap); |
|
726 TEST(ret == KErrNotSupported); |
|
727 CleanupStack::PopAndDestroy(viewBitmap); |
|
728 HBufC* fullFileName = NULL; |
|
729 ret = iLs.GetAppViewIcon(KUidTestApp, viewInfo.iUid, fullFileName); |
|
730 TEST(ret == KErrNone); |
|
731 TEST(fullFileName != NULL); |
|
732 INFO_PRINTF2(_L("Negative View icon file name is - %S"), fullFileName); |
|
733 TEST(fullFileName->Length() > 0); |
|
734 delete fullFileName; |
|
735 fullFileName = NULL; |
|
736 } |
|
737 } |
|
738 |
|
739 CT_LocaleStep::~CT_LocaleStep() |
|
740 /** |
|
741 Destructor |
|
742 */ |
|
743 { |
|
744 } |
|
745 |
|
746 CT_LocaleStep::CT_LocaleStep() |
|
747 /** |
|
748 Constructor |
|
749 */ |
|
750 { |
|
751 // Call base class method to set up the human readable name for logging |
|
752 SetTestStepName(KT_LocaleStep); |
|
753 } |
|
754 |
|
755 TVerdict CT_LocaleStep::doTestStepPreambleL() |
|
756 /** |
|
757 @return - TVerdict code |
|
758 Override of base class virtual |
|
759 */ |
|
760 { |
|
761 SetTestStepResult(EPass); |
|
762 return TestStepResult(); |
|
763 } |
|
764 |
|
765 TVerdict CT_LocaleStep::doTestStepPostambleL() |
|
766 /** |
|
767 @return - TVerdict code |
|
768 Override of base class virtual |
|
769 */ |
|
770 { |
|
771 return TestStepResult(); |
|
772 } |
|
773 |
|
774 |
|
775 TVerdict CT_LocaleStep::doTestStepL() |
|
776 /** |
|
777 @return - TVerdict code |
|
778 Override of base class virtual |
|
779 */ |
|
780 { |
|
781 INFO_PRINTF1(_L("Locale tests started")); |
|
782 |
|
783 FbsStartup(); |
|
784 TEST(KErrNone == iFs.Connect()); |
|
785 TEST(KErrNone == iLs.Connect()); |
|
786 |
|
787 // run the tests |
|
788 //DONT_CHECK due to changes to file system |
|
789 HEAP_TEST_LS_SESSION(iLs, 0, DONT_CHECK, TestLocaleApplicationInfoOnDemandL() ,NO_CLEANUP); |
|
790 HEAP_TEST_LS_SESSION(iLs, 0, DONT_CHECK, TestLocaleApplicationInfoL() ,NO_CLEANUP); |
|
791 HEAP_TEST_LS_SESSION(iLs, 0, DONT_CHECK, TestLocaleApplicationInfo1L() ,NO_CLEANUP); |
|
792 HEAP_TEST_LS_SESSION(iLs, 0, DONT_CHECK, TestLocaleViewCaptionAndIconOnDemandL(), NO_CLEANUP); |
|
793 HEAP_TEST_LS_SESSION(iLs, 0, DONT_CHECK, TestLocaleViewCaptionAndIconL() ,NO_CLEANUP); |
|
794 HEAP_TEST_LS_SESSION(iLs, 0, DONT_CHECK, TestLocaleDefaultIconL() ,NO_CLEANUP); |
|
795 |
|
796 iLs.Close(); |
|
797 iFs.Close(); |
|
798 |
|
799 INFO_PRINTF1(_L("Test completed!")); |
|
800 return TestStepResult(); |
|
801 } |