103
|
1 |
// Copyright (c) 1996-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".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// Capability test
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
/**
|
|
19 |
@file
|
|
20 |
@test
|
|
21 |
@internalComponent - Internal Symbian test code
|
|
22 |
*/
|
|
23 |
|
|
24 |
#include "TCAPABILITY.H"
|
|
25 |
|
|
26 |
_LIT(KTestResultsFile, "C:\\DATA\\TestResult.Dat");
|
|
27 |
_LIT(KSpace, " ");
|
|
28 |
_LIT(KTest0Name, "All capabilities");
|
|
29 |
_LIT(KTest0Exe, "TCAP_ALL.exe");
|
|
30 |
_LIT(KTest0Cap, "CAPABILITY_ALL");
|
|
31 |
_LIT(KTest1Name, "No capabilities");
|
|
32 |
_LIT(KTest1Exe, "TCAP_NONE.exe");
|
|
33 |
_LIT(KTest1Cap, "CAPABILITY_NONE");
|
|
34 |
_LIT(KTest2Name, "WriteDeviceData and SwEvent capabilities");
|
|
35 |
_LIT(KTest2Exe, "TCAP_ONE.exe");
|
|
36 |
_LIT(KTest2Cap, "WRITEDATA+SWEVENT");
|
|
37 |
_LIT(KTest3Name, "WriteDeviceData and PowerMgnt capabilities");
|
|
38 |
_LIT(KTest3Exe, "TCAP_TWO.exe");
|
|
39 |
_LIT(KTest3Cap, "WRITEDATA+POWERMGMT");
|
|
40 |
_LIT(KTest4Name, "PowerMgnt and SwEvent capabilities");
|
|
41 |
_LIT(KTest4Exe, "TCAP_THREE.exe");
|
|
42 |
_LIT(KTest4Cap, "POWERMGMT+SWEVENT");
|
|
43 |
|
|
44 |
|
|
45 |
//CCapabilityTest
|
|
46 |
CTCapability::CTCapability(CTestStep* aStep):
|
|
47 |
CTWsGraphicsBase(aStep)
|
|
48 |
{
|
|
49 |
}
|
|
50 |
|
|
51 |
CTCapability::~CTCapability()
|
|
52 |
{
|
|
53 |
}
|
|
54 |
|
|
55 |
void CTCapability::ConstructL()
|
|
56 |
{
|
|
57 |
//Empty function ConstructL is pure virtual function and this
|
|
58 |
//definition required to satisfy the compiler
|
|
59 |
}
|
|
60 |
|
|
61 |
//Reads the shared files which contains the total tests run and tests passed.
|
|
62 |
void CTCapability::GetCapabilityTestResultsL(TInt& aNoOfTests, TInt& aNoOfTestsPass)
|
|
63 |
{
|
|
64 |
TBuf<256> noOfTest;
|
|
65 |
TBuf<256> noOfTestPass;
|
|
66 |
RFs fileSession;
|
|
67 |
RFile file;
|
|
68 |
TFileText textFile;
|
|
69 |
User::LeaveIfError(fileSession.Connect());
|
|
70 |
CleanupClosePushL(fileSession);
|
|
71 |
User::LeaveIfError(file.Open(fileSession,KTestResultsFile,EFileRead));
|
|
72 |
CleanupClosePushL(file);
|
|
73 |
textFile.Set(file);
|
|
74 |
if(textFile.Read(noOfTest)==KErrNone)
|
|
75 |
{
|
|
76 |
TLex lexVar(noOfTest);
|
|
77 |
lexVar.Val(aNoOfTests);
|
|
78 |
if(textFile.Read(noOfTestPass)==KErrNone)
|
|
79 |
{
|
|
80 |
lexVar=noOfTestPass;
|
|
81 |
lexVar.Val(aNoOfTestsPass);
|
|
82 |
}
|
|
83 |
else
|
|
84 |
{
|
|
85 |
aNoOfTestsPass=0;
|
|
86 |
}
|
|
87 |
}
|
|
88 |
CleanupStack::PopAndDestroy(&file);
|
|
89 |
CleanupStack::PopAndDestroy(&fileSession);
|
|
90 |
}
|
|
91 |
|
|
92 |
void CTCapability::LaunchNewProcess(const TDesC& aExecutable,const TDesC& aCapability)
|
|
93 |
{
|
|
94 |
TBuf<128> args;
|
|
95 |
args.Append(aCapability);
|
|
96 |
args.Append(KSpace);
|
|
97 |
args.AppendNum(TheClient->iGroup->GroupWin()->Identifier());
|
|
98 |
RProcess pr;
|
|
99 |
// TInt noOfTest,noOfTestPass;
|
|
100 |
if (pr.Create(aExecutable,args)==KErrNone)
|
|
101 |
{
|
|
102 |
TRequestStatus status=NULL;
|
|
103 |
pr.Logon(status);
|
|
104 |
pr.Resume();
|
|
105 |
User::WaitForRequest(status);
|
|
106 |
//Close all the panic windows to avoid "Hangs the H4"
|
|
107 |
//PDEF100501: TEF Migrated Test TCapability Hangs the H4
|
|
108 |
if (iTest->iScreenNumber == 0)
|
|
109 |
iTest->CloseAllPanicWindows();
|
|
110 |
pr.Close();
|
|
111 |
// GetCapabilityTestResultsL(noOfTest,noOfTestPass);
|
|
112 |
// UpdateTestResults(noOfTest,noOfTestPass);
|
|
113 |
}
|
|
114 |
}
|
|
115 |
|
|
116 |
void CTCapability::RunTestCaseL(TInt /*aCurTestCase*/)
|
|
117 |
{
|
|
118 |
((CTCapabilityStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
|
|
119 |
switch(++iTest->iState)
|
|
120 |
{
|
|
121 |
/**
|
|
122 |
|
|
123 |
@SYMTestCaseID GRAPHICS-WSERV-0305
|
|
124 |
|
|
125 |
@SYMDEF DEF081259
|
|
126 |
|
|
127 |
@SYMTestCaseDesc Capability test with a process with all capability
|
|
128 |
|
|
129 |
@SYMTestPriority High
|
|
130 |
|
|
131 |
@SYMTestStatus Implemented
|
|
132 |
|
|
133 |
@SYMTestActions The security threat API's are called with all
|
|
134 |
capability to test whether the API's are accessible or not.
|
|
135 |
|
|
136 |
@SYMTestExpectedResults If the required capability is defined to test code then API should
|
|
137 |
accessible, otherwise it should panic the test.
|
|
138 |
|
|
139 |
*/
|
|
140 |
case 1:
|
|
141 |
((CTCapabilityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0305"));
|
|
142 |
iTest->LogSubTest(KTest0Name);
|
|
143 |
LaunchNewProcess(KTest0Exe, KTest0Cap);
|
|
144 |
break;
|
|
145 |
/**
|
|
146 |
|
|
147 |
@SYMTestCaseID GRAPHICS-WSERV-0306
|
|
148 |
|
|
149 |
@SYMDEF DEF081259
|
|
150 |
|
|
151 |
@SYMTestCaseDesc Capability test with a process with no capability
|
|
152 |
|
|
153 |
@SYMTestPriority High
|
|
154 |
|
|
155 |
@SYMTestStatus Implemented
|
|
156 |
|
|
157 |
@SYMTestActions The security threat API's are called with no
|
|
158 |
capability to test whether the API's are accessible or not.
|
|
159 |
|
|
160 |
@SYMTestExpectedResults If the required capability is defined to test code then API should
|
|
161 |
accessible, otherwise it should panic the test.
|
|
162 |
|
|
163 |
*/
|
|
164 |
case 2:
|
|
165 |
((CTCapabilityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0306"));
|
|
166 |
//create process with no capability
|
|
167 |
RDebug::Print(KPlatsecBegin);
|
|
168 |
iTest->LogSubTest(KTest1Name);
|
|
169 |
LaunchNewProcess(KTest1Exe,KTest1Cap);
|
|
170 |
break;
|
|
171 |
/**
|
|
172 |
|
|
173 |
@SYMTestCaseID GRAPHICS-WSERV-0307
|
|
174 |
|
|
175 |
@SYMDEF DEF081259
|
|
176 |
|
|
177 |
@SYMTestCaseDesc Capability test with a process with WriteDevicedata and SwEvent capability
|
|
178 |
|
|
179 |
@SYMTestPriority High
|
|
180 |
|
|
181 |
@SYMTestStatus Implemented
|
|
182 |
|
|
183 |
@SYMTestActions The security threat API's are called with WriteDevicedata and SwEvent
|
|
184 |
capability to test whether the API's are accessible or not.
|
|
185 |
|
|
186 |
@SYMTestExpectedResults If the required capability is defined to test code then API should
|
|
187 |
accessible, otherwise it should panic the test.
|
|
188 |
|
|
189 |
*/
|
|
190 |
case 3:
|
|
191 |
((CTCapabilityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0307"));
|
|
192 |
//create process with WriteDevicedata and SwEvent capability
|
|
193 |
iTest->LogSubTest(KTest2Name);
|
|
194 |
LaunchNewProcess(KTest2Exe,KTest2Cap);
|
|
195 |
break;
|
|
196 |
/**
|
|
197 |
|
|
198 |
@SYMTestCaseID GRAPHICS-WSERV-0308
|
|
199 |
|
|
200 |
@SYMDEF DEF081259
|
|
201 |
|
|
202 |
@SYMTestCaseDesc Capability test with a process with WriteDevicedata and PowerMgmt capability
|
|
203 |
|
|
204 |
@SYMTestPriority High
|
|
205 |
|
|
206 |
@SYMTestStatus Implemented
|
|
207 |
|
|
208 |
@SYMTestActions The security threat API's are called with WriteDevicedata and PowerMgmt
|
|
209 |
capability to test whether the API's are accessible or not.
|
|
210 |
|
|
211 |
@SYMTestExpectedResults If the required capability is defined to test code then API should
|
|
212 |
accessible, otherwise it should panic the test.
|
|
213 |
|
|
214 |
*/
|
|
215 |
case 4:
|
|
216 |
((CTCapabilityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0308"));
|
|
217 |
//create process with WriteDevicedata and PowerMgmt capability
|
|
218 |
iTest->LogSubTest(KTest3Name);
|
|
219 |
LaunchNewProcess(KTest3Exe,KTest3Cap);
|
|
220 |
break;
|
|
221 |
/**
|
|
222 |
|
|
223 |
@SYMTestCaseID GRAPHICS-WSERV-0309
|
|
224 |
|
|
225 |
@SYMDEF DEF081259
|
|
226 |
|
|
227 |
@SYMTestCaseDesc Capability test with a process with PowerMgmt and SwEvent capability
|
|
228 |
|
|
229 |
@SYMTestPriority High
|
|
230 |
|
|
231 |
@SYMTestStatus Implemented
|
|
232 |
|
|
233 |
@SYMTestActions The security threat API's are called with PowerMgmt and SwEvent
|
|
234 |
capability to test whether the API's are accessible or not.
|
|
235 |
|
|
236 |
@SYMTestExpectedResults If the required capability is defined to test code then API should
|
|
237 |
accessible, otherwise it should panic the test.
|
|
238 |
|
|
239 |
*/
|
|
240 |
case 5:
|
|
241 |
((CTCapabilityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0309"));
|
|
242 |
//create process with PowerMgmt and SwEvent capability
|
|
243 |
iTest->LogSubTest(KTest4Name);
|
|
244 |
LaunchNewProcess(KTest4Exe, KTest4Cap);
|
|
245 |
break;
|
|
246 |
default :
|
|
247 |
((CTCapabilityStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
|
|
248 |
((CTCapabilityStep*)iStep)->CloseTMSGraphicsStep();
|
|
249 |
RDebug::Print(KPlatsecEnd);
|
|
250 |
RFs fileSession;
|
|
251 |
User::LeaveIfError(fileSession.Connect());
|
|
252 |
CleanupClosePushL(fileSession);
|
|
253 |
CFileMan *fileMan=CFileMan::NewL(fileSession);
|
|
254 |
fileMan->Delete(KTestResultsFile);
|
|
255 |
delete fileMan;
|
|
256 |
CleanupStack::PopAndDestroy(&fileSession);
|
|
257 |
TestComplete();
|
|
258 |
break;
|
|
259 |
}
|
|
260 |
((CTCapabilityStep*)iStep)->RecordTestResultL();
|
|
261 |
}
|
|
262 |
|
|
263 |
__WS_CONSTRUCT_STEP__(Capability)
|