1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/emul/t_guiconfig.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,154 @@
1.4 +// Copyright (c) 2005-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\emul\t_guiconfig.cpp
1.18 +// Overview:
1.19 +// Test the kernel-side emulator GUI configuration API.
1.20 +// API Information:
1.21 +// RBusLogicalChannel, DLogicalChannel, WinsGui::CurrentConfiguration.
1.22 +// Details:
1.23 +// - Test retrieving the current emulator GUI configuration.
1.24 +// The following emulator configuration (.ini) files can be used with
1.25 +// this test to setup multiple configurations. Switch from one
1.26 +// configuration to the next by clicking in the upper left corner of
1.27 +// the emulator window, then run the test with a different configuration
1.28 +// selected.
1.29 +// >>> \epoc32\data\epoc.ini <<<
1.30 +// configuration c0.ini
1.31 +// configuration c1.ini
1.32 +// configuration c2.ini
1.33 +// configuration c3.ini
1.34 +// >>> \epoc32\data\c0.ini <<<
1.35 +// OnActivation 0 EKeyScreenDimension0
1.36 +// EmulatorControl NextConfig rect 1,1 30,30
1.37 +// windowtitle ZERO
1.38 +// >>> \epoc32\data\c1.ini <<<
1.39 +// OnActivation 0 EKeyScreenDimension1
1.40 +// EmulatorControl NextConfig rect 1,1 30,30
1.41 +// windowtitle ONE
1.42 +// >>> \epoc32\data\c2.ini <<<
1.43 +// OnActivation 0 EKeyScreenDimension2
1.44 +// EmulatorControl NextConfig rect 1,1 30,30
1.45 +// windowtitle TWO
1.46 +// >>> \epoc32\data\c3.ini <<<
1.47 +// OnActivation 0 EKeyScreenDimension3
1.48 +// EmulatorControl NextConfig rect 1,1 30,30
1.49 +// windowtitle THREE
1.50 +// Platforms/Drives/Compatibility:
1.51 +// Only available on the emulator.
1.52 +// Assumptions/Requirement/Pre-requisites:
1.53 +// Failures and causes:
1.54 +// Base Port information:
1.55 +//
1.56 +//
1.57 +
1.58 +#include <e32test.h>
1.59 +#include <e32def.h>
1.60 +#include <e32def_private.h>
1.61 +#include "d_guiconfig.h"
1.62 +
1.63 +_LIT(KLddFileName, "d_guiconfig.ldd");
1.64 +
1.65 +GLDEF_D RGuiConfigTest ldd;
1.66 +GLDEF_D RTest test(_L("Emulator GUI configuration"));
1.67 +
1.68 +void DoTest(const TDesC& aLddFileName)
1.69 + {
1.70 + TInt r;
1.71 + test.Start(_L("Loading LDD"));
1.72 +
1.73 + __KHEAP_MARK;
1.74 +
1.75 + r=User::LoadLogicalDevice(aLddFileName);
1.76 + test.Printf(_L("Returned %d\n"), r);
1.77 + test(r==KErrNone);
1.78 +
1.79 + test.Next(_L("Opening device driver"));
1.80 + test(ldd.Open()==KErrNone);
1.81 +
1.82 + test.Next(_L("Test retrieving current GUI configuration"));
1.83 + test.Printf(_L("Current emulator configuration is: %d"), ldd.GetConfig());
1.84 +
1.85 + test.Next(_L("Test generating key event"));
1.86 + test(ldd.GenerateKeyEvent()==KErrNone);
1.87 +
1.88 + TRequestStatus status;
1.89 + test.Console()->Read(status);
1.90 + User::WaitForRequest(status);
1.91 +
1.92 + if (test.Console()->KeyCode() == EKeyScreenDimension0)
1.93 + {
1.94 + test.Printf(_L("EKeyScreenDimension0 (0x%04x)\r\n"), test.Console()->KeyCode());
1.95 + // wait for the key-up code
1.96 + test.Console()->Read(status);
1.97 + User::WaitForRequest(status);
1.98 +
1.99 + test(test.Console()->KeyCode() == EKeyScreenDimension0);
1.100 + }
1.101 + else if (test.Console()->KeyCode()==EKeyScreenDimension1)
1.102 + {
1.103 + test.Printf(_L("EKeyScreenDimension1 (0x%04x)\r\n"), test.Console()->KeyCode());
1.104 + // wait for the key-up code
1.105 + test.Console()->Read(status);
1.106 + User::WaitForRequest(status);
1.107 +
1.108 + test(test.Console()->KeyCode() == EKeyScreenDimension1);
1.109 + }
1.110 + else if (test.Console()->KeyCode() == EKeyScreenDimension2)
1.111 + {
1.112 + test.Printf(_L("EKeyScreenDimension2 (0x%04x)\r\n"), test.Console()->KeyCode());
1.113 + // wait for the key-up code
1.114 + test.Console()->Read(status);
1.115 + User::WaitForRequest(status);
1.116 +
1.117 + test(test.Console()->KeyCode() == EKeyScreenDimension2);
1.118 + }
1.119 + else if (test.Console()->KeyCode() == EKeyScreenDimension3)
1.120 + {
1.121 + test.Printf(_L("EKeyScreenDimension3 (0x%04x)\r\n"), test.Console()->KeyCode());
1.122 + // wait for the key-up code
1.123 + test.Console()->Read(status);
1.124 + User::WaitForRequest(status);
1.125 +
1.126 + test(test.Console()->KeyCode() == EKeyScreenDimension3);
1.127 + }
1.128 + else
1.129 + {
1.130 + test.Printf(_L("Key: %5d (0x%04x)\r\n"),test.Console()->KeyCode(),test.Console()->KeyCode());
1.131 + test(EFalse);
1.132 + }
1.133 +
1.134 + test.Next(_L("Close"));
1.135 + ldd.Close();
1.136 +
1.137 + test.Next(_L("Unload"));
1.138 + r = RGuiConfigTest::Unload();
1.139 + test(r==KErrNone);
1.140 +
1.141 + test.End();
1.142 + }
1.143 +
1.144 +GLDEF_C TInt E32Main()
1.145 +//
1.146 +// Test LDD static data
1.147 +//
1.148 + {
1.149 + test.Title();
1.150 + test.Start(_L("Test emulator GUI configuration API"));
1.151 +
1.152 + DoTest(KLddFileName);
1.153 +
1.154 + test.End();
1.155 + return(KErrNone);
1.156 + }
1.157 +