os/mm/mmtestenv/mmtestfwunittest/src/tsu_mmtsth12/TSU_MmTsth12.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_mmtsth12/TSU_MmTsth12.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,270 @@
     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 12 : TestSuite.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 +#include <testframework.h>
    1.26 +
    1.27 +// Specific includes for this test suite
    1.28 +#include "TSU_MmTsthStep12.h"
    1.29 +#include "TSU_MmTsthSuite12.h"
    1.30 +
    1.31 +// Specific includes for these test steps
    1.32 +#include "TSU_MmTsth12.h"
    1.33 +
    1.34 +// --------------------------------------------
    1.35 +
    1.36 +// Unit Test Suite 12 : TestSuite.cpp
    1.37 +// Depends on : TestStep
    1.38 +
    1.39 +// Tests :-
    1.40 +// 1 ConstructL / InitialiseL
    1.41 +// 2 AddTestStepL
    1.42 +// 3 DoTestStep
    1.43 +// 11 Log - not tested explicitly (if things are logging, it's working!)
    1.44 +// 12 LogExtra - not tested explicitly
    1.45 +// 21 GetVersion
    1.46 +// 22 accessors
    1.47 +
    1.48 +// ---------------------
    1.49 +// RTestMmTsthU1201
    1.50 +RTestMmTsthU1201* RTestMmTsthU1201::NewL()
    1.51 +	{
    1.52 +	RTestMmTsthU1201* self = new(ELeave) RTestMmTsthU1201;
    1.53 +	return self;
    1.54 +	}
    1.55 +
    1.56 +// Each test step initialises its own name.
    1.57 +RTestMmTsthU1201::RTestMmTsthU1201()
    1.58 +	{
    1.59 +	iTestStepName = _L("MM-TSTH-U-1201");
    1.60 +	}
    1.61 +
    1.62 +// preamble
    1.63 +TVerdict RTestMmTsthU1201::OpenL()
    1.64 +	{
    1.65 +	// stub - purpose is that for this test we do not run the parent preamble
    1.66 +	// which initialises iStepStub
    1.67 +	return iTestStepResult = EPass;
    1.68 +	}
    1.69 +
    1.70 +// postamble
    1.71 +void RTestMmTsthU1201::Close()
    1.72 +	{
    1.73 +	}
    1.74 +
    1.75 +// do the test step
    1.76 +TVerdict RTestMmTsthU1201::DoTestStepL()
    1.77 +	{
    1.78 +	INFO_PRINTF1(_L("Unit test for TestSuite - ConstructL / InitialiseL"));
    1.79 +
    1.80 +	TVerdict currentVerdict = EPass;
    1.81 +
    1.82 +	CTestSuiteVirtualStub* theSuiteStub = new (ELeave) CTestSuiteVirtualStub;
    1.83 +	CleanupStack::PushL(theSuiteStub);
    1.84 +	TRAPD(err, theSuiteStub->ConstructL());
    1.85 +	if(err != KErrNone)
    1.86 +		{
    1.87 +		ERR_PRINTF1(_L("CTestSuiteVirtualStub::ConstructL() left"));
    1.88 +		CleanupStack::PopAndDestroy(theSuiteStub);
    1.89 +		return iTestStepResult = EFail;
    1.90 +		}
    1.91 +	iSuiteStub = theSuiteStub;
    1.92 +
    1.93 +	// NB ensure the suite can log - set its logger to ours
    1.94 +	iSuiteStub->SetLogSystem(iSuite->LogSystem());
    1.95 +
    1.96 +	// ConstructL calls InitialiseL.
    1.97 +	// the suite should be called TestSuiteVirtualStub and contain one step, TestStepVirtualStub
    1.98 +	// we can't access this direct but we can run DoTestStep() on it,
    1.99 +	// and any error code other than ETestSuiteError is a pass
   1.100 +	
   1.101 +	TVerdict stepVerdict = iSuiteStub->DoTestStep(_L("TestStepVirtualStub"), KNullDesC, KNullDesC);
   1.102 +	if(stepVerdict == ETestSuiteError)
   1.103 +	{
   1.104 +		ERR_PRINTF1(_L("RTestSuiteVirtualStub::InitialiseL() did not setup test step"));
   1.105 +		CleanupStack::PopAndDestroy(theSuiteStub);
   1.106 +		return iTestStepResult = EFail;
   1.107 +	}
   1.108 +
   1.109 +	CleanupStack::PopAndDestroy(theSuiteStub);
   1.110 +	iSuiteStub = NULL;
   1.111 +
   1.112 +	return iTestStepResult = currentVerdict; // should be EPass if we've got here
   1.113 +	}
   1.114 +
   1.115 +// ------------------------
   1.116 +// RTestMmTsthU1202
   1.117 +
   1.118 +RTestMmTsthU1202* RTestMmTsthU1202::NewL()
   1.119 +	{
   1.120 +	RTestMmTsthU1202* self = new(ELeave) RTestMmTsthU1202;
   1.121 +	return self;
   1.122 +	}
   1.123 +
   1.124 +// Each test step initialises its own name.
   1.125 +RTestMmTsthU1202::RTestMmTsthU1202()
   1.126 +	{
   1.127 +	iTestStepName = _L("MM-TSTH-U-1202");
   1.128 +	}
   1.129 +
   1.130 +// do the test step
   1.131 +TVerdict RTestMmTsthU1202::DoTestStepL()
   1.132 +	{
   1.133 +	INFO_PRINTF1(_L("Unit test for TestSuite - AddTestStepL"));
   1.134 +
   1.135 +	TVerdict currentVerdict = EPass;
   1.136 +
   1.137 +	TRAPD(err, iSuiteStub->AddTestStepL(RTestStepVirtualStub2::NewL()));
   1.138 +	if(err != KErrNone)
   1.139 +		{
   1.140 +		ERR_PRINTF1(_L("RTestSuiteVirtualStub::AddTestStepL() left"));
   1.141 +		return iTestStepResult = EFail;
   1.142 +		}
   1.143 +
   1.144 +	// find the step we just added
   1.145 +	TVerdict stepVerdict = iSuiteStub->DoTestStep(_L("TestStepVirtualStub2"), KNullDesC, KNullDesC);
   1.146 +	if(stepVerdict == ETestSuiteError)
   1.147 +		{
   1.148 +		ERR_PRINTF1(_L("RTestSuiteVirtualStub::AddTestStepL() failed"));
   1.149 +		return iTestStepResult = EFail;
   1.150 +		}
   1.151 +
   1.152 +	// no pop / delete - the SUITE owns the step, we don't.
   1.153 +	return iTestStepResult = currentVerdict; // should be EPass if we've got here
   1.154 +	}
   1.155 +
   1.156 +// ------------------------
   1.157 +// RTestMmTsthU1203
   1.158 +
   1.159 +RTestMmTsthU1203* RTestMmTsthU1203::NewL()
   1.160 +	{
   1.161 +	RTestMmTsthU1203* self = new(ELeave) RTestMmTsthU1203;
   1.162 +	return self;
   1.163 +	}
   1.164 +
   1.165 +// Each test step initialises its own name.
   1.166 +RTestMmTsthU1203::RTestMmTsthU1203()
   1.167 +	{
   1.168 +	iTestStepName = _L("MM-TSTH-U-1203");
   1.169 +	}
   1.170 +
   1.171 +// do the test step
   1.172 +TVerdict RTestMmTsthU1203::DoTestStepL()
   1.173 +	{
   1.174 +	INFO_PRINTF1(_L("Unit test for TestSuite - DoTestStepL"));
   1.175 +
   1.176 +	TVerdict currentVerdict = EPass;
   1.177 +
   1.178 +	// do the step. this time we're testing for PASS only
   1.179 +	TVerdict stepVerdict = iSuiteStub->DoTestStep(_L("TestStepVirtualStub"), KNullDesC, KNullDesC);
   1.180 +	if(stepVerdict != EPass)
   1.181 +		{
   1.182 +		ERR_PRINTF1(_L("RTestSuiteVirtualStub::DoTestStepL() failed"));
   1.183 +		return iTestStepResult = EFail;
   1.184 +		}
   1.185 +
   1.186 +	return iTestStepResult = currentVerdict; // should be EPass if we've got here
   1.187 +	}
   1.188 +
   1.189 +// ------------------------
   1.190 +// RTestMmTsthU1221
   1.191 +
   1.192 +RTestMmTsthU1221* RTestMmTsthU1221::NewL()
   1.193 +	{
   1.194 +	RTestMmTsthU1221* self = new(ELeave) RTestMmTsthU1221;
   1.195 +	return self;
   1.196 +	}
   1.197 +
   1.198 +// Each test step initialises its own name.
   1.199 +RTestMmTsthU1221::RTestMmTsthU1221()
   1.200 +	{
   1.201 +	iTestStepName = _L("MM-TSTH-U-1221");
   1.202 +	}
   1.203 +
   1.204 +// do the test step
   1.205 +TVerdict RTestMmTsthU1221::DoTestStepL()
   1.206 +	{
   1.207 +	INFO_PRINTF1(_L("Unit test for TestSuite - GetVersion"));
   1.208 +
   1.209 +	TVerdict currentVerdict = EPass;
   1.210 +
   1.211 +	// get the version, compare it against our known value
   1.212 +	_LIT(KTestVersion,"CTestSuiteVirtualStub Version");
   1.213 +	TPtrC version = iSuiteStub->GetVersion();
   1.214 +	if(version != KTestVersion)
   1.215 +		{
   1.216 +		ERR_PRINTF1(_L("RTestSuiteVirtualStub::GetVersion() failed"));
   1.217 +		return iTestStepResult = EFail;
   1.218 +		}
   1.219 +
   1.220 +	return iTestStepResult = currentVerdict; // should be EPass if we've got here
   1.221 +	}
   1.222 +
   1.223 +// ------------------------
   1.224 +// RTestMmTsthU1222
   1.225 +
   1.226 +RTestMmTsthU1222* RTestMmTsthU1222::NewL()
   1.227 +	{
   1.228 +	RTestMmTsthU1222* self = new(ELeave) RTestMmTsthU1222;
   1.229 +	return self;
   1.230 +	}
   1.231 +
   1.232 +// Each test step initialises its own name.
   1.233 +RTestMmTsthU1222::RTestMmTsthU1222()
   1.234 +	{
   1.235 +	iTestStepName = _L("MM-TSTH-U-1222");
   1.236 +	}
   1.237 +
   1.238 +// do the test step.
   1.239 +TVerdict RTestMmTsthU1222::DoTestStepL()
   1.240 +	{
   1.241 +	INFO_PRINTF1(_L("Unit test for TestSuite - accessors"));
   1.242 +
   1.243 +	TVerdict currentVerdict = EPass;
   1.244 +
   1.245 +	iSuiteStub->SetSeverity(ESevrInfo);
   1.246 +	TInt theSev = iSuiteStub->Severity();
   1.247 +	if(theSev != ESevrInfo)
   1.248 +		{
   1.249 +		ERR_PRINTF1(_L("CTestSuite::SetSeverity() failed"));
   1.250 +		return iTestStepResult = EFail;
   1.251 +		}
   1.252 +
   1.253 +	iSuiteStub->SetStepStatus(EStepStatusFinished);
   1.254 +	TTestStepStatus theStepStatus = iSuiteStub->StepStatus();
   1.255 +	if(theStepStatus != EStepStatusFinished)
   1.256 +		{
   1.257 +		ERR_PRINTF1(_L("CTestSuite::SetStepStatus() failed"));
   1.258 +		return iTestStepResult = EFail;
   1.259 +		}
   1.260 +
   1.261 +	CLog* theLog = CLog::NewL();
   1.262 +	iSuiteStub->SetLogSystem(theLog);
   1.263 +	CLog* theLogSystem = iSuiteStub->LogSystem();
   1.264 +	if(theLog != theLogSystem)
   1.265 +		{
   1.266 +		ERR_PRINTF1(_L("CTestSuite::SetLogSystem() failed"));
   1.267 +		delete theLog;
   1.268 +		return iTestStepResult = EFail;
   1.269 +		}
   1.270 +
   1.271 +	delete theLog;
   1.272 +	return iTestStepResult = currentVerdict; // should be EPass if we've got here
   1.273 +	}