windowing/windowserver/test/tauto/tevent_captureapp.cpp
changeset 188 1b081cb0800b
equal deleted inserted replaced
187:9f66f99ee56f 188:1b081cb0800b
       
     1 // Copyright (c) 2010 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 // Helper application for TEvent test case GRAPHICS-WSERV-0757
       
    15 //
       
    16 
       
    17 #include <e32base.h>
       
    18 #include <e32debug.h>
       
    19 #include <w32std.h>
       
    20 
       
    21 const TInt KCapturePriority = 1;
       
    22 
       
    23 LOCAL_C void MainL()
       
    24 	{
       
    25 	RWsSession session;
       
    26 	User::LeaveIfError(session.Connect());
       
    27 	CleanupClosePushL(session);
       
    28 	RWindowGroup group(session);
       
    29 	User::LeaveIfError(group.Construct(0));
       
    30 
       
    31 	// Capture keys EKeyF22 and EKeyF23 with raised
       
    32 	// priority for each of the three capture types.
       
    33 	TInt handle1 = User::LeaveIfError(group.CaptureKey(EKeyF22, 0, 0, KCapturePriority));
       
    34 	TInt handle2 = User::LeaveIfError(group.CaptureKeyUpAndDowns(EStdKeyF22, 0, 0, KCapturePriority));
       
    35 	TInt handle3 = User::LeaveIfError(group.CaptureLongKey(EKeyF22, EKeyF22, 0, 0, KCapturePriority, ELongCaptureNormal));
       
    36 	TInt handle4 = User::LeaveIfError(group.CaptureKey(EKeyF23, 0, 0, KCapturePriority));
       
    37 	TInt handle5 = User::LeaveIfError(group.CaptureKeyUpAndDowns(EStdKeyF23, 0, 0, KCapturePriority));
       
    38 	TInt handle6 = User::LeaveIfError(group.CaptureLongKey(EKeyF23, EKeyF23, 0, 0, KCapturePriority, ELongCaptureNormal));
       
    39 
       
    40 	// Complete rendezvous with TEvent. This signals that all the capture
       
    41 	// requests have been made.
       
    42 	RProcess::Rendezvous(KErrNone);
       
    43 
       
    44 	// Wait until killed by TEvent
       
    45 	User::WaitForAnyRequest();
       
    46 
       
    47 	group.CancelCaptureKey(handle1);
       
    48 	group.CancelCaptureKeyUpAndDowns(handle2);
       
    49 	group.CancelCaptureLongKey(handle3);
       
    50 	group.CancelCaptureKey(handle4);
       
    51 	group.CancelCaptureKeyUpAndDowns(handle5);
       
    52 	group.CancelCaptureLongKey(handle6);
       
    53 
       
    54 	CleanupStack::PopAndDestroy(&session);
       
    55 	}
       
    56 
       
    57 GLDEF_C TInt E32Main()
       
    58 	{	
       
    59 	__UHEAP_MARK;
       
    60 
       
    61 	CTrapCleanup* cleanupStack = CTrapCleanup::New(); 	
       
    62 	TRAPD(ret, MainL());	
       
    63 	delete cleanupStack;
       
    64 	
       
    65 	__UHEAP_MARKEND;
       
    66 	return ret;
       
    67 	}