appfw/apparchitecture/tef/T_CaptionStep.cpp
branchRCL_3
changeset 19 924385140d98
parent 0 2e3d3ce01487
child 20 c2c61fdca848
equal deleted inserted replaced
18:0818dd463d41 19:924385140d98
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    55 #include "T_CaptionStep.h"
    55 #include "T_CaptionStep.h"
    56 #include "appfwk_test_utils.h"
    56 #include "appfwk_test_utils.h"
    57 #include "appfwk_test.h"
    57 #include "appfwk_test.h"
    58 #include "ticoncaptionoverride.h" //KUidTestIconCapOverride defined here
    58 #include "ticoncaptionoverride.h" //KUidTestIconCapOverride defined here
    59 #include "TIconLoaderAndIconArrayForLeaks.h"
    59 #include "TIconLoaderAndIconArrayForLeaks.h"
       
    60 #include "T_SisFileInstaller.h"
    60 
    61 
    61 
    62 
    62 //
    63 //
    63 //
    64 //
    64 //		global consts and declarations
    65 //		global consts and declarations
    87 _LIT(KTestTApaAppInfoShortCaptionDefault,"TC UK");
    88 _LIT(KTestTApaAppInfoShortCaptionDefault,"TC UK");
    88 
    89 
    89 // Cenrep configuration details for English language
    90 // Cenrep configuration details for English language
    90 _LIT(KCenRepCaption, "CRTstCap UK");
    91 _LIT(KCenRepCaption, "CRTstCap UK");
    91 _LIT(KCenRepShortCaption, "CRTC UK");
    92 _LIT(KCenRepShortCaption, "CRTC UK");
    92 _LIT(KCenRepIconFilename, "Z:\\resource\\apps\\ticoncapoverride.mbm");
    93 _LIT(KCenRepIconFilename, "C:\\resource\\apps\\ticoncapoverride.mbm");
       
    94 
       
    95 _LIT(KTstAppStandAloneSisFile, "z:\\apparctest\\apparctestsisfiles\\TSTAPP_standalone.sis");
       
    96 _LIT(KTstAppStandAloneComponent, "TSTAPP_standalone");
       
    97 
       
    98 _LIT(KTstAppTiconcaptionoverrideSisFile, "z:\\apparctest\\apparctestsisfiles\\ticoncaptionoverride.sis");
       
    99 _LIT(KTstAppTiconcaptionoverrideComponent, "ticoncaptionoverride");
       
   100 
       
   101 _LIT(KForceRegAppSisFile, "z:\\apparctest\\apparctestsisfiles\\ForceRegApp1.sis");
       
   102 _LIT(KForceRegAppComponent, "ForceRegApp1");    
    93 
   103 
    94 const TUid KUidIconCaptionRepository = {0x1028583d}; // Central Repository UID.
   104 const TUid KUidIconCaptionRepository = {0x1028583d}; // Central Repository UID.
    95 const TInt KTextSize = 100;
   105 const TInt KTextSize = 100;
    96 
   106 
       
   107 const TInt KDelay = 4000000;
    97 //
   108 //
    98 //
   109 //
    99 //		CT_CaptionStep
   110 //		CT_CaptionStep
   100 //
   111 //
   101 //
   112 //
   102 
   113 
   103 
   114 
   104 void CT_CaptionStep::ChangeLocaleL(TLanguage aLanguage)
   115 void CT_CaptionStep::ChangeLocaleL(TLanguage aLanguage)
   105 	{
   116 	{
   106 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL 
   117 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL 
   107     _LIT(KLitLocaleDllNameBase, "elocl_lan");
   118     _LIT(KLitLanguageLocaleDllNameBase, "elocl_lan");
   108     _LIT(KLitLocaleDllNameExtension, ".loc");
   119     //Region and collation code values are hard coded, as the check, after changing the locale is made for the language only.
       
   120     _LIT(KLitRegionLocaleDllNameBase, "elocl_reg.826");        
       
   121     _LIT(KLitCollationLocaleDllNameBase, "elocl_col.001");
       
   122     _LIT(ThreeDigExt,".%03d");
       
   123     TExtendedLocale localeDll;    
       
   124     const TUidType uidType(TUid::Uid(0x10000079),TUid::Uid(0x100039e6));
       
   125     TBuf<16> languageLocaleDllName(KLitLanguageLocaleDllNameBase);  
       
   126     languageLocaleDllName.AppendFormat(ThreeDigExt, aLanguage);
       
   127     TBuf<16> regionLocaleDllName(KLitRegionLocaleDllNameBase);  
       
   128     TBuf<16> collationLocaleDllName(KLitCollationLocaleDllNameBase);  
       
   129     // Try to load the locale dll
       
   130     TInt error=localeDll.LoadLocale(languageLocaleDllName, regionLocaleDllName, collationLocaleDllName);
       
   131         
       
   132     if (error==KErrNotFound)
       
   133         {
       
   134         // Locale dll is not found for the asked language. 
       
   135         ERR_PRINTF2(_L("Failed to find the locale dll for %d"), aLanguage);
       
   136         }
       
   137            
       
   138     User::LeaveIfError(error);
       
   139     localeDll.SaveSystemSettings();
   109 #else
   140 #else
   110     _LIT(KLitLocaleDllNameBase, "ELOCL");
   141     _LIT(KLitLocaleDllNameBase, "ELOCL");
   111     _LIT(KLitLocaleDllNameExtension, ".LOC");
   142     _LIT(TwoDigExt,".%02d");
   112 #endif          
   143     
   113     RLibrary localeDll;
   144     RLibrary localeDll; 
   114     TBuf<16> localeDllName(KLitLocaleDllNameBase);
       
   115     CleanupClosePushL(localeDll);
   145     CleanupClosePushL(localeDll);
       
   146     
   116     const TUidType uidType(TUid::Uid(0x10000079),TUid::Uid(0x100039e6));
   147     const TUidType uidType(TUid::Uid(0x10000079),TUid::Uid(0x100039e6));
   117 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL         
   148     TBuf<16> localeDllName(KLitLocaleDllNameBase);  
   118     _LIT(ThreeDigExt,".%03d");
   149     localeDllName.AppendFormat(TwoDigExt, language);
   119     localeDllName.AppendFormat(ThreeDigExt, aLanguage);
   150     
   120 #else
   151     // Try to load the locale dll
   121     _LIT(TwoDigExt,".%02d");
       
   122     localeDllName.AppendFormat(TwoDigExt, aLanguage);
       
   123 #endif          
       
   124             
       
   125     TInt error=localeDll.Load(localeDllName, uidType);
   152     TInt error=localeDll.Load(localeDllName, uidType);
   126     if (error==KErrNotFound)
   153     if (error==KErrNotFound)
   127         {
   154         {
   128         localeDllName=KLitLocaleDllNameBase;
   155         // Locale dll is not found for the asked language. 
   129         localeDllName.Append(KLitLocaleDllNameExtension);
   156         ERR_PRINTF2(_L("Failed to find the locale dll for %d"), language);
   130         error=localeDll.Load(localeDllName, uidType);
       
   131         }
   157         }
       
   158     
   132     User::LeaveIfError(error);
   159     User::LeaveIfError(error);
   133             
       
   134 #ifdef  SYMBIAN_DISTINCT_LOCALE_MODEL
       
   135     TExtendedLocale myExtendedLocale;
       
   136     User::LeaveIfError(myExtendedLocale.LoadLocaleAspect(localeDllName));
       
   137     User::LeaveIfError(myExtendedLocale.SaveSystemSettings());
       
   138 #else   
       
   139     User::LeaveIfError(UserSvr::ChangeLocale(localeDllName));
   160     User::LeaveIfError(UserSvr::ChangeLocale(localeDllName));
       
   161     CleanupStack: opAndDestroy(); // localeDll
   140 #endif
   162 #endif
   141     CleanupStack::PopAndDestroy(&localeDll);
   163     
       
   164     // Check if the device locale has changed
       
   165     if (aLanguage == User::Language())
       
   166         {
       
   167         SetTestStepResult(EPass);
       
   168         }
       
   169     else
       
   170         {
       
   171         ERR_PRINTF3(_L("Failed to change the locale to %d whereas the current locale is"), aLanguage, User::Language());
       
   172         }	
   142 	}
   173 	}
   143 
   174 
   144 
   175 
   145 void CT_CaptionStep::DoLanguageTestL()
   176 void CT_CaptionStep::DoLanguageTestL()
   146 	{
   177 	{
   180 				User::LeaveIfError(KErrNotSupported);
   211 				User::LeaveIfError(KErrNotSupported);
   181 				break;
   212 				break;
   182 			};
   213 			};
   183 
   214 
   184 		// Change the locale
   215 		// Change the locale
   185 		ChangeLocaleL(languageToTest);
   216 		if(languageToTest != User::Language())
   186 		TEST(User::Language() == languageToTest);
   217 		    {
   187 		
   218             ChangeLocaleWaitForApplistUpdate(languageToTest);		
   188 		// Force the applist to be updated (so test app gets new language settings)
   219             TEST(User::Language() == languageToTest);
   189 		RPointerArray<TDesC> dummy;
   220 		    }
   190 		User::LeaveIfError(iLs.ForceRegistration(dummy));
       
   191 		
   221 		
   192 		// Do the same set of tests for each language
   222 		// Do the same set of tests for each language
   193 		TestCApaSystemControlListL();
   223 		TestCApaSystemControlListL();
   194 		TestCApaDoorL();
   224 		TestCApaDoorL();
   195 		TestTApaAppInfoStreamsL();
   225 		TestTApaAppInfoStreamsL();
   197 
   227 
   198 		INFO_PRINTF1(_L("Test for that language finished..."));
   228 		INFO_PRINTF1(_L("Test for that language finished..."));
   199 		}
   229 		}
   200 
   230 
   201 	// restore original locale, just in case...
   231 	// restore original locale, just in case...
   202 	ChangeLocaleL(language);
   232 	if(User::Language() != language)
       
   233 	    ChangeLocaleWaitForApplistUpdate(language);
       
   234 	
   203 	TEST(User::Language() == language);
   235 	TEST(User::Language() == language);
   204 	}	
   236 	}	
   205 
   237 
   206 /**
   238 /**
   207    @SYMTestCaseID	t_caption_TestCApaSystemControlListL
   239    @SYMTestCaseID	t_caption_TestCApaSystemControlListL
   406  */	
   438  */	
   407 void CT_CaptionStep::TestTApaAppInfoStreamsL()
   439 void CT_CaptionStep::TestTApaAppInfoStreamsL()
   408 	{
   440 	{
   409 	INFO_PRINTF1(_L("Testing TApaAppInfo streams... "));
   441 	INFO_PRINTF1(_L("Testing TApaAppInfo streams... "));
   410 
   442 
   411 	TApaAppInfo appInfoShort(KUidTestApp, _L("z:\\sys\\bin\\tstapp.exe"), _L("TstCap UK"),_L("TC UK"));
   443 	TApaAppInfo appInfoShort(KUidTestApp, _L("c:\\sys\\bin\\tstapp.exe"), _L("TstCap UK"),_L("TC UK"));
   412 	TEST(appInfoShort.iShortCaption.Compare(_L("TC UK"))==0);
   444 	TEST(appInfoShort.iShortCaption.Compare(_L("TC UK"))==0);
   413 
   445 
   414 	TFileName tempFile=_L("c:\\system\\test\\TC_temp.txt");
   446 	TFileName tempFile=_L("c:\\system\\test\\TC_temp.txt");
   415 	TInt ret = iFs.MkDirAll(tempFile);
   447 	TInt ret = iFs.MkDirAll(tempFile);
   416 	if (ret != KErrNone && ret != KErrAlreadyExists)
   448 	if (ret != KErrNone && ret != KErrAlreadyExists)
   468 	TLanguage language = User::Language();
   500 	TLanguage language = User::Language();
   469 	ChangeLocaleL(ELangEnglish);
   501 	ChangeLocaleL(ELangEnglish);
   470 	TEST(User::Language() == ELangEnglish);
   502 	TEST(User::Language() == ELangEnglish);
   471 	
   503 	
   472 	// Force the applist to be updated (so test app gets new language settings)
   504 	// Force the applist to be updated (so test app gets new language settings)
   473 	RPointerArray<TDesC> dummy;
   505 	ForceApplistUpdate();
   474 	User::LeaveIfError(iLs.ForceRegistration(dummy));
       
   475 
   506 
   476 	// SetAppShortCaption should return KErrNotFound if it could not find the app
   507 	// SetAppShortCaption should return KErrNotFound if it could not find the app
   477 	INFO_PRINTF1(_L(".....setting short caption for an unknown app"));
   508 	INFO_PRINTF1(_L(".....setting short caption for an unknown app"));
   478 	TInt err = iLs.SetAppShortCaption(KShortCaption1, ELangNone, TUid::Uid(0xFFF34556));
   509 	TInt err = iLs.SetAppShortCaption(KShortCaption1, ELangNone, TUid::Uid(0xFFF34556));
   479 	TEST(err == KErrNotFound);
   510 	TEST(err == KErrNotFound);
   507 	iLs.GetAppInfo(appInfo, KUidTestApp);
   538 	iLs.GetAppInfo(appInfo, KUidTestApp);
   508 	TEST(appInfo.iShortCaption == KShortCaption1);
   539 	TEST(appInfo.iShortCaption == KShortCaption1);
   509 
   540 
   510 	// Check short caption remains updated after a refresh of the applist
   541 	// Check short caption remains updated after a refresh of the applist
   511 	INFO_PRINTF1(_L(".....checking short caption remains updated after a refresh of the applist"));
   542 	INFO_PRINTF1(_L(".....checking short caption remains updated after a refresh of the applist"));
   512 	User::LeaveIfError(iLs.ForceRegistration(dummy));
   543 	ForceApplistUpdate();
   513 	iLs.GetAppInfo(appInfo, KUidTestApp);
   544 	iLs.GetAppInfo(appInfo, KUidTestApp);
   514 	TEST(appInfo.iShortCaption == KShortCaption1);
   545 	TEST(appInfo.iShortCaption == KShortCaption1);
   515 
   546 
   516 	// Check short caption remains updated after a locale change
   547 	// Check short caption remains updated after a locale change
   517 	INFO_PRINTF1(_L(".....checking short caption remains updated after a locale change"));
   548 	INFO_PRINTF1(_L(".....checking short caption remains updated after a locale change"));
   518 	ChangeLocaleL(ELangJapanese);
   549 	ChangeLocaleWaitForApplistUpdate(ELangJapanese);
   519 	TEST(User::Language() == ELangJapanese);	// Japanese locale exists in epoc32 tree but not defined in test app
   550 	TEST(User::Language() == ELangJapanese);	// Japanese locale exists in epoc32 tree but not defined in test app
   520 	User::LeaveIfError(iLs.ForceRegistration(dummy));
   551     ChangeLocaleWaitForApplistUpdate(ELangEnglish);				// back to English to see what happened in between
   521 	ChangeLocaleL(ELangEnglish);				// back to English to see what happened in between
       
   522 	TEST(User::Language() == ELangEnglish);
   552 	TEST(User::Language() == ELangEnglish);
   523 	User::LeaveIfError(iLs.ForceRegistration(dummy));
       
   524 	iLs.GetAppInfo(appInfo, KUidTestApp);
   553 	iLs.GetAppInfo(appInfo, KUidTestApp);
   525 	TEST(appInfo.iShortCaption == KShortCaption1);
   554 	TEST(appInfo.iShortCaption == KShortCaption1);
   526 
   555 
   527 	// Set short caption of an app for a language which is not the current one (ELangFrench, for example)
   556 	// Set short caption of an app for a language which is not the current one (ELangFrench, for example)
   528 	INFO_PRINTF1(_L(".....setting short caption of an app for a language which is not the current one"));
   557 	INFO_PRINTF1(_L(".....setting short caption of an app for a language which is not the current one"));
   529 	err = iLs.SetAppShortCaption(KShortCaption2, ELangFrench, KUidTestApp);
   558 	err = iLs.SetAppShortCaption(KShortCaption2, ELangFrench, KUidTestApp);
   530 	TEST(err == KErrNone);
   559 	TEST(err == KErrNone);
   531 	iLs.GetAppInfo(appInfo, KUidTestApp);
   560 	iLs.GetAppInfo(appInfo, KUidTestApp);
   532 	TEST(appInfo.iShortCaption == KShortCaption1);	// English, the current app language, doesn't change...
   561 	TEST(appInfo.iShortCaption == KShortCaption1);	// English, the current app language, doesn't change...
   533 	ChangeLocaleL(ELangFrench);
   562 	ChangeLocaleWaitForApplistUpdate(ELangFrench);
   534 	TEST(User::Language() == ELangFrench);
   563 	TEST(User::Language() == ELangFrench);
   535 	User::LeaveIfError(iLs.ForceRegistration(dummy));
       
   536 	iLs.GetAppInfo(appInfo, KUidTestApp);
   564 	iLs.GetAppInfo(appInfo, KUidTestApp);
   537 	TEST(appInfo.iShortCaption == KShortCaption2);	
   565 	TEST(appInfo.iShortCaption == KShortCaption2);	
   538 	
   566 	
   539 	// Set short caption of an app for a language which the app does not include (ELangAmerican)
   567 	// Set short caption of an app for a language which the app does not include (ELangAmerican)
   540 	INFO_PRINTF1(_L(".....setting short caption of an app for a language which the app does not include"));
   568 	INFO_PRINTF1(_L(".....setting short caption of an app for a language which the app does not include"));
   541 	ChangeLocaleL(ELangAmerican);
   569 	ChangeLocaleWaitForApplistUpdate(ELangAmerican);
   542 	TEST(User::Language() == ELangAmerican);
   570 	TEST(User::Language() == ELangAmerican);
   543 	User::LeaveIfError(iLs.ForceRegistration(dummy));
       
   544 	err = iLs.SetAppShortCaption(KShortCaption2, ELangAmerican, KUidTestApp);
   571 	err = iLs.SetAppShortCaption(KShortCaption2, ELangAmerican, KUidTestApp);
   545 	iLs.GetAppInfo(appInfo, KUidTestApp);
   572 	iLs.GetAppInfo(appInfo, KUidTestApp);
   546 	TEST(appInfo.iShortCaption == KShortCaption1);	// American takes the default...so English...which has just been updated.
   573 	TEST(appInfo.iShortCaption == KShortCaption1);	// American takes the default...so English...which has just been updated.
   547 
   574 
   548 	// Set short caption of an app for all languages with ELangNone
   575 	// Set short caption of an app for all languages with ELangNone
   549 	INFO_PRINTF1(_L(".....setting short caption for all languages with ELangNone"));
   576 	INFO_PRINTF1(_L(".....setting short caption for all languages with ELangNone"));
   550 	err = iLs.SetAppShortCaption(KShortCaption3, ELangNone, KUidTestApp);
   577 	err = iLs.SetAppShortCaption(KShortCaption3, ELangNone, KUidTestApp);
   551 	TEST(err == KErrNone);
   578 	TEST(err == KErrNone);
   552 	iLs.GetAppInfo(appInfo, KUidTestApp);
   579 	iLs.GetAppInfo(appInfo, KUidTestApp);
   553 	TEST(appInfo.iShortCaption == KShortCaption1);	// American takes the default...so English...which has just been updated.
   580 	TEST(appInfo.iShortCaption == KShortCaption1);	// American takes the default...so English...which has just been updated.
   554 	ChangeLocaleL(ELangEnglish);
   581 	ChangeLocaleWaitForApplistUpdate(ELangEnglish);
   555 	TEST(User::Language() == ELangEnglish);
   582 	TEST(User::Language() == ELangEnglish);
   556 	User::LeaveIfError(iLs.ForceRegistration(dummy));
       
   557 	iLs.GetAppInfo(appInfo, KUidTestApp);
   583 	iLs.GetAppInfo(appInfo, KUidTestApp);
   558 	TEST(appInfo.iShortCaption == KShortCaption1);	// English set individually ===> not updated by ELangNone
   584 	TEST(appInfo.iShortCaption == KShortCaption1);	// English set individually ===> not updated by ELangNone
   559 	ChangeLocaleL(ELangFrench);
   585 	ChangeLocaleWaitForApplistUpdate(ELangFrench);
   560 	TEST(User::Language() == ELangFrench);
   586 	TEST(User::Language() == ELangFrench);
   561 	User::LeaveIfError(iLs.ForceRegistration(dummy));
       
   562 	iLs.GetAppInfo(appInfo, KUidTestApp);
   587 	iLs.GetAppInfo(appInfo, KUidTestApp);
   563 	TEST(appInfo.iShortCaption == KShortCaption2);	// French set individually ===> not updated by ELangNone
   588 	TEST(appInfo.iShortCaption == KShortCaption2);	// French set individually ===> not updated by ELangNone
   564 	ChangeLocaleL(ELangGerman);
   589 	ChangeLocaleWaitForApplistUpdate(ELangGerman);
   565 	TEST(User::Language() == ELangGerman);
   590 	TEST(User::Language() == ELangGerman);
   566 	User::LeaveIfError(iLs.ForceRegistration(dummy));
       
   567 	iLs.GetAppInfo(appInfo, KUidTestApp);
   591 	iLs.GetAppInfo(appInfo, KUidTestApp);
   568 	TEST(appInfo.iShortCaption == KShortCaption3);	// German takes the one set by  ELangNone
   592 	TEST(appInfo.iShortCaption == KShortCaption3);	// German takes the one set by  ELangNone
   569 	ChangeLocaleL(ELangItalian);
   593 	ChangeLocaleWaitForApplistUpdate(ELangItalian);
   570 	TEST(User::Language() == ELangItalian);
   594 	TEST(User::Language() == ELangItalian);
   571 	User::LeaveIfError(iLs.ForceRegistration(dummy));
       
   572 	iLs.GetAppInfo(appInfo, KUidTestApp);
   595 	iLs.GetAppInfo(appInfo, KUidTestApp);
   573 	TEST(appInfo.iShortCaption == KShortCaption3);	// Italian takes the one set by ELangNone
   596 	TEST(appInfo.iShortCaption == KShortCaption3);	// Italian takes the one set by ELangNone
   574 	ChangeLocaleL(ELangSpanish);
   597 	ChangeLocaleWaitForApplistUpdate(ELangSpanish);
   575 	TEST(User::Language() == ELangSpanish);
   598 	TEST(User::Language() == ELangSpanish);
   576 	User::LeaveIfError(iLs.ForceRegistration(dummy));
       
   577 	iLs.GetAppInfo(appInfo, KUidTestApp);
   599 	iLs.GetAppInfo(appInfo, KUidTestApp);
   578 	TEST(appInfo.iShortCaption == KShortCaption3);	// Spanish takes the one set by ELangNone
   600 	TEST(appInfo.iShortCaption == KShortCaption3);	// Spanish takes the one set by ELangNone
   579 
   601 
   580 	// Set short caption of an app for a language which was set by the previous ELangNone
   602 	// Set short caption of an app for a language which was set by the previous ELangNone
   581 	INFO_PRINTF1(_L(".....setting short caption of an app which was set by the previous ELangNone"));
   603 	INFO_PRINTF1(_L(".....setting short caption of an app which was set by the previous ELangNone"));
   582 	ChangeLocaleL(ELangItalian);
   604 	ChangeLocaleWaitForApplistUpdate(ELangItalian);
   583 	TEST(User::Language() == ELangItalian);
   605 	TEST(User::Language() == ELangItalian);
   584 	User::LeaveIfError(iLs.ForceRegistration(dummy));
       
   585 	err = iLs.SetAppShortCaption(KShortCaption4, ELangItalian, KUidTestApp);
   606 	err = iLs.SetAppShortCaption(KShortCaption4, ELangItalian, KUidTestApp);
   586 	iLs.GetAppInfo(appInfo, KUidTestApp);
   607 	iLs.GetAppInfo(appInfo, KUidTestApp);
   587 	TEST(appInfo.iShortCaption == KShortCaption4);
   608 	TEST(appInfo.iShortCaption == KShortCaption4);
   588 
   609 
   589 	// Repeat set short caption of an app for all languages with ELangNone
   610 	// Repeat set short caption of an app for all languages with ELangNone
   590 	INFO_PRINTF1(_L(".....repeat setting short caption for all languages with ELangNone"));
   611 	INFO_PRINTF1(_L(".....repeat setting short caption for all languages with ELangNone"));
   591 	err = iLs.SetAppShortCaption(KShortCaption5, ELangNone, KUidTestApp);
   612 	err = iLs.SetAppShortCaption(KShortCaption5, ELangNone, KUidTestApp);
   592 	TEST(err == KErrNone);
   613 	TEST(err == KErrNone);
   593 	iLs.GetAppInfo(appInfo, KUidTestApp);
   614 	iLs.GetAppInfo(appInfo, KUidTestApp);
   594 	TEST(appInfo.iShortCaption == KShortCaption4);	// Italian set individually ===> not updated by ELangNone
   615 	TEST(appInfo.iShortCaption == KShortCaption4);	// Italian set individually ===> not updated by ELangNone
   595 	ChangeLocaleL(ELangEnglish);
   616 	ChangeLocaleWaitForApplistUpdate(ELangEnglish);
   596 	TEST(User::Language() == ELangEnglish);
   617 	TEST(User::Language() == ELangEnglish);
   597 	User::LeaveIfError(iLs.ForceRegistration(dummy));
       
   598 	iLs.GetAppInfo(appInfo, KUidTestApp);
   618 	iLs.GetAppInfo(appInfo, KUidTestApp);
   599 	TEST(appInfo.iShortCaption == KShortCaption1);	// English set individually ===> not updated by ELangNone
   619 	TEST(appInfo.iShortCaption == KShortCaption1);	// English set individually ===> not updated by ELangNone
   600 	ChangeLocaleL(ELangFrench);
   620 	ChangeLocaleWaitForApplistUpdate(ELangFrench);
   601 	TEST(User::Language() == ELangFrench);
   621 	TEST(User::Language() == ELangFrench);
   602 	User::LeaveIfError(iLs.ForceRegistration(dummy));
       
   603 	iLs.GetAppInfo(appInfo, KUidTestApp);
   622 	iLs.GetAppInfo(appInfo, KUidTestApp);
   604 	TEST(appInfo.iShortCaption == KShortCaption2);	// French set individually ===> not updated by ELangNone
   623 	TEST(appInfo.iShortCaption == KShortCaption2);	// French set individually ===> not updated by ELangNone
   605 	ChangeLocaleL(ELangGerman);
   624 	ChangeLocaleWaitForApplistUpdate(ELangGerman);
   606 	TEST(User::Language() == ELangGerman);
   625 	TEST(User::Language() == ELangGerman);
   607 	User::LeaveIfError(iLs.ForceRegistration(dummy));
       
   608 	iLs.GetAppInfo(appInfo, KUidTestApp);
   626 	iLs.GetAppInfo(appInfo, KUidTestApp);
   609 	TEST(appInfo.iShortCaption == KShortCaption5);	// German takes the one set by  ELangNone
   627 	TEST(appInfo.iShortCaption == KShortCaption5);	// German takes the one set by  ELangNone
   610 	ChangeLocaleL(ELangSpanish);
   628 	ChangeLocaleWaitForApplistUpdate(ELangSpanish);
   611 	TEST(User::Language() == ELangSpanish);
   629 	TEST(User::Language() == ELangSpanish);
   612 	User::LeaveIfError(iLs.ForceRegistration(dummy));
       
   613 	iLs.GetAppInfo(appInfo, KUidTestApp);
   630 	iLs.GetAppInfo(appInfo, KUidTestApp);
   614 	TEST(appInfo.iShortCaption == KShortCaption5);	// Spanish takes the one set by ELangNone
   631 	TEST(appInfo.iShortCaption == KShortCaption5);	// Spanish takes the one set by ELangNone
   615 	ChangeLocaleL(ELangAmerican);
   632 	ChangeLocaleWaitForApplistUpdate(ELangAmerican);
   616 	TEST(User::Language() == ELangAmerican);
   633 	TEST(User::Language() == ELangAmerican);
   617 	User::LeaveIfError(iLs.ForceRegistration(dummy));
       
   618 	iLs.GetAppInfo(appInfo, KUidTestApp);
   634 	iLs.GetAppInfo(appInfo, KUidTestApp);
   619 	TEST(appInfo.iShortCaption == KShortCaption1);	// American takes the default...so English...which has just been updated.
   635 	TEST(appInfo.iShortCaption == KShortCaption1);	// American takes the default...so English...which has just been updated.
   620 
   636 
   621 	// restore original settings....
   637 	// restore original settings....
   622 	INFO_PRINTF1(_L(".....restoring original settings"));
   638 	INFO_PRINTF1(_L(".....restoring original settings"));
   623 	ChangeLocaleL(language);
   639 	ChangeLocaleWaitForApplistUpdate(language);
   624 	TEST(User::Language() == language);
   640 	TEST(User::Language() == language);
   625 	// restore original short captions for all langs....(h4 doesn't perform reboots between tests)
   641 	// restore original short captions for all langs....(h4 doesn't perform reboots between tests)
   626 	TEST(iLs.SetAppShortCaption(KTestTApaAppInfoShortCaptionEnglish, ELangEnglish, KUidTestApp) == KErrNone);
   642 	TEST(iLs.SetAppShortCaption(KTestTApaAppInfoShortCaptionEnglish, ELangEnglish, KUidTestApp) == KErrNone);
   627 	TEST(iLs.SetAppShortCaption(KTestTApaAppInfoShortCaptionFrench, ELangFrench, KUidTestApp) == KErrNone);
   643 	TEST(iLs.SetAppShortCaption(KTestTApaAppInfoShortCaptionFrench, ELangFrench, KUidTestApp) == KErrNone);
   628 	TEST(iLs.SetAppShortCaption(KTestTApaAppInfoShortCaptionGerman, ELangGerman, KUidTestApp) == KErrNone);
   644 	TEST(iLs.SetAppShortCaption(KTestTApaAppInfoShortCaptionGerman, ELangGerman, KUidTestApp) == KErrNone);
   660 
   676 
   661 void CT_CaptionStep::TestIconCaptionOverridesL()
   677 void CT_CaptionStep::TestIconCaptionOverridesL()
   662 	{
   678 	{
   663 	INFO_PRINTF1(_L("APPFWK-APPARC-0087:TestIconCaptionOverridesL started..."));
   679 	INFO_PRINTF1(_L("APPFWK-APPARC-0087:TestIconCaptionOverridesL started..."));
   664 	
   680 	
   665 	//Change the system language to English before starting the tests
   681     //Change the system language to English before starting the tests
   666 	TRAPD(ret,ChangeLocaleL(ELangEnglish));
   682     TRAPD(ret,ChangeLocaleL(ELangEnglish));
   667 	TEST(ret == KErrNone);
   683     TEST(ret == KErrNone);
       
   684     TEST(User::Language() == ELangEnglish);
       
   685     ForceApplistUpdate();
   668 				
   686 				
   669 	TApaAppInfo appInfo;
   687 	TApaAppInfo appInfo;
   670 	//Get test app's information
   688 	//Get test app's information
   671 	iLs.GetAppInfo(appInfo, KUidTestIconCapOverride);
   689 	iLs.GetAppInfo(appInfo, KUidTestIconCapOverride);
   672 
   690 
   776 	TInt error = cenRep->Set(shortCapKey,KCenRepSC);
   794 	TInt error = cenRep->Set(shortCapKey,KCenRepSC);
   777 	
   795 	
   778 	//tests whether the process with WriteDeviceData capability can update the configuration settings.
   796 	//tests whether the process with WriteDeviceData capability can update the configuration settings.
   779 	TEST(error == KErrNone);
   797 	TEST(error == KErrNone);
   780 	
   798 	
   781 	// Force the applist to be updated (so test app gets new language settings)
   799 	ForceApplistUpdate();
   782 	RPointerArray<TDesC> dummy;
   800     
   783 	User::LeaveIfError(iLs.ForceRegistration(dummy));
       
   784 	
       
   785 	TApaAppInfo appInfo;
   801 	TApaAppInfo appInfo;
   786 	//Get test app's information
   802 	//Get test app's information
   787 	iLs.GetAppInfo(appInfo, KUidTestIconCapOverride);
   803 	iLs.GetAppInfo(appInfo, KUidTestIconCapOverride);
   788 
   804 
   789 	//compare the short caption with the updated value in central repository
   805 	//compare the short caption with the updated value in central repository
   795 	TEST(appInfo.iShortCaption == KCenRepSC);
   811 	TEST(appInfo.iShortCaption == KCenRepSC);
   796 	
   812 	
   797 	//sets the short caption back to the actual for other tests to work
   813 	//sets the short caption back to the actual for other tests to work
   798 	error = cenRep->Set(shortCapKey,KCenRepShortCaption);
   814 	error = cenRep->Set(shortCapKey,KCenRepShortCaption);
   799 	
   815 	
   800 	// Force the applist to be updated (so test app gets new language settings)
   816     // Force the applist to be updated (so test app gets new language settings)
   801 	User::LeaveIfError(iLs.ForceRegistration(dummy));
   817     ForceApplistUpdate();
   802 	
   818 	
   803 	CleanupStack::PopAndDestroy(cenRep); //cenRep object
   819 	CleanupStack::PopAndDestroy(cenRep); //cenRep object
   804 	INFO_PRINTF1(_L("APPFWK-APPARC-0089:TestCenRepChangeNotificationL finished..."));
   820 	INFO_PRINTF1(_L("APPFWK-APPARC-0089:TestCenRepChangeNotificationL finished..."));
   805 	}
   821 	}
   806 
   822 
   834 	
   850 	
   835 	TInt ret = 0;
   851 	TInt ret = 0;
   836 	//French
   852 	//French
   837 	_LIT(KCaptionFrench, "CRTstCap FR");
   853 	_LIT(KCaptionFrench, "CRTstCap FR");
   838 	_LIT(KShortCaptionFrench, "CRTC FR");
   854 	_LIT(KShortCaptionFrench, "CRTC FR");
   839 	_LIT(KIconFilenameFrench, "Z:\\resource\\apps\\svg_icon.svg");
   855 	_LIT(KIconFilenameFrench, "C:\\resource\\apps\\svg_icon.svg");
   840 
   856 
   841 	//German
   857 	//German
   842 	_LIT(KCaptionGerman, "TstCap GE");
   858 	_LIT(KCaptionGerman, "TstCap GE");
   843 	_LIT(KShortCaptionGerman, "TC GE");
   859 	_LIT(KShortCaptionGerman, "TC GE");
   844 	_LIT(KIconFilenameGerman, "Z:\\resource\\apps\\ticoncapoverride.mbm");
   860 	_LIT(KIconFilenameGerman, "C:\\resource\\apps\\ticoncapoverride.mbm");
   845 
   861 
   846 	TApaAppInfo appInfo;
   862 	TApaAppInfo appInfo;
   847 	RFile file;
   863 	RFile file;
   848 	TBuf<KTextSize> fileName;
   864 	TBuf<KTextSize> fileName;
   849 		
   865 		
   853 	TEST(ret == KErrNone);
   869 	TEST(ret == KErrNone);
   854 	INFO_PRINTF2(_L("----System Language==>%d"), User::Language());
   870 	INFO_PRINTF2(_L("----System Language==>%d"), User::Language());
   855 	
   871 	
   856 	TEST(User::Language() == ELangFrench);//check language is set to French.
   872 	TEST(User::Language() == ELangFrench);//check language is set to French.
   857 	
   873 	
   858 	// Force the applist to be updated (so test app gets new language settings)
   874     ForceApplistUpdate();
   859 	RPointerArray<TDesC> dummy;
       
   860 	User::LeaveIfError(iLs.ForceRegistration(dummy));
       
   861 	
   875 	
   862 	//Get test app's information
   876 	//Get test app's information
   863 	iLs.GetAppInfo(appInfo, KUidTestIconCapOverride);
   877 	iLs.GetAppInfo(appInfo, KUidTestIconCapOverride);
   864 
   878 
   865 	//Get test app's icon information
   879 	//Get test app's icon information
   894 	TEST(ret == KErrNone);
   908 	TEST(ret == KErrNone);
   895 	INFO_PRINTF2(_L("----System Language==>%d"), User::Language());
   909 	INFO_PRINTF2(_L("----System Language==>%d"), User::Language());
   896 	TEST(User::Language() == ELangGerman);//check language is set to German.
   910 	TEST(User::Language() == ELangGerman);//check language is set to German.
   897 	
   911 	
   898 	// Force the applist to be updated (so test app gets new language settings)
   912 	// Force the applist to be updated (so test app gets new language settings)
   899 	User::LeaveIfError(iLs.ForceRegistration(dummy));
   913 	ForceApplistUpdate();
   900 	
   914 	
   901 	//Get test app's information
   915 	//Get test app's information
   902 	iLs.GetAppInfo(appInfo, KUidTestIconCapOverride);
   916 	iLs.GetAppInfo(appInfo, KUidTestIconCapOverride);
   903 
   917 
   904 	file.Close();
   918 	file.Close();
   938 	INFO_PRINTF2(_L("----System Language==>%d"), User::Language());
   952 	INFO_PRINTF2(_L("----System Language==>%d"), User::Language());
   939 	
   953 	
   940 	TEST(User::Language() == ELangEnglish);//check language is set to English.
   954 	TEST(User::Language() == ELangEnglish);//check language is set to English.
   941 	
   955 	
   942 	// Force the applist to be updated (so test app gets new language settings)
   956 	// Force the applist to be updated (so test app gets new language settings)
   943 	User::LeaveIfError(iLs.ForceRegistration(dummy));
   957 	ForceApplistUpdate();
   944 	
   958 	
   945 	//Get test app's information
   959 	//Get test app's information
   946 	iLs.GetAppInfo(appInfo, KUidTestIconCapOverride);
   960 	iLs.GetAppInfo(appInfo, KUidTestIconCapOverride);
   947 
   961 
   948 	file.Close();
   962 	file.Close();
   971 	printString.Zero();
   985 	printString.Zero();
   972 	printString.Copy(KCenRepIconFilename);
   986 	printString.Copy(KCenRepIconFilename);
   973 	INFO_PRINTF2(_L("----Expected icon filename==>%S"), &printString);
   987 	INFO_PRINTF2(_L("----Expected icon filename==>%S"), &printString);
   974 	INFO_PRINTF2(_L("----Retrieved icon filename==>%S"), &fileName);
   988 	INFO_PRINTF2(_L("----Retrieved icon filename==>%S"), &fileName);
   975 	TEST(fileName.Compare(KCenRepIconFilename)==0);
   989 	TEST(fileName.Compare(KCenRepIconFilename)==0);
   976 	
   990 	file.Close();
   977 	INFO_PRINTF1(_L("APPFWK-APPARC-0090:TestIconCaptionOverridesWithChangeLangL finished..."));
   991 	INFO_PRINTF1(_L("APPFWK-APPARC-0090:TestIconCaptionOverridesWithChangeLangL finished..."));
   978 	}
   992 	}
   979 		
   993 		
   980 /**
   994 /**
   981 @SYMTestCaseID 				APPFWK-APPARC-0091
   995 @SYMTestCaseID 				APPFWK-APPARC-0091
  1009 	TestCenRepChangeNotificationL();
  1023 	TestCenRepChangeNotificationL();
  1010 	TestIconCaptionOverridesMemoryLeaksL();
  1024 	TestIconCaptionOverridesMemoryLeaksL();
  1011 	TestApiPrecedenceOverCenRepConfigInfoL();
  1025 	TestApiPrecedenceOverCenRepConfigInfoL();
  1012 	}
  1026 	}
  1013 	
  1027 	
       
  1028 void CT_CaptionStep::ForceApplistUpdate()
       
  1029 {
       
  1030     // Force the applist to be updated (so test app gets new language settings)
       
  1031     CSisFileInstaller sisFileInstaller;
       
  1032     INFO_PRINTF2(_L("Installing sis file from -> %S"), &KForceRegAppSisFile);
       
  1033     sisFileInstaller.InstallSisL(KForceRegAppSisFile);
       
  1034     sisFileInstaller.UninstallSisAndWaitForAppListUpdateL(KForceRegAppComponent); 
       
  1035 }
       
  1036 
       
  1037 void CT_CaptionStep::ChangeLocaleWaitForApplistUpdate(TLanguage aLanguage)
       
  1038     {
       
  1039     TRequestStatus status;
       
  1040     iLs.SetNotify(EFalse, status);
       
  1041     ChangeLocaleL(aLanguage);
       
  1042     User::WaitForRequest(status);
       
  1043     }
       
  1044 
       
  1045 TVerdict CT_CaptionStep::doTestStepPreambleL()
       
  1046     {
       
  1047     CSisFileInstaller sisFileInstaller;
       
  1048     INFO_PRINTF2(_L("Installing sis file from -> %S"), &KTstAppStandAloneSisFile);
       
  1049     sisFileInstaller.InstallSisAndWaitForAppListUpdateL(KTstAppStandAloneSisFile);
       
  1050     INFO_PRINTF2(_L("Installing sis file from -> %S"), &KTstAppTiconcaptionoverrideSisFile);
       
  1051     sisFileInstaller.InstallSisAndWaitForAppListUpdateL(KTstAppTiconcaptionoverrideSisFile);
       
  1052     SetTestStepResult(EPass);
       
  1053     return TestStepResult();
       
  1054     }
       
  1055 
       
  1056 TVerdict CT_CaptionStep::doTestStepPostambleL()
       
  1057     {
       
  1058     CSisFileInstaller sisFileInstaller;
       
  1059     sisFileInstaller.UninstallSisL(KTstAppStandAloneComponent);
       
  1060     sisFileInstaller.UninstallSisL(KTstAppTiconcaptionoverrideComponent);
       
  1061     return TestStepResult();    
       
  1062     }
       
  1063 
  1014 TVerdict CT_CaptionStep::doTestStepL()
  1064 TVerdict CT_CaptionStep::doTestStepL()
  1015 	{
  1065 	{
  1016 	INFO_PRINTF1(_L("Test T_Caption step started....\n"));
  1066 	INFO_PRINTF1(_L("Test T_Caption step started....\n"));
  1017 
  1067 
  1018 	// Connect to Servers
  1068 	// Connect to Servers
  1019 	TEST(iFs.Connect() == KErrNone);
  1069 	TEST(iFs.Connect() == KErrNone);
  1020 	TEST(iLs.Connect() == KErrNone);
  1070 	TEST(iLs.Connect() == KErrNone);
  1021 
  1071 
       
  1072     // Change the locale
       
  1073     ChangeLocaleL(ELangEnglish);
       
  1074     TEST(User::Language() == ELangEnglish);
       
  1075     ForceApplistUpdate();
       
  1076     
  1022 	// run language tests for the test caption
  1077 	// run language tests for the test caption
  1023 	TRAPD(r, DoLanguageTestL());
  1078 	TRAPD(r, DoLanguageTestL());
  1024 	TEST(r==KErrNone);
  1079 	TEST(r==KErrNone);
  1025 	INFO_PRINTF2(_L("DoLanguageTestL() finished with value '%d'\n"), r);
  1080 	INFO_PRINTF2(_L("DoLanguageTestL() finished with value '%d'\n"), r);
  1026 	
  1081