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 12 : TestSuite.cpp
21 // Test system includes
22 #include <testframework.h>
24 // Specific includes for this test suite
25 #include "TSU_MmTsthStep12.h"
26 #include "TSU_MmTsthSuite12.h"
28 // Specific includes for these test steps
29 #include "TSU_MmTsth12.h"
31 // --------------------------------------------
33 // Unit Test Suite 12 : TestSuite.cpp
34 // Depends on : TestStep
37 // 1 ConstructL / InitialiseL
40 // 11 Log - not tested explicitly (if things are logging, it's working!)
41 // 12 LogExtra - not tested explicitly
45 // ---------------------
47 RTestMmTsthU1201* RTestMmTsthU1201::NewL()
49 RTestMmTsthU1201* self = new(ELeave) RTestMmTsthU1201;
53 // Each test step initialises its own name.
54 RTestMmTsthU1201::RTestMmTsthU1201()
56 iTestStepName = _L("MM-TSTH-U-1201");
60 TVerdict RTestMmTsthU1201::OpenL()
62 // stub - purpose is that for this test we do not run the parent preamble
63 // which initialises iStepStub
64 return iTestStepResult = EPass;
68 void RTestMmTsthU1201::Close()
73 TVerdict RTestMmTsthU1201::DoTestStepL()
75 INFO_PRINTF1(_L("Unit test for TestSuite - ConstructL / InitialiseL"));
77 TVerdict currentVerdict = EPass;
79 CTestSuiteVirtualStub* theSuiteStub = new (ELeave) CTestSuiteVirtualStub;
80 CleanupStack::PushL(theSuiteStub);
81 TRAPD(err, theSuiteStub->ConstructL());
84 ERR_PRINTF1(_L("CTestSuiteVirtualStub::ConstructL() left"));
85 CleanupStack::PopAndDestroy(theSuiteStub);
86 return iTestStepResult = EFail;
88 iSuiteStub = theSuiteStub;
90 // NB ensure the suite can log - set its logger to ours
91 iSuiteStub->SetLogSystem(iSuite->LogSystem());
93 // ConstructL calls InitialiseL.
94 // the suite should be called TestSuiteVirtualStub and contain one step, TestStepVirtualStub
95 // we can't access this direct but we can run DoTestStep() on it,
96 // and any error code other than ETestSuiteError is a pass
98 TVerdict stepVerdict = iSuiteStub->DoTestStep(_L("TestStepVirtualStub"), KNullDesC, KNullDesC);
99 if(stepVerdict == ETestSuiteError)
101 ERR_PRINTF1(_L("RTestSuiteVirtualStub::InitialiseL() did not setup test step"));
102 CleanupStack::PopAndDestroy(theSuiteStub);
103 return iTestStepResult = EFail;
106 CleanupStack::PopAndDestroy(theSuiteStub);
109 return iTestStepResult = currentVerdict; // should be EPass if we've got here
112 // ------------------------
115 RTestMmTsthU1202* RTestMmTsthU1202::NewL()
117 RTestMmTsthU1202* self = new(ELeave) RTestMmTsthU1202;
121 // Each test step initialises its own name.
122 RTestMmTsthU1202::RTestMmTsthU1202()
124 iTestStepName = _L("MM-TSTH-U-1202");
128 TVerdict RTestMmTsthU1202::DoTestStepL()
130 INFO_PRINTF1(_L("Unit test for TestSuite - AddTestStepL"));
132 TVerdict currentVerdict = EPass;
134 TRAPD(err, iSuiteStub->AddTestStepL(RTestStepVirtualStub2::NewL()));
137 ERR_PRINTF1(_L("RTestSuiteVirtualStub::AddTestStepL() left"));
138 return iTestStepResult = EFail;
141 // find the step we just added
142 TVerdict stepVerdict = iSuiteStub->DoTestStep(_L("TestStepVirtualStub2"), KNullDesC, KNullDesC);
143 if(stepVerdict == ETestSuiteError)
145 ERR_PRINTF1(_L("RTestSuiteVirtualStub::AddTestStepL() failed"));
146 return iTestStepResult = EFail;
149 // no pop / delete - the SUITE owns the step, we don't.
150 return iTestStepResult = currentVerdict; // should be EPass if we've got here
153 // ------------------------
156 RTestMmTsthU1203* RTestMmTsthU1203::NewL()
158 RTestMmTsthU1203* self = new(ELeave) RTestMmTsthU1203;
162 // Each test step initialises its own name.
163 RTestMmTsthU1203::RTestMmTsthU1203()
165 iTestStepName = _L("MM-TSTH-U-1203");
169 TVerdict RTestMmTsthU1203::DoTestStepL()
171 INFO_PRINTF1(_L("Unit test for TestSuite - DoTestStepL"));
173 TVerdict currentVerdict = EPass;
175 // do the step. this time we're testing for PASS only
176 TVerdict stepVerdict = iSuiteStub->DoTestStep(_L("TestStepVirtualStub"), KNullDesC, KNullDesC);
177 if(stepVerdict != EPass)
179 ERR_PRINTF1(_L("RTestSuiteVirtualStub::DoTestStepL() failed"));
180 return iTestStepResult = EFail;
183 return iTestStepResult = currentVerdict; // should be EPass if we've got here
186 // ------------------------
189 RTestMmTsthU1221* RTestMmTsthU1221::NewL()
191 RTestMmTsthU1221* self = new(ELeave) RTestMmTsthU1221;
195 // Each test step initialises its own name.
196 RTestMmTsthU1221::RTestMmTsthU1221()
198 iTestStepName = _L("MM-TSTH-U-1221");
202 TVerdict RTestMmTsthU1221::DoTestStepL()
204 INFO_PRINTF1(_L("Unit test for TestSuite - GetVersion"));
206 TVerdict currentVerdict = EPass;
208 // get the version, compare it against our known value
209 _LIT(KTestVersion,"CTestSuiteVirtualStub Version");
210 TPtrC version = iSuiteStub->GetVersion();
211 if(version != KTestVersion)
213 ERR_PRINTF1(_L("RTestSuiteVirtualStub::GetVersion() failed"));
214 return iTestStepResult = EFail;
217 return iTestStepResult = currentVerdict; // should be EPass if we've got here
220 // ------------------------
223 RTestMmTsthU1222* RTestMmTsthU1222::NewL()
225 RTestMmTsthU1222* self = new(ELeave) RTestMmTsthU1222;
229 // Each test step initialises its own name.
230 RTestMmTsthU1222::RTestMmTsthU1222()
232 iTestStepName = _L("MM-TSTH-U-1222");
236 TVerdict RTestMmTsthU1222::DoTestStepL()
238 INFO_PRINTF1(_L("Unit test for TestSuite - accessors"));
240 TVerdict currentVerdict = EPass;
242 iSuiteStub->SetSeverity(ESevrInfo);
243 TInt theSev = iSuiteStub->Severity();
244 if(theSev != ESevrInfo)
246 ERR_PRINTF1(_L("CTestSuite::SetSeverity() failed"));
247 return iTestStepResult = EFail;
250 iSuiteStub->SetStepStatus(EStepStatusFinished);
251 TTestStepStatus theStepStatus = iSuiteStub->StepStatus();
252 if(theStepStatus != EStepStatusFinished)
254 ERR_PRINTF1(_L("CTestSuite::SetStepStatus() failed"));
255 return iTestStepResult = EFail;
258 CLog* theLog = CLog::NewL();
259 iSuiteStub->SetLogSystem(theLog);
260 CLog* theLogSystem = iSuiteStub->LogSystem();
261 if(theLog != theLogSystem)
263 ERR_PRINTF1(_L("CTestSuite::SetLogSystem() failed"));
265 return iTestStepResult = EFail;
269 return iTestStepResult = currentVerdict; // should be EPass if we've got here