appfw/apparchitecture/tef/T_CaptionStep.cpp
branchRCL_3
changeset 63 c2c61fdca848
parent 62 924385140d98
--- a/appfw/apparchitecture/tef/T_CaptionStep.cpp	Tue Aug 31 15:24:25 2010 +0300
+++ b/appfw/apparchitecture/tef/T_CaptionStep.cpp	Wed Sep 01 12:24:48 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -57,7 +57,6 @@
 #include "appfwk_test.h"
 #include "ticoncaptionoverride.h" //KUidTestIconCapOverride defined here
 #include "TIconLoaderAndIconArrayForLeaks.h"
-#include "T_SisFileInstaller.h"
 
 
 //
@@ -90,21 +89,11 @@
 // Cenrep configuration details for English language
 _LIT(KCenRepCaption, "CRTstCap UK");
 _LIT(KCenRepShortCaption, "CRTC UK");
-_LIT(KCenRepIconFilename, "C:\\resource\\apps\\ticoncapoverride.mbm");
-
-_LIT(KTstAppStandAloneSisFile, "z:\\apparctest\\apparctestsisfiles\\TSTAPP_standalone.sis");
-_LIT(KTstAppStandAloneComponent, "TSTAPP_standalone");
-
-_LIT(KTstAppTiconcaptionoverrideSisFile, "z:\\apparctest\\apparctestsisfiles\\ticoncaptionoverride.sis");
-_LIT(KTstAppTiconcaptionoverrideComponent, "ticoncaptionoverride");
-
-_LIT(KForceRegAppSisFile, "z:\\apparctest\\apparctestsisfiles\\ForceRegApp1.sis");
-_LIT(KForceRegAppComponent, "ForceRegApp1");    
+_LIT(KCenRepIconFilename, "Z:\\resource\\apps\\ticoncapoverride.mbm");
 
 const TUid KUidIconCaptionRepository = {0x1028583d}; // Central Repository UID.
 const TInt KTextSize = 100;
 
-const TInt KDelay = 4000000;
 //
 //
 //		CT_CaptionStep
