os/graphics/windowing/windowserver/test/tcapability/TCapTest.CPP
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 1995-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
// Automatically test the window server capabilities.
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include <e32std.h>
sl@0
    19
#include "W32STD.H"
sl@0
    20
#include "../../SERVER/w32cmd.h"
sl@0
    21
#include <e32svr.h>
sl@0
    22
#include <bacline.h>
sl@0
    23
#include <hal.h>
sl@0
    24
sl@0
    25
typedef TInt (*TPanicFunction)(TInt aInt,TDes& capability,TInt aExternalGroupId);
sl@0
    26
LOCAL_D const TUint KPanicThreadHeapSize=0x2000;
sl@0
    27
#define EWindowGroupHandle 1234
sl@0
    28
#define EWindowGroupHandle2 4567
sl@0
    29
_LIT(KCAPABILITY_ALL,"CAPABILITY_ALL");
sl@0
    30
_LIT(KCAPABILITY_NONE,"CAPABILITY_NONE");
sl@0
    31
_LIT(KWRITEDATA_SWEVENT,"WRITEDATA+SWEVENT");
sl@0
    32
_LIT(KWRITEDATA_POWERMGMT,"WRITEDATA+POWERMGMT");
sl@0
    33
_LIT(KPOWERMGMT_SWEVENT,"POWERMGMT+SWEVENT");
sl@0
    34
_LIT(KSetOrdinalPositionPri,"EWsWinOpSetOrdinalPositionPri Capability Check");
sl@0
    35
_LIT(KSetOrdinalPositionErr,"EWsWinOpSetOrdinalPositionErr Capability Check");
sl@0
    36
TLogMessageText LogMessageText;
sl@0
    37
sl@0
    38
//Enum for indicating which capability is checked.
sl@0
    39
enum TTestCapability
sl@0
    40
	{
sl@0
    41
	EWriteDeviceData,
sl@0
    42
	ESwEvent,
sl@0
    43
	EPowerMgmt,
sl@0
    44
	EDoNotTest,
sl@0
    45
	ENoCapReq,
sl@0
    46
	EEikSrvSID,
sl@0
    47
	ESwEventPri,
sl@0
    48
	ENoSwEventPri,
sl@0
    49
	ENoSwEventPriSmallOrdinal,
sl@0
    50
	ESwEventErr,
sl@0
    51
	ENoSwEventErr,
sl@0
    52
	ENoSwEventErrSmallOrdinal,
sl@0
    53
	};
sl@0
    54
sl@0
    55
//Enum for test exit reasons
sl@0
    56
enum TTestState
sl@0
    57
	{
sl@0
    58
	EWsExitReasonBad,
sl@0
    59
	EWsTestNext,
sl@0
    60
	EWsTestFinished,
sl@0
    61
	};
sl@0
    62
	
sl@0
    63
	
sl@0
    64
TTestCapability gTheTestCapability;
sl@0
    65
TInt gTestState=KErrNone;
sl@0
    66
sl@0
    67
sl@0
    68
//Panics if EWsExitReasonBad
sl@0
    69
enum TAutoPanics
sl@0
    70
	{
sl@0
    71
	EAutoPanicPanicFailed,
sl@0
    72
	};
sl@0
    73
sl@0
    74
//Thread function structure
sl@0
    75
struct SPanicParams
sl@0
    76
	{
sl@0
    77
	TInt num;
sl@0
    78
	TPanicFunction func;
sl@0
    79
	TBuf<256> capability;
sl@0
    80
	TInt externalGroupId;
sl@0
    81
	};
sl@0
    82
sl@0
    83
class CTestBase
sl@0
    84
	{
sl@0
    85
public:
sl@0
    86
	CTestBase();
sl@0
    87
	~CTestBase();
sl@0
    88
	void ConstructL(const TDes* aCapabilityTest);
sl@0
    89
	TInt TestWsPanicL(TPanicFunction aFunction, TInt aInt, const TDes& aCommandLine);
sl@0
    90
	void UpdateLogsL();
sl@0
    91
private :
sl@0
    92
	TInt TestPanicL(SPanicParams* aPtr);
sl@0
    93
	TInt LaunchPanicThread(RThread& aThread, SPanicParams* aPtr);
sl@0
    94
	void Test(TInt aCondition);
sl@0
    95
private :
sl@0
    96
	TInt iThreadNumber;
sl@0
    97
	RWsSession iWs;
sl@0
    98
	TBuf<256> iCapabilityTest;
sl@0
    99
	TInt iTestCount;
sl@0
   100
	TInt iTestPass;
sl@0
   101
	};
sl@0
   102
sl@0
   103
//RWsSession derived class to test the EWservMessShutdown message
sl@0
   104
class RShellWsSession : public RWsSession
sl@0
   105
	{
sl@0
   106
public:
sl@0
   107
	void ShutDown();
sl@0
   108
	};
sl@0
   109
	
sl@0
   110
void RShellWsSession::ShutDown()
sl@0
   111
	{
sl@0
   112
	SendReceive(EWservMessShutdown,TIpcArgs(EWservShutdownCheck));
sl@0
   113
	}
sl@0
   114
	
sl@0
   115
