0
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
* Example CTestStep derived implementation
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
/**
|
|
22 |
@file WriteStringStep.cpp
|
|
23 |
*/
|
|
24 |
#include "ShortFunsStep.h"
|
|
25 |
#include "Te_RegStepTestSuiteDefs.h"
|
|
26 |
|
|
27 |
_LIT(KPassed, "passed");
|
|
28 |
_LIT(KFailed, "failed");
|
|
29 |
#define PASSORFAIL (funcTestPassed?&KPassed():&KFailed())
|
|
30 |
|
|
31 |
CShortFunsTestStep::~CShortFunsTestStep()
|
|
32 |
/**
|
|
33 |
* Destructor
|
|
34 |
*/
|
|
35 |
{
|
|
36 |
}
|
|
37 |
|
|
38 |
CShortFunsTestStep::CShortFunsTestStep()
|
|
39 |
/**
|
|
40 |
* Constructor
|
|
41 |
*/
|
|
42 |
{
|
|
43 |
SetTestStepName(KShortFunsTestStep);
|
|
44 |
}
|
|
45 |
|
|
46 |
TVerdict CShortFunsTestStep::doTestStepPreambleL()
|
|
47 |
/**
|
|
48 |
* @return - TVerdict code
|
|
49 |
* Override of base class virtual
|
|
50 |
*/
|
|
51 |
{
|
|
52 |
// There is no initiation work so set this result to pass.
|
|
53 |
SetTestStepResult(EPass);
|
|
54 |
return TestStepResult();
|
|
55 |
}
|
|
56 |
|
|
57 |
TVerdict CShortFunsTestStep::doTestStepL()
|
|
58 |
/**
|
|
59 |
* @return - TVerdict code
|
|
60 |
* Override of base class pure virtual
|
|
61 |
* Our implementation only gets called if the base class doTestStepPreambleL() did
|
|
62 |
* not leave. That being the case, the current test result value will be EPass.
|
|
63 |
*/
|
|
64 |
{
|
|
65 |
INFO_PRINTF1(_L("Start to test some small functions."));
|
|
66 |
SetTestStepResult(EFail);
|
|
67 |
|
|
68 |
TBool funcTestPassed = EFalse;
|
|
69 |
//TBool totalTestPassed = ETrue;
|
|
70 |
TInt passCount = 0;
|
|
71 |
TInt expectedPassCount = 9;
|
|
72 |
|
|
73 |
_LIT(KTestCaseName, "TestCaseName");
|
|
74 |
_LIT(KOOMTest, "OOMTest");
|
|
75 |
_LIT(KTestStepError, "TestStepError");
|
|
76 |
_LIT(KLoopIndex, "LoopIndex");
|
|
77 |
_LIT(KScriptDriveName, "ScriptDriveName");
|
|
78 |
_LIT(KSystemDrive, "SystemDrive");
|
|
79 |
_LIT(KSetupParaValue, "SetupParaValue");
|
|
80 |
|
|
81 |
TPtrC serverName = GetServerName();
|
|
82 |
if (serverName == KServerName())
|
|
83 |
{
|
|
84 |
funcTestPassed = EPass;
|
|
85 |
++passCount;
|
|
86 |
}
|
|
87 |
INFO_PRINTF4(_L("GetServerName test %S! ServerName=%S, ExpectedServerName=%S"), PASSORFAIL, &serverName, &KServerName());
|
|
88 |
|
|
89 |
funcTestPassed = EFalse;
|
|
90 |
TBuf<KMaxTestExecuteNameLength> testCaseName;
|
|
91 |
TBool ret = TestCaseName(testCaseName);
|
|
92 |
TPtrC expectedTestCaseName;
|
|
93 |
GetStringFromConfig(ConfigSection(), KTestCaseName, expectedTestCaseName);
|
|
94 |
if (testCaseName == expectedTestCaseName)
|
|
95 |
{
|
|
96 |
funcTestPassed = ETrue;
|
|
97 |
++passCount;
|
|
98 |
}
|
|
99 |
INFO_PRINTF4(_L("TestCaseName test %S! TestCaseName=%S, ExpectedTestCaseName=%S"), PASSORFAIL, &testCaseName, &expectedTestCaseName);
|
|
100 |
|
|
101 |
funcTestPassed = ETrue;
|
|
102 |
TPtrC testStepName = TestStepName();
|
|
103 |
if (testStepName == KShortFunsTestStep)
|
|
104 |
{
|
|
105 |
funcTestPassed = ETrue;
|
|
106 |
++passCount;
|
|
107 |
}
|
|
108 |
INFO_PRINTF4(_L("TestStepName test %S! TestStepName=%S, ExpectedTestStepName=%S"), PASSORFAIL, &testStepName, &KShortFunsTestStep());
|
|
109 |
|
|
110 |
funcTestPassed = ETrue;
|
|
111 |
TBool OOMTest;
|
|
112 |
GetBoolFromConfig(ConfigSection(), KOOMTest, OOMTest);
|
|
113 |
if (ShouldRunOOMTest() == OOMTest)
|
|
114 |
{
|
|
115 |
funcTestPassed = ETrue;
|
|
116 |
++passCount;
|
|
117 |
}
|
|
118 |
INFO_PRINTF4(_L("ShouldRunOOMTest test %S! OOMValue=%d, ExpectedOOMValue=%d"), PASSORFAIL, ShouldRunOOMTest(), OOMTest);
|
|
119 |
|
|
120 |
funcTestPassed = ETrue;
|
|
121 |
TInt expectedTestStepError = 0;
|
|
122 |
GetIntFromConfig(ConfigSection(), KTestStepError, expectedTestStepError);
|
|
123 |
SetTestStepError(-46);
|
|
124 |
TInt testStepError = TestStepError();
|
|
125 |
SetTestStepError(0);
|
|
126 |
if (testStepError == expectedTestStepError)
|
|
127 |
{
|
|
128 |
funcTestPassed = ETrue;
|
|
129 |
++passCount;
|
|
130 |
}
|
|
131 |
INFO_PRINTF4(_L("TestStepError test %S! TestStepError=%d, ExpectedTestStepError=%d"), PASSORFAIL, testStepError, expectedTestStepError);
|
|
132 |
|
|
133 |
funcTestPassed = ETrue;
|
|
134 |
TInt expectedLoopIndex = 0;
|
|
135 |
GetIntFromConfig(ConfigSection(), KLoopIndex, expectedLoopIndex);
|
|
136 |
TInt loopIndex = GetLoopIndex();
|
|
137 |
if (loopIndex == expectedLoopIndex)
|
|
138 |
{
|
|
139 |
funcTestPassed = ETrue;
|
|
140 |
++passCount;
|
|
141 |
}
|
|
142 |
INFO_PRINTF4(_L("GetLoopIndex test %S! LoopIndex=%d, ExpectedLoopIndex=%d"), PASSORFAIL, loopIndex, expectedLoopIndex);
|
|
143 |
|
|
144 |
funcTestPassed = ETrue;
|
|
145 |
TPtrC expectedScriptDriveName;
|
|
146 |
GetStringFromConfig(ConfigSection(), KScriptDriveName, expectedScriptDriveName);
|
|
147 |
TPtrC scriptDriveName = ScriptDriveName();
|
|
148 |
if (0 == scriptDriveName.CompareF(expectedScriptDriveName))
|
|
149 |
{
|
|
150 |
funcTestPassed = ETrue;
|
|
151 |
++passCount;
|
|
152 |
}
|
|
153 |
INFO_PRINTF4(_L("ScriptDriveName test %S! ScriptDriveName=%S, ExpectedScriptDriveName=%S"), PASSORFAIL, &scriptDriveName, &expectedScriptDriveName);
|
|
154 |
|
|
155 |
funcTestPassed = ETrue;
|
|
156 |
TPtrC expectedSystemDriveName;
|
|
157 |
GetStringFromConfig(ConfigSection(), KSystemDrive, expectedSystemDriveName);
|
|
158 |
TPtrC systemDriveName = GetSystemDrive();
|
|
159 |
if (0 == scriptDriveName.CompareF(expectedSystemDriveName))
|
|
160 |
{
|
|
161 |
funcTestPassed = ETrue;
|
|
162 |
++passCount;
|
|
163 |
}
|
|
164 |
INFO_PRINTF4(_L("GetSystemDrive test %S! SystemDrive=%S, ExpectedSystemDrive=%S"), PASSORFAIL, &systemDriveName, &expectedSystemDriveName);
|
|
165 |
|
|
166 |
funcTestPassed = ETrue;
|
|
167 |
TInt expectedSetupValue = 0;
|
|
168 |
GetIntFromConfig(ConfigSection(), KSetupParaValue, expectedSetupValue);
|
|
169 |
TInt setupValue = GetSetupState();
|
|
170 |
if (setupValue == expectedSetupValue)
|
|
171 |
{
|
|
172 |
funcTestPassed = ETrue;
|
|
173 |
++passCount;
|
|
174 |
}
|
|
175 |
INFO_PRINTF4(_L("GetSetupState test %S! SetupValue=%d, ExpectedSetupValue=%d"), PASSORFAIL, setupValue, expectedSetupValue);
|
|
176 |
|
|
177 |
if (passCount != expectedPassCount)
|
|
178 |
{
|
|
179 |
ERR_PRINTF1(_L("Short functions test failed!"));
|
|
180 |
}
|
|
181 |
else
|
|
182 |
{
|
|
183 |
INFO_PRINTF1(_L("Short functions test passed!"));
|
|
184 |
SetTestStepResult(EPass);
|
|
185 |
}
|
|
186 |
|
|
187 |
return TestStepResult();
|
|
188 |
}
|
|
189 |
|
|
190 |
TVerdict CShortFunsTestStep::doTestStepPostambleL()
|
|
191 |
/**
|
|
192 |
* @return - TVerdict code
|
|
193 |
* Override of base class virtual
|
|
194 |
*/
|
|
195 |
{
|
|
196 |
return TestStepResult();
|
|
197 |
}
|