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