os/mm/mmtestenv/mmtestfwunittest/src/tsu_mmtsth02/TSU_MmTsth02.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmtestenv/mmtestfwunittest/src/tsu_mmtsth02/TSU_MmTsth02.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,167 @@
     1.4 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// This file contains the test steps for Unit Test Suite 02 : Script.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +// EPOC includes
    1.22 +#include <e32base.h>
    1.23 +
    1.24 +// Test system includes
    1.25 +// Test system includes
    1.26 +#include <testframework.h>
    1.27 +#include "script.h"
    1.28 +#include "parseline.h"
    1.29 +#include "Filename.h"
    1.30 +
    1.31 +// Specific includes for this test suite
    1.32 +#include "TSU_MmTsthSuite02.h"
    1.33 +
    1.34 +// Specific includes for these test steps
    1.35 +#include "TSU_MmTsth02.h"
    1.36 +
    1.37 +// --------------------------------------------
    1.38 +
    1.39 +// Unit Test Suite 02: Script.cpp
    1.40 +// Depends on : Parseline, FileName
    1.41 +
    1.42 +// Tests :-
    1.43 +// 1 construct a CScript
    1.44 +// 2 open a script file
    1.45 +// 3 execute a script file
    1.46 +// 12 add / display results	(removed - the functionality is covered by Parseline tests 0102 and 0103)
    1.47 + 
    1.48 +// ---------------------
    1.49 +// RTestMmTsthU0201
    1.50 +
    1.51 +RTestMmTsthU0201* RTestMmTsthU0201::NewL()
    1.52 +	{
    1.53 +	RTestMmTsthU0201* self = new(ELeave) RTestMmTsthU0201;
    1.54 +	return self;
    1.55 +	}
    1.56 +
    1.57 +// Each test step initialises its own name.
    1.58 +RTestMmTsthU0201::RTestMmTsthU0201()
    1.59 +	{
    1.60 +	iTestStepName = _L("MM-TSTH-U-0201");
    1.61 +	}
    1.62 +
    1.63 +// Do the test step.
    1.64 +TVerdict RTestMmTsthU0201::DoTestStepL()
    1.65 +	{
    1.66 +	INFO_PRINTF1(_L("Unit test for Script : construction"));
    1.67 +
    1.68 +	TVerdict currentVerdict = EPass;
    1.69 +
    1.70 +	// initialise a CParseLine
    1.71 +	CLog* theLogClient  = iSuite->LogSystem();
    1.72 +	CTestUtils* theTestUtils  = CTestUtils::NewL(theLogClient);
    1.73 +	CleanupStack::PushL(theTestUtils);
    1.74 +	TInt64 defTime(-1);
    1.75 +	CScript* theTestScript = CScript::NewLC(theTestUtils, theLogClient, defTime, KNullDesC);
    1.76 +
    1.77 +	// if we got here, we're constructed successfully
    1.78 +	INFO_PRINTF1(_L("CScript constructed successfully"));
    1.79 +
    1.80 +	CleanupStack::PopAndDestroy(2); // theTestScript, theTestUtils
    1.81 +	theTestScript = NULL; // just to remove warning
    1.82 +
    1.83 +	return iTestStepResult = currentVerdict; // should be EPass if we've got here
    1.84 +	}
    1.85 +
    1.86 +// ---------------------
    1.87 +// RTestMmTsthU0202
    1.88 +
    1.89 +RTestMmTsthU0202* RTestMmTsthU0202::NewL()
    1.90 +	{
    1.91 +	RTestMmTsthU0202* self = new(ELeave) RTestMmTsthU0202;
    1.92 +	return self;
    1.93 +	}
    1.94 +
    1.95 +// Each test step initialises its own name.
    1.96 +RTestMmTsthU0202::RTestMmTsthU0202()
    1.97 +	{
    1.98 +	iTestStepName = _L("MM-TSTH-U-0202");
    1.99 +	}
   1.100 +
   1.101 +// Do the test step.
   1.102 +TVerdict RTestMmTsthU0202::DoTestStepL()
   1.103 +	{
   1.104 +	INFO_PRINTF1(_L("Unit test for Script - OpenScriptFile"));
   1.105 +
   1.106 +	TVerdict currentVerdict = EPass;
   1.107 +
   1.108 +	_LIT(KDummyScriptName, "TSU_MMTSTH02_DUMMY");
   1.109 +	CFileName* scriptFileName = CFileName::NewLC();
   1.110 +	*scriptFileName = KDummyScriptName;
   1.111 +	if (iTestScript->OpenScriptFile(scriptFileName) == EFalse)
   1.112 +	{
   1.113 +		ERR_PRINTF2(_L("OpenScriptFile failed to open %S"), &KDummyScriptName());
   1.114 +		currentVerdict = EFail;
   1.115 +	}
   1.116 +	CleanupStack::PopAndDestroy(scriptFileName);
   1.117 +	return iTestStepResult = currentVerdict; // should be EPass if we've got here
   1.118 +	}
   1.119 +
   1.120 +// ---------------------
   1.121 +// RTestMmTsthU0203
   1.122 +
   1.123 +RTestMmTsthU0203* RTestMmTsthU0203::NewL()
   1.124 +	{
   1.125 +	RTestMmTsthU0203* self = new(ELeave) RTestMmTsthU0203;
   1.126 +	return self;
   1.127 +	}
   1.128 +
   1.129 +// Each test step initialises its own name.
   1.130 +RTestMmTsthU0203::RTestMmTsthU0203()
   1.131 +	{
   1.132 +	iTestStepName = _L("MM-TSTH-U-0203");
   1.133 +	}
   1.134 +
   1.135 +// Do the test step.
   1.136 +TVerdict RTestMmTsthU0203::DoTestStepL()
   1.137 +	{
   1.138 +	INFO_PRINTF1(_L("Unit test for Script - ExecuteScriptL"));
   1.139 +
   1.140 +	TVerdict currentVerdict = EPass;
   1.141 +
   1.142 +	_LIT(KDummyScriptName, "TSU_MMTSTH02_DUMMY");
   1.143 +	CFileName* scriptFileName = CFileName::NewLC();
   1.144 +	*scriptFileName = KDummyScriptName;
   1.145 +	if (iTestScript->OpenScriptFile(scriptFileName) == EFalse)
   1.146 +		{
   1.147 +		ERR_PRINTF2(_L("OpenScriptFile failed to open %S"), &KDummyScriptName());
   1.148 +		CleanupStack::PopAndDestroy(scriptFileName);
   1.149 +		return iTestStepResult = EInconclusive;
   1.150 +		}
   1.151 +
   1.152 +	// execute the script
   1.153 +	TVerdict theTestVerdict=EFail;
   1.154 +	TRAPD(err, theTestVerdict = iTestScript->ExecuteScriptL());
   1.155 +
   1.156 +	if(err != KErrNone)
   1.157 +		{
   1.158 +		ERR_PRINTF2(_L("ExecuteScriptL left with error code %d"), err);
   1.159 +		currentVerdict = EFail;
   1.160 +		}
   1.161 +	else if (theTestVerdict!=EPass)
   1.162 +		{
   1.163 +		ERR_PRINTF2(_L("ExecuteScriptL returned with error  %d"), theTestVerdict);
   1.164 +		currentVerdict =theTestVerdict;
   1.165 +		}
   1.166 +
   1.167 +	CleanupStack::PopAndDestroy(scriptFileName);
   1.168 +	return iTestStepResult = currentVerdict; // should be EPass if we've got here
   1.169 +	}
   1.170 +