os/graphics/graphicstest/uibench/src/tmultiptreventhandlingperf.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2008-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
//
sl@0
    15
sl@0
    16
/**
sl@0
    17
 @file
sl@0
    18
 @test
sl@0
    19
 @internalComponent - Internal Symbian test code 
sl@0
    20
*/
sl@0
    21
sl@0
    22
#include "tmultiptreventhandlingperf.h"
sl@0
    23
#include <hal.h>
sl@0
    24
sl@0
    25
_LIT(KPerformanceTimingChunk, "PerformanceTimingChunk");
sl@0
    26
sl@0
    27
// Number of iterations for eventset
sl@0
    28
const TInt KNumOfIterations = 100;
sl@0
    29
sl@0
    30
// Maximum descriptor length for results
sl@0
    31
const TInt KMaxDescLength = 528;
sl@0
    32
sl@0
    33
// Static variables used for synchronisation between threads
sl@0
    34
GLDEF_D TInt NumOfEventsAdded = 0;
sl@0
    35
GLDEF_D RMutex Mutex;
sl@0
    36
GLDEF_D RCondVar ConVar;
sl@0
    37
sl@0
    38
void MultiPtrPerfPanic(TInt aPanic)
sl@0
    39
	{
sl@0
    40
	User::Panic(_L("MultiPterEventHanldingPerformancePanic"), aPanic);
sl@0
    41
	}
sl@0
    42
sl@0
    43
// This function opens the chunk and adds the failure description followed by '*'
sl@0
    44
TInt CMultiPtrPerfTestControl::Failed(TPoint3D aExp3DPoint, TPoint3D aActual3DPoint, TInt aErrorCode, TInt aExpPtrNum, TInt aActPtrNum)
sl@0
    45
	{
sl@0
    46
	TInt ret = iChunk.OpenGlobal(KPerformanceTimingChunk, ETrue);
sl@0
    47
	if (ret != KErrNone)
sl@0
    48
		{
sl@0
    49
		return ret;
sl@0
    50
		}
sl@0
    51
	TUint8* desPtr = iChunk.Base() + iChunkOffset;
sl@0
    52
	TPtr8 ptrDes(desPtr, 0, KMaxDescLength);
sl@0
    53
	
sl@0
    54
	TBuf<80> buf;
sl@0
    55
	if (aExpPtrNum != aActPtrNum)
sl@0
    56
		{
sl@0
    57
		_LIT(KFailedPointerNum, "Failed Expected Pointer Num = %d Actual Pointer Num = %d*");
sl@0
    58
		buf.AppendFormat(KFailedPointerNum, aExpPtrNum, aActPtrNum);
sl@0
    59
		ptrDes.Append(buf);
sl@0
    60
		} 
sl@0
    61
	else if (aErrorCode != KErrNone)
sl@0
    62
		{
sl@0
    63
		_LIT(KFailedErrorCode, "Failed Errorcode = %d*");
sl@0
    64
		buf.AppendFormat(KFailedErrorCode, aErrorCode);
sl@0
    65
		ptrDes.Append(buf);
sl@0
    66
		}
sl@0
    67
	else
sl@0
    68
		{
sl@0
    69
		_LIT(KFailedWrongCoord, "Failed Coordinates Expected = [%d, %d, %d] Actual = [%d, %d, %d]*");
sl@0
    70
		buf.AppendFormat(KFailedWrongCoord, aExp3DPoint.iX, aExp3DPoint.iY, aExp3DPoint.iZ, aActual3DPoint.iX, aActual3DPoint.iY, aActual3DPoint.iZ);
sl@0
    71
		ptrDes.Append(buf);
sl@0
    72
		}
sl@0
    73
	
sl@0
    74
	iChunk.Close();
sl@0
    75
	return ret;
sl@0
    76
	}
sl@0
    77
sl@0
    78
// This function opens the chunk and adds a pointer event not supported message followed by '#'
sl@0
    79