@@ -115,61 +104,41 @@
 void CT_CaptionStep::ChangeLocaleL(TLanguage aLanguage)
 	{
 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL 
-    _LIT(KLitLanguageLocaleDllNameBase, "elocl_lan");
-    //Region and collation code values are hard coded, as the check, after changing the locale is made for the language only.
-    _LIT(KLitRegionLocaleDllNameBase, "elocl_reg.826");        
-    _LIT(KLitCollationLocaleDllNameBase, "elocl_col.001");
-    _LIT(ThreeDigExt,".%03d");
-    TExtendedLocale localeDll;    
-    const TUidType uidType(TUid::Uid(0x10000079),TUid::Uid(0x100039e6));
-    TBuf<16> languageLocaleDllName(KLitLanguageLocaleDllNameBase);  
-    languageLocaleDllName.AppendFormat(ThreeDigExt, aLanguage);
-    TBuf<16> regionLocaleDllName(KLitRegionLocaleDllNameBase);  
-    TBuf<16> collationLocaleDllName(KLitCollationLocaleDllNameBase);  
-    // Try to load the locale dll
-    TInt error=localeDll.LoadLocale(languageLocaleDllName, regionLocaleDllName, collationLocaleDllName);
-        
-    if (error==KErrNotFound)
-        {
-        // Locale dll is not found for the asked language. 
-        ERR_PRINTF2(_L("Failed to find the locale dll for %d"), aLanguage);
-        }
-           
-    User::LeaveIfError(error);
-    localeDll.SaveSystemSettings();
+    _LIT(KLitLocaleDllNameBase, "elocl_lan");
+    _LIT(KLitLocaleDllNameExtension, ".loc");
 #else
     _LIT(KLitLocaleDllNameBase, "ELOCL");
-    _LIT(TwoDigExt,".%02d");
-    
-    RLibrary localeDll; 
+    _LIT(KLitLocaleDllNameExtension, ".LOC");
+#endif          
+    RLibrary localeDll;
+    TBuf<16> localeDllName(KLitLocaleDllNameBase);
     CleanupClosePushL(localeDll);
-    
     const TUidType uidType(TUid::Uid(0x10000079),TUid::Uid(0x100039e6));
-    TBuf<16> localeDllName(KLitLocaleDllNameBase);  
-    localeDllName.AppendFormat(TwoDigExt, language);
-    
-    // Try to load the locale dll
+#ifdef SYMBIAN_DISTINCT_LOCALE_MODEL         
+    _LIT(ThreeDigExt,".%03d");
+    localeDllName.AppendFormat(ThreeDigExt, aLanguage);
+#else
+    _LIT(TwoDigExt,".%02d");
+    localeDllName.AppendFormat(TwoDigExt, aLanguage);
+#endif          
+            
     TInt error=localeDll.Load(localeDllName, uidType);
     if (error==KErrNotFound)
         {
-        // Locale dll is not found for the asked language. 
-        ERR_PRINTF2(_L("Failed to find the locale dll for %d"), language);
+        localeDllName=KLitLocaleDllNameBase;
+        localeDllName.Append(KLitLocaleDllNameExtension);
+        error=localeDll.Load(localeDllName, uidType);
         }
-    
     User::LeaveIfError(error);
+            
+#ifdef  SYMBIAN_DISTINCT_LOCALE_MODEL
+    TExtendedLocale myExtendedLocale;
+    User::LeaveIfError(myExtendedLocale.LoadLocaleAspect(localeDllName));
+    User::LeaveIfError(myExtendedLocale.SaveSystemSettings());
+#else   
     User::LeaveIfError(UserSvr::ChangeLocale(localeDllName));
-    CleanupStack: opAndDestroy(); // localeDll
 #endif
-    
-    // Check if the device locale has changed
-    if (aLanguage == User::Language())
-        {
-        SetTestStepResult(EPass);
-        }
-    else
-        {
-        ERR_PRINTF3(_L("Failed to change the locale to %d whereas the current locale is"), aLanguage, User::Language());
-        }	
+    CleanupStack::PopAndDestroy(&localeDll);
 	}
 
 
@@ -213,11 +182,12 @@
 			};
 
 		// Change the locale
-		if(languageToTest != User::Language())
-		    {
-            ChangeLocaleWaitForApplistUpdate(languageToTest);		
-            TEST(User::Language() == languageToTest);
-		    }
+		ChangeLocaleL(languageToTest);
+		TEST(User::Language() == languageToTest);
+		
+		// Force the applist to be updated (so test app gets new language settings)
+		RPointerArray<TDesC> dummy;
+		User::LeaveIfError(iLs.ForceRegistration(dummy));
 		
 		// Do the same set of tests for each language
 		TestCApaSystemControlListL();
@@ -229,9 +199,7 @@
 		}
 
 	// restore original locale, just in case...
-	if(User::Language() != language)
-	    ChangeLocaleWaitForApplistUpdate(language);
-	
+	ChangeLocaleL(language);
 	TEST(User::Language() == language);
 	}	
 
@@ -440,7 +408,7 @@
 	{
 	INFO_PRINTF1(_L("Testing TApaAppInfo streams... "));
 
-	TApaAppInfo appInfoShort(KUidTestApp, _L("c:\\sys\\bin\\tstapp.exe"), _L("TstCap UK"),_L("TC UK"));
+	TApaAppInfo appInfoShort(KUidTestApp, _L("z:\\sys\\bin\\tstapp.exe"), _L("TstCap UK"),_L("TC UK"));
 	TEST(appInfoShort.iShortCaption.Compare(_L("TC UK"))==0);
 
 	TFileName tempFile=_L("c:\\system\\test\\TC_temp.txt");
@@ -502,7 +470,8 @@
 	TEST(User::Language() == ELangEnglish);
 	
 	// Force the applist to be updated (so test app gets new language settings)
-	ForceApplistUpdate();
+	RPointerArray<TDesC> dummy;
+	User::LeaveIfError(iLs.ForceRegistration(dummy));
 
 	// SetAppShortCaption should return KErrNotFound if it could not find the app
 	INFO_PRINTF1(_L(".....setting short caption for an unknown app"));
@@ -540,16 +509,18 @@
 
 	// Check short caption remains updated after a refresh of the applist
 	INFO_PRINTF1(_L(".....checking short caption remains updated after a refresh of the applist"));
-	ForceApplistUpdate();
+	User::LeaveIfError(iLs.ForceRegistration(dummy));
 	iLs.GetAppInfo(appInfo, KUidTestApp);
 	TEST(appInfo.iShortCaption == KShortCaption1);
 
 	// Check short caption remains updated after a locale change
 	INFO_PRINTF1(_L(".....checking short caption remains updated after a locale change"));
-	ChangeLocaleWaitForApplistUpdate(ELangJapanese);
+	ChangeLocaleL(ELangJapanese);
 	TEST(User::Language() == ELangJapanese);	// Japanese locale exists in epoc32 tree but not defined in test app
-    ChangeLocaleWaitForApplistUpdate(ELangEnglish);				// back to English to see what happened in between
+	User::LeaveIfError(iLs.ForceRegistration(dummy));
+	ChangeLocaleL(ELangEnglish);				// back to English to see what happened in between
 	TEST(User::Language() == ELangEnglish);
+	User::LeaveIfError(iLs.ForceRegistration(dummy));
 	iLs.GetAppInfo(appInfo, KUidTestApp);
 	TEST(appInfo.iShortCaption == KShortCaption1);
 
@@ -559,15 +530,17 @@
 	TEST(err == KErrNone);
 	iLs.GetAppInfo(appInfo, KUidTestApp);
 	TEST(appInfo.iShortCaption == KShortCaption1);	// English, the current app language, doesn't change...
-	ChangeLocaleWaitForApplistUpdate(ELangFrench);
+	ChangeLocaleL(ELangFrench);
 	TEST(User::Language() == ELangFrench);
+	User::LeaveIfError(iLs.ForceRegistration(dummy));
 	iLs.GetAppInfo(appInfo, KUidTestApp);
 	TEST(appInfo.iShortCaption == KShortCaption2);	
 	
 	// Set short caption of an app for a language which the app does not include (ELangAmerican)
 	INFO_PRINTF1(_L(".....setting short caption of an app for a language which the app does not include"));
-	ChangeLocaleWaitForApplistUpdate(ELangAmerican);
+	ChangeLocaleL(ELangAmerican);
 	TEST(User::Language() == ELangAmerican);
+	User::LeaveIfError(iLs.ForceRegistration(dummy));
 	err = iLs.SetAppShortCaption(KShortCaption2, ELangAmerican, KUidTestApp);
 	iLs.GetAppInfo(appInfo, KUidTestApp);
 	TEST(appInfo.iShortCaption == KShortCaption1);	// American takes the default...so English...which has just been updated.
@@ -578,31 +551,37 @@
 	TEST(err == KErrNone);
 	iLs.GetAppInfo(appInfo, KUidTestApp);
 	TEST(appInfo.iShortCaption == KShortCaption1);	// American takes the default...so English...which has just been updated.
-	ChangeLocaleWaitForApplistUpdate(ELangEnglish);
+	ChangeLocaleL(ELangEnglish);
 	TEST(User::Language() == ELangEnglish);
+	User::LeaveIfError(iLs.ForceRegistration(dummy));
 	iLs.GetAppInfo(appInfo, KUidTestApp);
 	TEST(appInfo.iShortCaption == KShortCaption1);	// English set individually ===> not updated by ELangNone
-	ChangeLocaleWaitForApplistUpdate(ELangFrench);
+	ChangeLocaleL(ELangFrench);
 	TEST(User::Language() == ELangFrench);
+	User::LeaveIfError(iLs.ForceRegistration(dummy));
 	iLs.GetAppInfo(appInfo, KUidTestApp);
 	TEST(appInfo.iShortCaption == KShortCaption2);	// French set individually ===> not updated by ELangNone
-	ChangeLocaleWaitForApplistUpdate(ELangGerman);
+	ChangeLocaleL(ELangGerman);
 	TEST(User::Language() == ELangGerman);
+	User::LeaveIfError(iLs.ForceRegistration(dummy));
 	iLs.GetAppInfo(appInfo, KUidTestApp);
 	TEST(appInfo.iShortCaption == KShortCaption3);	// German takes the one set by  ELangNone
-	ChangeLocaleWaitForApplistUpdate(ELangItalian);
+	ChangeLocaleL(ELangItalian);
 	TEST(User::Language() == ELangItalian);
+	User::LeaveIfError(iLs.ForceRegistration(dummy));
 	iLs.GetAppInfo(appInfo, KUidTestApp);
 	TEST(appInfo.iShortCaption == KShortCaption3);	// Italian takes the one set by ELangNone
-	ChangeLocaleWaitForApplistUpdate(ELangSpanish);
+	ChangeLocaleL(ELangSpanish);
 	TEST(User::Language() == ELangSpanish);
+	User::LeaveIfError(iLs.ForceRegistration(dummy));
 	iLs.GetAppInfo(appInfo, KUidTestApp);
 	TEST(appInfo.iShortCaption == KShortCaption3);	// Spanish takes the one set by ELangNone
 
 	// Set short caption of an app for a language which was set by the previous ELangNone
 	INFO_PRINTF1(_L(".....setting short caption of an app which was set by the previous ELangNone"));
-	ChangeLocaleWaitForApplistUpdate(ELangItalian);
+	ChangeLocaleL(ELangItalian);
 	TEST(User::Language() == ELangItalian);
+	User::LeaveIfError(iLs.ForceRegistration(dummy));
 	err = iLs.SetAppShortCaption(KShortCaption4, ELangItalian, KUidTestApp);
 	iLs.GetAppInfo(appInfo, KUidTestApp);
 	TEST(appInfo.iShortCaption == KShortCaption4);
@@ -613,30 +592,35 @@
 	TEST(err == KErrNone);
 	iLs.GetAppInfo(appInfo, KUidTestApp);
 	TEST(appInfo.iShortCaption == KShortCaption4);	// Italian set individually ===> not updated by ELangNone
-	ChangeLocaleWaitForApplistUpdate(ELangEnglish);
+	ChangeLocaleL(ELangEnglish);
 	TEST(User::Language() == ELangEnglish);
+	User::LeaveIfError(iLs.ForceRegistration(dummy));
 	iLs.GetAppInfo(appInfo, KUidTestApp);
 	TEST(appInfo.iShortCaption == KShortCaption1);	// English set individually ===> not updated by ELangNone
-	ChangeLocaleWaitForApplistUpdate(ELangFrench);
+	ChangeLocaleL(ELangFrench);
 	TEST(User::Language() == ELangFrench);
+	User::LeaveIfError(iLs.ForceRegistration(dummy));
 	iLs.GetAppInfo(appInfo, KUidTestApp);
 	TEST(appInfo.iShortCaption == KShortCaption2);	// French set individually ===> not updated by ELangNone
-	ChangeLocaleWaitForApplistUpdate(ELangGerman);
+	ChangeLocaleL(ELangGerman);
 	TEST(User::Language() == ELangGerman);
+	User::LeaveIfError(iLs.ForceRegistration(dummy));
 	iLs.GetAppInfo(appInfo, KUidTestApp);
 	TEST(appInfo.iShortCaption == KShortCaption5);	// German takes the one set by  ELangNone
-	ChangeLocaleWaitForApplistUpdate(ELangSpanish);
+	ChangeLocaleL(ELangSpanish);
 	TEST(User::Language() == ELangSpanish);
+	User::LeaveIfError(iLs.ForceRegistration(dummy));
 	iLs.GetAppInfo(appInfo, KUidTestApp);
 	TEST(appInfo.iShortCaption == KShortCaption5);	// Spanish takes the one set by ELangNone
-	ChangeLocaleWaitForApplistUpdate(ELangAmerican);
+	ChangeLocaleL(ELangAmerican);
 	TEST(User::Language() == ELangAmerican);
+	User::LeaveIfError(iLs.ForceRegistration(dummy));
 	iLs.GetAppInfo(appInfo, KUidTestApp);
 	TEST(appInfo.iShortCaption == KShortCaption1);	// American takes the default...so English...which has just been updated.
 
 	// restore original settings....
 	INFO_PRINTF1(_L(".....restoring original settings"));
-	ChangeLocaleWaitForApplistUpdate(language);
+	ChangeLocaleL(language);
 	TEST(User::Language() == language);
 	// restore original short captions for all langs....(h4 doesn't perform reboots between tests)
 	TEST(iLs.SetAppShortCaption(KTestTApaAppInfoShortCaptionEnglish, ELangEnglish, KUidTestApp) == KErrNone);
@@ -678,11 +662,9 @@
 	{
 	INFO_PRINTF1(_L("APPFWK-APPARC-0087:TestIconCaptionOverridesL started..."));
 	
-    //Change the system language to English before starting the tests
-    TRAPD(ret,ChangeLocaleL(ELangEnglish));
-    TEST(ret == KErrNone);
-    TEST(User::Language() == ELangEnglish);
-    ForceApplistUpdate();
+	//Change the system language to English before starting the tests
+	TRAPD(ret,ChangeLocaleL(ELangEnglish));
+	TEST(ret == KErrNone);
 				
 	TApaAppInfo appInfo;
 	//Get test app's information
@@ -796,8 +778,10 @@
 	//tests whether the process with WriteDeviceData capability can update the configuration settings.
 	TEST(error == KErrNone);
 	
-	ForceApplistUpdate();
-    
+	// Force the applist to be updated (so test app gets new language settings)
+	RPointerArray<TDesC> dummy;
+	User::LeaveIfError(iLs.ForceRegistration(dummy));
+	
 	TApaAppInfo appInfo;
 	//Get test app's information
 	iLs.GetAppInfo(appInfo, KUidTestIconCapOverride);
@@ -813,8 +797,8 @@
 	//sets the short caption back to the actual for other tests to work
 	error = cenRep->Set(shortCapKey,KCenRepShortCaption);
 	
-    // Force the applist to be updated (so test app gets new language settings)
-    ForceApplistUpdate();
+	// Force the applist to be updated (so test app gets new language settings)
+	User::LeaveIfError(iLs.ForceRegistration(dummy));
 	
 	CleanupStack::PopAndDestroy(cenRep); //cenRep object
 	INFO_PRINTF1(_L("APPFWK-APPARC-0089:TestCenRepChangeNotificationL finished..."));
@@ -852,12 +836,12 @@
 	//French
 	_LIT(KCaptionFrench, "CRTstCap FR");
 	_LIT(KShortCaptionFrench, "CRTC FR");
-	_LIT(KIconFilenameFrench, "C:\\resource\\apps\\svg_icon.svg");
+	_LIT(KIconFilenameFrench, "Z:\\resource\\apps\\svg_icon.svg");
 
 	//German
 	_LIT(KCaptionGerman, "TstCap GE");
 	_LIT(KShortCaptionGerman, "TC GE");
-	_LIT(KIconFilenameGerman, "C:\\resource\\apps\\ticoncapoverride.mbm");
+	_LIT(KIconFilenameGerman, "Z:\\resource\\apps\\ticoncapoverride.mbm");
 
 	TApaAppInfo appInfo;
 	RFile file;
@@ -871,7 +855,9 @@
 	
 	TEST(User::Language() == ELangFrench);//check language is set to French.
 	
-    ForceApplistUpdate();
+	// Force the applist to be updated (so test app gets new language settings)
+	RPointerArray<TDesC> dummy;
+	User::LeaveIfError(iLs.ForceRegistration(dummy));
 	
 	//Get test app's information
 	iLs.GetAppInfo(appInfo, KUidTestIconCapOverride);
@@ -910,7 +896,7 @@
 	TEST(User::Language() == ELangGerman);//check language is set to German.
 	
 	// Force the applist to be updated (so test app gets new language settings)
-	ForceApplistUpdate();
+	User::LeaveIfError(iLs.ForceRegistration(dummy));
 	
 	//Get test app's information
 	iLs.GetAppInfo(appInfo, KUidTestIconCapOverride);
@@ -954,7 +940,7 @@
 	TEST(User::Language() == ELangEnglish);//check language is set to English.
 	
 	// Force the applist to be updated (so test app gets new language settings)
-	ForceApplistUpdate();
+	User::LeaveIfError(iLs.ForceRegistration(dummy));
 	
 	//Get test app's information
 	iLs.GetAppInfo(appInfo, KUidTestIconCapOverride);
@@ -987,7 +973,7 @@
 	INFO_PRINTF2(_L("----Expected icon filename==>%S"), &printString);
 	INFO_PRINTF2(_L("----Retrieved icon filename==>%S"), &fileName);
 	TEST(fileName.Compare(KCenRepIconFilename)==0);
-	file.Close();
+	
 	INFO_PRINTF1(_L("APPFWK-APPARC-0090:TestIconCaptionOverridesWithChangeLangL finished..."));
 	}
 		
@@ -1025,42 +1011,6 @@
 	TestApiPrecedenceOverCenRepConfigInfoL();
 	}
 	
-void CT_CaptionStep::ForceApplistUpdate()
-{
-    // Force the applist to be updated (so test app gets new language settings)
-    CSisFileInstaller sisFileInstaller;
-    INFO_PRINTF2(_L("Installing sis file from -> %S"), &KForceRegAppSisFile);
-    sisFileInstaller.InstallSisL(KForceRegAppSisFile);
-    sisFileInstaller.UninstallSisAndWaitForAppListUpdateL(KForceRegAppComponent); 
-}
-
-void CT_CaptionStep::ChangeLocaleWaitForApplistUpdate(TLanguage aLanguage)
-    {
-    TRequestStatus status;
-    iLs.SetNotify(EFalse, status);
-    ChangeLocaleL(aLanguage);
-    User::WaitForRequest(status);
-    }
-
-TVerdict CT_CaptionStep::doTestStepPreambleL()
-    {
-    CSisFileInstaller sisFileInstaller;
-    INFO_PRINTF2(_L("Installing sis file from -> %S"), &KTstAppStandAloneSisFile);
-    sisFileInstaller.InstallSisAndWaitForAppListUpdateL(KTstAppStandAloneSisFile);
-    INFO_PRINTF2(_L("Installing sis file from -> %S"), &KTstAppTiconcaptionoverrideSisFile);
-    sisFileInstaller.InstallSisAndWaitForAppListUpdateL(KTstAppTiconcaptionoverrideSisFile);
-    SetTestStepResult(EPass);
-    return TestStepResult();
-    }
-
-TVerdict CT_CaptionStep::doTestStepPostambleL()
-    {
-    CSisFileInstaller sisFileInstaller;
-    sisFileInstaller.UninstallSisL(KTstAppStandAloneComponent);
-    sisFileInstaller.UninstallSisL(KTstAppTiconcaptionoverrideComponent);
-    return TestStepResult();    
-    }
-
 TVerdict CT_CaptionStep::doTestStepL()
 	{
 	INFO_PRINTF1(_L("Test T_Caption step started....\n"));
@@ -1069,11 +1019,6 @@
 	TEST(iFs.Connect() == KErrNone);
 	TEST(iLs.Connect() == KErrNone);
 
-    // Change the locale
-    ChangeLocaleL(ELangEnglish);
-    TEST(User::Language() == ELangEnglish);
-    ForceApplistUpdate();
-    
 	// run language tests for the test caption
 	TRAPD(r, DoLanguageTestL());
 	TEST(r==KErrNone);