os/kernelhwsrv/kerneltest/e32test/device/t_keyboardrotate.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 the License "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
// e32test\device\t_keyboardrotate.cpp
sl@0
    15
// Keyboard Rotation test file
sl@0
    16
// 
sl@0
    17
//
sl@0
    18
sl@0
    19
#include <e32test.h>
sl@0
    20
#include <e32svr.h>
sl@0
    21
#include <e32event.h>
sl@0
    22
#include <e32event_private.h>
sl@0
    23
#include <hal.h>
sl@0
    24
sl@0
    25
 //---------------------------------------------
sl@0
    26
 //! @SYMTestCaseID PBASE_KEYBOARDROTATE
sl@0
    27
 //! @SYMTestType UT
sl@0
    28
 //! @SYMTestCaseDesc Manual test of keyboard rotation modifiers.
sl@0
    29
 //! @SYMREQ CR - APOS-666C3S 
sl@0
    30
 //! @SYMTestActions Select each of 4 possible keyboard rotations and verify correct behaviour.
sl@0
    31
 //! @SYMTestExpectedResults The described section of the keyboard is rotated as displayed by the test.
sl@0
    32
 //! @SYMTestPriority High
sl@0
    33
 //---------------------------------------------
sl@0
    34
sl@0
    35
LOCAL_D RTest test(_L("T_KEYBOARDROTATE"));
sl@0
    36
sl@0
    37
GLDEF_C TInt E32Main()	
sl@0
    38
	{
sl@0
    39
sl@0
    40
	test.Title();
sl@0
    41
	test.Start(_L("Test Keyboard Rotation Modifiers\n"));
sl@0
    42
	test.Printf(_L("The following 3x3 grid of keys can be rotated: \n\n"));
sl@0
    43
	test.Printf(_L("Q W E\n\n"));
sl@0
    44
	test.Printf(_L("A S D\n\n"));
sl@0
    45
	test.Printf(_L("Z X C\n\n"));
sl@0
    46
sl@0
    47
	TKeyCode response;
sl@0
    48
	TRawEvent event;
sl@0
    49
sl@0
    50
	TInt machineuid;
sl@0
    51
	HAL::Get(HAL::EMachineUid, machineuid);
sl@0
    52
	if(machineuid != HAL::EMachineUid_Lubbock && machineuid != HAL::EMachineUid_Win32Emulator)
sl@0
    53
		{
sl@0
    54
		test.Printf(_L("Test only supports Lubbock platform and emulator\n"));
sl@0
    55
		test.End();
sl@0
    56
		return(0);
sl@0
    57
		}
sl@0
    58
sl@0
    59
	for(;;)
sl@0
    60
		{
sl@0
    61
		test.Printf(_L("Select desired option: \n\n"));
sl@0
    62
		test.Printf(_L("(1) Rotate 90 deg clockwise\n"));
sl@0
    63
		test.Printf(_L("(2) Rotate 180 deg clockwise\n"));
sl@0
    64
		test.Printf(_L("(3) Rotate 270 deg clockwise\n"));
sl@0
    65
		test.Printf(_L("(4) Return to default layout\n\n"));
sl@0
    66
		test.Printf(_L("Press any other key to exit\n\n"));
sl@0
    67
sl@0
    68
		response=test.Getch();
sl@0
    69
sl@0
    70
		switch((TInt)response)
sl@0
    71
			{
sl@0
    72
			case '1':
sl@0
    73
				event.Set(TRawEvent::EUpdateModifiers, EModifierRotateBy90);
sl@0
    74
				UserSvr::AddEvent(event);
sl@0
    75
				test.Printf(_L("The keyboard layout is now as follows: \n\n"));
sl@0
    76
				test.Printf(_L("Z A Q\n\n"));
sl@0
    77
				test.Printf(_L("X S W\n\n"));
sl@0
    78
				test.Printf(_L("C D E\n\n"));
sl@0
    79
				break;
sl@0
    80
sl@0
    81
			case '2':
sl@0
    82
				event.Set(TRawEvent::EUpdateModifiers, EModifierRotateBy180);
sl@0
    83
				UserSvr::AddEvent(event);
sl@0
    84
				test.Printf(_L("The keyboard layout is now as follows: \n\n"));
sl@0
    85
				test.Printf(_L("C X Z\n\n"));
sl@0
    86
				test.Printf(_L("D S A\n\n"));
sl@0
    87
				test.Printf(_L("E W Q\n\n"));
sl@0
    88
				break;
sl@0
    89
sl@0
    90
			case '3':
sl@0
    91
				event.Set(TRawEvent::EUpdateModifiers, EModifierRotateBy270);
sl@0
    92
				UserSvr::AddEvent(event);
sl@0
    93
				test.Printf(_L("The keyboard layout is now as follows: \n\n"));
sl@0
    94
				test.Printf(_L("E D C\n\n"));
sl@0
    95
				test.Printf(_L("W S X\n\n"));
sl@0
    96
				test.Printf(_L("Q A Z\n\n"));
sl@0
    97
				break;
sl@0
    98
sl@0
    99
			case '4':
sl@0
   100
				event.Set(TRawEvent::EUpdateModifiers, EModifierCancelRotation);
sl@0
   101
				UserSvr::AddEvent(event);
sl@0
   102
				test.Printf(_L("The keyboard layout is now as follows: \n\n"));
sl@0
   103
				test.Printf(_L("Q W E\n\n"));
sl@0
   104
				test.Printf(_L("A S D\n\n"));
sl@0
   105
				test.Printf(_L("Z X C\n\n"));
sl@0
   106
				break;
sl@0
   107
sl@0
   108
			default:
sl@0
   109
				event.Set(TRawEvent::EUpdateModifiers, EModifierCancelRotation);
sl@0
   110
				UserSvr::AddEvent(event);
sl@0
   111
				test.End();
sl@0
   112
				return(0);
sl@0
   113
			}
sl@0
   114
		
sl@0
   115
		test.Printf(_L("Test the new keyboard layout below and press enter when finished:\n"));
sl@0
   116
sl@0
   117
		while(response!=EKeyEnter)
sl@0
   118
			{
sl@0
   119
			response=test.Getch();
sl@0
   120
			test.Printf(TPtrC((TUint16 *)&response, 1));
sl@0
   121
			}
sl@0
   122
sl@0
   123
		test.Printf(_L("\n\n"));
sl@0
   124
		}
sl@0
   125
    }
sl@0
   126