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 02 : Script.cpp
21 // Test system includes
22 // Test system includes
23 #include <testframework.h>
25 #include "parseline.h"
28 // Specific includes for this test suite
29 #include "TSU_MmTsthSuite02.h"
31 // Specific includes for these test steps
32 #include "TSU_MmTsth02.h"
34 // --------------------------------------------
36 // Unit Test Suite 02: Script.cpp
37 // Depends on : Parseline, FileName
40 // 1 construct a CScript
41 // 2 open a script file
42 // 3 execute a script file
43 // 12 add / display results (removed - the functionality is covered by Parseline tests 0102 and 0103)
45 // ---------------------
48 RTestMmTsthU0201* RTestMmTsthU0201::NewL()
50 RTestMmTsthU0201* self = new(ELeave) RTestMmTsthU0201;
54 // Each test step initialises its own name.
55 RTestMmTsthU0201::RTestMmTsthU0201()
57 iTestStepName = _L("MM-TSTH-U-0201");
61 TVerdict RTestMmTsthU0201::DoTestStepL()
63 INFO_PRINTF1(_L("Unit test for Script : construction"));
65 TVerdict currentVerdict = EPass;
67 // initialise a CParseLine
68 CLog* theLogClient = iSuite->LogSystem();
69 CTestUtils* theTestUtils = CTestUtils::NewL(theLogClient);
70 CleanupStack::PushL(theTestUtils);
72 CScript* theTestScript = CScript::NewLC(theTestUtils, theLogClient, defTime, KNullDesC);
74 // if we got here, we're constructed successfully
75 INFO_PRINTF1(_L("CScript constructed successfully"));
77 CleanupStack::PopAndDestroy(2); // theTestScript, theTestUtils
78 theTestScript = NULL; // just to remove warning
80 return iTestStepResult = currentVerdict; // should be EPass if we've got here
83 // ---------------------
86 RTestMmTsthU0202* RTestMmTsthU0202::NewL()
88 RTestMmTsthU0202* self = new(ELeave) RTestMmTsthU0202;
92 // Each test step initialises its own name.
93 RTestMmTsthU0202::RTestMmTsthU0202()
95 iTestStepName = _L("MM-TSTH-U-0202");
99 TVerdict RTestMmTsthU0202::DoTestStepL()
101 INFO_PRINTF1(_L("Unit test for Script - OpenScriptFile"));
103 TVerdict currentVerdict = EPass;
105 _LIT(KDummyScriptName, "TSU_MMTSTH02_DUMMY");
106 CFileName* scriptFileName = CFileName::NewLC();
107 *scriptFileName = KDummyScriptName;
108 if (iTestScript->OpenScriptFile(scriptFileName) == EFalse)
110 ERR_PRINTF2(_L("OpenScriptFile failed to open %S"), &KDummyScriptName());
111 currentVerdict = EFail;
113 CleanupStack::PopAndDestroy(scriptFileName);
114 return iTestStepResult = currentVerdict; // should be EPass if we've got here
117 // ---------------------
120 RTestMmTsthU0203* RTestMmTsthU0203::NewL()
122 RTestMmTsthU0203* self = new(ELeave) RTestMmTsthU0203;
126 // Each test step initialises its own name.
127 RTestMmTsthU0203::RTestMmTsthU0203()
129 iTestStepName = _L("MM-TSTH-U-0203");
133 TVerdict RTestMmTsthU0203::DoTestStepL()
135 INFO_PRINTF1(_L("Unit test for Script - ExecuteScriptL"));
137 TVerdict currentVerdict = EPass;
139 _LIT(KDummyScriptName, "TSU_MMTSTH02_DUMMY");
140 CFileName* scriptFileName = CFileName::NewLC();
141 *scriptFileName = KDummyScriptName;
142 if (iTestScript->OpenScriptFile(scriptFileName) == EFalse)
144 ERR_PRINTF2(_L("OpenScriptFile failed to open %S"), &KDummyScriptName());
145 CleanupStack::PopAndDestroy(scriptFileName);
146 return iTestStepResult = EInconclusive;
149 // execute the script
150 TVerdict theTestVerdict=EFail;
151 TRAPD(err, theTestVerdict = iTestScript->ExecuteScriptL());
155 ERR_PRINTF2(_L("ExecuteScriptL left with error code %d"), err);
156 currentVerdict = EFail;
158 else if (theTestVerdict!=EPass)
160 ERR_PRINTF2(_L("ExecuteScriptL returned with error %d"), theTestVerdict);
161 currentVerdict =theTestVerdict;
164 CleanupStack::PopAndDestroy(scriptFileName);
165 return iTestStepResult = currentVerdict; // should be EPass if we've got here