LOCAL_C TInt PanicThreadFunc(TAny* aPtr)
sl@0
   116
	{
sl@0
   117
	CTrapCleanup* CleanUpStack=CTrapCleanup::New();
sl@0
   118
	SPanicParams* ptr=(SPanicParams*)aPtr;
sl@0
   119
	TInt ret;
sl@0
   120
	TRAP(ret,ret=(*ptr->func)(ptr->num,ptr->capability,ptr->externalGroupId));
sl@0
   121
	delete CleanUpStack;
sl@0
   122
	if (ret==EWsExitReasonBad)
sl@0
   123
		{
sl@0
   124
		User::Panic(_L("Auto"),EAutoPanicPanicFailed);
sl@0
   125
		}
sl@0
   126
	return(ret);
sl@0
   127
	}
sl@0
   128
sl@0
   129
CTestBase::CTestBase() 
sl@0
   130
	{
sl@0
   131
	}
sl@0
   132
	
sl@0
   133
CTestBase::~CTestBase() 
sl@0
   134
	{
sl@0
   135
	iWs.Close();
sl@0
   136
	}
sl@0
   137
	
sl@0
   138
void CTestBase::ConstructL(const TDes* aCapabilityTest)
sl@0
   139
	{
sl@0
   140
	iTestCount=iTestPass=0;
sl@0
   141
	iWs.Connect();
sl@0
   142
	TLex lex(*aCapabilityTest);
sl@0
   143
 	TPtrC capability = lex.NextToken();
sl@0
   144
 	iCapabilityTest.Append(capability);
sl@0
   145
	}
sl@0
   146
	
sl@0
   147
TInt CTestBase::LaunchPanicThread(RThread& aThread, SPanicParams* aPtr)
sl@0
   148
	{
sl@0
   149
	TBuf<32> threadName;
sl@0
   150
	_LIT(KPanicThread, "AutoPanicThread%d");
sl@0
   151
	threadName.AppendFormat(KPanicThread,iThreadNumber++);
sl@0
   152
	return(aThread.Create(threadName,PanicThreadFunc,KDefaultStackSize,KPanicThreadHeapSize,KPanicThreadHeapSize,aPtr,EOwnerThread));
sl@0
   153
	}
sl@0
   154
	
sl@0
   155
