sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Hardware Configuration Respoitory Test Application sl@0: // sl@0: sl@0: #define __E32TEST_EXTENSION__ sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #include "hcr_hai.h" // for SSettingC structure sl@0: #include "hcr_uids.h" sl@0: sl@0: using namespace HCR; sl@0: sl@0: #include "d_hcrut.h" sl@0: sl@0: #include "d_hcrsim_testdata.h" sl@0: sl@0: #define __TRACE_LINE__() test.Printf(_L("%d\n"),__LINE__) sl@0: sl@0: RTest test(_L("T_HCRUT")); sl@0: sl@0: _LIT(KTestDriver,"d_hcrut"); sl@0: sl@0: RHcrTest HcrTest; sl@0: sl@0: sl@0: void TestBoundaryFindSettingsInCategory() sl@0: { sl@0: TInt32 firstEl; sl@0: TInt32 lastEl; sl@0: sl@0: sl@0: //Test low end boundary conditions in the compiled repository, first and sl@0: //end elements don't belong to the repository sl@0: TUint32 TestCat = KHCRUID_TestCategory1; sl@0: TInt NumInTestCat = 15; sl@0: sl@0: test_KErrNone(HcrTest.Test_FindCompiledSettingsInCategory(TestCat, sl@0: &firstEl, &lastEl)); sl@0: test_Equal((lastEl - firstEl + 1), NumInTestCat); sl@0: sl@0: // Load file repository data for the boundary test condition sl@0: const TText * fileBc0 = (const TText *)"filerepos_bc0.dat"; sl@0: test_KErrNone(HcrTest.Test_SwitchFileRepository(fileBc0)); sl@0: sl@0: // Test the low end boundary conditions in the file repository. sl@0: // First element in the category is also the first element in the sl@0: // repository sl@0: TestCat = 0x00000001; sl@0: NumInTestCat = 4; sl@0: sl@0: test_KErrNone(HcrTest.Test_FindFileSettingsInCategory(TestCat, sl@0: &firstEl, &lastEl)); sl@0: test_Equal((lastEl - firstEl + 1), NumInTestCat); sl@0: sl@0: // Test the high end boundary conditions in the file repository. sl@0: // Last element in the category is also the last element in the sl@0: // repository sl@0: TestCat = 0xFFFFFFFF; sl@0: NumInTestCat = 4; sl@0: sl@0: test_KErrNone(HcrTest.Test_FindFileSettingsInCategory(TestCat, sl@0: &firstEl, &lastEl)); sl@0: test_Equal((lastEl - firstEl + 1), NumInTestCat); sl@0: sl@0: sl@0: sl@0: //Load relevant coreImg repository sl@0: const TText * fileBc1 = (const TText *)"filerepos_bc1.dat"; sl@0: test_KErrNone(HcrTest.Test_SwitchFileRepository(fileBc1)); sl@0: sl@0: sl@0: //Test the low end boundary condition when first element of the sl@0: //repository does not belong to the requested category, so first element sl@0: // in TestBc1Cat0 is second in the repository. sl@0: TestCat = 0x2; sl@0: NumInTestCat = 4; sl@0: sl@0: test_KErrNone(HcrTest.Test_FindFileSettingsInCategory(TestCat, sl@0: &firstEl, &lastEl)); sl@0: test_Equal((lastEl - firstEl + 1), NumInTestCat); sl@0: sl@0: sl@0: sl@0: //Test the high end boundary condition when last element in the sl@0: // repository does not belong to TestBc1Cat1 in opposite to the previous sl@0: //element which part of this category. sl@0: TestCat = 0x10000002; sl@0: NumInTestCat = 7; sl@0: sl@0: test_KErrNone(HcrTest.Test_FindFileSettingsInCategory(TestCat, sl@0: &firstEl, &lastEl)); sl@0: test_Equal((lastEl - firstEl + 1), NumInTestCat); sl@0: sl@0: sl@0: //The required category has only one element and it's first setting sl@0: //in the repository sl@0: TestCat = 0x01; sl@0: NumInTestCat = 1; sl@0: sl@0: test_KErrNone(HcrTest.Test_FindFileSettingsInCategory(TestCat, sl@0: &firstEl, &lastEl)); sl@0: test_Equal((lastEl - firstEl + 1), NumInTestCat); sl@0: sl@0: //The required category has only one element and it's the last setting sl@0: //in the repository sl@0: TestCat = 0xFFFFFFFF; sl@0: NumInTestCat = 1; sl@0: sl@0: test_KErrNone(HcrTest.Test_FindFileSettingsInCategory(TestCat, sl@0: &firstEl, &lastEl)); sl@0: test_Equal((lastEl - firstEl + 1), NumInTestCat); sl@0: sl@0: sl@0: //Standard use case, all elements of the category are situated somewhere sl@0: //in the middle of the repository sl@0: TestCat = 0x10000002; sl@0: NumInTestCat = 7; sl@0: sl@0: test_KErrNone(HcrTest.Test_FindFileSettingsInCategory(TestCat, sl@0: &firstEl, &lastEl)); sl@0: test_Equal((lastEl - firstEl + 1), NumInTestCat); sl@0: } sl@0: sl@0: //--------------------------------------------- sl@0: //! @SYMTestCaseID sl@0: //! @SYMTestType sl@0: //! @SYMPREQ sl@0: //! @SYMTestCaseDesc sl@0: //! @SYMTestActions sl@0: //! sl@0: //! @SYMTestExpectedResults sl@0: //! sl@0: //! @SYMTestPriority sl@0: //! @SYMTestStatus sl@0: //--------------------------------------------- sl@0: TInt TestBasics () sl@0: { sl@0: test.Next(_L("Check Integrity test")); sl@0: #ifdef __WINS__ sl@0: test.Printf(_L("Skipped on the emulator")); sl@0: #else sl@0: test_KErrNone( HcrTest.Test_CheckIntegrity()); sl@0: #endif // __WINS__ sl@0: sl@0: test.Next(_L("Check Content test")); sl@0: #ifdef __WINS__ sl@0: test.Printf(_L("Skipped on the emulator")); sl@0: #else sl@0: test_KErrNone( HcrTest.Test_CheckContent()); sl@0: #endif // __WINS__ sl@0: sl@0: sl@0: test.Next(_L("Switch repository test")); sl@0: test_KErrNone(HcrTest.Test_SwitchRepository()); sl@0: sl@0: test.Next(_L("Invoke FindSettingsInCategory boundary conditon tests")); sl@0: TestBoundaryFindSettingsInCategory(); sl@0: sl@0: // Wait for idle + async cleanup (waits for DKernelEventHandler to go away) sl@0: TInt r = UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, (TAny*)5000, 0); sl@0: test_KErrNone(r); sl@0: sl@0: User::After(5000000); sl@0: sl@0: sl@0: return KErrNone; sl@0: } sl@0: sl@0: sl@0: TInt TRepositoryGetWordValueUnitTests () sl@0: { sl@0: test.Next(_L("Unit tests for HCR::TRepositoryFile::GetWordValue && HCR::TRepositoryCompiled::GetWordValue")); sl@0: sl@0: SSettingC* setting; sl@0: for(setting = SettingsList; setting < SettingsList + sizeof(SettingsList) / sizeof(SSettingC); ++setting) sl@0: { sl@0: TCategoryUid category = setting->iName.iId.iCat; sl@0: TElementId key = setting->iName.iId.iKey; sl@0: TInt type = setting->iName.iType; sl@0: test_KErrNone( HcrTest.Test_TRepositoryGetWordValue(category, key, type)); sl@0: sl@0: } sl@0: sl@0: // Wait for idle + async cleanup (waits for DKernelEventHandler to go away) sl@0: TInt r = UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, (TAny*)5000, 0); sl@0: test_KErrNone(r); sl@0: sl@0: return KErrNone; sl@0: } sl@0: sl@0: TInt NegativeTestsLargeValues () sl@0: { sl@0: test.Next(_L("Negative tests for HCR::TRepository::GetLargeValues")); sl@0: sl@0: TInt expectedError = KErrArgument; sl@0: sl@0: test_KErrNone( HcrTest.Test_NegativeTestsLargeValues(expectedError)); sl@0: sl@0: // Wait for idle + async cleanup (waits for DKernelEventHandler to go away) sl@0: TInt r = UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, (TAny*)5000, 0); sl@0: test_KErrNone(r); sl@0: sl@0: return KErrNone; sl@0: } sl@0: sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: TInt r; sl@0: sl@0: test.Title(); sl@0: test.Start(_L("=== HCR Test Suite")); sl@0: sl@0: sl@0: test.Next(_L("=== Open test LDD")); sl@0: r = User::LoadLogicalDevice(KTestDriver); sl@0: test_Assert((r==KErrNone || r==KErrAlreadyExists),void (0)); sl@0: sl@0: r = HcrTest.Open(); sl@0: test_KErrNone(r); sl@0: // Do test cases sl@0: // sl@0: TestBasics(); sl@0: sl@0: NegativeTestsLargeValues(); sl@0: TRepositoryGetWordValueUnitTests(); sl@0: sl@0: test.Next(_L("=== Close LDD")); sl@0: HcrTest.Close(); sl@0: sl@0: r = User::FreeLogicalDevice(RHcrTest::Name()); sl@0: test_KErrNone(r); sl@0: sl@0: test.End(); sl@0: sl@0: return(KErrNone); sl@0: } sl@0: