55
|
1 |
// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
|
|
16 |
#include <e32test.h>
|
|
17 |
#include <f32file.h>
|
|
18 |
#include <badesca.h>
|
|
19 |
|
|
20 |
#include "srvrepos_noc.h"
|
|
21 |
#include "srvres.h"
|
|
22 |
#include "cachemgr.h"
|
|
23 |
#include "sessnotf.h"
|
|
24 |
#include "t_cenrep_helper.h"
|
|
25 |
|
|
26 |
RTest TheTest(_L("t_cenrep_pma_fota.exe"));
|
|
27 |
_LIT(KCachedVersionFile,"C:\\private\\10202be9\\romversion\\romversion_info.txt");
|
|
28 |
_LIT(KModifiedSwVersion, "z:\\private\\10202be9\\sw_modified.txt");
|
|
29 |
_LIT(KPMADriveCre,"C:\\private\\10202be9\\persists\\protected\\f1000602.cre");
|
|
30 |
|
|
31 |
const TUid KUidRepository = { 0xf1000601 };
|
|
32 |
|
|
33 |
const TUint32 KModifiedIntKey = 1;
|
|
34 |
const TUint32 KModifiedRealKey = 2;
|
|
35 |
const TUint32 KModifiedStringKey = 3;
|
|
36 |
const TUint32 KDeletedIntKey = 4;
|
|
37 |
const TUint32 KNewIntKey = 5;
|
|
38 |
|
|
39 |
const TInt KModifiedIntValue = 123;
|
|
40 |
const TReal KModifiedRealValue = 20.23;
|
|
41 |
_LIT(KModifiedStringValue, "modified string");
|
|
42 |
|
|
43 |
///////////////////////////////////////////////////////////////////////////////////////
|
|
44 |
///////////////////////////////////////////////////////////////////////////////////////
|
|
45 |
//Test macros and functions
|
|
46 |
LOCAL_C void Check(TInt aValue, TInt aLine)
|
|
47 |
{
|
|
48 |
if (!aValue)
|
|
49 |
{
|
|
50 |
TRAPD(err, CleanupCDriveL());
|
|
51 |
if (err != KErrNone)
|
|
52 |
{
|
|
53 |
RDebug::Print(_L( "*** CleanupCDriveL also failed with error %d expecting KErrNone\r\n"),err);
|
|
54 |
}
|
|
55 |
TheTest(EFalse, aLine);
|
|
56 |
}
|
|
57 |
}
|
|
58 |
|
|
59 |
LOCAL_C void Check(TInt aValue, TInt aExpected, TInt aLine)
|
|
60 |
{
|
|
61 |
if (aValue != aExpected)
|
|
62 |
{
|
|
63 |
RDebug::Print(_L( "*** Expected error: %d, got: %d\r\n"), aExpected,aValue);
|
|
64 |
TRAPD(err, CleanupCDriveL());
|
|
65 |
if (err != KErrNone)
|
|
66 |
{
|
|
67 |
RDebug::Print(_L( "*** CleanupCDriveL also failed with error %d expecting KErrNone\r\n"),err);
|
|
68 |
}
|
|
69 |
TheTest(EFalse, aLine);
|
|
70 |
}
|
|
71 |
}
|
|
72 |
|
|
73 |
#define TEST(arg) ::Check((arg), __LINE__)
|
|
74 |
#define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
|
|
75 |
|
|
76 |
LOCAL_C void CopyTestFilesL()
|
|
77 |
{
|
|
78 |
_LIT( KPMAInstallRepSource, "z:\\private\\10202BE9\\f10006*.txi" );
|
|
79 |
_LIT( KPMAInstallRepTarget, "c:\\private\\10202BE9\\*.txt" );
|
|
80 |
_LIT( KPMAModifiedRepSource, "z:\\private\\10202BE9\\f10006*.pma" );
|
|
81 |
_LIT( KPMAModifiedRepTarget, "c:\\private\\10202BE9\\persists\\protected\\*.cre" );
|
|
82 |
|
|
83 |
RFs rfs;
|
|
84 |
User::LeaveIfError(rfs.Connect());
|
|
85 |
CleanupClosePushL(rfs);
|
|
86 |
CFileMan* fm = CFileMan::NewL(rfs);
|
|
87 |
CleanupStack::PushL(fm);
|
|
88 |
|
|
89 |
CopyTestFilesL(*fm, KPMAInstallRepSource, KPMAInstallRepTarget);
|
|
90 |
CopyTestFilesL(*fm, KPMAModifiedRepSource, KPMAModifiedRepTarget);
|
|
91 |
|
|
92 |
CleanupStack::PopAndDestroy(2, &rfs);
|
|
93 |
}
|
|
94 |
|
|
95 |
///////////////////////////////////////////////////////////////////////////////////////
|
|
96 |
///////////////////////////////////////////////////////////////////////////////////////
|
|
97 |
static void CloseTServerResources(TAny*)
|
|
98 |
{
|
|
99 |
TServerResources::Close();
|
|
100 |
}
|
|
101 |
|
|
102 |
LOCAL_C void CleanUp()
|
|
103 |
{
|
|
104 |
// If cache manager is initialized and used before, we flush it
|
|
105 |
if (TServerResources::iCacheManager)
|
|
106 |
{
|
|
107 |
TServerResources::iCacheManager->FlushCache();
|
|
108 |
}
|
|
109 |
TServerResources::iObserver->CloseiOpenRepositories();
|
|
110 |
TServerResources::iObserver->Reset();
|
|
111 |
TServerResources::iOwnerIdLookUpTable.Reset();
|
|
112 |
User::After(KGeneralDelay);
|
|
113 |
}
|
|
114 |
|
|
115 |
LOCAL_C void VerifyPMAUnchangedByFOTAL()
|
|
116 |
{
|
|
117 |
//Check the merge content for correctness.
|
|
118 |
CSessionNotifier* notifier = new (ELeave) CSessionNotifier;
|
|
119 |
CleanupStack::PushL(notifier);
|
|
120 |
|
|
121 |
CServerRepository* repository = new (ELeave) CServerRepository();
|
|
122 |
CleanupStack::PushL(repository);
|
|
123 |
|
|
124 |
repository->OpenL(KUidRepository, *notifier);
|
|
125 |
|
|
126 |
//Get the user added setting, it should still be there.
|
|
127 |
TInt intValue = 0;
|
|
128 |
TInt r = repository->Get(KNewIntKey, intValue);
|
|
129 |
TEST(r == KErrNone);
|
|
130 |
//Get the user deleted setting, it should still be missing.
|
|
131 |
r = repository->Get(KDeletedIntKey, intValue);
|
|
132 |
TEST(r == KErrNotFound);
|
|
133 |
|
|
134 |
//Get user modified settings. It should still contain the user modification
|
|
135 |
r = repository->Get(KModifiedIntKey, intValue);
|
|
136 |
TEST(r == KErrNone);
|
|
137 |
TEST(intValue == KModifiedIntValue);
|
|
138 |
|
|
139 |
TReal realValue = 0.0;
|
|
140 |
r = repository->Get(KModifiedRealKey, realValue);
|
|
141 |
TEST(r == KErrNone);
|
|
142 |
TEST(realValue == KModifiedRealValue);
|
|
143 |
|
|
144 |
TBuf8<50> stringValue;
|
|
145 |
r = repository->Get(KModifiedStringKey, stringValue);
|
|
146 |
TEST(r == KErrNone);
|
|
147 |
TPtr16 str16((TUint16*) stringValue.Ptr(), stringValue.Length() / 2,stringValue.Length() / 2);
|
|
148 |
TEST(str16.Compare(KModifiedStringValue) == 0);
|
|
149 |
|
|
150 |
repository->Close();
|
|
151 |
CleanupStack::PopAndDestroy(2);//repository, notifier
|
|
152 |
}
|
|
153 |
|
|
154 |
/**
|
|
155 |
@SYMTestCaseID PDS-CENTRALREPOSITORY-CT-4122
|
|
156 |
@SYMTestCaseDesc FOTx update test on PMA keyspaces
|
|
157 |
@SYMTestPriority High
|
|
158 |
@SYMTestActions Copy a PMA cre file to PMA drive that contains different value from the ROM keyspace.
|
|
159 |
Call CheckROMReflashL to simulate a reboot of cenrep.
|
|
160 |
Check that all the setting in the PMA cre file is not modified at all to the ROM value.
|
|
161 |
@SYMTestExpectedResults After calling CheckROMReflashL setting values in the PMA drive's cre file should not changed
|
|
162 |
@SYMREQ REQ42876
|
|
163 |
*/
|
|
164 |
LOCAL_C void PMARepFOTxL()
|
|
165 |
{
|
|
166 |
TheTest.Next(_L( " @SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4122 PMA FOTx update test" ));//Force a rom update for this repository.
|
|
167 |
|
|
168 |
TServerResources::InitialiseL();
|
|
169 |
CleanupStack::PushL(TCleanupItem(CloseTServerResources, 0));
|
|
170 |
|
|
171 |
CFileMan* fm = CFileMan::NewL(TServerResources::iFs);
|
|
172 |
CleanupStack::PushL(fm);
|
|
173 |
|
|
174 |
//Initial cleanup
|
|
175 |
//Copy of modified stored rom version info
|
|
176 |
User::LeaveIfError(fm->Copy(KModifiedSwVersion, KCachedVersionFile,CFileMan::EOverWrite));
|
|
177 |
User::LeaveIfError(fm->Attribs(KCachedVersionFile, 0, KEntryAttReadOnly,TTime(0)));
|
|
178 |
CleanupStack::PopAndDestroy();//fm
|
|
179 |
|
|
180 |
User::After(KGeneralDelay);
|
|
181 |
// flush the cache manager contents.
|
|
182 |
CleanUp();
|
|
183 |
|
|
184 |
CServerRepository::CheckROMReflashL();
|
|
185 |
|
|
186 |
VerifyPMAUnchangedByFOTAL();
|
|
187 |
|
|
188 |
CleanupStack::Pop(); // CloseTServerResources
|
|
189 |
|
|
190 |
TServerResources::Close();
|
|
191 |
}
|
|
192 |
|
|
193 |
/**
|
|
194 |
@SYMTestCaseID PDS-CENTRALREPOSITORY-CT-4123
|
|
195 |
@SYMTestCaseDesc FOTx test on PMA keyspaces with no basis in install directory or rom
|
|
196 |
@SYMTestPriority High
|
|
197 |
@SYMTestActions Copy a repository into the PMA drive that has no rom or SWI equivalent.
|
|
198 |
Call CheckROMReflashL to simulate a reboot of cenrep.
|
|
199 |
Verify that the persisted repository is NOT removed.
|
|
200 |
@SYMTestExpectedResults Persisted repository is not removed during rom update.
|
|
201 |
@SYMREQ REQ42876
|
|
202 |
*/
|
|
203 |
LOCAL_C void NoRomNoInstallPMARepFOTxL()
|
|
204 |
{
|
|
205 |
TheTest.Next(_L( " @SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4123 PMA FOTx delete test" ));
|
|
206 |
|
|
207 |
TServerResources::InitialiseL();
|
|
208 |
CleanupStack::PushL(TCleanupItem(CloseTServerResources, 0));
|
|
209 |
|
|
210 |
CFileMan* fm = CFileMan::NewL(TServerResources::iFs);
|
|
211 |
CleanupStack::PushL(fm);
|
|
212 |
|
|
213 |
//Copy of modified stored rom version info
|
|
214 |
User::LeaveIfError(fm->Copy(KModifiedSwVersion, KCachedVersionFile,CFileMan::EOverWrite));
|
|
215 |
User::LeaveIfError(fm->Attribs(KCachedVersionFile, 0, KEntryAttReadOnly,TTime(0)));
|
|
216 |
User::After(KGeneralDelay);
|
|
217 |
CleanupStack::PopAndDestroy();//fm
|
|
218 |
|
|
219 |
CServerRepository::CheckROMReflashL();
|
|
220 |
TEntry entry;
|
|
221 |
|
|
222 |
TEST(TServerResources::iFs.Entry(KPMADriveCre, entry) == KErrNone);
|
|
223 |
|
|
224 |
CleanupStack::Pop(); //CloseTServerResources
|
|
225 |
|
|
226 |
TServerResources::Close();
|
|
227 |
|
|
228 |
}
|
|
229 |
|
|
230 |
LOCAL_C void DoTestsL()
|
|
231 |
{
|
|
232 |
PMARepFOTxL();
|
|
233 |
NoRomNoInstallPMARepFOTxL();
|
|
234 |
}
|
|
235 |
|
|
236 |
LOCAL_C void MainL()
|
|
237 |
{
|
|
238 |
CopyTestFilesL();
|
|
239 |
|
|
240 |
// create and install the active scheduler we need
|
|
241 |
CActiveScheduler* s = new (ELeave) CActiveScheduler;
|
|
242 |
CleanupStack::PushL(s);
|
|
243 |
CActiveScheduler::Install(s);
|
|
244 |
|
|
245 |
DoTestsL();
|
|
246 |
|
|
247 |
CleanupCDriveL();
|
|
248 |
|
|
249 |
// Cleanup the scheduler
|
|
250 |
CleanupStack::PopAndDestroy(s);
|
|
251 |
}
|
|
252 |
|
|
253 |
TInt E32Main()
|
|
254 |
{
|
|
255 |
TheTest.Title ();
|
|
256 |
TheTest.Start(_L( "PMA Fota Unit Tests" ));
|
|
257 |
|
|
258 |
CTrapCleanup* cleanup = CTrapCleanup::New();
|
|
259 |
TheTest(cleanup != NULL);
|
|
260 |
|
|
261 |
__UHEAP_MARK;
|
|
262 |
|
|
263 |
TRAPD(err, MainL());
|
|
264 |
TEST2(err, KErrNone);
|
|
265 |
|
|
266 |
__UHEAP_MARKEND;
|
|
267 |
|
|
268 |
TheTest.End ();
|
|
269 |
TheTest.Close ();
|
|
270 |
|
|
271 |
delete cleanup;
|
|
272 |
|
|
273 |
User::Heap().Check();
|
|
274 |
return KErrNone;
|
|
275 |
}
|
|
276 |
|