TInt CMultiPtrPerfTestControl::PointerEventsNotSupported()
sl@0
    80
    {
sl@0
    81
    iPointerEventNotSupported = ETrue;
sl@0
    82
    TInt ret = iChunk.OpenGlobal(KPerformanceTimingChunk, ETrue);
sl@0
    83
        if (ret != KErrNone)
sl@0
    84
            {
sl@0
    85
            return ret;
sl@0
    86
            }
sl@0
    87
    TUint8* desPtr = iChunk.Base() + iChunkOffset;
sl@0
    88
    TPtr8 ptrDes(desPtr, 0, KMaxDescLength);
sl@0
    89
    TBuf<80> buf;
sl@0
    90
    _LIT(KPointerEventsNotSupported, "Test Skipped As Pointer Events Are Not Supported By This Configuration#");
sl@0
    91
    buf.AppendFormat(KPointerEventsNotSupported);
sl@0
    92
    ptrDes.Append(buf);
sl@0
    93
    iChunk.Close();
sl@0
    94
    return ret;
sl@0
    95
    }
sl@0
    96
sl@0
    97
// This function calulates the average latency, opens the chunk and appends
sl@0
    98
// the same in descriptor form. Then close the child thread and calls function 
sl@0
    99
// for creating new thread for events. 
sl@0
   100
// If all the events have been tested then stops the tests
sl@0
   101
// by calling active CActiveScheduler::Stop. 
sl@0
   102
TInt CMultiPtrPerfTestControl::CalculateLatencyAndStartThread()
sl@0
   103
	{
sl@0
   104
	TInt ret = KErrNone;
sl@0
   105
	switch (iPtrAppUi->TestCaseNum())
sl@0
   106
		{
sl@0
   107
		case 1:
sl@0
   108
		case 5:
sl@0
   109
		case 9:
sl@0
   110
		case 13:	
sl@0
   111
			iAverageLatency = iLatency/(4*KNumOfIterations);
sl@0
   112
			break;
sl@0
   113
		case 2:
sl@0
   114
		case 6:
sl@0
   115
		case 10:
sl@0
   116
		case 14:
sl@0
   117
			iAverageLatency = iLatency/(8*KNumOfIterations);
sl@0
   118
			break;
sl@0
   119
		case 3:
sl@0
   120
		case 7:
sl@0
   121
		case 11:
sl@0
   122
		case 15:
sl@0
   123
			iAverageLatency = iLatency/(16*KNumOfIterations);
sl@0
   124
			break;
sl@0
   125
		case 4:
sl@0
   126
		case 8:
sl@0
   127
		case 12:
sl@0
   128
		case 16:
sl@0
   129
			iAverageLatency = iLatency/(32*KNumOfIterations);
sl@0
   130
			break;
sl@0
   131
		default:
sl@0
   132
			MultiPtrPerfPanic(EMultiPtrPerfPanicWrongTest);
sl@0
   133
		}
sl@0
   134
sl@0
   135
	ret = iChunk.OpenGlobal(KPerformanceTimingChunk, ETrue);
sl@0
   136
	if (ret != KErrNone)
sl@0
   137
		{
sl@0
   138
		return ret;
sl@0
   139
		}
sl@0
   140
	TUint8* desPtr = iChunk.Base() + iChunkOffset;
sl@0
   141
	TPtr8 ptrDes(desPtr, iLatLenInLetters, KMaxDescLength);
sl@0
   142
	
sl@0
   143
	TBuf<66> buf;
sl@0
   144
	buf.Num(iAverageLatency);
sl@0
   145
	buf.Append(',');
sl@0
   146
	ptrDes.Append(buf);
sl@0
   147
	
sl@0
   148
	// reset the iLatency for next set of test
sl@0
   149
	iLatency = 0;	
sl@0
   150
	
sl@0
   151
	// For writing the next latency in chunk memory
sl@0
   152
	iLatLenInLetters = ptrDes.Length();
sl@0
   153
	
sl@0
   154
	iChunk.Close();
sl@0
   155
	
sl@0
   156
	// Before calling the thread Function close the current thread and then call the function
sl@0
   157
	// here when we kill the child thread it releases both mutex and condvar that it holds
sl@0
   158
	iPtrAppUi->ChildThread().Kill(KErrNone);
sl@0
   159
	iPtrAppUi->ChildThread().Close();
sl@0
   160
	
sl@0
   161
	if (iPtrAppUi->TestCaseNum() == 16)
sl@0
   162
		{
sl@0
   163
		// It it is the last test case then stop the active scheduler
sl@0
   164
		CActiveScheduler::Stop();
sl@0
   165
		return ret;
sl@0
   166
		}
sl@0
   167
	else
sl@0
   168
		{
sl@0
   169
		return iPtrAppUi->CreateEventSimulatingThreads();
sl@0
   170
		}
sl@0
   171
	}
