sl@0: // Copyright (c) 2002-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 "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: // This file contains the test steps for Unit Test Suite 11 : TestStep.cpp sl@0: // sl@0: // sl@0: sl@0: // EPOC includes sl@0: #include sl@0: sl@0: // Test system includes sl@0: #include sl@0: sl@0: // Specific includes for this test suite sl@0: #include "TSU_MmTsthStep11.h" sl@0: #include "TSU_MmTsthSuite11.h" sl@0: sl@0: // Specific includes for these test steps sl@0: #include "TSU_MmTsth11.h" sl@0: #include "TestStepVirtualStub.h" sl@0: #include "TestSuiteVirtualStub.h" sl@0: sl@0: // -------------------------------------------- sl@0: sl@0: // Unit Test Suite 11 : TestStep.cpp sl@0: // Depends on : none sl@0: // Requires : subclass implementing pure virtual DoTestStepL() sl@0: sl@0: // Tests :- sl@0: // RTestStep() constructor (thru stub) sl@0: // test accessors sl@0: // DoTestStepL sl@0: // DoTestStepPreamble sl@0: // DoTestStepPostamble sl@0: // Load / unload config sl@0: sl@0: // --------------------- sl@0: // RTestMmTsthU1101 sl@0: sl@0: RTestMmTsthU1101* RTestMmTsthU1101::NewL() sl@0: { sl@0: RTestMmTsthU1101* self = new(ELeave) RTestMmTsthU1101; sl@0: return self; sl@0: } sl@0: sl@0: // Each test step initialises its own name. sl@0: RTestMmTsthU1101::RTestMmTsthU1101() sl@0: { sl@0: iTestStepName = _L("MM-TSTH-U-1101"); sl@0: } sl@0: sl@0: sl@0: // preamble sl@0: TVerdict RTestMmTsthU1101::OpenL() sl@0: { sl@0: // stub - purpose is that for this test we do not run the parent preamble sl@0: // which initialises iStepStub sl@0: return iTestStepResult = EPass; sl@0: } sl@0: sl@0: // postamble sl@0: void RTestMmTsthU1101::Close() sl@0: { sl@0: } sl@0: sl@0: // do the test step sl@0: TVerdict RTestMmTsthU1101::DoTestStepL() sl@0: { sl@0: INFO_PRINTF1(_L("Unit test for TestStep - construct")); sl@0: TVerdict currentVerdict = EPass; sl@0: sl@0: RTestStepVirtualStub* theStepStub = NULL; sl@0: TRAPD(err, theStepStub = RTestStepVirtualStub::NewL()); sl@0: if(err != KErrNone) sl@0: { sl@0: ERR_PRINTF1(_L("RTestStepVirtualStub::NewL() left")); sl@0: return iTestStepResult = EFail; sl@0: } sl@0: sl@0: const TPtrC& theName = theStepStub->StepName(); sl@0: if(theName != KTestStepVirtualStubName) sl@0: { sl@0: ERR_PRINTF1(_L("RTestStepVirtualStub did not initialise correctly")); sl@0: delete theStepStub; sl@0: return iTestStepResult = EFail; sl@0: } sl@0: sl@0: delete theStepStub; sl@0: return iTestStepResult = currentVerdict; // should be EPass if we've got here sl@0: } sl@0: sl@0: // ------------------------ sl@0: // RTestMmTsthU1102 sl@0: RTestMmTsthU1102* RTestMmTsthU1102::NewL() sl@0: { sl@0: RTestMmTsthU1102* self = new(ELeave) RTestMmTsthU1102; sl@0: return self; sl@0: } sl@0: sl@0: // Each test step initialises its own name. sl@0: RTestMmTsthU1102::RTestMmTsthU1102() sl@0: { sl@0: iTestStepName = _L("MM-TSTH-U-1102"); sl@0: } sl@0: sl@0: // do the test step sl@0: TVerdict RTestMmTsthU1102::DoTestStepL() sl@0: { sl@0: // RTestStepVirtualStub contains extra methods by which we can verify our accessors sl@0: INFO_PRINTF1(_L("Unit test for TestStep - accessors")); sl@0: sl@0: TVerdict currentVerdict = EPass; sl@0: sl@0: // test accessor to set name - not part of RTestStep sl@0: TBufC KTestStepName = _L("TestStepName"); sl@0: iStepStub->TestSetStepName(KTestStepName); sl@0: const TPtrC& theName = iStepStub->StepName(); sl@0: if(theName != KTestStepName) sl@0: { sl@0: ERR_PRINTF1(_L("RTestStep::StepName() failed")); sl@0: return iTestStepResult = EFail; sl@0: } sl@0: sl@0: TVerdict theResult = EInconclusive; sl@0: iStepStub->SetResult(theResult); sl@0: // test accessor to get result - not part of RTestStep sl@0: if(theResult != iStepStub->TestGetResult()) sl@0: { sl@0: ERR_PRINTF1(_L("RTestStep::SetResult() failed")); sl@0: return iTestStepResult = EFail; sl@0: } sl@0: sl@0: CTestSuiteVirtualStub* theSuite = new (ELeave) CTestSuiteVirtualStub; sl@0: CleanupStack::PushL(theSuite); sl@0: theSuite->ConstructL(); sl@0: sl@0: iStepStub->SetSuite(theSuite); sl@0: // test accessor to get suite - not part of RTestStep sl@0: if(theSuite != iStepStub->TestGetSuite()) sl@0: { sl@0: ERR_PRINTF1(_L("RTestStep::SetSuite() failed")); sl@0: CleanupStack::PopAndDestroy(); // theSuite sl@0: return iTestStepResult = EFail; sl@0: } sl@0: // cleanup sl@0: CleanupStack::PopAndDestroy(); // theSuite sl@0: sl@0: return iTestStepResult = currentVerdict; // should be EPass if we've got here sl@0: } sl@0: sl@0: // --------------------- sl@0: // RTestMmTsthU1103 sl@0: sl@0: RTestMmTsthU1103* RTestMmTsthU1103::NewL() sl@0: { sl@0: RTestMmTsthU1103* self = new(ELeave) RTestMmTsthU1103; sl@0: return self; sl@0: } sl@0: sl@0: // Each test step initialises its own name. sl@0: RTestMmTsthU1103::RTestMmTsthU1103() sl@0: { sl@0: iTestStepName = _L("MM-TSTH-U-1103"); sl@0: } sl@0: sl@0: // do the test step. sl@0: TVerdict RTestMmTsthU1103::DoTestStepL() sl@0: { sl@0: // RTestStepVirtualStub contains extra methods by which we can verify our accessors sl@0: INFO_PRINTF1(_L("Unit test for TestStep - preamble")); sl@0: sl@0: TVerdict currentVerdict = EPass; sl@0: sl@0: iStepStub->OpenL(); sl@0: if(!iStepStub->PreambleRun()) sl@0: { sl@0: ERR_PRINTF1(_L("RTestStep::OpenL() failed")); sl@0: return iTestStepResult = EFail; sl@0: } sl@0: sl@0: return iTestStepResult = currentVerdict; // should be EPass if we've got here sl@0: } sl@0: sl@0: // --------------------- sl@0: // RTestMmTsthU1104 sl@0: sl@0: RTestMmTsthU1104* RTestMmTsthU1104::NewL() sl@0: { sl@0: RTestMmTsthU1104* self = new(ELeave) RTestMmTsthU1104; sl@0: return self; sl@0: } sl@0: sl@0: // Each test step initialises its own name. sl@0: RTestMmTsthU1104::RTestMmTsthU1104() sl@0: { sl@0: iTestStepName = _L("MM-TSTH-U-1104"); sl@0: } sl@0: sl@0: // do the test step sl@0: TVerdict RTestMmTsthU1104::DoTestStepL() sl@0: { sl@0: // RTestStepVirtualStub contains extra methods by which we can verify our accessors sl@0: INFO_PRINTF1(_L("Unit test for TestStep - postamble")); sl@0: sl@0: TVerdict currentVerdict = EPass; sl@0: sl@0: iStepStub->Close(); sl@0: if(!iStepStub->PostambleRun()) sl@0: { sl@0: ERR_PRINTF1(_L("RTestStep::Close() failed")); sl@0: return iTestStepResult = EFail; sl@0: } sl@0: sl@0: return iTestStepResult = currentVerdict; // should be EPass if we've got here sl@0: } sl@0: sl@0: // --------------------- sl@0: // RTestMmTsthU1105 sl@0: RTestMmTsthU1105* RTestMmTsthU1105::NewL() sl@0: { sl@0: RTestMmTsthU1105* self = new(ELeave) RTestMmTsthU1105; sl@0: return self; sl@0: } sl@0: sl@0: // Each test step initialises its own name. sl@0: RTestMmTsthU1105::RTestMmTsthU1105() sl@0: { sl@0: iTestStepName = _L("MM-TSTH-U-1105"); sl@0: } sl@0: sl@0: // do the test step sl@0: TVerdict RTestMmTsthU1105::DoTestStepL() sl@0: { sl@0: // RTestStepVirtualStub contains extra methods by which we can verify our accessors sl@0: INFO_PRINTF1(_L("Unit test for TestStep - step")); sl@0: sl@0: TVerdict currentVerdict = EPass; sl@0: sl@0: iStepStub->DoTestStepL(); sl@0: if(!iStepStub->StepRun()) sl@0: { sl@0: ERR_PRINTF1(_L("RTestStep::DoTestStepL() failed")); sl@0: return iTestStepResult = EFail; sl@0: } sl@0: sl@0: return iTestStepResult = currentVerdict; // should be EPass if we've got here sl@0: } sl@0: sl@0: // ------------------------ sl@0: // RTestMmTsthU1111 sl@0: RTestMmTsthU1111* RTestMmTsthU1111::NewL() sl@0: { sl@0: RTestMmTsthU1111* self = new(ELeave) RTestMmTsthU1111; sl@0: return self; sl@0: } sl@0: sl@0: // Each test step initialises its own name. sl@0: RTestMmTsthU1111::RTestMmTsthU1111() sl@0: { sl@0: iTestStepName = _L("MM-TSTH-U-1111"); sl@0: } sl@0: sl@0: // do the test step sl@0: TVerdict RTestMmTsthU1111::DoTestStepL() sl@0: { sl@0: const TInt KTestBufSize = 64; sl@0: sl@0: // RTestStepVirtualStub contains extra methods by which we can verify our accessors sl@0: INFO_PRINTF1(_L("Unit test for TestStep - load config")); sl@0: sl@0: TVerdict currentVerdict = EPass; sl@0: sl@0: TBufC KConfigName = _L("TSU_MMTSTH11_config.ini"); sl@0: iStepStub->LoadConfig(KConfigName); sl@0: sl@0: // we get no return saying that the file hasn't loaded - sl@0: // therefore check something in the file we know is there : [SectionOne] keybool = true sl@0: // because these functions are protected, we have to wrap them in iStepStub sl@0: sl@0: TBool aBoolResult; sl@0: TBool returnValue = iStepStub->TestGetBoolFromConfig(_L("SectionOne"),_L("Keybool"), aBoolResult); sl@0: if(!returnValue) sl@0: { sl@0: ERR_PRINTF1(_L("RTestStep::LoadConfig() failed")); sl@0: iStepStub->UnloadConfig(); sl@0: return iTestStepResult = EFail; sl@0: } sl@0: sl@0: iStepStub->UnloadConfig(); sl@0: return iTestStepResult = currentVerdict; // should be EPass if we've got here sl@0: } sl@0: sl@0: // ------------------------ sl@0: sl@0: