First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Test process priority control
21 @internalComponent - Internal Symbian test code
29 TInt ProcPriTestOtherProcess(TAny *aScreenNumber)
31 CTrapCleanup* CleanUpStack=CTrapCleanup::New();
33 User::LeaveIfError(ws.Connect());
36 CWsScreenDevice* screen = NULL;
38 TRAP(err, screen = new (ELeave) CWsScreenDevice(ws));
41 if ((err=screen->Construct((TInt)aScreenNumber))!=KErrNone)
47 RWindowGroup group(ws);
49 group.SetName(OTHER_PROC_GROUP_NAME);
52 sem1.OpenGlobal(PROC_PRI_SEMAPHORE_NAME1);
53 sem2.OpenGlobal(PROC_PRI_SEMAPHORE_NAME2);
54 sem1.Signal(); // Signal thread fully initialised
55 sem2.Wait(); // Wait for command to disable focus
57 group.EnableReceiptOfFocus(EFalse);
59 sem1.Signal(); // Signal focus disabled
60 sem2.Wait(); // Wait for command to enable focus
62 group.EnableReceiptOfFocus(ETrue);
64 sem1.Signal(); // Signal focus enabled
65 sem2.Wait(); // Wait until signalled to exit
67 group.EnableReceiptOfFocus(EFalse); // To stop shell being tasked into foreground
76 CTProcPri::CTProcPri(CTestStep* aStep) : CTWsGraphicsBase(aStep)
80 CTProcPri::~CTProcPri()
82 if (iFlags&ECreatedSem1)
84 if (iFlags&ECreatedSem2)
89 void CTProcPri::TestPriChangeL()
91 #define BACK_PRI EPriorityForeground
92 #define FORE_PRI EPriorityForeground
94 TEST(proc.Priority()==BACK_PRI);
95 if (proc.Priority()!=BACK_PRI)
96 INFO_PRINTF3(_L("proc.Priority() return value - Expected: %d, Actual: %d"), BACK_PRI, proc.Priority());
101 TEST(proc.Priority()==FORE_PRI);
102 if (proc.Priority()!=FORE_PRI)
103 INFO_PRINTF3(_L("proc.Priority() return value - Expected: %d, Actual: %d"), FORE_PRI, proc.Priority());
108 TEST(proc.Priority()==BACK_PRI);
109 if (proc.Priority()!=BACK_PRI)
110 INFO_PRINTF3(_L("proc.Priority() return value - Expected: %d, Actual: %d"), BACK_PRI, proc.Priority());
113 User::LeaveIfError(ident=TheClient->iWs.FindWindowGroupIdentifier(0,OTHER_PROC_GROUP_NAME,0));
114 TInt retVal = TheClient->iWs.SetWindowGroupOrdinalPosition(ident,1);
115 TEST(retVal==KErrNone);
116 if (retVal!=KErrNone)
117 INFO_PRINTF3(_L("TheClient->iWs.SetWindowGroupOrdinalPosition(ident,1) return value - Expected: %d, Actual: %d"), KErrNone, retVal);
119 TEST(proc.Priority()==FORE_PRI);
120 if (proc.Priority()!=FORE_PRI)
121 INFO_PRINTF3(_L("proc.Priority() return value - Expected: %d, Actual: %d"), FORE_PRI, proc.Priority());
123 retVal = TheClient->iWs.SetWindowGroupOrdinalPosition(ident,0);
124 TEST(retVal==KErrNone);
125 if (retVal!=KErrNone)
126 INFO_PRINTF3(_L("TheClient->iWs.SetWindowGroupOrdinalPosition(ident,0) return value - Expected: %d, Actual: %d"), KErrNone, retVal);
128 TEST(proc.Priority()==BACK_PRI);
129 if (proc.Priority()!=BACK_PRI)
130 INFO_PRINTF3(_L("proc.Priority() return value - Expected: %d, Actual: %d"), BACK_PRI, proc.Priority());
133 iProcess->Logon(stat); //Must Logon before the last Signal so we can be sure that it is still alive to get round a base issue
135 User::WaitForRequest(stat);
137 TEST(proc.Priority()==FORE_PRI);
138 if (proc.Priority()!=FORE_PRI)
139 INFO_PRINTF3(_L("proc.Priority() return value - Expected: %d, Actual: %d"), FORE_PRI, proc.Priority());
143 void CTProcPri::ConstructL()
145 User::LeaveIfError(iSem1.CreateGlobal(PROC_PRI_SEMAPHORE_NAME1,0,KOwnerType));
146 iFlags|=ECreatedSem1;
147 User::LeaveIfError(iSem2.CreateGlobal(PROC_PRI_SEMAPHORE_NAME2,0,KOwnerType));
148 iFlags|=ECreatedSem2;
149 iProcess=CProcess::NewL(CProcess::eProcessPriortyTest,iTest->iScreenNumber);
153 void CTProcPri::RunTestCaseL(TInt /*aCurTestCase*/)
155 _LIT(KTest1,"Priority Change");
156 ((CTProcPriStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
158 switch(++iTest->iState)
162 @SYMTestCaseID GRAPHICS-WSERV-0315
166 @SYMTestCaseDesc Test that the priority of a process or thread changes depending
167 on how the the process or thread is being used
169 @SYMTestPriority High
171 @SYMTestStatus Implemented
173 @SYMTestActions Create a process or thread and use it. Check the priority of the
174 process or thread changes depending on how it is being used
176 @SYMTestExpectedResults Prioirty of the process of thread changes depending on
181 ((CTProcPriStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0315"));
182 iTest->LogSubTest(KTest1);
186 ((CTProcPriStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
187 ((CTProcPriStep*)iStep)->CloseTMSGraphicsStep();
191 ((CTProcPriStep*)iStep)->RecordTestResultL();
194 __WS_CONSTRUCT_STEP__(ProcPri)