sl@0
|
1 |
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// This file contains RTest based test which checks behaviour of InitialiseLocale.exe
|
sl@0
|
15 |
// when persisted locale is corrrupt/damaged
|
sl@0
|
16 |
//
|
sl@0
|
17 |
//
|
sl@0
|
18 |
|
sl@0
|
19 |
#include <bautils.h>
|
sl@0
|
20 |
#include <f32file.h>
|
sl@0
|
21 |
#include <e32cmn.h>
|
sl@0
|
22 |
#include <e32test.h>
|
sl@0
|
23 |
#include <e32std.h>
|
sl@0
|
24 |
#include <e32const.h>
|
sl@0
|
25 |
#include <babackup.h>
|
sl@0
|
26 |
#include <hal.h>
|
sl@0
|
27 |
#include <centralrepository.h>
|
sl@0
|
28 |
#include "LocaleRepository.h"
|
sl@0
|
29 |
#include "InitialiseLocale.h"
|
sl@0
|
30 |
#include "T_CheckLocale.h"
|
sl@0
|
31 |
|
sl@0
|
32 |
|
sl@0
|
33 |
// Name of the exe to be called explicitly
|
sl@0
|
34 |
_LIT(KInitPersistLocaleExeName, "InitialiseLocale.exe");
|
sl@0
|
35 |
|
sl@0
|
36 |
LOCAL_D RTest test(_L("T_RebootLocaleNewLocaleModel"));
|
sl@0
|
37 |
|
sl@0
|
38 |
|
sl@0
|
39 |
// Central Repository Data cage file-path
|
sl@0
|
40 |
_LIT(KPersistLocale, "C:\\private\\10202be9\\persists\\1020E4D3.*");
|
sl@0
|
41 |
|
sl@0
|
42 |
RFs TheFs;
|
sl@0
|
43 |
|
sl@0
|
44 |
/*
|
sl@0
|
45 |
This function prepares for next test i.e, tests InitialiseLocale behaves
|
sl@0
|
46 |
when persisted file is damaged/corrupt.
|
sl@0
|
47 |
*/
|
sl@0
|
48 |
void SetUpTestCorruptLocale()
|
sl@0
|
49 |
{
|
sl@0
|
50 |
TExtendedLocale myExtendedLocale;
|
sl@0
|
51 |
myExtendedLocale.LoadSystemSettings() ;
|
sl@0
|
52 |
|
sl@0
|
53 |
test.Printf(_L("\n Changing Locale to Chinese Locale(31) so that default values are evident"));
|
sl@0
|
54 |
|
sl@0
|
55 |
// Change the locale to Default Locale, all settings from single Dll
|
sl@0
|
56 |
myExtendedLocale.LoadLocale(KCNLanguage(), KCNRegion(), KCNCollation());
|
sl@0
|
57 |
|
sl@0
|
58 |
// Save the changes to system settings
|
sl@0
|
59 |
myExtendedLocale.SaveSystemSettings();
|
sl@0
|
60 |
|
sl@0
|
61 |
// Wait so that it persists to repository
|
sl@0
|
62 |
User::After(1000000);
|
sl@0
|
63 |
|
sl@0
|
64 |
User::LeaveIfError(TheFs.Connect());
|
sl@0
|
65 |
// Delete/damage the persisted file so that InitialiseLocale.exe
|
sl@0
|
66 |
// detects the damage and loads default locale
|
sl@0
|
67 |
BaflUtils::DeleteFile(TheFs, KPersistLocale);
|
sl@0
|
68 |
TheFs.Close();
|
sl@0
|
69 |
test.Printf(_L("\n Deleted persist file from C: \n"));
|
sl@0
|
70 |
}
|
sl@0
|
71 |
/**
|
sl@0
|
72 |
@SYMTestCaseID SYSLIB-BAFL-CIT-0142
|
sl@0
|
73 |
@SYMTestCaseDesc Check that InitialiseLocale can get the correct locale information after reboot in the new locale model.
|
sl@0
|
74 |
@SYMTestPriority High
|
sl@0
|
75 |
@SYMTestActions Ensure that InitialiseLocale can get the correct locale information after reboot in the new locale model.
|
sl@0
|
76 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
77 |
@SYMREQ PREQ1924
|
sl@0
|
78 |
*/
|
sl@0
|
79 |
LOCAL_D void TestRebootLocale()
|
sl@0
|
80 |
{
|
sl@0
|
81 |
test.Start(_L(" @SYMTestCaseID:TI18N-INITLOCALE-CT-4006 after rebooting check the locale content"));
|
sl@0
|
82 |
TestLocaleDLLName(test, KCNLanguage(), KCNRegion(), KCNCollation());
|
sl@0
|
83 |
TestLocaleContent(test, KCNLanguageID, KCNCurrencySymbol, KCNTCollationMethodID);
|
sl@0
|
84 |
test.End();
|
sl@0
|
85 |
|
sl@0
|
86 |
}
|
sl@0
|
87 |
|
sl@0
|
88 |
|
sl@0
|
89 |
/** Tests behavior of Initialisation mechanism after system reboots
|
sl@0
|
90 |
This test requires that,
|
sl@0
|
91 |
1. The T_LocaleFlexiNewLocaleModel is executed
|
sl@0
|
92 |
2. Epoc be shut down
|
sl@0
|
93 |
3. Epoc restarted (so that InitialisationLocale.exe is called)
|
sl@0
|
94 |
4. Then this test be run
|
sl@0
|
95 |
*/
|
sl@0
|
96 |
void TestRebootLocaleBehavior()
|
sl@0
|
97 |
{
|
sl@0
|
98 |
RProcess process;
|
sl@0
|
99 |
// Kick-in InitialiseLocale.exe once again explicitly, This will be
|
sl@0
|
100 |
// done as part of system start in actual release code.
|
sl@0
|
101 |
TInt r = process.Create(KInitPersistLocaleExeName, KNullDesC);
|
sl@0
|
102 |
if(r == KErrNone)
|
sl@0
|
103 |
{
|
sl@0
|
104 |
process.Resume(); // Start the process going
|
sl@0
|
105 |
User::After(1000000);
|
sl@0
|
106 |
|
sl@0
|
107 |
TestRebootLocale();
|
sl@0
|
108 |
|
sl@0
|
109 |
User::After(1000000);
|
sl@0
|
110 |
process.Close();
|
sl@0
|
111 |
User::After(1000000);
|
sl@0
|
112 |
}
|
sl@0
|
113 |
}
|
sl@0
|
114 |
|
sl@0
|
115 |
|
sl@0
|
116 |
TInt E32Main()
|
sl@0
|
117 |
{
|
sl@0
|
118 |
CTrapCleanup* cleanup = CTrapCleanup::New();
|
sl@0
|
119 |
test(cleanup != NULL);
|
sl@0
|
120 |
|
sl@0
|
121 |
__UHEAP_MARK;
|
sl@0
|
122 |
test.Start(_L("Test to test reboot system"));
|
sl@0
|
123 |
test.Title();
|
sl@0
|
124 |
|
sl@0
|
125 |
TRAPD(err, ::TestRebootLocaleBehavior());
|
sl@0
|
126 |
|
sl@0
|
127 |
test(err == KErrNone);
|
sl@0
|
128 |
|
sl@0
|
129 |
TRAPD(err1, ::SetUpTestCorruptLocale());
|
sl@0
|
130 |
test(err1 == KErrNone);
|
sl@0
|
131 |
|
sl@0
|
132 |
test.End();
|
sl@0
|
133 |
test.Close();
|
sl@0
|
134 |
|
sl@0
|
135 |
__UHEAP_MARKEND;
|
sl@0
|
136 |
delete cleanup;
|
sl@0
|
137 |
|
sl@0
|
138 |
return(KErrNone);
|
sl@0
|
139 |
}
|