sl@0
   172
sl@0
   173
// This function is called by Cone whenever a event is outstanding
sl@0
   174
// Here we check if the sent event is same as the expected event in array.
sl@0
   175
// Then resumes the thread for next set of events. When all the events are completed
sl@0
   176
// calls CalculateLatencyAndStartThread
sl@0
   177
void CMultiPtrPerfTestControl::HandlePointerEventL(const TPointerEvent& aPointerEvent)
sl@0
   178
	{
sl@0
   179
    ASSERT(!iPointerEventNotSupported);
sl@0
   180
	// The event that is received is (0,0,0) then it is the first event that the test code is sending
sl@0
   181
	const TAdvancedPointerEvent* advancedPointerEvent = aPointerEvent.AdvancedPointerEvent();
sl@0
   182
	
sl@0
   183
	if (iPtrAppUi->TestCaseNum() == 0)
sl@0
   184
		{
sl@0
   185
		if (advancedPointerEvent->PointerNumber() == 0 && advancedPointerEvent->Position3D() == TPoint3D())
sl@0
   186
			{
sl@0
   187
			iPtrAppUi->CreateEventSimulatingThreads();
sl@0
   188
			return;
sl@0
   189
			}
sl@0
   190
		else
sl@0
   191
			{
sl@0
   192
			return;	// ignore other events before starting the tests
sl@0
   193
			}
sl@0
   194
		}
sl@0
   195
sl@0
   196
	// Get the current time.
sl@0
   197
	// Subtract from the test start time.
sl@0
   198
	TTime currentTime;
sl@0
   199
	currentTime.UniversalTime();
sl@0
   200
	TInt64 curTime64 = currentTime.Int64();
sl@0
   201
	TInt timeSinceTestStart = curTime64 - iPtrAppUi->TestStartTime();
sl@0
   202
	
sl@0
   203
	// Get the event, get the time stored in Z corodinate
sl@0
   204
	// Then subtract the calculated time from Z coordinate
sl@0
   205
	iLatency += timeSinceTestStart - advancedPointerEvent->ProximityAndPressure(); 
sl@0
   206
	
sl@0
   207
	// Get the current event from buffer and compare it with got event
sl@0
   208
	TAdvancedPointerEvent expectedPtrEvent;
sl@0
   209
	if(0 == iEventBuffer.Remove(&expectedPtrEvent))
sl@0
   210
		{
sl@0
   211
		iPtrAppUi->Failed(TPoint3D(), TPoint3D(), KErrNotFound);
sl@0
   212
		return;
sl@0
   213
		}
sl@0
   214
	
sl@0
   215
	// Here Z corodinate is not checked.
sl@0
   216
	if (expectedPtrEvent.iPosition != advancedPointerEvent->iPosition)
sl@0
   217
		{
sl@0
   218
		iPtrAppUi->Failed(expectedPtrEvent.Position3D(), advancedPointerEvent->Position3D(), KErrNone);
sl@0
   219
		return;
sl@0
   220
		}
sl@0
   221
	
sl@0
   222
	if (expectedPtrEvent.PointerNumber() != advancedPointerEvent->PointerNumber())
sl@0
   223
		{
sl@0
   224
		iPtrAppUi->Failed(TPoint3D(), TPoint3D(), KErrNone, expectedPtrEvent.PointerNumber(), advancedPointerEvent->PointerNumber());
sl@0
   225
		return;
sl@0
   226
		}
sl@0
   227
	
sl@0
   228
	iPtrAppUi->DecrementEventCount();
sl@0
   229
	NumOfEventsAdded--;
sl@0
   230
	
sl@0
   231
	// Event count is zero when all the events have been tested
sl@0
   232
	if (iPtrAppUi->EventCount() == 0)
sl@0
   233
		{
sl@0
   234
		TInt ret = CalculateLatencyAndStartThread(); 
sl@0
   235
		if (ret != KErrNone)
sl@0
   236
			{
sl@0
   237
			iPtrAppUi->Failed(TPoint3D(), TPoint3D(), ret);
sl@0
   238
			return;
sl@0
   239
			}
sl@0
   240
		}
sl@0
   241
	else if (NumOfEventsAdded == 0) 
sl@0
   242
		{
sl@0
   243
		ConVar.Signal();
sl@0
   244
		}
sl@0
   245
	}
sl@0
   246
sl@0
   247
void CMultiPtrPerfTestControl::AddExpectedEvent(TAdvancedPointerEvent& aExpEvent)
sl@0
   248
	{
sl@0
   249
	iEventBuffer.Add(&aExpEvent);
sl@0
   250
	}
sl@0
   251
sl@0
   252
CMultiPtrPerfTestControl::~CMultiPtrPerfTestControl()
sl@0
   253
	{
sl@0
   254
	iChunk.Close();
sl@0
   255
	}
sl@0
   256
sl@0
   257
void CMultiPtrPerfTestControl::ConstructL()
sl@0
   258
	{
sl@0
   259
    iPointerEventNotSupported = EFalse;
sl@0
   260
	ConstructL(TPoint(), ControlEnv()->ScreenDevice()->SizeInPixels());
sl@0
   261
	}
sl@0
   262
sl@0
   263
void CMultiPtrPerfTestControl::ConstructL(TPoint aOrigin, TSize aSize)
sl@0
   264
	{
sl@0
   265
    iEventBuffer.SetLengthL(EEventBufferSize);
sl@0
   266
    
sl@0
   267
    iPtrAppUi = static_cast<CMultiPtrPerfTestAppUi*>(ControlEnv()->AppUi());
sl@0
   268
        
sl@0
   269
    CreateWindowL();
sl@0
   270
    Window().EnableAdvancedPointers();
sl@0
   271
    EnableDragEvents();
sl@0
   272
    SetExtent(aOrigin, aSize);
sl@0
   273
    ActivateL();
sl@0
   274
    
sl@0
   275
 	// Get the cmdline argument of this process in descriptor
sl@0
   276
 	// convert the descriptor to number and store it in iChunkOffset
sl@0
   277
 	TBuf<128> buf;
sl@0
   278
 	User::CommandLine(buf);
sl@0
   279
 	TLex lex(buf);
sl@0
   280
 	User::LeaveIfError(lex.Val(iChunkOffset));
sl@0
   281
	}
sl@0
   282
sl@0
   283
// This function gets the current time and subtracts it from the time when the whole test was started.
sl@0
   284
// Simulates the event and suspends the thread if aWaitAfterEachEvent is ETrue
sl@0
   285
// If aWaitAfterEachEvent is EFalse then it suspends the thread after each set of event i,e after 4, 8, 16 and 32 events 
sl@0
   286
