1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/lowlevellibsandfws/apputils/initLocale/test/T_RebootNewLocaleModel.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,139 @@
1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// This file contains RTest based test which checks behaviour of InitialiseLocale.exe
1.18 +// when persisted locale is corrrupt/damaged
1.19 +//
1.20 +//
1.21 +
1.22 +#include <bautils.h>
1.23 +#include <f32file.h>
1.24 +#include <e32cmn.h>
1.25 +#include <e32test.h>
1.26 +#include <e32std.h>
1.27 +#include <e32const.h>
1.28 +#include <babackup.h>
1.29 +#include <hal.h>
1.30 +#include <centralrepository.h>
1.31 +#include "LocaleRepository.h"
1.32 +#include "InitialiseLocale.h"
1.33 +#include "T_CheckLocale.h"
1.34 +
1.35 +
1.36 +// Name of the exe to be called explicitly
1.37 +_LIT(KInitPersistLocaleExeName, "InitialiseLocale.exe");
1.38 +
1.39 +LOCAL_D RTest test(_L("T_RebootLocaleNewLocaleModel"));
1.40 +
1.41 +
1.42 +// Central Repository Data cage file-path
1.43 +_LIT(KPersistLocale, "C:\\private\\10202be9\\persists\\1020E4D3.*");
1.44 +
1.45 +RFs TheFs;
1.46 +
1.47 +/*
1.48 +This function prepares for next test i.e, tests InitialiseLocale behaves
1.49 +when persisted file is damaged/corrupt.
1.50 +*/
1.51 +void SetUpTestCorruptLocale()
1.52 + {
1.53 + TExtendedLocale myExtendedLocale;
1.54 + myExtendedLocale.LoadSystemSettings() ;
1.55 +
1.56 + test.Printf(_L("\n Changing Locale to Chinese Locale(31) so that default values are evident"));
1.57 +
1.58 + // Change the locale to Default Locale, all settings from single Dll
1.59 + myExtendedLocale.LoadLocale(KCNLanguage(), KCNRegion(), KCNCollation());
1.60 +
1.61 + // Save the changes to system settings
1.62 + myExtendedLocale.SaveSystemSettings();
1.63 +
1.64 + // Wait so that it persists to repository
1.65 + User::After(1000000);
1.66 +
1.67 + User::LeaveIfError(TheFs.Connect());
1.68 + // Delete/damage the persisted file so that InitialiseLocale.exe
1.69 + // detects the damage and loads default locale
1.70 + BaflUtils::DeleteFile(TheFs, KPersistLocale);
1.71 + TheFs.Close();
1.72 + test.Printf(_L("\n Deleted persist file from C: \n"));
1.73 + }
1.74 +/**
1.75 +@SYMTestCaseID SYSLIB-BAFL-CIT-0142
1.76 +@SYMTestCaseDesc Check that InitialiseLocale can get the correct locale information after reboot in the new locale model.
1.77 +@SYMTestPriority High
1.78 +@SYMTestActions Ensure that InitialiseLocale can get the correct locale information after reboot in the new locale model.
1.79 +@SYMTestExpectedResults The test must not fail.
1.80 +@SYMREQ PREQ1924
1.81 +*/
1.82 +LOCAL_D void TestRebootLocale()
1.83 + {
1.84 + test.Start(_L(" @SYMTestCaseID:TI18N-INITLOCALE-CT-4006 after rebooting check the locale content"));
1.85 + TestLocaleDLLName(test, KCNLanguage(), KCNRegion(), KCNCollation());
1.86 + TestLocaleContent(test, KCNLanguageID, KCNCurrencySymbol, KCNTCollationMethodID);
1.87 + test.End();
1.88 +
1.89 + }
1.90 +
1.91 +
1.92 +/** Tests behavior of Initialisation mechanism after system reboots
1.93 +This test requires that,
1.94 +1. The T_LocaleFlexiNewLocaleModel is executed
1.95 +2. Epoc be shut down
1.96 +3. Epoc restarted (so that InitialisationLocale.exe is called)
1.97 +4. Then this test be run
1.98 +*/
1.99 +void TestRebootLocaleBehavior()
1.100 + {
1.101 + RProcess process;
1.102 + // Kick-in InitialiseLocale.exe once again explicitly, This will be
1.103 + // done as part of system start in actual release code.
1.104 + TInt r = process.Create(KInitPersistLocaleExeName, KNullDesC);
1.105 + if(r == KErrNone)
1.106 + {
1.107 + process.Resume(); // Start the process going
1.108 + User::After(1000000);
1.109 +
1.110 + TestRebootLocale();
1.111 +
1.112 + User::After(1000000);
1.113 + process.Close();
1.114 + User::After(1000000);
1.115 + }
1.116 + }
1.117 +
1.118 +
1.119 +TInt E32Main()
1.120 + {
1.121 + CTrapCleanup* cleanup = CTrapCleanup::New();
1.122 + test(cleanup != NULL);
1.123 +
1.124 + __UHEAP_MARK;
1.125 + test.Start(_L("Test to test reboot system"));
1.126 + test.Title();
1.127 +
1.128 + TRAPD(err, ::TestRebootLocaleBehavior());
1.129 +
1.130 + test(err == KErrNone);
1.131 +
1.132 + TRAPD(err1, ::SetUpTestCorruptLocale());
1.133 + test(err1 == KErrNone);
1.134 +
1.135 + test.End();
1.136 + test.Close();
1.137 +
1.138 + __UHEAP_MARKEND;
1.139 + delete cleanup;
1.140 +
1.141 + return(KErrNone);
1.142 + }