TInt CTestBase::TestPanicL(SPanicParams* aPtr)
sl@0
   156
	{
sl@0
   157
	RThread thread;
sl@0
   158
	TRequestStatus stat;
sl@0
   159
	TInt err=LaunchPanicThread(thread, aPtr);
sl@0
   160
	if (err==KErrAlreadyExists)
sl@0
   161
		{
sl@0
   162
		// wait for kernel to clear up old threads
sl@0
   163
		// and have several attempts at starting the thread
sl@0
   164
		// if unsuccessful the first time
sl@0
   165
		for (TInt i=0;i<3;i++)
sl@0
   166
			{
sl@0
   167
			User::After(TTimeIntervalMicroSeconds32(100000));		//0.1 secs
sl@0
   168
			err=LaunchPanicThread(thread, aPtr);
sl@0
   169
			if (err!=KErrAlreadyExists)
sl@0
   170
				{
sl@0
   171
				break;
sl@0
   172
				}
sl@0
   173
			}
sl@0
   174
		}
sl@0
   175
	User::LeaveIfError(err);
sl@0
   176
	thread.Logon(stat);
sl@0
   177
	User::SetJustInTime(EFalse);
sl@0
   178
	thread.Resume();
sl@0
   179
	User::WaitForRequest(stat);
sl@0
   180
	User::SetJustInTime(ETrue);
sl@0
   181
	TInt threadExit=thread.ExitReason();
sl@0
   182
	if (threadExit!=EWsTestFinished)
sl@0
   183
		{
sl@0
   184
		if (gTheTestCapability==ENoCapReq)
sl@0
   185
			{
sl@0
   186
			Test(threadExit==KErrNone);
sl@0
   187
			}
sl@0
   188
		else if(gTheTestCapability==EEikSrvSID)
sl@0
   189
			{
sl@0
   190
			Test(threadExit==KErrPermissionDenied);
sl@0
   191
			}
sl@0
   192
		else if(!iCapabilityTest.Compare(KCAPABILITY_ALL))
sl@0
   193
			{
sl@0
   194
			if(gTheTestCapability!=EDoNotTest)
sl@0
   195
				{
sl@0
   196
				iTestCount++;
sl@0
   197
				if(gTheTestCapability==ESwEventPri)
sl@0
   198
					{
sl@0
   199
					Test(threadExit==KPasswordWindowGroupPriority);
sl@0
   200
					}
sl@0
   201
				else
sl@0
   202
					{
sl@0
   203
					Test(threadExit==KErrNone);
sl@0
   204
					}
sl@0
   205
				}
sl@0
   206
			}
sl@0
   207
		else if(!iCapabilityTest.Compare(KCAPABILITY_NONE))
sl@0
   208
			{
sl@0
   209
			if(gTheTestCapability!=EDoNotTest)
sl@0
   210
				{
sl@0
   211
				iTestCount++;
sl@0
   212
				if((gTheTestCapability==ENoSwEventPriSmallOrdinal)||(gTheTestCapability==ENoSwEventPri))
sl@0
   213
					{
sl@0
   214
					Test(threadExit==KPasswordWindowGroupPriority-1);
sl@0
   215
					}
sl@0
   216
				else if(gTheTestCapability==ENoSwEventErrSmallOrdinal)
sl@0
   217
					{
sl@0
   218
					Test(threadExit==KErrNone);
sl@0
   219
					}
sl@0
   220
				else if(gTheTestCapability==ENoSwEventErr)
sl@0
   221
					{
sl@0
   222
					Test(threadExit==KErrPermissionDenied);
sl@0
   223
					}
sl@0
   224
				else
sl@0
   225
					{
sl@0
   226
					Test((threadExit==EWservPanicPermissionDenied)||(threadExit==KErrPermissionDenied));
sl@0
   227
					}
sl@0
   228
				}
sl@0
   229
			}
sl@0
   230
		else if(!iCapabilityTest.Compare(KWRITEDATA_SWEVENT))
sl@0
   231
			{
sl@0
   232
			if(gTheTestCapability==EWriteDeviceData || gTheTestCapability==ESwEvent)
sl@0
   233
				{
sl@0
   234
				iTestCount++;
sl@0
   235
				Test(threadExit==KErrNone);
sl@0
   236
				}
sl@0
   237
			if(gTheTestCapability==EPowerMgmt)
sl@0
   238
				{
sl@0
   239
				iTestCount++;
sl@0
   240
				Test((threadExit==EWservPanicPermissionDenied)||(threadExit==KErrPermissionDenied));
sl@0
   241
				}
sl@0
   242
			}
sl@0
   243
		else if(!iCapabilityTest.Compare(KWRITEDATA_POWERMGMT))
sl@0
   244
			{
sl@0
   245
			if(gTheTestCapability==EWriteDeviceData || gTheTestCapability==EPowerMgmt)
sl@0
   246
				{
sl@0
   247
				iTestCount++;
sl@0
   248
				Test(threadExit==KErrNone);
sl@0
   249
				}
sl@0
   250
			if(gTheTestCapability==ESwEvent) 	
sl@0
   251
				{
sl@0
   252
				iTestCount++;
sl@0
   253
				Test((threadExit==EWservPanicPermissionDenied)||(threadExit==KErrPermissionDenied));
sl@0
   254
				}
sl@0
   255
			}
sl@0
   256
		else if(!iCapabilityTest.Compare(KPOWERMGMT_SWEVENT))
sl@0
   257
			{
sl@0
   258
			if(gTheTestCapability==EPowerMgmt || gTheTestCapability==ESwEvent)
sl@0
   259
				{
sl@0
   260
				iTestCount++;
sl@0
   261
				Test(threadExit==KErrNone);
sl@0
   262
				}
sl@0
   263
			if(gTheTestCapability==EWriteDeviceData) 
sl@0
   264
				{
sl@0
   265
				iTestCount++;
sl@0
   266
				Test((threadExit==EWservPanicPermissionDenied)||(threadExit==KErrPermissionDenied));
sl@0
   267
				}
sl@0
   268
			}
sl@0
   269
		}
sl@0
   270
	thread.Close();
sl@0
   271
	return(threadExit);
sl@0
   272
	}
sl@0
   273
sl@0
   274
TInt CTestBase::TestWsPanicL(TPanicFunction aFunction,TInt aTestNo, const TDes& aCommandLine)
sl@0
   275
	{
sl@0
   276
	TLex lex(aCommandLine);
sl@0
   277
 	TPtrC capability = lex.NextToken();
sl@0
   278
 	TPtrC idstr = lex.NextToken();
sl@0
   279
 	lex = idstr;
sl@0
   280
 	TInt id = 0;
sl@0
   281
 	lex.Val(id);
sl@0
   282
sl@0
   283
	SPanicParams params;
sl@0
   284
	params.num=aTestNo;
sl@0
   285
	params.func=aFunction;
sl@0
   286
	params.capability.Copy(capability);
sl@0
   287
	params.externalGroupId = id;
sl@0
   288
	return TestPanicL(&params);
sl@0
   289
	}
sl@0
   290
sl@0
   291
void CTestBase::Test(TInt aCondition)
sl@0
   292
	{
sl@0
   293
	if(!aCondition)
sl@0
   294
		{
sl@0
   295
		TLogMessageText buf;
sl@0
   296
		_LIT(Fail,"AUTO Failed in Capability Test : ");
sl@0
   297
		buf.Append(Fail);
sl@0
   298
		buf.Append(iCapabilityTest);
sl@0
   299
		iWs.LogMessage(buf);
sl@0
   300
		iWs.Flush();
sl@0
   301
		}
sl@0
   302
	else
sl@0
   303
		{
sl@0
   304
		iTestPass++;
sl@0
   305
		}
sl@0
   306
	}
sl@0
   307
	
sl@0
   308
