Update contrib.
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // This file contains the test steps for Unit Test Suite 11 : TestStep.cpp
21 // Test system includes
22 #include <testframework.h>
24 // Specific includes for this test suite
25 #include "TSU_MmTsthStep11.h"
26 #include "TSU_MmTsthSuite11.h"
28 // Specific includes for these test steps
29 #include "TSU_MmTsth11.h"
30 #include "TestStepVirtualStub.h"
31 #include "TestSuiteVirtualStub.h"
33 // --------------------------------------------
35 // Unit Test Suite 11 : TestStep.cpp
37 // Requires : subclass implementing pure virtual DoTestStepL()
40 // RTestStep() constructor (thru stub)
44 // DoTestStepPostamble
45 // Load / unload config
47 // ---------------------
50 RTestMmTsthU1101* RTestMmTsthU1101::NewL()
52 RTestMmTsthU1101* self = new(ELeave) RTestMmTsthU1101;
56 // Each test step initialises its own name.
57 RTestMmTsthU1101::RTestMmTsthU1101()
59 iTestStepName = _L("MM-TSTH-U-1101");
64 TVerdict RTestMmTsthU1101::OpenL()
66 // stub - purpose is that for this test we do not run the parent preamble
67 // which initialises iStepStub
68 return iTestStepResult = EPass;
72 void RTestMmTsthU1101::Close()
77 TVerdict RTestMmTsthU1101::DoTestStepL()
79 INFO_PRINTF1(_L("Unit test for TestStep - construct"));
80 TVerdict currentVerdict = EPass;
82 RTestStepVirtualStub* theStepStub = NULL;
83 TRAPD(err, theStepStub = RTestStepVirtualStub::NewL());
86 ERR_PRINTF1(_L("RTestStepVirtualStub::NewL() left"));
87 return iTestStepResult = EFail;
90 const TPtrC& theName = theStepStub->StepName();
91 if(theName != KTestStepVirtualStubName)
93 ERR_PRINTF1(_L("RTestStepVirtualStub did not initialise correctly"));
95 return iTestStepResult = EFail;
99 return iTestStepResult = currentVerdict; // should be EPass if we've got here
102 // ------------------------
104 RTestMmTsthU1102* RTestMmTsthU1102::NewL()
106 RTestMmTsthU1102* self = new(ELeave) RTestMmTsthU1102;
110 // Each test step initialises its own name.
111 RTestMmTsthU1102::RTestMmTsthU1102()
113 iTestStepName = _L("MM-TSTH-U-1102");
117 TVerdict RTestMmTsthU1102::DoTestStepL()
119 // RTestStepVirtualStub contains extra methods by which we can verify our accessors
120 INFO_PRINTF1(_L("Unit test for TestStep - accessors"));
122 TVerdict currentVerdict = EPass;
124 // test accessor to set name - not part of RTestStep
125 TBufC<KMaxLenTestStepName> KTestStepName = _L("TestStepName");
126 iStepStub->TestSetStepName(KTestStepName);
127 const TPtrC& theName = iStepStub->StepName();
128 if(theName != KTestStepName)
130 ERR_PRINTF1(_L("RTestStep::StepName() failed"));
131 return iTestStepResult = EFail;
134 TVerdict theResult = EInconclusive;
135 iStepStub->SetResult(theResult);
136 // test accessor to get result - not part of RTestStep
137 if(theResult != iStepStub->TestGetResult())
139 ERR_PRINTF1(_L("RTestStep::SetResult() failed"));
140 return iTestStepResult = EFail;
143 CTestSuiteVirtualStub* theSuite = new (ELeave) CTestSuiteVirtualStub;
144 CleanupStack::PushL(theSuite);
145 theSuite->ConstructL();
147 iStepStub->SetSuite(theSuite);
148 // test accessor to get suite - not part of RTestStep
149 if(theSuite != iStepStub->TestGetSuite())
151 ERR_PRINTF1(_L("RTestStep::SetSuite() failed"));
152 CleanupStack::PopAndDestroy(); // theSuite
153 return iTestStepResult = EFail;
156 CleanupStack::PopAndDestroy(); // theSuite
158 return iTestStepResult = currentVerdict; // should be EPass if we've got here
161 // ---------------------
164 RTestMmTsthU1103* RTestMmTsthU1103::NewL()
166 RTestMmTsthU1103* self = new(ELeave) RTestMmTsthU1103;
170 // Each test step initialises its own name.
171 RTestMmTsthU1103::RTestMmTsthU1103()
173 iTestStepName = _L("MM-TSTH-U-1103");
177 TVerdict RTestMmTsthU1103::DoTestStepL()
179 // RTestStepVirtualStub contains extra methods by which we can verify our accessors
180 INFO_PRINTF1(_L("Unit test for TestStep - preamble"));
182 TVerdict currentVerdict = EPass;
185 if(!iStepStub->PreambleRun())
187 ERR_PRINTF1(_L("RTestStep::OpenL() failed"));
188 return iTestStepResult = EFail;
191 return iTestStepResult = currentVerdict; // should be EPass if we've got here
194 // ---------------------
197 RTestMmTsthU1104* RTestMmTsthU1104::NewL()
199 RTestMmTsthU1104* self = new(ELeave) RTestMmTsthU1104;
203 // Each test step initialises its own name.
204 RTestMmTsthU1104::RTestMmTsthU1104()
206 iTestStepName = _L("MM-TSTH-U-1104");
210 TVerdict RTestMmTsthU1104::DoTestStepL()
212 // RTestStepVirtualStub contains extra methods by which we can verify our accessors
213 INFO_PRINTF1(_L("Unit test for TestStep - postamble"));
215 TVerdict currentVerdict = EPass;
218 if(!iStepStub->PostambleRun())
220 ERR_PRINTF1(_L("RTestStep::Close() failed"));
221 return iTestStepResult = EFail;
224 return iTestStepResult = currentVerdict; // should be EPass if we've got here
227 // ---------------------
229 RTestMmTsthU1105* RTestMmTsthU1105::NewL()
231 RTestMmTsthU1105* self = new(ELeave) RTestMmTsthU1105;
235 // Each test step initialises its own name.
236 RTestMmTsthU1105::RTestMmTsthU1105()
238 iTestStepName = _L("MM-TSTH-U-1105");
242 TVerdict RTestMmTsthU1105::DoTestStepL()
244 // RTestStepVirtualStub contains extra methods by which we can verify our accessors
245 INFO_PRINTF1(_L("Unit test for TestStep - step"));
247 TVerdict currentVerdict = EPass;
249 iStepStub->DoTestStepL();
250 if(!iStepStub->StepRun())
252 ERR_PRINTF1(_L("RTestStep::DoTestStepL() failed"));
253 return iTestStepResult = EFail;
256 return iTestStepResult = currentVerdict; // should be EPass if we've got here
259 // ------------------------
261 RTestMmTsthU1111* RTestMmTsthU1111::NewL()
263 RTestMmTsthU1111* self = new(ELeave) RTestMmTsthU1111;
267 // Each test step initialises its own name.
268 RTestMmTsthU1111::RTestMmTsthU1111()
270 iTestStepName = _L("MM-TSTH-U-1111");
274 TVerdict RTestMmTsthU1111::DoTestStepL()
276 const TInt KTestBufSize = 64;
278 // RTestStepVirtualStub contains extra methods by which we can verify our accessors
279 INFO_PRINTF1(_L("Unit test for TestStep - load config"));
281 TVerdict currentVerdict = EPass;
283 TBufC<KTestBufSize> KConfigName = _L("TSU_MMTSTH11_config.ini");
284 iStepStub->LoadConfig(KConfigName);
286 // we get no return saying that the file hasn't loaded -
287 // therefore check something in the file we know is there : [SectionOne] keybool = true
288 // because these functions are protected, we have to wrap them in iStepStub
291 TBool returnValue = iStepStub->TestGetBoolFromConfig(_L("SectionOne"),_L("Keybool"), aBoolResult);
294 ERR_PRINTF1(_L("RTestStep::LoadConfig() failed"));
295 iStepStub->UnloadConfig();
296 return iTestStepResult = EFail;
299 iStepStub->UnloadConfig();
300 return iTestStepResult = currentVerdict; // should be EPass if we've got here
303 // ------------------------