1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmtestenv/mmtestfwunittest/src/tsu_mmtsth11/TSU_MmTsth11.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,305 @@
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 11 : TestStep.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_MmTsthStep11.h"
1.29 +#include "TSU_MmTsthSuite11.h"
1.30 +
1.31 +// Specific includes for these test steps
1.32 +#include "TSU_MmTsth11.h"
1.33 +#include "TestStepVirtualStub.h"
1.34 +#include "TestSuiteVirtualStub.h"
1.35 +
1.36 +// --------------------------------------------
1.37 +
1.38 +// Unit Test Suite 11 : TestStep.cpp
1.39 +// Depends on : none
1.40 +// Requires : subclass implementing pure virtual DoTestStepL()
1.41 +
1.42 +// Tests :-
1.43 +// RTestStep() constructor (thru stub)
1.44 +// test accessors
1.45 +// DoTestStepL
1.46 +// DoTestStepPreamble
1.47 +// DoTestStepPostamble
1.48 +// Load / unload config
1.49 +
1.50 +// ---------------------
1.51 +// RTestMmTsthU1101
1.52 +
1.53 +RTestMmTsthU1101* RTestMmTsthU1101::NewL()
1.54 + {
1.55 + RTestMmTsthU1101* self = new(ELeave) RTestMmTsthU1101;
1.56 + return self;
1.57 + }
1.58 +
1.59 +// Each test step initialises its own name.
1.60 +RTestMmTsthU1101::RTestMmTsthU1101()
1.61 + {
1.62 + iTestStepName = _L("MM-TSTH-U-1101");
1.63 + }
1.64 +
1.65 +
1.66 +// preamble
1.67 +TVerdict RTestMmTsthU1101::OpenL()
1.68 + {
1.69 + // stub - purpose is that for this test we do not run the parent preamble
1.70 + // which initialises iStepStub
1.71 + return iTestStepResult = EPass;
1.72 + }
1.73 +
1.74 +// postamble
1.75 +void RTestMmTsthU1101::Close()
1.76 + {
1.77 + }
1.78 +
1.79 +// do the test step
1.80 +TVerdict RTestMmTsthU1101::DoTestStepL()
1.81 + {
1.82 + INFO_PRINTF1(_L("Unit test for TestStep - construct"));
1.83 + TVerdict currentVerdict = EPass;
1.84 +
1.85 + RTestStepVirtualStub* theStepStub = NULL;
1.86 + TRAPD(err, theStepStub = RTestStepVirtualStub::NewL());
1.87 + if(err != KErrNone)
1.88 + {
1.89 + ERR_PRINTF1(_L("RTestStepVirtualStub::NewL() left"));
1.90 + return iTestStepResult = EFail;
1.91 + }
1.92 +
1.93 + const TPtrC& theName = theStepStub->StepName();
1.94 + if(theName != KTestStepVirtualStubName)
1.95 + {
1.96 + ERR_PRINTF1(_L("RTestStepVirtualStub did not initialise correctly"));
1.97 + delete theStepStub;
1.98 + return iTestStepResult = EFail;
1.99 + }
1.100 +
1.101 + delete theStepStub;
1.102 + return iTestStepResult = currentVerdict; // should be EPass if we've got here
1.103 + }
1.104 +
1.105 +// ------------------------
1.106 +// RTestMmTsthU1102
1.107 +RTestMmTsthU1102* RTestMmTsthU1102::NewL()
1.108 + {
1.109 + RTestMmTsthU1102* self = new(ELeave) RTestMmTsthU1102;
1.110 + return self;
1.111 + }
1.112 +
1.113 +// Each test step initialises its own name.
1.114 +RTestMmTsthU1102::RTestMmTsthU1102()
1.115 + {
1.116 + iTestStepName = _L("MM-TSTH-U-1102");
1.117 + }
1.118 +
1.119 +// do the test step
1.120 +TVerdict RTestMmTsthU1102::DoTestStepL()
1.121 + {
1.122 + // RTestStepVirtualStub contains extra methods by which we can verify our accessors
1.123 + INFO_PRINTF1(_L("Unit test for TestStep - accessors"));
1.124 +
1.125 + TVerdict currentVerdict = EPass;
1.126 +
1.127 + // test accessor to set name - not part of RTestStep
1.128 + TBufC<KMaxLenTestStepName> KTestStepName = _L("TestStepName");
1.129 + iStepStub->TestSetStepName(KTestStepName);
1.130 + const TPtrC& theName = iStepStub->StepName();
1.131 + if(theName != KTestStepName)
1.132 + {
1.133 + ERR_PRINTF1(_L("RTestStep::StepName() failed"));
1.134 + return iTestStepResult = EFail;
1.135 + }
1.136 +
1.137 + TVerdict theResult = EInconclusive;
1.138 + iStepStub->SetResult(theResult);
1.139 + // test accessor to get result - not part of RTestStep
1.140 + if(theResult != iStepStub->TestGetResult())
1.141 + {
1.142 + ERR_PRINTF1(_L("RTestStep::SetResult() failed"));
1.143 + return iTestStepResult = EFail;
1.144 + }
1.145 +
1.146 + CTestSuiteVirtualStub* theSuite = new (ELeave) CTestSuiteVirtualStub;
1.147 + CleanupStack::PushL(theSuite);
1.148 + theSuite->ConstructL();
1.149 +
1.150 + iStepStub->SetSuite(theSuite);
1.151 + // test accessor to get suite - not part of RTestStep
1.152 + if(theSuite != iStepStub->TestGetSuite())
1.153 + {
1.154 + ERR_PRINTF1(_L("RTestStep::SetSuite() failed"));
1.155 + CleanupStack::PopAndDestroy(); // theSuite
1.156 + return iTestStepResult = EFail;
1.157 + }
1.158 + // cleanup
1.159 + CleanupStack::PopAndDestroy(); // theSuite
1.160 +
1.161 + return iTestStepResult = currentVerdict; // should be EPass if we've got here
1.162 + }
1.163 +
1.164 +// ---------------------
1.165 +// RTestMmTsthU1103
1.166 +
1.167 +RTestMmTsthU1103* RTestMmTsthU1103::NewL()
1.168 + {
1.169 + RTestMmTsthU1103* self = new(ELeave) RTestMmTsthU1103;
1.170 + return self;
1.171 + }
1.172 +
1.173 +// Each test step initialises its own name.
1.174 +RTestMmTsthU1103::RTestMmTsthU1103()
1.175 + {
1.176 + iTestStepName = _L("MM-TSTH-U-1103");
1.177 + }
1.178 +
1.179 +// do the test step.
1.180 +TVerdict RTestMmTsthU1103::DoTestStepL()
1.181 + {
1.182 + // RTestStepVirtualStub contains extra methods by which we can verify our accessors
1.183 + INFO_PRINTF1(_L("Unit test for TestStep - preamble"));
1.184 +
1.185 + TVerdict currentVerdict = EPass;
1.186 +
1.187 + iStepStub->OpenL();
1.188 + if(!iStepStub->PreambleRun())
1.189 + {
1.190 + ERR_PRINTF1(_L("RTestStep::OpenL() failed"));
1.191 + return iTestStepResult = EFail;
1.192 + }
1.193 +
1.194 + return iTestStepResult = currentVerdict; // should be EPass if we've got here
1.195 + }
1.196 +
1.197 +// ---------------------
1.198 +// RTestMmTsthU1104
1.199 +
1.200 +RTestMmTsthU1104* RTestMmTsthU1104::NewL()
1.201 + {
1.202 + RTestMmTsthU1104* self = new(ELeave) RTestMmTsthU1104;
1.203 + return self;
1.204 + }
1.205 +
1.206 +// Each test step initialises its own name.
1.207 +RTestMmTsthU1104::RTestMmTsthU1104()
1.208 + {
1.209 + iTestStepName = _L("MM-TSTH-U-1104");
1.210 + }
1.211 +
1.212 +// do the test step
1.213 +TVerdict RTestMmTsthU1104::DoTestStepL()
1.214 + {
1.215 + // RTestStepVirtualStub contains extra methods by which we can verify our accessors
1.216 + INFO_PRINTF1(_L("Unit test for TestStep - postamble"));
1.217 +
1.218 + TVerdict currentVerdict = EPass;
1.219 +
1.220 + iStepStub->Close();
1.221 + if(!iStepStub->PostambleRun())
1.222 + {
1.223 + ERR_PRINTF1(_L("RTestStep::Close() failed"));
1.224 + return iTestStepResult = EFail;
1.225 + }
1.226 +
1.227 + return iTestStepResult = currentVerdict; // should be EPass if we've got here
1.228 + }
1.229 +
1.230 +// ---------------------
1.231 +// RTestMmTsthU1105
1.232 +RTestMmTsthU1105* RTestMmTsthU1105::NewL()
1.233 + {
1.234 + RTestMmTsthU1105* self = new(ELeave) RTestMmTsthU1105;
1.235 + return self;
1.236 + }
1.237 +
1.238 +// Each test step initialises its own name.
1.239 +RTestMmTsthU1105::RTestMmTsthU1105()
1.240 + {
1.241 + iTestStepName = _L("MM-TSTH-U-1105");
1.242 + }
1.243 +
1.244 +// do the test step
1.245 +TVerdict RTestMmTsthU1105::DoTestStepL()
1.246 + {
1.247 + // RTestStepVirtualStub contains extra methods by which we can verify our accessors
1.248 + INFO_PRINTF1(_L("Unit test for TestStep - step"));
1.249 +
1.250 + TVerdict currentVerdict = EPass;
1.251 +
1.252 + iStepStub->DoTestStepL();
1.253 + if(!iStepStub->StepRun())
1.254 + {
1.255 + ERR_PRINTF1(_L("RTestStep::DoTestStepL() failed"));
1.256 + return iTestStepResult = EFail;
1.257 + }
1.258 +
1.259 + return iTestStepResult = currentVerdict; // should be EPass if we've got here
1.260 + }
1.261 +
1.262 +// ------------------------
1.263 +// RTestMmTsthU1111
1.264 +RTestMmTsthU1111* RTestMmTsthU1111::NewL()
1.265 + {
1.266 + RTestMmTsthU1111* self = new(ELeave) RTestMmTsthU1111;
1.267 + return self;
1.268 + }
1.269 +
1.270 +// Each test step initialises its own name.
1.271 +RTestMmTsthU1111::RTestMmTsthU1111()
1.272 + {
1.273 + iTestStepName = _L("MM-TSTH-U-1111");
1.274 + }
1.275 +
1.276 +// do the test step
1.277 +TVerdict RTestMmTsthU1111::DoTestStepL()
1.278 + {
1.279 + const TInt KTestBufSize = 64;
1.280 +
1.281 + // RTestStepVirtualStub contains extra methods by which we can verify our accessors
1.282 + INFO_PRINTF1(_L("Unit test for TestStep - load config"));
1.283 +
1.284 + TVerdict currentVerdict = EPass;
1.285 +
1.286 + TBufC<KTestBufSize> KConfigName = _L("TSU_MMTSTH11_config.ini");
1.287 + iStepStub->LoadConfig(KConfigName);
1.288 +
1.289 + // we get no return saying that the file hasn't loaded -
1.290 + // therefore check something in the file we know is there : [SectionOne] keybool = true
1.291 + // because these functions are protected, we have to wrap them in iStepStub
1.292 +
1.293 + TBool aBoolResult;
1.294 + TBool returnValue = iStepStub->TestGetBoolFromConfig(_L("SectionOne"),_L("Keybool"), aBoolResult);
1.295 + if(!returnValue)
1.296 + {
1.297 + ERR_PRINTF1(_L("RTestStep::LoadConfig() failed"));
1.298 + iStepStub->UnloadConfig();
1.299 + return iTestStepResult = EFail;
1.300 + }
1.301 +
1.302 + iStepStub->UnloadConfig();
1.303 + return iTestStepResult = currentVerdict; // should be EPass if we've got here
1.304 + }
1.305 +
1.306 +// ------------------------
1.307 +
1.308 +