void CTestBase::UpdateLogsL()
sl@0
   309
	{
sl@0
   310
	TBuf<256> testResult;
sl@0
   311
	RFs fileSession;
sl@0
   312
	RFile resultFile;
sl@0
   313
	User::LeaveIfError(fileSession.Connect());
sl@0
   314
	CleanupClosePushL(fileSession);
sl@0
   315
	resultFile.Replace(fileSession,_L("C:\\DATA\\TestResult.Dat"),EFileWrite);
sl@0
   316
	CleanupClosePushL(resultFile);
sl@0
   317
	TFileText fileText;
sl@0
   318
	fileText.Set(resultFile);
sl@0
   319
	testResult.Num(iTestCount);
sl@0
   320
	fileText.Write(testResult);
sl@0
   321
	testResult.Num(iTestPass);
sl@0
   322
	fileText.Write(testResult);
sl@0
   323
	resultFile.Close();
sl@0
   324
	fileSession.Close();
sl@0
   325
	CleanupStack::PopAndDestroy(&resultFile);
sl@0
   326
	CleanupStack::PopAndDestroy(&fileSession);
sl@0
   327
	}
sl@0
   328
	
sl@0
   329
TInt TestCapability(TInt aTest, TDes& aCapability, TInt aExternalGroupId)
sl@0
   330
	{
sl@0
   331
	_LIT(KDllName,"CLICK");
sl@0
   332
	RWsSession ws;
sl@0
   333
	ws.Connect();
sl@0
   334
	CleanupClosePushL(ws);
sl@0
   335
	RWindowGroup gr1(ws);
sl@0
   336
	RWindowGroup gr2(ws);
sl@0
   337
	gr1.Construct(EWindowGroupHandle,EFalse);
sl@0
   338
	gr2.Construct(EWindowGroupHandle2,EFalse);
sl@0
   339
	CleanupClosePushL(gr1);
sl@0
   340
	CleanupClosePushL(gr2);
sl@0
   341
	TWsEvent event;
sl@0
   342
	RSoundPlugIn click1(ws);
sl@0
   343
	CWsScreenDevice *screenDevice;
sl@0
   344
	TRawEvent rawEvent;
sl@0
   345
	CPalette* defPalette=CPalette::NewDefaultL(EColor256);
sl@0
   346
	TInt ret=KErrNone;
sl@0
   347
	switch(aTest)
sl@0
   348
		{
sl@0
   349
		case 0:
sl@0
   350
	//		ws.LogMessage(_L("EWsClOpSetKeyboardRepeatRate Capability Check"));
sl@0
   351
			gTheTestCapability=EWriteDeviceData;
sl@0
   352
			ret=ws.SetKeyboardRepeatRate(TTimeIntervalMicroSeconds32(1000000), TTimeIntervalMicroSeconds32(500000));
sl@0
   353
			ws.Flush();
sl@0
   354
			break;
sl@0
   355
		case 1:
sl@0
   356
	//		ws.LogMessage(_L("EWsClOpSetDoubleClick Capability Check"));
sl@0
   357
			gTheTestCapability=EWriteDeviceData;
sl@0
   358
			ret=ws.SetDoubleClick(TTimeIntervalMicroSeconds32(900000),10);	
sl@0
   359
			ws.Flush();
sl@0
   360
			break;
sl@0
   361
		case 2:
sl@0
   362
	//		ws.LogMessage(_L("EWsClOpSendEventToWindowGroup (external group) Capability Check"));
sl@0
   363
			gTheTestCapability=ESwEvent;
sl@0
   364
			event.SetType(EEventModifiersChanged);
sl@0
   365
			ret=ws.SendEventToWindowGroup(aExternalGroupId,event);
sl@0
   366
			break;
sl@0
   367
		case 3:
sl@0
   368
	//		ws.LogMessage(_L("EWsClOpSendEventToAllWindowGroup Capability Check"));
sl@0
   369
			gTheTestCapability=ESwEvent;
sl@0
   370
			event.SetType(EEventModifiersChanged);
sl@0
   371
			ret=ws.SendEventToAllWindowGroups(event);
sl@0
   372
			break;
sl@0
   373
		case 4:
sl@0
   374
	//		ws.LogMessage(_L("EWsClOpSendEventToAllWindowGroupPriority Capability Check"));
sl@0
   375
			gTheTestCapability=ESwEvent;
sl@0
   376
			event.SetType(EEventModifiersChanged);
sl@0
   377
			gr1.SetOrdinalPosition(0,1);
sl@0
   378
			ret=ws.SendEventToAllWindowGroups(gr1.OrdinalPriority(),event);
sl@0
   379
			break;
sl@0
   380
		case 5:
sl@0
   381
	//		ws.LogMessage(_L("EWsClOpSendEventToOneWindowGroupPerClient Capability Check"));
sl@0
   382
			gTheTestCapability=ESwEvent;
sl@0
   383
			event.SetType(EEventModifiersChanged);
sl@0
   384
			ret=ws.SendEventToOneWindowGroupsPerClient(event);
sl@0
   385
			break;
sl@0
   386
		case 6:
sl@0
   387
	//		ws.LogMessage(_L("EWsClOpSendMessageToWindowGroup (external group) Capability Check"));
sl@0
   388
			gTheTestCapability=ESwEvent;
sl@0
   389
			ret=ws.SendMessageToWindowGroup(aExternalGroupId,TUid::Uid(123),_L8("SomeParams"));
sl@0
   390
			break;
sl@0
   391
		case 7:
sl@0
   392
	//		ws.LogMessage(_L("EWsClOpClaimSystemPointerCursorList Capability Check"));
sl@0
   393
			gTheTestCapability=EWriteDeviceData;
sl@0
   394
			ret=ws.ClaimSystemPointerCursorList();
sl@0
   395
			//This may return KErrInUse if succeeds.
sl@0
   396
			if(ret==KErrInUse)
sl@0
   397
				{
sl@0
   398
				ret=KErrNone;
sl@0
   399
				}
sl@0
   400
			break;
sl@0
   401
		case 8:
sl@0
   402
	//		ws.LogMessage(_L("EWsClOpSetClientCursorMode Capability Check"));
sl@0
   403
			gTheTestCapability=EWriteDeviceData;
sl@0
   404
			ret=ws.SetClientCursorMode(EPointerCursorNone);
sl@0
   405
			ws.Flush();
sl@0
   406
			break;
sl@0
   407
		case 9:
sl@0
   408
			//Check only if capability is not defined,since the windowgroup is not focused.
sl@0
   409
			if(aCapability.Compare(KCAPABILITY_ALL)&&aCapability.Compare(KWRITEDATA_POWERMGMT)&&aCapability.Compare(KWRITEDATA_SWEVENT))
sl@0
   410
				{
sl@0
   411
	//			ws.LogMessage(_L("EWsClOpSetPointerCursorPosition Capability Check"));
sl@0
   412
				gTheTestCapability=EWriteDeviceData;
sl@0
   413
				ret=ws.SetPointerCursorPosition(TPoint(60,20));
sl@0
   414
				ws.Flush();
sl@0
   415
				}
sl@0
   416
			else
sl@0
   417
				{
sl@0
   418
				gTheTestCapability=EDoNotTest;	
sl@0
   419
				}
sl@0
   420
			break;
sl@0
   421
		case 10:
sl@0
   422
	//		ws.LogMessage(_L("EWsClOpSetModifierState Capability Check"));
sl@0
   423
			gTheTestCapability=EWriteDeviceData;
sl@0
   424
			ret=ws.SetModifierState(EModifierCapsLock,ETurnOnModifier);
sl@0
   425
			ret=ws.SetModifierState(EModifierCapsLock,ETurnOffModifier); 
sl@0
   426
			ws.Flush();
sl@0
   427
			break;
sl@0
   428
		case 11:
sl@0
   429
			{
sl@0
   430
	//		ws.LogMessage(_L("EWsClOpRawEvent Capability Check"));
sl@0
   431
			gTheTestCapability=ESwEvent;
sl@0
   432
			rawEvent.Set(TRawEvent::EActive);
sl@0
   433
			ws.SimulateRawEvent(rawEvent);
sl@0
   434
			ws.Flush();
sl@0
   435
			}
sl@0
   436
			break;
sl@0
   437
		case 12:
sl@0
   438
			{
sl@0
   439
	//		ws.LogMessage(_L("EWsClOpKeyEvent Capability Check"));
sl@0
   440
			gTheTestCapability=ESwEvent;
sl@0
   441
			TKeyEvent keyEvent;
sl@0
   442
			keyEvent.iCode='J';
sl@0
   443
			keyEvent.iScanCode=0;
sl@0
   444
			keyEvent.iModifiers=EModifierAutorepeatable;
sl@0
   445
			keyEvent.iRepeats=0;
sl@0
   446
			ws.SimulateKeyEvent(keyEvent);
sl@0
   447
			ws.Flush();
sl@0
   448
			}
sl@0
   449
			break;
sl@0
   450
		case 13:
sl@0
   451
	//		ws.LogMessage(_L("EWsClOpSendOffEventsToShell Capability Check"));
sl@0
   452
			gTheTestCapability=EPowerMgmt;
sl@0
   453
			ret=ws.RequestOffEvents(EFalse);
sl@0
   454
			break;
sl@0
   455
		case 14:
sl@0
   456
	//		ws.LogMessage(_L("EWsClOpSetFaded Capability Check"));
sl@0
   457
			gTheTestCapability=EWriteDeviceData;
sl@0
   458
			ret=ws.SetSystemFaded(EFalse);
sl@0
   459
			break;
sl@0
   460
		case 15:
sl@0
   461
			//Since there is some problem in running the  EWsClOpNoFlickerFree
sl@0
   462
			//code this test is not run if WriteDeviceData capability is defined.
sl@0
   463
	//		ws.LogMessage(_L("EWsClOpNoFlickerFree Capability Check"));
sl@0
   464
			if(aCapability.Compare(KCAPABILITY_ALL)&&aCapability.Compare(KWRITEDATA_POWERMGMT)&&aCapability.Compare(KWRITEDATA_SWEVENT))
sl@0
   465
				{
sl@0
   466
				CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws);
sl@0
   467
				gTheTestCapability=EWriteDeviceData;
sl@0
   468
				TInt err;
sl@0
   469
				if ((err=screen->Construct(0))!=KErrNone)
sl@0
   470
					{
sl@0
   471
					delete screen;
sl@0
   472
					User::Leave(err);
sl@0
   473
					}
sl@0
   474
				ws.TestWrite(ws.WsHandle(), EWsClOpNoFlickerFree, NULL, 0);
sl@0
   475
				ws.Flush();
sl@0
   476
				delete screen;
sl@0
   477
				}
sl@0
   478
			else
sl@0
   479
				{
sl@0
   480
				gTheTestCapability=EDoNotTest;
sl@0
   481
				}
sl@0
   482
			break;
sl@0
   483
		case 16:
sl@0
   484
	//		ws.LogMessage(_L("EWsClOpSetFocusScreen Capability Check"));
sl@0
   485
			gTheTestCapability=EWriteDeviceData;
sl@0
   486
			ret=ws.SetFocusScreen(0);
sl@0
   487
			break;
sl@0
   488
		case 17:
sl@0
   489
			{
sl@0
   490
			//Check only if capability is not defined. Otherwise it will shut down the shell.
sl@0
   491
			if(aCapability.Compare(KCAPABILITY_ALL)&&aCapability.Compare(KWRITEDATA_POWERMGMT)&&aCapability.Compare(KPOWERMGMT_SWEVENT))
sl@0
   492
				{
sl@0
   493
	//			ws.LogMessage(_L("EWservMessShutdown Capability Check"));
sl@0
   494
				gTheTestCapability=EPowerMgmt;
sl@0
   495
				RShellWsSession wsShell;
sl@0
   496
				wsShell.Connect();
sl@0
   497
				wsShell.ShutDown();
sl@0
   498
				}
sl@0
   499
			else
sl@0
   500
				{
sl@0
   501
				gTheTestCapability=EDoNotTest;	
sl@0
   502
				}
sl@0
   503
			break;
sl@0
   504
			}
sl@0
   505
		case 18:
sl@0
   506
	//		ws.LogMessage(_L("EWsWinOpCaptureKey Capability Check"));
sl@0
   507
			gTheTestCapability=ESwEvent;
sl@0
   508
			ret=gr2.CaptureKey('a',EModifierFunc,EModifierFunc);
sl@0
   509
			//If the function succeeds capability check,the ret value is handle identifying the capture key.
sl@0
   510
			if(ret>0)
sl@0
   511
				{
sl@0
   512
				ret=KErrNone;
sl@0
   513
				}
sl@0
   514
			break;
sl@0
   515
		case 19:
sl@0
   516
	//		ws.LogMessage(_L("EWsWinOpCaptureKeyUpsAndDowns Capability Check"));
sl@0
   517
			gTheTestCapability=ESwEvent;
sl@0
   518
			ret=gr2.CaptureKeyUpAndDowns('a',0,0);
sl@0
   519
			//If the function succeeds capability check,the ret value is handle identifying the capture key.
sl@0
   520
			if(ret>0)
sl@0
   521
				{
sl@0
   522
				ret=KErrNone;
sl@0
   523
				}
sl@0
   524
			break;
sl@0
   525
		case 20:
sl@0
   526
	//		ws.LogMessage(_L("EWsWinOpCaptureLongKey Capability Check"));
sl@0
   527
			gTheTestCapability=ESwEvent;
sl@0
   528
			ret=gr2.CaptureLongKey(EKeyEscape,'e',0,0,2,ELongCaptureNormal|ELongCaptureRepeatEvents);
sl@0
   529
			//If the function succeeds capability check,the ret value is handle identifying the capture key.
sl@0
   530
			if(ret>0)
sl@0
   531
				{
sl@0
   532
				ret=KErrNone;
sl@0
   533
				}
sl@0
   534
			break;
sl@0
   535
		case 21:
sl@0
   536
	//		ws.LogMessage(_L("EWsClickOpLoad Capability Check"));
sl@0
   537
			gTheTestCapability=EWriteDeviceData;
sl@0
   538
			click1.Construct();
sl@0
   539
			CleanupClosePushL(click1);
sl@0
   540
			ret=click1.Load(KDllName);
sl@0
   541
			CleanupStack::PopAndDestroy(&click1);
sl@0
   542
			break;
sl@0
   543
		case 22:
sl@0
   544
	//		ws.LogMessage(_L("EWsClickOpUnLoad Capability Check"));
sl@0
   545
			gTheTestCapability=EWriteDeviceData;
sl@0
   546
			click1.Construct();
sl@0
   547
			ret=click1.Unload();
sl@0
   548
			break;
sl@0
   549
		case 23:
sl@0
   550
	//		ws.LogMessage(_L("EWsSdOpSetScreenMode Capability Check"));
sl@0
   551
			gTheTestCapability=EWriteDeviceData;
sl@0
   552
			screenDevice=new(ELeave) CWsScreenDevice(ws);
sl@0
   553
			CleanupStack::PushL(screenDevice);
sl@0
   554
			screenDevice->Construct(0);
sl@0
   555
			screenDevice->SetScreenMode(0);
sl@0
   556
			CleanupStack::PopAndDestroy(screenDevice);
sl@0
   557
			break;
sl@0
   558
		case 24:
sl@0
   559
	//		ws.LogMessage(_L("EWsSdOpSetScreenModeEnforcement Capability Check"));
sl@0
   560
			gTheTestCapability=EWriteDeviceData;
sl@0
   561
			screenDevice=new(ELeave) CWsScreenDevice(ws);
sl@0
   562
			CleanupStack::PushL(screenDevice);
sl@0
   563
			screenDevice->Construct(0);
sl@0
   564
			screenDevice->SetScreenModeEnforcement(ESizeEnforcementNone);
sl@0
   565
			ws.Flush();
sl@0
   566
			CleanupStack::PopAndDestroy(screenDevice);
sl@0
   567
			break;
sl@0
   568
		case 25:
sl@0
   569
			{
sl@0
   570
	//		ws.LogMessage(_L("EWsSdOpSetPalette Capability Check"));
sl@0
   571
			gTheTestCapability=EWriteDeviceData;
sl@0
   572
			screenDevice=new(ELeave) CWsScreenDevice(ws);
sl@0
   573
			CleanupStack::PushL(screenDevice);
sl@0
   574
			screenDevice->Construct(0);
sl@0
   575
			ret=screenDevice->SetCustomPalette(defPalette);
sl@0
   576
			//Returns KErrNotSupported if succeeds capability check.
sl@0
   577
			if(ret==KErrNotSupported)
sl@0
   578
				{
sl@0
   579
				ret=KErrNone;
sl@0
   580
				}
sl@0
   581
			CleanupStack::PopAndDestroy(screenDevice);
sl@0
   582
			}
sl@0
   583
			break;
sl@0
   584
		case 26:
sl@0
   585
			{
sl@0
   586
			//Checking the capability for SetHotKeys
sl@0
   587
	//		ws.LogMessage(_L("EWsClOpSetHotKey Capability Check"));
sl@0
   588
			gTheTestCapability=ESwEvent;
sl@0
   589
			ret=ws.SetHotKey(EHotKeyEnableLogging,'e',EModifierFunc|EModifierCtrl|EModifierShift,0);
sl@0
   590
			ws.Flush();
sl@0
   591
			}
sl@0
   592
			break;
sl@0
   593
		case 27:
sl@0
   594
			{
sl@0
   595
			//Checking the capability for ClearHotKeys
sl@0
   596
	//		ws.LogMessage(_L("EWsClOpClearHotKeys Capability Check"));
sl@0
   597
			gTheTestCapability=ESwEvent;
sl@0
   598
			ret=ws.ClearHotKeys(EHotKeyEnableLogging);
sl@0
   599
			ws.Flush();
sl@0
   600
			}
sl@0
   601
			break;
sl@0
   602
		case 28:
sl@0
   603
	//		ws.LogMessage(_L("EWsClOpSendEventToWindowGroup (own group) Capability Check"));
sl@0
   604
			gTheTestCapability=ENoCapReq;
sl@0
   605
			event.SetType(EEventModifiersChanged);
sl@0
   606
			ret=ws.SendEventToWindowGroup(gr1.Identifier(),event);
sl@0
   607
			break;
sl@0
   608
		case 29:
sl@0
   609
	//		ws.LogMessage(_L("EWsClOpSendMessageToWindowGroup (own group) Capability Check"));
sl@0
   610
			gTheTestCapability=ENoCapReq;
sl@0
   611
			ret=ws.SendMessageToWindowGroup(gr1.Identifier(),TUid::Uid(123),_L8("SomeParams"));
sl@0
   612
			break;
sl@0
   613
		case 30:
sl@0
   614
	//		ws.LogMessage(_L("EWsClOpSetBackLight Capability Check"));
sl@0
   615
			gTheTestCapability=EEikSrvSID;
sl@0
   616
			screenDevice=new(ELeave) CWsScreenDevice(ws);
sl@0
   617
			CleanupStack::PushL(screenDevice);
sl@0
   618
			screenDevice->Construct(0);
sl@0
   619
			ret=screenDevice->SetBackLight(ETrue);	//Always returns KErrPermissionDenied.
sl@0
   620
			CleanupStack::PopAndDestroy(screenDevice);
sl@0
   621
			break;
sl@0
   622
		case 31:
sl@0
   623
			{
sl@0
   624
			TBool test=EFalse;
sl@0
   625
			if(!aCapability.Compare(KCAPABILITY_ALL))
sl@0
   626
				{
sl@0
   627
				gTheTestCapability=ESwEventPri;
sl@0
   628
				test=ETrue;
sl@0
   629
				}
sl@0
   630
			else if(!aCapability.Compare(KCAPABILITY_NONE))
sl@0
   631
				{
sl@0
   632
				gTheTestCapability=ENoSwEventPri;
sl@0
   633
				test=ETrue;
sl@0
   634
				}
sl@0
   635
			else
sl@0
   636
				{
sl@0
   637
				gTheTestCapability=EDoNotTest;	
sl@0
   638
				}
sl@0
   639
			if(test)
sl@0
   640
				{
sl@0
   641
				LogMessageText.Format(KSetOrdinalPositionPri);
sl@0
   642
				ws.LogMessage(LogMessageText);
sl@0
   643
				gr1.SetOrdinalPosition(0,KPasswordWindowGroupPriority);
sl@0
   644
				ret=ws.GetWindowGroupOrdinalPriority(gr1.Identifier());
sl@0
   645
				}
sl@0
   646
			}
sl@0
   647
			break;
sl@0
   648
		case 32:
sl@0
   649
			if(!aCapability.Compare(KCAPABILITY_NONE))
sl@0
   650
				{
sl@0
   651
				LogMessageText.Format(KSetOrdinalPositionPri);
sl@0
   652
				ws.LogMessage(LogMessageText);
sl@0
   653
				gTheTestCapability=ENoSwEventPriSmallOrdinal;
sl@0
   654
				gr1.SetOrdinalPosition(0,KPasswordWindowGroupPriority-1);
sl@0
   655
				ret=ws.GetWindowGroupOrdinalPriority(gr1.Identifier());
sl@0
   656
				}
sl@0
   657
			else
sl@0
   658
				{
sl@0
   659
				gTheTestCapability=EDoNotTest;	
sl@0
   660
				}
sl@0
   661
			break;
sl@0
   662
		case 33:
sl@0
   663
			{
sl@0
   664
			TBool test=EFalse;
sl@0
   665
			if(!aCapability.Compare(KCAPABILITY_ALL))
sl@0
   666
				{
sl@0
   667
				gTheTestCapability=ESwEventErr;
sl@0
   668
				test=ETrue;
sl@0
   669
				}
sl@0
   670
			else if(!aCapability.Compare(KCAPABILITY_NONE))
sl@0
   671
				{
sl@0
   672
				gTheTestCapability=ENoSwEventErr;
sl@0
   673
				test=ETrue;
sl@0
   674
				}
sl@0
   675
			else
sl@0
   676
				{
sl@0
   677
				gTheTestCapability=EDoNotTest;	
sl@0
   678
				}
sl@0
   679
			if(test)
sl@0
   680
				{
sl@0
   681
				LogMessageText.Format(KSetOrdinalPositionErr);
sl@0
   682
				ws.LogMessage(LogMessageText);
sl@0
   683
				ret=gr1.SetOrdinalPositionErr(0,KPasswordWindowGroupPriority);
sl@0
   684
				}
sl@0
   685
			}
sl@0
   686
			break;
sl@0
   687
		case 34:
sl@0
   688
			if(!aCapability.Compare(KCAPABILITY_NONE))
sl@0
   689
				{
sl@0
   690
				LogMessageText.Format(KSetOrdinalPositionErr);
sl@0
   691
				ws.LogMessage(LogMessageText);
sl@0
   692
				gTheTestCapability=ENoSwEventErrSmallOrdinal;
sl@0
   693
				ret=gr1.SetOrdinalPositionErr(0,KPasswordWindowGroupPriority-1);
sl@0
   694
				}
sl@0
   695
			else
sl@0
   696
				{
sl@0
   697
				gTheTestCapability=EDoNotTest;	
sl@0
   698
				}
sl@0
   699
			break;
sl@0
   700
		case 35:
sl@0
   701
			// EWsClOpSetCloseProximityThresholds Capability Check			
sl@0
   702
			gTheTestCapability=EWriteDeviceData;
sl@0
   703
			ret=ws.SetCloseProximityThresholds(-20, -50);
sl@0
   704
			ws.SetCloseProximityThresholds(KMaxTInt, KMinTInt);
sl@0
   705
			break;
sl@0
   706
		case 36:
sl@0
   707
			// EWsClOpSetHighPressureThresholds Capability Check			
sl@0
   708
			gTheTestCapability=EWriteDeviceData;
sl@0
   709
			ret=ws.SetHighPressureThresholds(4000, 2000);
sl@0
   710
			ws.SetHighPressureThresholds(KMaxTInt, KMinTInt);
sl@0
   711
			break;
sl@0
   712
		default:
sl@0
   713
			ret=gTestState=EWsTestFinished;
sl@0
   714
		}
