1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserver/test/tauto/TCAPABILITY.CPP Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,263 @@
1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Capability test
1.18 +//
1.19 +//
1.20 +
1.21 +/**
1.22 + @file
1.23 + @test
1.24 + @internalComponent - Internal Symbian test code
1.25 +*/
1.26 +
1.27 +#include "TCAPABILITY.H"
1.28 +
1.29 +_LIT(KTestResultsFile, "C:\\DATA\\TestResult.Dat");
1.30 +_LIT(KSpace, " ");
1.31 +_LIT(KTest0Name, "All capabilities");
1.32 +_LIT(KTest0Exe, "TCAP_ALL.exe");
1.33 +_LIT(KTest0Cap, "CAPABILITY_ALL");
1.34 +_LIT(KTest1Name, "No capabilities");
1.35 +_LIT(KTest1Exe, "TCAP_NONE.exe");
1.36 +_LIT(KTest1Cap, "CAPABILITY_NONE");
1.37 +_LIT(KTest2Name, "WriteDeviceData and SwEvent capabilities");
1.38 +_LIT(KTest2Exe, "TCAP_ONE.exe");
1.39 +_LIT(KTest2Cap, "WRITEDATA+SWEVENT");
1.40 +_LIT(KTest3Name, "WriteDeviceData and PowerMgnt capabilities");
1.41 +_LIT(KTest3Exe, "TCAP_TWO.exe");
1.42 +_LIT(KTest3Cap, "WRITEDATA+POWERMGMT");
1.43 +_LIT(KTest4Name, "PowerMgnt and SwEvent capabilities");
1.44 +_LIT(KTest4Exe, "TCAP_THREE.exe");
1.45 +_LIT(KTest4Cap, "POWERMGMT+SWEVENT");
1.46 +
1.47 +
1.48 +//CCapabilityTest
1.49 +CTCapability::CTCapability(CTestStep* aStep):
1.50 + CTWsGraphicsBase(aStep)
1.51 + {
1.52 + }
1.53 +
1.54 +CTCapability::~CTCapability()
1.55 + {
1.56 + }
1.57 +
1.58 +void CTCapability::ConstructL()
1.59 + {
1.60 + //Empty function ConstructL is pure virtual function and this
1.61 + //definition required to satisfy the compiler
1.62 + }
1.63 +
1.64 +//Reads the shared files which contains the total tests run and tests passed.
1.65 +void CTCapability::GetCapabilityTestResultsL(TInt& aNoOfTests, TInt& aNoOfTestsPass)
1.66 + {
1.67 + TBuf<256> noOfTest;
1.68 + TBuf<256> noOfTestPass;
1.69 + RFs fileSession;
1.70 + RFile file;
1.71 + TFileText textFile;
1.72 + User::LeaveIfError(fileSession.Connect());
1.73 + CleanupClosePushL(fileSession);
1.74 + User::LeaveIfError(file.Open(fileSession,KTestResultsFile,EFileRead));
1.75 + CleanupClosePushL(file);
1.76 + textFile.Set(file);
1.77 + if(textFile.Read(noOfTest)==KErrNone)
1.78 + {
1.79 + TLex lexVar(noOfTest);
1.80 + lexVar.Val(aNoOfTests);
1.81 + if(textFile.Read(noOfTestPass)==KErrNone)
1.82 + {
1.83 + lexVar=noOfTestPass;
1.84 + lexVar.Val(aNoOfTestsPass);
1.85 + }
1.86 + else
1.87 + {
1.88 + aNoOfTestsPass=0;
1.89 + }
1.90 + }
1.91 + CleanupStack::PopAndDestroy(&file);
1.92 + CleanupStack::PopAndDestroy(&fileSession);
1.93 + }
1.94 +
1.95 + void CTCapability::LaunchNewProcess(const TDesC& aExecutable,const TDesC& aCapability)
1.96 + {
1.97 + TBuf<128> args;
1.98 + args.Append(aCapability);
1.99 + args.Append(KSpace);
1.100 + args.AppendNum(TheClient->iGroup->GroupWin()->Identifier());
1.101 + RProcess pr;
1.102 +// TInt noOfTest,noOfTestPass;
1.103 + if (pr.Create(aExecutable,args)==KErrNone)
1.104 + {
1.105 + TRequestStatus status=NULL;
1.106 + pr.Logon(status);
1.107 + pr.Resume();
1.108 + User::WaitForRequest(status);
1.109 + //Close all the panic windows to avoid "Hangs the H4"
1.110 + //PDEF100501: TEF Migrated Test TCapability Hangs the H4
1.111 + if (iTest->iScreenNumber == 0)
1.112 + iTest->CloseAllPanicWindows();
1.113 + pr.Close();
1.114 +// GetCapabilityTestResultsL(noOfTest,noOfTestPass);
1.115 +// UpdateTestResults(noOfTest,noOfTestPass);
1.116 + }
1.117 + }
1.118 +
1.119 +void CTCapability::RunTestCaseL(TInt /*aCurTestCase*/)
1.120 + {
1.121 + ((CTCapabilityStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
1.122 + switch(++iTest->iState)
1.123 + {
1.124 +/**
1.125 +
1.126 + @SYMTestCaseID GRAPHICS-WSERV-0305
1.127 +
1.128 + @SYMDEF DEF081259
1.129 +
1.130 + @SYMTestCaseDesc Capability test with a process with all capability
1.131 +
1.132 + @SYMTestPriority High
1.133 +
1.134 + @SYMTestStatus Implemented
1.135 +
1.136 + @SYMTestActions The security threat API's are called with all
1.137 + capability to test whether the API's are accessible or not.
1.138 +
1.139 + @SYMTestExpectedResults If the required capability is defined to test code then API should
1.140 + accessible, otherwise it should panic the test.
1.141 +
1.142 +*/
1.143 + case 1:
1.144 + ((CTCapabilityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0305"));
1.145 + iTest->LogSubTest(KTest0Name);
1.146 + LaunchNewProcess(KTest0Exe, KTest0Cap);
1.147 + break;
1.148 +/**
1.149 +
1.150 + @SYMTestCaseID GRAPHICS-WSERV-0306
1.151 +
1.152 + @SYMDEF DEF081259
1.153 +
1.154 + @SYMTestCaseDesc Capability test with a process with no capability
1.155 +
1.156 + @SYMTestPriority High
1.157 +
1.158 + @SYMTestStatus Implemented
1.159 +
1.160 + @SYMTestActions The security threat API's are called with no
1.161 + capability to test whether the API's are accessible or not.
1.162 +
1.163 + @SYMTestExpectedResults If the required capability is defined to test code then API should
1.164 + accessible, otherwise it should panic the test.
1.165 +
1.166 +*/
1.167 + case 2:
1.168 + ((CTCapabilityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0306"));
1.169 + //create process with no capability
1.170 + RDebug::Print(KPlatsecBegin);
1.171 + iTest->LogSubTest(KTest1Name);
1.172 + LaunchNewProcess(KTest1Exe,KTest1Cap);
1.173 + break;
1.174 +/**
1.175 +
1.176 + @SYMTestCaseID GRAPHICS-WSERV-0307
1.177 +
1.178 + @SYMDEF DEF081259
1.179 +
1.180 + @SYMTestCaseDesc Capability test with a process with WriteDevicedata and SwEvent capability
1.181 +
1.182 + @SYMTestPriority High
1.183 +
1.184 + @SYMTestStatus Implemented
1.185 +
1.186 + @SYMTestActions The security threat API's are called with WriteDevicedata and SwEvent
1.187 + capability to test whether the API's are accessible or not.
1.188 +
1.189 + @SYMTestExpectedResults If the required capability is defined to test code then API should
1.190 + accessible, otherwise it should panic the test.
1.191 +
1.192 +*/
1.193 + case 3:
1.194 + ((CTCapabilityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0307"));
1.195 + //create process with WriteDevicedata and SwEvent capability
1.196 + iTest->LogSubTest(KTest2Name);
1.197 + LaunchNewProcess(KTest2Exe,KTest2Cap);
1.198 + break;
1.199 +/**
1.200 +
1.201 + @SYMTestCaseID GRAPHICS-WSERV-0308
1.202 +
1.203 + @SYMDEF DEF081259
1.204 +
1.205 + @SYMTestCaseDesc Capability test with a process with WriteDevicedata and PowerMgmt capability
1.206 +
1.207 + @SYMTestPriority High
1.208 +
1.209 + @SYMTestStatus Implemented
1.210 +
1.211 + @SYMTestActions The security threat API's are called with WriteDevicedata and PowerMgmt
1.212 + capability to test whether the API's are accessible or not.
1.213 +
1.214 + @SYMTestExpectedResults If the required capability is defined to test code then API should
1.215 + accessible, otherwise it should panic the test.
1.216 +
1.217 +*/
1.218 + case 4:
1.219 + ((CTCapabilityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0308"));
1.220 + //create process with WriteDevicedata and PowerMgmt capability
1.221 + iTest->LogSubTest(KTest3Name);
1.222 + LaunchNewProcess(KTest3Exe,KTest3Cap);
1.223 + break;
1.224 +/**
1.225 +
1.226 + @SYMTestCaseID GRAPHICS-WSERV-0309
1.227 +
1.228 + @SYMDEF DEF081259
1.229 +
1.230 + @SYMTestCaseDesc Capability test with a process with PowerMgmt and SwEvent capability
1.231 +
1.232 + @SYMTestPriority High
1.233 +
1.234 + @SYMTestStatus Implemented
1.235 +
1.236 + @SYMTestActions The security threat API's are called with PowerMgmt and SwEvent
1.237 + capability to test whether the API's are accessible or not.
1.238 +
1.239 + @SYMTestExpectedResults If the required capability is defined to test code then API should
1.240 + accessible, otherwise it should panic the test.
1.241 +
1.242 +*/
1.243 + case 5:
1.244 + ((CTCapabilityStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0309"));
1.245 + //create process with PowerMgmt and SwEvent capability
1.246 + iTest->LogSubTest(KTest4Name);
1.247 + LaunchNewProcess(KTest4Exe, KTest4Cap);
1.248 + break;
1.249 + default :
1.250 + ((CTCapabilityStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
1.251 + ((CTCapabilityStep*)iStep)->CloseTMSGraphicsStep();
1.252 + RDebug::Print(KPlatsecEnd);
1.253 + RFs fileSession;
1.254 + User::LeaveIfError(fileSession.Connect());
1.255 + CleanupClosePushL(fileSession);
1.256 + CFileMan *fileMan=CFileMan::NewL(fileSession);
1.257 + fileMan->Delete(KTestResultsFile);
1.258 + delete fileMan;
1.259 + CleanupStack::PopAndDestroy(&fileSession);
1.260 + TestComplete();
1.261 + break;
1.262 + }
1.263 + ((CTCapabilityStep*)iStep)->RecordTestResultL();
1.264 + }
1.265 +
1.266 +__WS_CONSTRUCT_STEP__(Capability)