sl@0
|
1 |
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// This file contains the test steps for Unit Test Suite 02 : Script.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
// EPOC includes
|
sl@0
|
19 |
#include <e32base.h>
|
sl@0
|
20 |
|
sl@0
|
21 |
// Test system includes
|
sl@0
|
22 |
// Test system includes
|
sl@0
|
23 |
#include <testframework.h>
|
sl@0
|
24 |
#include "script.h"
|
sl@0
|
25 |
#include "parseline.h"
|
sl@0
|
26 |
#include "Filename.h"
|
sl@0
|
27 |
|
sl@0
|
28 |
// Specific includes for this test suite
|
sl@0
|
29 |
#include "TSU_MmTsthSuite02.h"
|
sl@0
|
30 |
|
sl@0
|
31 |
// Specific includes for these test steps
|
sl@0
|
32 |
#include "TSU_MmTsth02.h"
|
sl@0
|
33 |
|
sl@0
|
34 |
// --------------------------------------------
|
sl@0
|
35 |
|
sl@0
|
36 |
// Unit Test Suite 02: Script.cpp
|
sl@0
|
37 |
// Depends on : Parseline, FileName
|
sl@0
|
38 |
|
sl@0
|
39 |
// Tests :-
|
sl@0
|
40 |
// 1 construct a CScript
|
sl@0
|
41 |
// 2 open a script file
|
sl@0
|
42 |
// 3 execute a script file
|
sl@0
|
43 |
// 12 add / display results (removed - the functionality is covered by Parseline tests 0102 and 0103)
|
sl@0
|
44 |
|
sl@0
|
45 |
// ---------------------
|
sl@0
|
46 |
// RTestMmTsthU0201
|
sl@0
|
47 |
|
sl@0
|
48 |
RTestMmTsthU0201* RTestMmTsthU0201::NewL()
|
sl@0
|
49 |
{
|
sl@0
|
50 |
RTestMmTsthU0201* self = new(ELeave) RTestMmTsthU0201;
|
sl@0
|
51 |
return self;
|
sl@0
|
52 |
}
|
sl@0
|
53 |
|
sl@0
|
54 |
// Each test step initialises its own name.
|
sl@0
|
55 |
RTestMmTsthU0201::RTestMmTsthU0201()
|
sl@0
|
56 |
{
|
sl@0
|
57 |
iTestStepName = _L("MM-TSTH-U-0201");
|
sl@0
|
58 |
}
|
sl@0
|
59 |
|
sl@0
|
60 |
// Do the test step.
|
sl@0
|
61 |
TVerdict RTestMmTsthU0201::DoTestStepL()
|
sl@0
|
62 |
{
|
sl@0
|
63 |
INFO_PRINTF1(_L("Unit test for Script : construction"));
|
sl@0
|
64 |
|
sl@0
|
65 |
TVerdict currentVerdict = EPass;
|
sl@0
|
66 |
|
sl@0
|
67 |
// initialise a CParseLine
|
sl@0
|
68 |
CLog* theLogClient = iSuite->LogSystem();
|
sl@0
|
69 |
CTestUtils* theTestUtils = CTestUtils::NewL(theLogClient);
|
sl@0
|
70 |
CleanupStack::PushL(theTestUtils);
|
sl@0
|
71 |
TInt64 defTime(-1);
|
sl@0
|
72 |
CScript* theTestScript = CScript::NewLC(theTestUtils, theLogClient, defTime, KNullDesC);
|
sl@0
|
73 |
|
sl@0
|
74 |
// if we got here, we're constructed successfully
|
sl@0
|
75 |
INFO_PRINTF1(_L("CScript constructed successfully"));
|
sl@0
|
76 |
|
sl@0
|
77 |
CleanupStack::PopAndDestroy(2); // theTestScript, theTestUtils
|
sl@0
|
78 |
theTestScript = NULL; // just to remove warning
|
sl@0
|
79 |
|
sl@0
|
80 |
return iTestStepResult = currentVerdict; // should be EPass if we've got here
|
sl@0
|
81 |
}
|
sl@0
|
82 |
|
sl@0
|
83 |
// ---------------------
|
sl@0
|
84 |
// RTestMmTsthU0202
|
sl@0
|
85 |
|
sl@0
|
86 |
RTestMmTsthU0202* RTestMmTsthU0202::NewL()
|
sl@0
|
87 |
{
|
sl@0
|
88 |
RTestMmTsthU0202* self = new(ELeave) RTestMmTsthU0202;
|
sl@0
|
89 |
return self;
|
sl@0
|
90 |
}
|
sl@0
|
91 |
|
sl@0
|
92 |
// Each test step initialises its own name.
|
sl@0
|
93 |
RTestMmTsthU0202::RTestMmTsthU0202()
|
sl@0
|
94 |
{
|
sl@0
|
95 |
iTestStepName = _L("MM-TSTH-U-0202");
|
sl@0
|
96 |
}
|
sl@0
|
97 |
|
sl@0
|
98 |
// Do the test step.
|
sl@0
|
99 |
TVerdict RTestMmTsthU0202::DoTestStepL()
|
sl@0
|
100 |
{
|
sl@0
|
101 |
INFO_PRINTF1(_L("Unit test for Script - OpenScriptFile"));
|
sl@0
|
102 |
|
sl@0
|
103 |
TVerdict currentVerdict = EPass;
|
sl@0
|
104 |
|
sl@0
|
105 |
_LIT(KDummyScriptName, "TSU_MMTSTH02_DUMMY");
|
sl@0
|
106 |
CFileName* scriptFileName = CFileName::NewLC();
|
sl@0
|
107 |
*scriptFileName = KDummyScriptName;
|
sl@0
|
108 |
if (iTestScript->OpenScriptFile(scriptFileName) == EFalse)
|
sl@0
|
109 |
{
|
sl@0
|
110 |
ERR_PRINTF2(_L("OpenScriptFile failed to open %S"), &KDummyScriptName());
|
sl@0
|
111 |
currentVerdict = EFail;
|
sl@0
|
112 |
}
|
sl@0
|
113 |
CleanupStack::PopAndDestroy(scriptFileName);
|
sl@0
|
114 |
return iTestStepResult = currentVerdict; // should be EPass if we've got here
|
sl@0
|
115 |
}
|
sl@0
|
116 |
|
sl@0
|
117 |
// ---------------------
|
sl@0
|
118 |
// RTestMmTsthU0203
|
sl@0
|
119 |
|
sl@0
|
120 |
RTestMmTsthU0203* RTestMmTsthU0203::NewL()
|
sl@0
|
121 |
{
|
sl@0
|
122 |
RTestMmTsthU0203* self = new(ELeave) RTestMmTsthU0203;
|
sl@0
|
123 |
return self;
|
sl@0
|
124 |
}
|
sl@0
|
125 |
|
sl@0
|
126 |
// Each test step initialises its own name.
|
sl@0
|
127 |
RTestMmTsthU0203::RTestMmTsthU0203()
|
sl@0
|
128 |
{
|
sl@0
|
129 |
iTestStepName = _L("MM-TSTH-U-0203");
|
sl@0
|
130 |
}
|
sl@0
|
131 |
|
sl@0
|
132 |
// Do the test step.
|
sl@0
|
133 |
TVerdict RTestMmTsthU0203::DoTestStepL()
|
sl@0
|
134 |
{
|
sl@0
|
135 |
INFO_PRINTF1(_L("Unit test for Script - ExecuteScriptL"));
|
sl@0
|
136 |
|
sl@0
|
137 |
TVerdict currentVerdict = EPass;
|
sl@0
|
138 |
|
sl@0
|
139 |
_LIT(KDummyScriptName, "TSU_MMTSTH02_DUMMY");
|
sl@0
|
140 |
CFileName* scriptFileName = CFileName::NewLC();
|
sl@0
|
141 |
*scriptFileName = KDummyScriptName;
|
sl@0
|
142 |
if (iTestScript->OpenScriptFile(scriptFileName) == EFalse)
|
sl@0
|
143 |
{
|
sl@0
|
144 |
ERR_PRINTF2(_L("OpenScriptFile failed to open %S"), &KDummyScriptName());
|
sl@0
|
145 |
CleanupStack::PopAndDestroy(scriptFileName);
|
sl@0
|
146 |
return iTestStepResult = EInconclusive;
|
sl@0
|
147 |
}
|
sl@0
|
148 |
|
sl@0
|
149 |
// execute the script
|
sl@0
|
150 |
TVerdict theTestVerdict=EFail;
|
sl@0
|
151 |
TRAPD(err, theTestVerdict = iTestScript->ExecuteScriptL());
|
sl@0
|
152 |
|
sl@0
|
153 |
if(err != KErrNone)
|
sl@0
|
154 |
{
|
sl@0
|
155 |
ERR_PRINTF2(_L("ExecuteScriptL left with error code %d"), err);
|
sl@0
|
156 |
currentVerdict = EFail;
|
sl@0
|
157 |
}
|
sl@0
|
158 |
else if (theTestVerdict!=EPass)
|
sl@0
|
159 |
{
|
sl@0
|
160 |
ERR_PRINTF2(_L("ExecuteScriptL returned with error %d"), theTestVerdict);
|
sl@0
|
161 |
currentVerdict =theTestVerdict;
|
sl@0
|
162 |
}
|
sl@0
|
163 |
|
sl@0
|
164 |
CleanupStack::PopAndDestroy(scriptFileName);
|
sl@0
|
165 |
return iTestStepResult = currentVerdict; // should be EPass if we've got here
|
sl@0
|
166 |
}
|
sl@0
|
167 |
|