void SimulatePointerEvents(TInt aCount, CMultiPtrPerfTestAppUi* appUi, TBool aMultiPtrEvent = EFalse, TBool aWaitAfterEachEvent = ETrue)
sl@0
   287
	{
sl@0
   288
	TRawEvent rawEvent;
sl@0
   289
	TPoint ptrPos;
sl@0
   290
	TTime currentTime;
sl@0
   291
	TInt64 testStartTime = appUi->TestStartTime();
sl@0
   292
	TInt ptrNum = 0;
sl@0
   293
	TInt ptrMax = 0;
sl@0
   294
	// HAL as already been tested at the start of these tests. So no need to test once again
sl@0
   295
	HAL::Get(HALData::EPointerNumberOfPointers, ptrMax);
sl@0
   296
	
sl@0
   297
	appUi->SetNumberOfEvents((KNumOfIterations*aCount)-1);
sl@0
   298
sl@0
   299
	// For testing time taken for each event and for each set of events we make use of RMutex and RConvar.
sl@0
   300
	// RMutex is used not to preempt this thread until events has been added
sl@0
   301
	// RConVar is used to hold this thread until the events have been tested
sl@0
   302
	for (TInt loop = 0; loop < KNumOfIterations; loop++)
sl@0
   303
		{
sl@0
   304
		ptrNum = 0;
sl@0
   305
		ptrPos.iX = ptrPos.iY = 0;
sl@0
   306
		Mutex.Wait();
sl@0
   307
		for (TInt count = 0; count < aCount/2; count++, ptrNum++)
sl@0
   308
			{
sl@0
   309
			if (ptrNum >= ptrMax)
sl@0
   310
				{
sl@0
   311
				ptrNum = 0;
sl@0
   312
				}			
sl@0
   313
			ptrPos.iX += 2;
sl@0
   314
			ptrPos.iY += 1;
sl@0
   315
			
sl@0
   316
			TWsEvent event;
sl@0
   317
			event.InitAdvancedPointerEvent(TPointerEvent::EButton1Down, 0, TPoint3D(ptrPos.iX, ptrPos.iY, 0), (aMultiPtrEvent ? ptrNum : 0));
sl@0
   318
			appUi->AddExpectedEvent(*event.Pointer());
sl@0
   319
			currentTime.UniversalTime();
sl@0
   320
			TInt64 curTime64 = currentTime.Int64();
sl@0
   321
			TInt timeSinceTestStart = curTime64 - testStartTime;
sl@0
   322
			rawEvent.Set(TRawEvent::EButton1Down, ptrPos.iX, ptrPos.iY, timeSinceTestStart, (aMultiPtrEvent ? ptrNum : 0));
sl@0
   323
			UserSvr::AddEvent(rawEvent);
sl@0
   324
			NumOfEventsAdded++;
sl@0
   325
			if (aWaitAfterEachEvent)
sl@0
   326
				{
sl@0
   327
				while(NumOfEventsAdded)
sl@0
   328
					ConVar.Wait(Mutex);
sl@0
   329
				}
sl@0
   330
			
sl@0
   331
			event.InitAdvancedPointerEvent(TPointerEvent::EButton1Up, 0, TPoint3D(ptrPos.iX, ptrPos.iY, 0), (aMultiPtrEvent ? ptrNum : 0));
sl@0
   332
			appUi->AddExpectedEvent(*event.Pointer());
sl@0
   333
			currentTime.UniversalTime();
sl@0
   334
			curTime64 = currentTime.Int64();
sl@0
   335
			timeSinceTestStart = curTime64 - testStartTime;
sl@0
   336
			rawEvent.Set(TRawEvent::EButton1Up, ptrPos.iX, ptrPos.iY, timeSinceTestStart, (aMultiPtrEvent ? ptrNum : 0));
sl@0
   337
			UserSvr::AddEvent(rawEvent);
sl@0
   338
			NumOfEventsAdded++;
sl@0
   339
			if (aWaitAfterEachEvent)
sl@0
   340
				{
sl@0
   341
				while(NumOfEventsAdded)
sl@0
   342
					ConVar.Wait(Mutex);
sl@0
   343
				}
sl@0
   344
			}
sl@0
   345
		if (!aWaitAfterEachEvent)
sl@0
   346
			{
sl@0
   347
			while(NumOfEventsAdded)
sl@0
   348
				ConVar.Wait(Mutex);
sl@0
   349
			}
sl@0
   350
		Mutex.Signal();
sl@0
   351
		}
sl@0
   352
	}
sl@0
   353
sl@0
   354
TInt EventSimulatingThreadStartFunc(TAny* aAny)
sl@0
   355
	{
sl@0
   356
	CMultiPtrPerfTestAppUi* appUi = static_cast<CMultiPtrPerfTestAppUi*>(aAny);
sl@0
   357
sl@0
   358
	switch(appUi->TestCaseNum()++)
sl@0
   359
		{
sl@0
   360
		case 0:
sl@0
   361
			SimulatePointerEvents(4, appUi);
sl@0
   362
			break;
sl@0
   363
		case 1:
sl@0
   364
			SimulatePointerEvents(8, appUi);
sl@0
   365
			break;
sl@0
   366
		case 2:
sl@0
   367
			SimulatePointerEvents(16, appUi);
sl@0
   368
			break;
sl@0
   369
		case 3:
sl@0
   370
			SimulatePointerEvents(32, appUi);
sl@0
   371
			break;
sl@0
   372
		case 4:
sl@0
   373
			SimulatePointerEvents(4, appUi, ETrue);
sl@0
   374
			break;
sl@0
   375
		case 5:
sl@0
   376
			SimulatePointerEvents(8, appUi, ETrue);
sl@0
   377
			break;
sl@0
   378
		case 6:
sl@0
   379
			SimulatePointerEvents(16, appUi, ETrue);
sl@0
   380
			break;
sl@0
   381
		case 7:
sl@0
   382
			SimulatePointerEvents(32, appUi, ETrue);
sl@0
   383
			break;
sl@0
   384
		case 8:
sl@0
   385
			SimulatePointerEvents(4, appUi, EFalse, EFalse);
sl@0
   386
			break;
sl@0
   387
		case 9:
sl@0
   388
			SimulatePointerEvents(8, appUi, EFalse, EFalse);
sl@0
   389
			break;
sl@0
   390
		case 10:
sl@0
   391
			SimulatePointerEvents(16, appUi, EFalse, EFalse);
sl@0
   392
			break;
sl@0
   393
		case 11:
sl@0
   394
			SimulatePointerEvents(32, appUi, EFalse, EFalse);
sl@0
   395
			break;
sl@0
   396
		case 12:
sl@0
   397
			SimulatePointerEvents(4, appUi, ETrue, EFalse);
sl@0
   398
			break;
sl@0
   399
		case 13:
sl@0
   400
			SimulatePointerEvents(8, appUi, ETrue, EFalse);
sl@0
   401
			break;
sl@0
   402
		case 14:
sl@0
   403
			SimulatePointerEvents(16, appUi, ETrue, EFalse);
sl@0
   404
			break;
sl@0
   405
		case 15:
sl@0
   406
			SimulatePointerEvents(32, appUi, ETrue, EFalse);
sl@0
   407
			break;		
sl@0
   408
		default:
sl@0
   409
			break;
sl@0
   410
		}
sl@0
   411
	return KErrNone;
sl@0
   412
	}
sl@0
   413
sl@0
   414
TInt CMultiPtrPerfTestAppUi::CreateEventSimulatingThreads()
sl@0
   415
	{
sl@0
   416
	// Depending upon the iTestCase number create thread and simulate events in that thread function
sl@0
   417
	TInt ret = KErrNone;
sl@0
   418
	_LIT(KSimulateEventsThread, "Events simulating thread");
sl@0
   419
	ret = iThread.Create(KSimulateEventsThread, EventSimulatingThreadStartFunc, KDefaultStackSize, 0x4000, 0x4000, this, EOwnerThread);
sl@0
   420
	if (ret == KErrNone)
sl@0
   421
		{
sl@0
   422
		iThread.Resume();
sl@0
   423
		}
sl@0
   424
	return ret;
sl@0
   425
	}
sl@0
   426
sl@0
   427
void CMultiPtrPerfTestAppUi::AddExpectedEvent(TAdvancedPointerEvent& aExpEvent)
sl@0
   428
	{
sl@0
   429
	iControl->AddExpectedEvent(aExpEvent);
sl@0
   430
	}
sl@0
   431
sl@0
   432
void CMultiPtrPerfTestAppUi::Failed(TPoint3D aExp3DPoint, TPoint3D aActual3DPoint, TInt aErrorCode, TInt aExpPtrNum, TInt aActPtrNum)
sl@0
   433
	{
sl@0
   434
	// Write error description in the memory of shared chunk 
sl@0
   435
	// so that the main performance test just stops by saying that it failed
sl@0
   436
	// and then stop the active scheduler.
sl@0
   437
	iControl->Failed(aExp3DPoint, aActual3DPoint, aErrorCode, aExpPtrNum, aActPtrNum);
sl@0
   438
	CActiveScheduler::Stop();
sl@0
   439
	}
sl@0
   440
sl@0
   441
void CMultiPtrPerfTestAppUi::PointerEventsNotSupported()
sl@0
   442
    {
sl@0
   443
    // Write a pointer events not supported message in the memory of shared chunk 
sl@0
   444
    // so that the main performance test just skips the pointer test
sl@0
   445
    iControl->PointerEventsNotSupported();
sl@0
   446
    }
sl@0
   447
sl@0
   448
CMultiPtrPerfTestAppUi::CMultiPtrPerfTestAppUi()
sl@0
   449
	{
sl@0
   450
	}
sl@0
   451
sl@0
   452
CMultiPtrPerfTestAppUi::~CMultiPtrPerfTestAppUi()
sl@0
   453
	{
sl@0
   454
	RemoveFromStack(iControl);
sl@0
   455
	delete iControl;
sl@0
   456
	}
sl@0
   457
sl@0
   458
void CMultiPtrPerfTestAppUi::ConstructL()
sl@0
   459
	{
sl@0
   460
	CCoeAppUi::ConstructL();
sl@0
   461
	
sl@0
   462
	TTime testStartTime;
sl@0
   463
	testStartTime.UniversalTime();
sl@0
   464
	iTestStartTime = testStartTime.Int64();
sl@0
   465
	
sl@0
   466
	iControl = new (ELeave) CMultiPtrPerfTestControl();
sl@0
   467
	iControl->ConstructL();
sl@0
   468
	AddToStackL(iControl);
sl@0
   469
	}
sl@0
   470
sl@0
   471
void ConstructControlEnvironmentL(CCoeEnv* aCoe)
sl@0
   472
	{
sl@0
   473
 	aCoe->ConstructL();
sl@0
   474
 	CMultiPtrPerfTestAppUi* appUi=new(ELeave) CMultiPtrPerfTestAppUi();
sl@0
   475
 	CleanupStack::PushL(appUi);			// If it leaves after this then there is no way of deleting the appui
sl@0
   476
 	aCoe->SetAppUi(appUi);				// So pushed it on to cleanup stack
sl@0
   477
 	aCoe->WsSession().SetAutoFlush(ETrue);
sl@0
   478
 	appUi->ConstructL();
sl@0
   479
 	User::LeaveIfError(Mutex.CreateLocal(EOwnerProcess));
sl@0
   480
 	User::LeaveIfError(ConVar.CreateLocal(EOwnerProcess));
sl@0
   481
 	CleanupStack::Pop(appUi);
sl@0
   482
	}
sl@0
   483
sl@0
   484
GLDEF_C TInt E32Main()
sl@0
   485
	{
sl@0
   486
	__UHEAP_MARK;
sl@0
   487
	CCoeEnv* coe = new CCoeEnv;
sl@0
   488
	if (!coe)
sl@0
   489
		{
sl@0
   490
		return KErrNoMemory; 
sl@0
   491
		}
sl@0
   492
	TRAPD(err, ConstructControlEnvironmentL(coe));
sl@0
   493
	if (err != KErrNone)
sl@0
   494
		{
sl@0
   495
		delete coe;
sl@0
   496
		}
sl@0
   497
	else	// If KErrNone then no need to delte coe as it is taken care by ConEnv
sl@0
   498
		{
sl@0
   499
        // Check whether the configuration supports pointer events.
sl@0
   500
        // If it dosn't support pointer events then the pointer cursor area will be empty,
sl@0
   501
        // in this case skip the test and inform the test framework that the test has been skipped
sl@0
   502
        TRect pointerCursorArea = coe->WsSession().PointerCursorArea();
sl@0
   503
        if(pointerCursorArea.IsEmpty())
sl@0
   504
            {
sl@0
   505
            RDebug::Printf("PointerCursorArea is Empty");
sl@0
   506
            CMultiPtrPerfTestAppUi* appUi = static_cast<CMultiPtrPerfTestAppUi*>(coe->AppUi());
sl@0
   507
            appUi->PointerEventsNotSupported();
sl@0
   508
            }
sl@0
   509
        else
sl@0
   510
            {
sl@0
   511
            // First event which starts the test from HandlePointerEventL
sl@0
   512
            TRawEvent rawEvent;
sl@0
   513
            rawEvent.Set(TRawEvent::EButton1Down, 0, 0, 0, 0);
sl@0
   514
            UserSvr::AddEvent(rawEvent);
sl@0
   515
            coe->ExecuteD();
sl@0
   516
            }
sl@0
   517
		Mutex.Close();
sl@0
   518
		ConVar.Close();
sl@0
   519
	 	}
sl@0
   520
	
sl@0
   521
	__UHEAP_MARKEND;
sl@0
   522
	return err;
sl@0
   523
	}