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 01 : Parseline.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: #include "script.h" sl@0: #include "parseline.h" sl@0: #include "Filename.h" sl@0: sl@0: // Specific includes for this test suite sl@0: #include "TSU_MmTsthSuite01.h" sl@0: sl@0: // Specific includes for these test steps sl@0: #include "TSU_MmTsth01.h" sl@0: sl@0: // -------------------------------------------- sl@0: sl@0: // Unit Test Suite 01 : Parseline.cpp sl@0: // Depends on : none sl@0: sl@0: // Tests :- sl@0: // 1 Initialise a CParseLine sl@0: // 2 Process line : load & run a sample step sl@0: // 3 Run a sample panic step sl@0: // 4 Run a utility sl@0: // 11 CSuiteDLL initialise and verify sl@0: sl@0: // (NB these tests are to test the parser ONLY; the underlying functionality of the sl@0: // commands parsed is tested in CTestStep, CTestSuite, CTestUtils etc. suites) sl@0: sl@0: // --------------------- sl@0: // RTestMmTsthU0101 sl@0: sl@0: RTestMmTsthU0101* RTestMmTsthU0101::NewL() sl@0: { sl@0: RTestMmTsthU0101* self = new(ELeave) RTestMmTsthU0101; sl@0: return self; sl@0: } sl@0: sl@0: // Each test step initialises its own name. sl@0: RTestMmTsthU0101::RTestMmTsthU0101() sl@0: { sl@0: iTestStepName = _L("MM-TSTH-U-0101"); sl@0: } sl@0: sl@0: // preamble sl@0: TVerdict RTestMmTsthU0101::OpenL() sl@0: { sl@0: // don't call the default preamble sl@0: return iTestStepResult = EPass; sl@0: } sl@0: sl@0: // postamble sl@0: void RTestMmTsthU0101::Close() sl@0: { sl@0: // don't call the default postamble sl@0: } sl@0: sl@0: // Do the test step. sl@0: TVerdict RTestMmTsthU0101::DoTestStepL() sl@0: { sl@0: INFO_PRINTF1(_L("Unit test for Parseline")); sl@0: sl@0: TVerdict currentVerdict = EPass; sl@0: sl@0: // initialise a CParseLine sl@0: CLog* theLogClient = iSuite->LogSystem(); sl@0: CTestUtils* theTestUtils = CTestUtils::NewL(theLogClient); sl@0: TInt64 theGuardTimer (-1); sl@0: sl@0: CleanupStack::PushL(theTestUtils); sl@0: CScript* theParseScript = CScript::NewLC(theTestUtils, theLogClient, theGuardTimer, KNullDesC); sl@0: CParseLine* theParser = CParseLine::NewL(theParseScript, theTestUtils, theLogClient, theGuardTimer, KNullDesC); sl@0: CleanupStack::PushL(theParser); sl@0: sl@0: // if we got here, we're constructed successfully sl@0: INFO_PRINTF1(_L("CParseLine constructed successfully")); sl@0: sl@0: CleanupStack::PopAndDestroy(3); // theParser, theParseScript, theTestUtils sl@0: sl@0: return iTestStepResult = currentVerdict; sl@0: } sl@0: sl@0: sl@0: // --------------------- sl@0: // RTestMmTsthU0102 sl@0: sl@0: RTestMmTsthU0102* RTestMmTsthU0102::NewL() sl@0: { sl@0: RTestMmTsthU0102* self = new(ELeave) RTestMmTsthU0102; sl@0: return self; sl@0: } sl@0: sl@0: // Each test step initialises its own name. sl@0: RTestMmTsthU0102::RTestMmTsthU0102() sl@0: { sl@0: iTestStepName = _L("MM-TSTH-U-0102"); sl@0: } sl@0: sl@0: // Do the test step. sl@0: TVerdict RTestMmTsthU0102::DoTestStepL() sl@0: { sl@0: INFO_PRINTF1(_L("Unit test for ProcessLineL 1")); sl@0: sl@0: TVerdict currentVerdict = EPass; sl@0: _LIT8(KTestStepScriptLine1, "LOAD_SUITE TSU_MMTSTH01"); sl@0: _LIT8(KTestStepScriptLine2, "RUN_TEST_STEP 1000 TSU_MMTSTH01 RTestStepDummy"); sl@0: sl@0: TRAPD(err1, iParseLine->ProcessLineL(KTestStepScriptLine1, 1)); sl@0: if(err1 != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("ProcessLineL for LOAD_SUITE left, error code %d"), err1); sl@0: return iTestStepResult = EFail; sl@0: } sl@0: TRAPD(err2, iParseLine->ProcessLineL(KTestStepScriptLine2, 2)); sl@0: if(err2 != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("ProcessLineL for RUN_TEST_STEP left, error code %d"), err2); sl@0: return iTestStepResult = EFail; sl@0: } sl@0: sl@0: return iTestStepResult = currentVerdict; sl@0: } sl@0: sl@0: // --------------------- sl@0: // RTestMmTsthU0103 sl@0: sl@0: RTestMmTsthU0103* RTestMmTsthU0103::NewL() sl@0: { sl@0: RTestMmTsthU0103* self = new(ELeave) RTestMmTsthU0103; sl@0: return self; sl@0: } sl@0: sl@0: // Each test step initialises its own name. sl@0: RTestMmTsthU0103::RTestMmTsthU0103() sl@0: { sl@0: iTestStepName = _L("MM-TSTH-U-0103"); sl@0: } sl@0: sl@0: // Do the test step. sl@0: TVerdict RTestMmTsthU0103::DoTestStepL() sl@0: { sl@0: INFO_PRINTF1(_L("Unit test for ProcessLineL 2")); sl@0: sl@0: TVerdict currentVerdict = EPass; sl@0: _LIT8(KTestStepScriptLine1, "LOAD_SUITE TSU_MMTSTH01"); sl@0: _LIT8(KTestStepScriptLine2, "RUN_PANIC_STEP 1000 TSU_MMTSTH01 RPanicTestStepDummy, PanicDummy, 0"); sl@0: sl@0: TRAPD(err1, iParseLine->ProcessLineL(KTestStepScriptLine1, 1)); sl@0: if(err1 != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("ProcessLineL for LOAD_SUITE left, error code %d"), err1); sl@0: return iTestStepResult = EInconclusive; sl@0: } sl@0: TRAPD(err2, iParseLine->ProcessLineL(KTestStepScriptLine2, 2)); sl@0: if(err2 != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("ProcessLineL for RUN_PANIC_STEP left, error code %d"), err2); sl@0: return iTestStepResult = EFail; sl@0: } sl@0: sl@0: return iTestStepResult = currentVerdict; sl@0: } sl@0: sl@0: sl@0: // --------------------- sl@0: // RTestMmTsthU0104 sl@0: sl@0: RTestMmTsthU0104* RTestMmTsthU0104::NewL() sl@0: { sl@0: RTestMmTsthU0104* self = new(ELeave) RTestMmTsthU0104; sl@0: return self; sl@0: } sl@0: sl@0: // Each test step initialises its own name. sl@0: RTestMmTsthU0104::RTestMmTsthU0104() sl@0: { sl@0: iTestStepName = _L("MM-TSTH-U-0104"); sl@0: } sl@0: sl@0: // Do the test step. sl@0: TVerdict RTestMmTsthU0104::DoTestStepL() sl@0: { sl@0: sl@0: INFO_PRINTF1(_L("This test step is not available on EKA2 - Passing test!")); sl@0: return EPass; sl@0: sl@0: } sl@0: sl@0: // --------------------- sl@0: // RTestMmTsthU0111 sl@0: sl@0: RTestMmTsthU0111* RTestMmTsthU0111::NewL() sl@0: { sl@0: RTestMmTsthU0111* self = new(ELeave) RTestMmTsthU0111; sl@0: return self; sl@0: } sl@0: sl@0: // Each test step initialises its own name. sl@0: RTestMmTsthU0111::RTestMmTsthU0111() sl@0: { sl@0: iTestStepName = _L("MM-TSTH-U-0111"); sl@0: } sl@0: sl@0: // Do the test step. sl@0: TVerdict RTestMmTsthU0111::DoTestStepL() sl@0: { sl@0: INFO_PRINTF1(_L("Unit test for CSuiteDLL")); sl@0: sl@0: TVerdict currentVerdict = EPass; sl@0: sl@0: // create a new CSuiteDll object to store info on loaded DLL sl@0: _LIT(KTestSuiteName, "TSU_MMTSTH01"); sl@0: CSuiteDll* newRef = NULL; sl@0: TRAPD(err, newRef = CSuiteDll::NewL(KTestSuiteName, iLogClient)); sl@0: if(err != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("CSuiteDll::NewL left, error code %d"), err); sl@0: return iTestStepResult = EFail; sl@0: } sl@0: sl@0: // make sure it's not NULL, get its name out and see if it matches sl@0: CTestSuite* theTestSuite = newRef->Suite(); sl@0: if(theTestSuite == NULL) sl@0: { sl@0: ERR_PRINTF1(_L("CSuiteDll::Suite() is NULL")); sl@0: return iTestStepResult = EFail; sl@0: } sl@0: sl@0: TPtrC theName = newRef->Name(); sl@0: if (theName != KTestSuiteName) sl@0: { sl@0: ERR_PRINTF2(_L("CSuiteDll::Name() is %S"), &theName); sl@0: return iTestStepResult = EFail; sl@0: } sl@0: sl@0: return iTestStepResult = currentVerdict; sl@0: } sl@0: sl@0: // --------------------- sl@0: // Dummy test step for Parseline testing sl@0: sl@0: RTestStepDummy* RTestStepDummy::NewL() sl@0: { sl@0: RTestStepDummy* self = new(ELeave) RTestStepDummy; sl@0: return self; sl@0: } sl@0: sl@0: // Each test step initialises its own name. sl@0: RTestStepDummy::RTestStepDummy() sl@0: { sl@0: iTestStepName = _L("RTestStepDummy"); sl@0: } sl@0: sl@0: // Do the test step. sl@0: TVerdict RTestStepDummy::DoTestStepL() sl@0: { sl@0: INFO_PRINTF1(_L("Dummy step completed")); sl@0: sl@0: TVerdict currentVerdict = EPass; sl@0: sl@0: return iTestStepResult = currentVerdict; sl@0: } sl@0: sl@0: sl@0: // --------------------- sl@0: // Dummy panic test steps for Parseline testing sl@0: sl@0: RPanicTestStepDummy* RPanicTestStepDummy::NewL() sl@0: { sl@0: RPanicTestStepDummy* self = new(ELeave) RPanicTestStepDummy; sl@0: return self; sl@0: } sl@0: sl@0: // Each test step initialises its own name. sl@0: RPanicTestStepDummy::RPanicTestStepDummy() sl@0: { sl@0: iTestStepName = _L("RPanicTestStepDummy"); sl@0: } sl@0: sl@0: // Do the test step. sl@0: TVerdict RPanicTestStepDummy::DoTestStepL() sl@0: { sl@0: INFO_PRINTF1(_L("Dummy panic step running")); sl@0: User::Panic(_L("PanicDummy"), 0); sl@0: sl@0: // NB this code cannot be reached sl@0: TVerdict currentVerdict = EPass; sl@0: return iTestStepResult = currentVerdict; sl@0: } sl@0: sl@0: