sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // This file contains RTest based test which checks behaviour of InitialiseLocale.exe sl@0: // when persisted locale is corrrupt/damaged sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "LocaleRepository.h" sl@0: #include "InitialiseLocale.h" sl@0: #include "T_CheckLocale.h" sl@0: sl@0: sl@0: // Name of the exe to be called explicitly sl@0: _LIT(KInitPersistLocaleExeName, "InitialiseLocale.exe"); sl@0: sl@0: LOCAL_D RTest test(_L("T_RebootLocaleNewLocaleModel")); sl@0: sl@0: sl@0: // Central Repository Data cage file-path sl@0: _LIT(KPersistLocale, "C:\\private\\10202be9\\persists\\1020E4D3.*"); sl@0: sl@0: RFs TheFs; sl@0: sl@0: /* sl@0: This function prepares for next test i.e, tests InitialiseLocale behaves sl@0: when persisted file is damaged/corrupt. sl@0: */ sl@0: void SetUpTestCorruptLocale() sl@0: { sl@0: TExtendedLocale myExtendedLocale; sl@0: myExtendedLocale.LoadSystemSettings() ; sl@0: sl@0: test.Printf(_L("\n Changing Locale to Chinese Locale(31) so that default values are evident")); sl@0: sl@0: // Change the locale to Default Locale, all settings from single Dll sl@0: myExtendedLocale.LoadLocale(KCNLanguage(), KCNRegion(), KCNCollation()); sl@0: sl@0: // Save the changes to system settings sl@0: myExtendedLocale.SaveSystemSettings(); sl@0: sl@0: // Wait so that it persists to repository sl@0: User::After(1000000); sl@0: sl@0: User::LeaveIfError(TheFs.Connect()); sl@0: // Delete/damage the persisted file so that InitialiseLocale.exe sl@0: // detects the damage and loads default locale sl@0: BaflUtils::DeleteFile(TheFs, KPersistLocale); sl@0: TheFs.Close(); sl@0: test.Printf(_L("\n Deleted persist file from C: \n")); sl@0: } sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CIT-0142 sl@0: @SYMTestCaseDesc Check that InitialiseLocale can get the correct locale information after reboot in the new locale model. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Ensure that InitialiseLocale can get the correct locale information after reboot in the new locale model. sl@0: @SYMTestExpectedResults The test must not fail. sl@0: @SYMREQ PREQ1924 sl@0: */ sl@0: LOCAL_D void TestRebootLocale() sl@0: { sl@0: test.Start(_L(" @SYMTestCaseID:TI18N-INITLOCALE-CT-4006 after rebooting check the locale content")); sl@0: TestLocaleDLLName(test, KCNLanguage(), KCNRegion(), KCNCollation()); sl@0: TestLocaleContent(test, KCNLanguageID, KCNCurrencySymbol, KCNTCollationMethodID); sl@0: test.End(); sl@0: sl@0: } sl@0: sl@0: sl@0: /** Tests behavior of Initialisation mechanism after system reboots sl@0: This test requires that, sl@0: 1. The T_LocaleFlexiNewLocaleModel is executed sl@0: 2. Epoc be shut down sl@0: 3. Epoc restarted (so that InitialisationLocale.exe is called) sl@0: 4. Then this test be run sl@0: */ sl@0: void TestRebootLocaleBehavior() sl@0: { sl@0: RProcess process; sl@0: // Kick-in InitialiseLocale.exe once again explicitly, This will be sl@0: // done as part of system start in actual release code. sl@0: TInt r = process.Create(KInitPersistLocaleExeName, KNullDesC); sl@0: if(r == KErrNone) sl@0: { sl@0: process.Resume(); // Start the process going sl@0: User::After(1000000); sl@0: sl@0: TestRebootLocale(); sl@0: sl@0: User::After(1000000); sl@0: process.Close(); sl@0: User::After(1000000); sl@0: } sl@0: } sl@0: sl@0: sl@0: TInt E32Main() sl@0: { sl@0: CTrapCleanup* cleanup = CTrapCleanup::New(); sl@0: test(cleanup != NULL); sl@0: sl@0: __UHEAP_MARK; sl@0: test.Start(_L("Test to test reboot system")); sl@0: test.Title(); sl@0: sl@0: TRAPD(err, ::TestRebootLocaleBehavior()); sl@0: sl@0: test(err == KErrNone); sl@0: sl@0: TRAPD(err1, ::SetUpTestCorruptLocale()); sl@0: test(err1 == KErrNone); sl@0: sl@0: test.End(); sl@0: test.Close(); sl@0: sl@0: __UHEAP_MARKEND; sl@0: delete cleanup; sl@0: sl@0: return(KErrNone); sl@0: }