First public contribution.
1 // Copyright (c) 2008-2009 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 the License "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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Hardware Configuration Respoitory Test Application
17 #define __E32TEST_EXTENSION__
23 #include <drivers/hcr.h>
25 #include "hcr_hai.h" // for SSettingC structure
32 #include "d_hcrsim_testdata.h"
34 #define __TRACE_LINE__() test.Printf(_L("%d\n"),__LINE__)
36 RTest test(_L("T_HCRUT"));
38 _LIT(KTestDriver,"d_hcrut");
43 void TestBoundaryFindSettingsInCategory()
49 //Test low end boundary conditions in the compiled repository, first and
50 //end elements don't belong to the repository
51 TUint32 TestCat = KHCRUID_TestCategory1;
52 TInt NumInTestCat = 15;
54 test_KErrNone(HcrTest.Test_FindCompiledSettingsInCategory(TestCat,
56 test_Equal((lastEl - firstEl + 1), NumInTestCat);
58 // Load file repository data for the boundary test condition
59 const TText * fileBc0 = (const TText *)"filerepos_bc0.dat";
60 test_KErrNone(HcrTest.Test_SwitchFileRepository(fileBc0));
62 // Test the low end boundary conditions in the file repository.
63 // First element in the category is also the first element in the
68 test_KErrNone(HcrTest.Test_FindFileSettingsInCategory(TestCat,
70 test_Equal((lastEl - firstEl + 1), NumInTestCat);
72 // Test the high end boundary conditions in the file repository.
73 // Last element in the category is also the last element in the
78 test_KErrNone(HcrTest.Test_FindFileSettingsInCategory(TestCat,
80 test_Equal((lastEl - firstEl + 1), NumInTestCat);
84 //Load relevant coreImg repository
85 const TText * fileBc1 = (const TText *)"filerepos_bc1.dat";
86 test_KErrNone(HcrTest.Test_SwitchFileRepository(fileBc1));
89 //Test the low end boundary condition when first element of the
90 //repository does not belong to the requested category, so first element
91 // in TestBc1Cat0 is second in the repository.
95 test_KErrNone(HcrTest.Test_FindFileSettingsInCategory(TestCat,
97 test_Equal((lastEl - firstEl + 1), NumInTestCat);
101 //Test the high end boundary condition when last element in the
102 // repository does not belong to TestBc1Cat1 in opposite to the previous
103 //element which part of this category.
104 TestCat = 0x10000002;
107 test_KErrNone(HcrTest.Test_FindFileSettingsInCategory(TestCat,
109 test_Equal((lastEl - firstEl + 1), NumInTestCat);
112 //The required category has only one element and it's first setting
117 test_KErrNone(HcrTest.Test_FindFileSettingsInCategory(TestCat,
119 test_Equal((lastEl - firstEl + 1), NumInTestCat);
121 //The required category has only one element and it's the last setting
123 TestCat = 0xFFFFFFFF;
126 test_KErrNone(HcrTest.Test_FindFileSettingsInCategory(TestCat,
128 test_Equal((lastEl - firstEl + 1), NumInTestCat);
131 //Standard use case, all elements of the category are situated somewhere
132 //in the middle of the repository
133 TestCat = 0x10000002;
136 test_KErrNone(HcrTest.Test_FindFileSettingsInCategory(TestCat,
138 test_Equal((lastEl - firstEl + 1), NumInTestCat);
141 //---------------------------------------------
148 //! @SYMTestExpectedResults
152 //---------------------------------------------
155 test.Next(_L("Check Integrity test"));
157 test.Printf(_L("Skipped on the emulator"));
159 test_KErrNone( HcrTest.Test_CheckIntegrity());
162 test.Next(_L("Check Content test"));
164 test.Printf(_L("Skipped on the emulator"));
166 test_KErrNone( HcrTest.Test_CheckContent());
170 test.Next(_L("Switch repository test"));
171 test_KErrNone(HcrTest.Test_SwitchRepository());
173 test.Next(_L("Invoke FindSettingsInCategory boundary conditon tests"));
174 TestBoundaryFindSettingsInCategory();
176 // Wait for idle + async cleanup (waits for DKernelEventHandler to go away)
177 TInt r = UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, (TAny*)5000, 0);
180 User::After(5000000);
187 TInt TRepositoryGetWordValueUnitTests ()
189 test.Next(_L("Unit tests for HCR::TRepositoryFile::GetWordValue && HCR::TRepositoryCompiled::GetWordValue"));
192 for(setting = SettingsList; setting < SettingsList + sizeof(SettingsList) / sizeof(SSettingC); ++setting)
194 TCategoryUid category = setting->iName.iId.iCat;
195 TElementId key = setting->iName.iId.iKey;
196 TInt type = setting->iName.iType;
197 test_KErrNone( HcrTest.Test_TRepositoryGetWordValue(category, key, type));
201 // Wait for idle + async cleanup (waits for DKernelEventHandler to go away)
202 TInt r = UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, (TAny*)5000, 0);
208 TInt NegativeTestsLargeValues ()
210 test.Next(_L("Negative tests for HCR::TRepository::GetLargeValues"));
212 TInt expectedError = KErrArgument;
214 test_KErrNone( HcrTest.Test_NegativeTestsLargeValues(expectedError));
216 // Wait for idle + async cleanup (waits for DKernelEventHandler to go away)
217 TInt r = UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, (TAny*)5000, 0);
224 GLDEF_C TInt E32Main()
229 test.Start(_L("=== HCR Test Suite"));
232 test.Next(_L("=== Open test LDD"));
233 r = User::LoadLogicalDevice(KTestDriver);
234 test_Assert((r==KErrNone || r==KErrAlreadyExists),void (0));
242 NegativeTestsLargeValues();
243 TRepositoryGetWordValueUnitTests();
245 test.Next(_L("=== Close LDD"));
248 r = User::FreeLogicalDevice(RHcrTest::Name());