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 01 : Parseline.cpp
21 // Test system includes
22 #include <testframework.h>
24 #include "parseline.h"
27 // Specific includes for this test suite
28 #include "TSU_MmTsthSuite01.h"
30 // Specific includes for these test steps
31 #include "TSU_MmTsth01.h"
33 // --------------------------------------------
35 // Unit Test Suite 01 : Parseline.cpp
39 // 1 Initialise a CParseLine
40 // 2 Process line : load & run a sample step
41 // 3 Run a sample panic step
43 // 11 CSuiteDLL initialise and verify
45 // (NB these tests are to test the parser ONLY; the underlying functionality of the
46 // commands parsed is tested in CTestStep, CTestSuite, CTestUtils etc. suites)
48 // ---------------------
51 RTestMmTsthU0101* RTestMmTsthU0101::NewL()
53 RTestMmTsthU0101* self = new(ELeave) RTestMmTsthU0101;
57 // Each test step initialises its own name.
58 RTestMmTsthU0101::RTestMmTsthU0101()
60 iTestStepName = _L("MM-TSTH-U-0101");
64 TVerdict RTestMmTsthU0101::OpenL()
66 // don't call the default preamble
67 return iTestStepResult = EPass;
71 void RTestMmTsthU0101::Close()
73 // don't call the default postamble
77 TVerdict RTestMmTsthU0101::DoTestStepL()
79 INFO_PRINTF1(_L("Unit test for Parseline"));
81 TVerdict currentVerdict = EPass;
83 // initialise a CParseLine
84 CLog* theLogClient = iSuite->LogSystem();
85 CTestUtils* theTestUtils = CTestUtils::NewL(theLogClient);
86 TInt64 theGuardTimer (-1);
88 CleanupStack::PushL(theTestUtils);
89 CScript* theParseScript = CScript::NewLC(theTestUtils, theLogClient, theGuardTimer, KNullDesC);
90 CParseLine* theParser = CParseLine::NewL(theParseScript, theTestUtils, theLogClient, theGuardTimer, KNullDesC);
91 CleanupStack::PushL(theParser);
93 // if we got here, we're constructed successfully
94 INFO_PRINTF1(_L("CParseLine constructed successfully"));
96 CleanupStack::PopAndDestroy(3); // theParser, theParseScript, theTestUtils
98 return iTestStepResult = currentVerdict;
102 // ---------------------
105 RTestMmTsthU0102* RTestMmTsthU0102::NewL()
107 RTestMmTsthU0102* self = new(ELeave) RTestMmTsthU0102;
111 // Each test step initialises its own name.
112 RTestMmTsthU0102::RTestMmTsthU0102()
114 iTestStepName = _L("MM-TSTH-U-0102");
118 TVerdict RTestMmTsthU0102::DoTestStepL()
120 INFO_PRINTF1(_L("Unit test for ProcessLineL 1"));
122 TVerdict currentVerdict = EPass;
123 _LIT8(KTestStepScriptLine1, "LOAD_SUITE TSU_MMTSTH01");
124 _LIT8(KTestStepScriptLine2, "RUN_TEST_STEP 1000 TSU_MMTSTH01 RTestStepDummy");
126 TRAPD(err1, iParseLine->ProcessLineL(KTestStepScriptLine1, 1));
129 ERR_PRINTF2(_L("ProcessLineL for LOAD_SUITE left, error code %d"), err1);
130 return iTestStepResult = EFail;
132 TRAPD(err2, iParseLine->ProcessLineL(KTestStepScriptLine2, 2));
135 ERR_PRINTF2(_L("ProcessLineL for RUN_TEST_STEP left, error code %d"), err2);
136 return iTestStepResult = EFail;
139 return iTestStepResult = currentVerdict;
142 // ---------------------
145 RTestMmTsthU0103* RTestMmTsthU0103::NewL()
147 RTestMmTsthU0103* self = new(ELeave) RTestMmTsthU0103;
151 // Each test step initialises its own name.
152 RTestMmTsthU0103::RTestMmTsthU0103()
154 iTestStepName = _L("MM-TSTH-U-0103");
158 TVerdict RTestMmTsthU0103::DoTestStepL()
160 INFO_PRINTF1(_L("Unit test for ProcessLineL 2"));
162 TVerdict currentVerdict = EPass;
163 _LIT8(KTestStepScriptLine1, "LOAD_SUITE TSU_MMTSTH01");
164 _LIT8(KTestStepScriptLine2, "RUN_PANIC_STEP 1000 TSU_MMTSTH01 RPanicTestStepDummy, PanicDummy, 0");
166 TRAPD(err1, iParseLine->ProcessLineL(KTestStepScriptLine1, 1));
169 ERR_PRINTF2(_L("ProcessLineL for LOAD_SUITE left, error code %d"), err1);
170 return iTestStepResult = EInconclusive;
172 TRAPD(err2, iParseLine->ProcessLineL(KTestStepScriptLine2, 2));
175 ERR_PRINTF2(_L("ProcessLineL for RUN_PANIC_STEP left, error code %d"), err2);
176 return iTestStepResult = EFail;
179 return iTestStepResult = currentVerdict;
183 // ---------------------
186 RTestMmTsthU0104* RTestMmTsthU0104::NewL()
188 RTestMmTsthU0104* self = new(ELeave) RTestMmTsthU0104;
192 // Each test step initialises its own name.
193 RTestMmTsthU0104::RTestMmTsthU0104()
195 iTestStepName = _L("MM-TSTH-U-0104");
199 TVerdict RTestMmTsthU0104::DoTestStepL()
202 INFO_PRINTF1(_L("This test step is not available on EKA2 - Passing test!"));
207 // ---------------------
210 RTestMmTsthU0111* RTestMmTsthU0111::NewL()
212 RTestMmTsthU0111* self = new(ELeave) RTestMmTsthU0111;
216 // Each test step initialises its own name.
217 RTestMmTsthU0111::RTestMmTsthU0111()
219 iTestStepName = _L("MM-TSTH-U-0111");
223 TVerdict RTestMmTsthU0111::DoTestStepL()
225 INFO_PRINTF1(_L("Unit test for CSuiteDLL"));
227 TVerdict currentVerdict = EPass;
229 // create a new CSuiteDll object to store info on loaded DLL
230 _LIT(KTestSuiteName, "TSU_MMTSTH01");
231 CSuiteDll* newRef = NULL;
232 TRAPD(err, newRef = CSuiteDll::NewL(KTestSuiteName, iLogClient));
235 ERR_PRINTF2(_L("CSuiteDll::NewL left, error code %d"), err);
236 return iTestStepResult = EFail;
239 // make sure it's not NULL, get its name out and see if it matches
240 CTestSuite* theTestSuite = newRef->Suite();
241 if(theTestSuite == NULL)
243 ERR_PRINTF1(_L("CSuiteDll::Suite() is NULL"));
244 return iTestStepResult = EFail;
247 TPtrC theName = newRef->Name();
248 if (theName != KTestSuiteName)
250 ERR_PRINTF2(_L("CSuiteDll::Name() is %S"), &theName);
251 return iTestStepResult = EFail;
254 return iTestStepResult = currentVerdict;
257 // ---------------------
258 // Dummy test step for Parseline testing
260 RTestStepDummy* RTestStepDummy::NewL()
262 RTestStepDummy* self = new(ELeave) RTestStepDummy;
266 // Each test step initialises its own name.
267 RTestStepDummy::RTestStepDummy()
269 iTestStepName = _L("RTestStepDummy");
273 TVerdict RTestStepDummy::DoTestStepL()
275 INFO_PRINTF1(_L("Dummy step completed"));
277 TVerdict currentVerdict = EPass;
279 return iTestStepResult = currentVerdict;
283 // ---------------------
284 // Dummy panic test steps for Parseline testing
286 RPanicTestStepDummy* RPanicTestStepDummy::NewL()
288 RPanicTestStepDummy* self = new(ELeave) RPanicTestStepDummy;
292 // Each test step initialises its own name.
293 RPanicTestStepDummy::RPanicTestStepDummy()
295 iTestStepName = _L("RPanicTestStepDummy");
299 TVerdict RPanicTestStepDummy::DoTestStepL()
301 INFO_PRINTF1(_L("Dummy panic step running"));
302 User::Panic(_L("PanicDummy"), 0);
304 // NB this code cannot be reached
305 TVerdict currentVerdict = EPass;
306 return iTestStepResult = currentVerdict;