sl@0
|
1 |
// Copyright (c) 2008-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 the License "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 |
// Hardware Configuration Respoitory Test Application
|
sl@0
|
15 |
//
|
sl@0
|
16 |
|
sl@0
|
17 |
#define __E32TEST_EXTENSION__
|
sl@0
|
18 |
#include <e32test.h>
|
sl@0
|
19 |
#include <e32svr.h>
|
sl@0
|
20 |
#include <u32hal.h>
|
sl@0
|
21 |
#include <hal.h>
|
sl@0
|
22 |
#include <hal_data.h>
|
sl@0
|
23 |
#include <drivers/hcr.h>
|
sl@0
|
24 |
|
sl@0
|
25 |
#include "hcr_hai.h" // for SSettingC structure
|
sl@0
|
26 |
#include "hcr_uids.h"
|
sl@0
|
27 |
|
sl@0
|
28 |
using namespace HCR;
|
sl@0
|
29 |
|
sl@0
|
30 |
#include "d_hcrut.h"
|
sl@0
|
31 |
|
sl@0
|
32 |
#include "d_hcrsim_testdata.h"
|
sl@0
|
33 |
|
sl@0
|
34 |
#define __TRACE_LINE__() test.Printf(_L("%d\n"),__LINE__)
|
sl@0
|
35 |
|
sl@0
|
36 |
RTest test(_L("T_HCRUT"));
|
sl@0
|
37 |
|
sl@0
|
38 |
_LIT(KTestDriver,"d_hcrut");
|
sl@0
|
39 |
|
sl@0
|
40 |
RHcrTest HcrTest;
|
sl@0
|
41 |
|
sl@0
|
42 |
|
sl@0
|
43 |
void TestBoundaryFindSettingsInCategory()
|
sl@0
|
44 |
{
|
sl@0
|
45 |
TInt32 firstEl;
|
sl@0
|
46 |
TInt32 lastEl;
|
sl@0
|
47 |
|
sl@0
|
48 |
|
sl@0
|
49 |
//Test low end boundary conditions in the compiled repository, first and
|
sl@0
|
50 |
//end elements don't belong to the repository
|
sl@0
|
51 |
TUint32 TestCat = KHCRUID_TestCategory1;
|
sl@0
|
52 |
TInt NumInTestCat = 15;
|
sl@0
|
53 |
|
sl@0
|
54 |
test_KErrNone(HcrTest.Test_FindCompiledSettingsInCategory(TestCat,
|
sl@0
|
55 |
&firstEl, &lastEl));
|
sl@0
|
56 |
test_Equal((lastEl - firstEl + 1), NumInTestCat);
|
sl@0
|
57 |
|
sl@0
|
58 |
// Load file repository data for the boundary test condition
|
sl@0
|
59 |
const TText * fileBc0 = (const TText *)"filerepos_bc0.dat";
|
sl@0
|
60 |
test_KErrNone(HcrTest.Test_SwitchFileRepository(fileBc0));
|
sl@0
|
61 |
|
sl@0
|
62 |
// Test the low end boundary conditions in the file repository.
|
sl@0
|
63 |
// First element in the category is also the first element in the
|
sl@0
|
64 |
// repository
|
sl@0
|
65 |
TestCat = 0x00000001;
|
sl@0
|
66 |
NumInTestCat = 4;
|
sl@0
|
67 |
|
sl@0
|
68 |
test_KErrNone(HcrTest.Test_FindFileSettingsInCategory(TestCat,
|
sl@0
|
69 |
&firstEl, &lastEl));
|
sl@0
|
70 |
test_Equal((lastEl - firstEl + 1), NumInTestCat);
|
sl@0
|
71 |
|
sl@0
|
72 |
// Test the high end boundary conditions in the file repository.
|
sl@0
|
73 |
// Last element in the category is also the last element in the
|
sl@0
|
74 |
// repository
|
sl@0
|
75 |
TestCat = 0xFFFFFFFF;
|
sl@0
|
76 |
NumInTestCat = 4;
|
sl@0
|
77 |
|
sl@0
|
78 |
test_KErrNone(HcrTest.Test_FindFileSettingsInCategory(TestCat,
|
sl@0
|
79 |
&firstEl, &lastEl));
|
sl@0
|
80 |
test_Equal((lastEl - firstEl + 1), NumInTestCat);
|
sl@0
|
81 |
|
sl@0
|
82 |
|
sl@0
|
83 |
|
sl@0
|
84 |
//Load relevant coreImg repository
|
sl@0
|
85 |
const TText * fileBc1 = (const TText *)"filerepos_bc1.dat";
|
sl@0
|
86 |
test_KErrNone(HcrTest.Test_SwitchFileRepository(fileBc1));
|
sl@0
|
87 |
|
sl@0
|
88 |
|
sl@0
|
89 |
//Test the low end boundary condition when first element of the
|
sl@0
|
90 |
//repository does not belong to the requested category, so first element
|
sl@0
|
91 |
// in TestBc1Cat0 is second in the repository.
|
sl@0
|
92 |
TestCat = 0x2;
|
sl@0
|
93 |
NumInTestCat = 4;
|
sl@0
|
94 |
|
sl@0
|
95 |
test_KErrNone(HcrTest.Test_FindFileSettingsInCategory(TestCat,
|
sl@0
|
96 |
&firstEl, &lastEl));
|
sl@0
|
97 |
test_Equal((lastEl - firstEl + 1), NumInTestCat);
|
sl@0
|
98 |
|
sl@0
|
99 |
|
sl@0
|
100 |
|
sl@0
|
101 |
//Test the high end boundary condition when last element in the
|
sl@0
|
102 |
// repository does not belong to TestBc1Cat1 in opposite to the previous
|
sl@0
|
103 |
//element which part of this category.
|
sl@0
|
104 |
TestCat = 0x10000002;
|
sl@0
|
105 |
NumInTestCat = 7;
|
sl@0
|
106 |
|
sl@0
|
107 |
test_KErrNone(HcrTest.Test_FindFileSettingsInCategory(TestCat,
|
sl@0
|
108 |
&firstEl, &lastEl));
|
sl@0
|
109 |
test_Equal((lastEl - firstEl + 1), NumInTestCat);
|
sl@0
|
110 |
|
sl@0
|
111 |
|
sl@0
|
112 |
//The required category has only one element and it's first setting
|
sl@0
|
113 |
//in the repository
|
sl@0
|
114 |
TestCat = 0x01;
|
sl@0
|
115 |
NumInTestCat = 1;
|
sl@0
|
116 |
|
sl@0
|
117 |
test_KErrNone(HcrTest.Test_FindFileSettingsInCategory(TestCat,
|
sl@0
|
118 |
&firstEl, &lastEl));
|
sl@0
|
119 |
test_Equal((lastEl - firstEl + 1), NumInTestCat);
|
sl@0
|
120 |
|
sl@0
|
121 |
//The required category has only one element and it's the last setting
|
sl@0
|
122 |
//in the repository
|
sl@0
|
123 |
TestCat = 0xFFFFFFFF;
|
sl@0
|
124 |
NumInTestCat = 1;
|
sl@0
|
125 |
|
sl@0
|
126 |
test_KErrNone(HcrTest.Test_FindFileSettingsInCategory(TestCat,
|
sl@0
|
127 |
&firstEl, &lastEl));
|
sl@0
|
128 |
test_Equal((lastEl - firstEl + 1), NumInTestCat);
|
sl@0
|
129 |
|
sl@0
|
130 |
|
sl@0
|
131 |
//Standard use case, all elements of the category are situated somewhere
|
sl@0
|
132 |
//in the middle of the repository
|
sl@0
|
133 |
TestCat = 0x10000002;
|
sl@0
|
134 |
NumInTestCat = 7;
|
sl@0
|
135 |
|
sl@0
|
136 |
test_KErrNone(HcrTest.Test_FindFileSettingsInCategory(TestCat,
|
sl@0
|
137 |
&firstEl, &lastEl));
|
sl@0
|
138 |
test_Equal((lastEl - firstEl + 1), NumInTestCat);
|
sl@0
|
139 |
}
|
sl@0
|
140 |
|
sl@0
|
141 |
//---------------------------------------------
|
sl@0
|
142 |
//! @SYMTestCaseID
|
sl@0
|
143 |
//! @SYMTestType
|
sl@0
|
144 |
//! @SYMPREQ
|
sl@0
|
145 |
//! @SYMTestCaseDesc
|
sl@0
|
146 |
//! @SYMTestActions
|
sl@0
|
147 |
//!
|
sl@0
|
148 |
//! @SYMTestExpectedResults
|
sl@0
|
149 |
//!
|
sl@0
|
150 |
//! @SYMTestPriority
|
sl@0
|
151 |
//! @SYMTestStatus
|
sl@0
|
152 |
//---------------------------------------------
|
sl@0
|
153 |
TInt TestBasics ()
|
sl@0
|
154 |
{
|
sl@0
|
155 |
test.Next(_L("Check Integrity test"));
|
sl@0
|
156 |
#ifdef __WINS__
|
sl@0
|
157 |
test.Printf(_L("Skipped on the emulator"));
|
sl@0
|
158 |
#else
|
sl@0
|
159 |
test_KErrNone( HcrTest.Test_CheckIntegrity());
|
sl@0
|
160 |
#endif // __WINS__
|
sl@0
|
161 |
|
sl@0
|
162 |
test.Next(_L("Check Content test"));
|
sl@0
|
163 |
#ifdef __WINS__
|
sl@0
|
164 |
test.Printf(_L("Skipped on the emulator"));
|
sl@0
|
165 |
#else
|
sl@0
|
166 |
test_KErrNone( HcrTest.Test_CheckContent());
|
sl@0
|
167 |
#endif // __WINS__
|
sl@0
|
168 |
|
sl@0
|
169 |
|
sl@0
|
170 |
test.Next(_L("Switch repository test"));
|
sl@0
|
171 |
test_KErrNone(HcrTest.Test_SwitchRepository());
|
sl@0
|
172 |
|
sl@0
|
173 |
test.Next(_L("Invoke FindSettingsInCategory boundary conditon tests"));
|
sl@0
|
174 |
TestBoundaryFindSettingsInCategory();
|
sl@0
|
175 |
|
sl@0
|
176 |
// Wait for idle + async cleanup (waits for DKernelEventHandler to go away)
|
sl@0
|
177 |
TInt r = UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, (TAny*)5000, 0);
|
sl@0
|
178 |
test_KErrNone(r);
|
sl@0
|
179 |
|
sl@0
|
180 |
User::After(5000000);
|
sl@0
|
181 |
|
sl@0
|
182 |
|
sl@0
|
183 |
return KErrNone;
|
sl@0
|
184 |
}
|
sl@0
|
185 |
|
sl@0
|
186 |
|
sl@0
|
187 |
TInt TRepositoryGetWordValueUnitTests ()
|
sl@0
|
188 |
{
|
sl@0
|
189 |
test.Next(_L("Unit tests for HCR::TRepositoryFile::GetWordValue && HCR::TRepositoryCompiled::GetWordValue"));
|
sl@0
|
190 |
|
sl@0
|
191 |
SSettingC* setting;
|
sl@0
|
192 |
for(setting = SettingsList; setting < SettingsList + sizeof(SettingsList) / sizeof(SSettingC); ++setting)
|
sl@0
|
193 |
{
|
sl@0
|
194 |
TCategoryUid category = setting->iName.iId.iCat;
|
sl@0
|
195 |
TElementId key = setting->iName.iId.iKey;
|
sl@0
|
196 |
TInt type = setting->iName.iType;
|
sl@0
|
197 |
test_KErrNone( HcrTest.Test_TRepositoryGetWordValue(category, key, type));
|
sl@0
|
198 |
|
sl@0
|
199 |
}
|
sl@0
|
200 |
|
sl@0
|
201 |
// Wait for idle + async cleanup (waits for DKernelEventHandler to go away)
|
sl@0
|
202 |
TInt r = UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, (TAny*)5000, 0);
|
sl@0
|
203 |
test_KErrNone(r);
|
sl@0
|
204 |
|
sl@0
|
205 |
return KErrNone;
|
sl@0
|
206 |
}
|
sl@0
|
207 |
|
sl@0
|
208 |
TInt NegativeTestsLargeValues ()
|
sl@0
|
209 |
{
|
sl@0
|
210 |
test.Next(_L("Negative tests for HCR::TRepository::GetLargeValues"));
|
sl@0
|
211 |
|
sl@0
|
212 |
TInt expectedError = KErrArgument;
|
sl@0
|
213 |
|
sl@0
|
214 |
test_KErrNone( HcrTest.Test_NegativeTestsLargeValues(expectedError));
|
sl@0
|
215 |
|
sl@0
|
216 |
// Wait for idle + async cleanup (waits for DKernelEventHandler to go away)
|
sl@0
|
217 |
TInt r = UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, (TAny*)5000, 0);
|
sl@0
|
218 |
test_KErrNone(r);
|
sl@0
|
219 |
|
sl@0
|
220 |
return KErrNone;
|
sl@0
|
221 |
}
|
sl@0
|
222 |
|
sl@0
|
223 |
|
sl@0
|
224 |
GLDEF_C TInt E32Main()
|
sl@0
|
225 |
{
|
sl@0
|
226 |
TInt r;
|
sl@0
|
227 |
|
sl@0
|
228 |
test.Title();
|
sl@0
|
229 |
test.Start(_L("=== HCR Test Suite"));
|
sl@0
|
230 |
|
sl@0
|
231 |
|
sl@0
|
232 |
test.Next(_L("=== Open test LDD"));
|
sl@0
|
233 |
r = User::LoadLogicalDevice(KTestDriver);
|
sl@0
|
234 |
test_Assert((r==KErrNone || r==KErrAlreadyExists),void (0));
|
sl@0
|
235 |
|
sl@0
|
236 |
r = HcrTest.Open();
|
sl@0
|
237 |
test_KErrNone(r);
|
sl@0
|
238 |
// Do test cases
|
sl@0
|
239 |
//
|
sl@0
|
240 |
TestBasics();
|
sl@0
|
241 |
|
sl@0
|
242 |
NegativeTestsLargeValues();
|
sl@0
|
243 |
TRepositoryGetWordValueUnitTests();
|
sl@0
|
244 |
|
sl@0
|
245 |
test.Next(_L("=== Close LDD"));
|
sl@0
|
246 |
HcrTest.Close();
|
sl@0
|
247 |
|
sl@0
|
248 |
r = User::FreeLogicalDevice(RHcrTest::Name());
|
sl@0
|
249 |
test_KErrNone(r);
|
sl@0
|
250 |
|
sl@0
|
251 |
test.End();
|
sl@0
|
252 |
|
sl@0
|
253 |
return(KErrNone);
|
sl@0
|
254 |
}
|
sl@0
|
255 |
|