sl@0
   715
	CleanupStack::PopAndDestroy(&gr2);	
sl@0
   716
	CleanupStack::PopAndDestroy(&gr1);
sl@0
   717
	CleanupStack::PopAndDestroy(&ws);
sl@0
   718
	return ret;
sl@0
   719
	}
sl@0
   720
sl@0
   721
void MainL()
sl@0
   722
	{
sl@0
   723
    TBuf<256> commandLine;
sl@0
   724
    User::CommandLine(commandLine);
sl@0
   725
	CTestBase testBase;
sl@0
   726
	testBase.ConstructL(&commandLine);
sl@0
   727
	TInt ii=0;
sl@0
   728
	while(gTestState!=EWsTestFinished)
sl@0
   729
		testBase.TestWsPanicL(&TestCapability,ii++,commandLine) ;
sl@0
   730
//	testBase.UpdateLogsL();	
sl@0
   731
	}
sl@0
   732
sl@0
   733
GLDEF_C TInt E32Main()
sl@0
   734
	{
sl@0
   735
	__UHEAP_MARK;
sl@0
   736
	CTrapCleanup* cleanUpStack=CTrapCleanup::New();
sl@0
   737
	if(cleanUpStack==NULL)
sl@0
   738
		{
sl@0
   739
		return KErrNoMemory;
sl@0
   740
		}
sl@0
   741
	TRAP_IGNORE(MainL())
sl@0
   742
	delete cleanUpStack;
sl@0
   743
	__UHEAP_MARKEND;
sl@0
   744
	return(KErrNone);
sl@0
   745
	}