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 02 : Script.cpp sl@0: // sl@0: // sl@0: sl@0: // EPOC includes sl@0: #include <e32base.h> sl@0: sl@0: // Test system includes sl@0: // Test system includes sl@0: #include <testframework.h> 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_MmTsthSuite02.h" sl@0: sl@0: // Specific includes for these test steps sl@0: #include "TSU_MmTsth02.h" sl@0: sl@0: // -------------------------------------------- sl@0: sl@0: // Unit Test Suite 02: Script.cpp sl@0: // Depends on : Parseline, FileName sl@0: sl@0: // Tests :- sl@0: // 1 construct a CScript sl@0: // 2 open a script file sl@0: // 3 execute a script file sl@0: // 12 add / display results (removed - the functionality is covered by Parseline tests 0102 and 0103) sl@0: sl@0: // --------------------- sl@0: // RTestMmTsthU0201 sl@0: sl@0: RTestMmTsthU0201* RTestMmTsthU0201::NewL() sl@0: { sl@0: RTestMmTsthU0201* self = new(ELeave) RTestMmTsthU0201; sl@0: return self; sl@0: } sl@0: sl@0: // Each test step initialises its own name. sl@0: RTestMmTsthU0201::RTestMmTsthU0201() sl@0: { sl@0: iTestStepName = _L("MM-TSTH-U-0201"); sl@0: } sl@0: sl@0: // Do the test step. sl@0: TVerdict RTestMmTsthU0201::DoTestStepL() sl@0: { sl@0: INFO_PRINTF1(_L("Unit test for Script : construction")); 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: CleanupStack::PushL(theTestUtils); sl@0: TInt64 defTime(-1); sl@0: CScript* theTestScript = CScript::NewLC(theTestUtils, theLogClient, defTime, KNullDesC); sl@0: sl@0: // if we got here, we're constructed successfully sl@0: INFO_PRINTF1(_L("CScript constructed successfully")); sl@0: sl@0: CleanupStack::PopAndDestroy(2); // theTestScript, theTestUtils sl@0: theTestScript = NULL; // just to remove warning sl@0: sl@0: return iTestStepResult = currentVerdict; // should be EPass if we've got here sl@0: } sl@0: sl@0: // --------------------- sl@0: // RTestMmTsthU0202 sl@0: sl@0: RTestMmTsthU0202* RTestMmTsthU0202::NewL() sl@0: { sl@0: RTestMmTsthU0202* self = new(ELeave) RTestMmTsthU0202; sl@0: return self; sl@0: } sl@0: sl@0: // Each test step initialises its own name. sl@0: RTestMmTsthU0202::RTestMmTsthU0202() sl@0: { sl@0: iTestStepName = _L("MM-TSTH-U-0202"); sl@0: } sl@0: sl@0: // Do the test step. sl@0: TVerdict RTestMmTsthU0202::DoTestStepL() sl@0: { sl@0: INFO_PRINTF1(_L("Unit test for Script - OpenScriptFile")); sl@0: sl@0: TVerdict currentVerdict = EPass; sl@0: sl@0: _LIT(KDummyScriptName, "TSU_MMTSTH02_DUMMY"); sl@0: CFileName* scriptFileName = CFileName::NewLC(); sl@0: *scriptFileName = KDummyScriptName; sl@0: if (iTestScript->OpenScriptFile(scriptFileName) == EFalse) sl@0: { sl@0: ERR_PRINTF2(_L("OpenScriptFile failed to open %S"), &KDummyScriptName()); sl@0: currentVerdict = EFail; sl@0: } sl@0: CleanupStack::PopAndDestroy(scriptFileName); sl@0: return iTestStepResult = currentVerdict; // should be EPass if we've got here sl@0: } sl@0: sl@0: // --------------------- sl@0: // RTestMmTsthU0203 sl@0: sl@0: RTestMmTsthU0203* RTestMmTsthU0203::NewL() sl@0: { sl@0: RTestMmTsthU0203* self = new(ELeave) RTestMmTsthU0203; sl@0: return self; sl@0: } sl@0: sl@0: // Each test step initialises its own name. sl@0: RTestMmTsthU0203::RTestMmTsthU0203() sl@0: { sl@0: iTestStepName = _L("MM-TSTH-U-0203"); sl@0: } sl@0: sl@0: // Do the test step. sl@0: TVerdict RTestMmTsthU0203::DoTestStepL() sl@0: { sl@0: INFO_PRINTF1(_L("Unit test for Script - ExecuteScriptL")); sl@0: sl@0: TVerdict currentVerdict = EPass; sl@0: sl@0: _LIT(KDummyScriptName, "TSU_MMTSTH02_DUMMY"); sl@0: CFileName* scriptFileName = CFileName::NewLC(); sl@0: *scriptFileName = KDummyScriptName; sl@0: if (iTestScript->OpenScriptFile(scriptFileName) == EFalse) sl@0: { sl@0: ERR_PRINTF2(_L("OpenScriptFile failed to open %S"), &KDummyScriptName()); sl@0: CleanupStack::PopAndDestroy(scriptFileName); sl@0: return iTestStepResult = EInconclusive; sl@0: } sl@0: sl@0: // execute the script sl@0: TVerdict theTestVerdict=EFail; sl@0: TRAPD(err, theTestVerdict = iTestScript->ExecuteScriptL()); sl@0: sl@0: if(err != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("ExecuteScriptL left with error code %d"), err); sl@0: currentVerdict = EFail; sl@0: } sl@0: else if (theTestVerdict!=EPass) sl@0: { sl@0: ERR_PRINTF2(_L("ExecuteScriptL returned with error %d"), theTestVerdict); sl@0: currentVerdict =theTestVerdict; sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(scriptFileName); sl@0: return iTestStepResult = currentVerdict; // should be EPass if we've got here sl@0: } sl@0: