1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/window/t_wsimp.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,152 @@
1.4 +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// e32test\window\t_wsimp.cpp
1.18 +//
1.19 +//
1.20 +
1.21 +#include <e32std.h>
1.22 +#include <e32std_private.h>
1.23 +#include <e32test.h>
1.24 +#include <e32ver.h>
1.25 +#include <e32hal.h>
1.26 +#include <e32twin.h>
1.27 +#include <e32svr.h>
1.28 +#include <hal.h>
1.29 +
1.30 +LOCAL_D RConsole theConsole;
1.31 +
1.32 +LOCAL_C void readKeys()
1.33 +//
1.34 +// Read keys until ESC pressed
1.35 +//
1.36 + {
1.37 +
1.38 + TRequestStatus s;
1.39 + TConsoleKey k;
1.40 + do
1.41 + {
1.42 + theConsole.Read(k,s);
1.43 + User::WaitForRequest(s);
1.44 + } while((TInt)k.Code()!=EKeyEscape);
1.45 + }
1.46 +
1.47 +LOCAL_C void printf(TRefByValue<const TDesC> aFmt,...)
1.48 +//
1.49 +// Print to the console
1.50 +//
1.51 + {
1.52 +
1.53 + if (theConsole.Handle()==KNullHandle)
1.54 + {
1.55 + TInt r=theConsole.Init(_L("T_SWIMP"),TSize(KConsFullScreen,KConsFullScreen));
1.56 + __ASSERT_ALWAYS(r==KErrNone,User::Panic(_L("Open-Console"),0));
1.57 + r=theConsole.Control(_L("+Maximize +NewLine -Lock -Wrap"));
1.58 + __ASSERT_ALWAYS(r==KErrNone,User::Panic(_L("Config-Console"),0));
1.59 + }
1.60 + VA_LIST list;
1.61 + VA_START(list,aFmt);
1.62 + TBuf<0x100> aBuf;
1.63 + aBuf.AppendFormatList(aFmt,list);
1.64 + TInt r=theConsole.Write(aBuf);
1.65 + __ASSERT_ALWAYS(r==KErrNone,User::Panic(_L("Write-Console"),0));
1.66 + }
1.67 +
1.68 +
1.69 +GLDEF_C TInt E32Main()
1.70 +//
1.71 +// Test the various kernel types.
1.72 +//
1.73 + {
1.74 +
1.75 + TVersion v(KE32MajorVersionNumber,KE32MinorVersionNumber,KE32BuildVersionNumber);
1.76 + TName vName = v.Name();
1.77 + printf(_L("T_SWIMP %S\n"),&vName);
1.78 + TName uvName = User::Version().Name();
1.79 + printf(_L("Epoc/32 %S\n"),&uvName);
1.80 +//
1.81 + TRequestStatus s;
1.82 + TConsoleKey k;
1.83 + theConsole.Read(k,s);
1.84 + theConsole.ReadCancel();
1.85 + User::WaitForRequest(s);
1.86 + __ASSERT_ALWAYS(s.Int()==KErrCancel || s.Int()==KErrNone, User::Panic(_L("Test Fail"),1));
1.87 +//
1.88 + TInt r=theConsole.Control(_L("+Raw"));
1.89 + __ASSERT_ALWAYS(r==KErrNone,User::Panic(_L("Set Raw Mode"),0));
1.90 +//
1.91 + printf(_L("Raw mode - hit ESC to continue\r\n"));
1.92 +//
1.93 + FOREVER
1.94 + {
1.95 + theConsole.Read(k,s);
1.96 + User::WaitForRequest(s);
1.97 + if (k.Type()==TRawEvent::EKeyDown)
1.98 + {
1.99 + if (k.Code()==4)
1.100 + break;
1.101 + printf(_L("Down %d\r\n"),k.Code());
1.102 + }
1.103 + else if (k.Type()==TRawEvent::EKeyUp)
1.104 + printf(_L("Up %d\r\n"),k.Code());
1.105 + }
1.106 +//
1.107 + r=theConsole.Control(_L("-Raw"));
1.108 + __ASSERT_ALWAYS(r==KErrNone,User::Panic(_L("Reset Raw Mode"),0));
1.109 +//
1.110 + printf(_L("Normal mode - hit ESC to continue\r\n"));
1.111 +//
1.112 + FOREVER
1.113 + {
1.114 + theConsole.Read(k,s);
1.115 + User::WaitForRequest(s);
1.116 + if (k.Code()==EKeyEscape)
1.117 + break;
1.118 + printf(_L("Key %d\r\n"),k.Code());
1.119 + }
1.120 +//
1.121 + printf(_L("Completed OK\n"));
1.122 +//
1.123 + printf(_L("Key click set to LOUD - press keys, ESC to continue...\n"));
1.124 +
1.125 + TInt max;
1.126 + HAL::Get(HAL::EKeyboardClickVolumeMax, max);
1.127 + HAL::Set(HAL::EKeyboardClickVolume, max);
1.128 + HAL::Set(HAL::EKeyboardClickState, ETrue);
1.129 +
1.130 + readKeys();
1.131 +
1.132 + printf(_L("Key click set to SOFT...\n"));
1.133 +
1.134 + HAL::Set(HAL::EKeyboardClickVolume, 0);
1.135 + HAL::Set(HAL::EKeyboardClickState, ETrue);
1.136 +
1.137 + readKeys();
1.138 +
1.139 + printf(_L("Key click set to LOUD...\n"));
1.140 +
1.141 + HAL::Set(HAL::EKeyboardClickVolume, max);
1.142 + HAL::Set(HAL::EKeyboardClickState, ETrue);
1.143 +
1.144 + readKeys();
1.145 +
1.146 + printf(_L("Key click set to LOUD and OFF...\n"));
1.147 +
1.148 + HAL::Set(HAL::EKeyboardClickVolume, max);
1.149 + HAL::Set(HAL::EKeyboardClickState, EFalse);
1.150 +
1.151 + readKeys();
1.152 +
1.153 + return(KErrNone);
1.154 + }
1.155 +