os/kernelhwsrv/kerneltest/e32test/emul/t_guiconfig.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2005-2009 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 the License "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 // e32test\emul\t_guiconfig.cpp
    15 // Overview:
    16 // Test the kernel-side emulator GUI configuration API.
    17 // API Information:
    18 // RBusLogicalChannel, DLogicalChannel, WinsGui::CurrentConfiguration.
    19 // Details:
    20 // - Test retrieving the current emulator GUI configuration.
    21 // The following emulator configuration (.ini) files can be used with
    22 // this test to setup multiple configurations. Switch from one
    23 // configuration to the next by clicking in the upper left corner of
    24 // the emulator window, then run the test with a different configuration
    25 // selected.
    26 // >>> \epoc32\data\epoc.ini <<<
    27 // configuration c0.ini
    28 // configuration c1.ini
    29 // configuration c2.ini
    30 // configuration c3.ini
    31 // >>> \epoc32\data\c0.ini <<<
    32 // OnActivation 0 EKeyScreenDimension0
    33 // EmulatorControl NextConfig rect 1,1 30,30
    34 // windowtitle ZERO
    35 // >>> \epoc32\data\c1.ini <<<
    36 // OnActivation 0 EKeyScreenDimension1
    37 // EmulatorControl NextConfig rect 1,1 30,30
    38 // windowtitle ONE
    39 // >>> \epoc32\data\c2.ini <<<
    40 // OnActivation 0 EKeyScreenDimension2
    41 // EmulatorControl NextConfig rect 1,1 30,30
    42 // windowtitle TWO
    43 // >>> \epoc32\data\c3.ini <<<
    44 // OnActivation 0 EKeyScreenDimension3
    45 // EmulatorControl NextConfig rect 1,1 30,30
    46 // windowtitle THREE
    47 // Platforms/Drives/Compatibility:
    48 // Only available on the emulator.
    49 // Assumptions/Requirement/Pre-requisites:
    50 // Failures and causes:
    51 // Base Port information:
    52 // 
    53 //
    54 
    55 #include <e32test.h>
    56 #include <e32def.h>
    57 #include <e32def_private.h>
    58 #include "d_guiconfig.h"
    59 
    60 _LIT(KLddFileName, "d_guiconfig.ldd");
    61 
    62 GLDEF_D RGuiConfigTest ldd;
    63 GLDEF_D RTest test(_L("Emulator GUI configuration"));
    64 
    65 void DoTest(const TDesC& aLddFileName)
    66 	{
    67 	TInt r;
    68     test.Start(_L("Loading LDD"));
    69 
    70 	__KHEAP_MARK;
    71 
    72 	r=User::LoadLogicalDevice(aLddFileName);
    73 	test.Printf(_L("Returned %d\n"), r);
    74     test(r==KErrNone);
    75 
    76 	test.Next(_L("Opening device driver"));
    77 	test(ldd.Open()==KErrNone);
    78 
    79 	test.Next(_L("Test retrieving current GUI configuration"));
    80 	test.Printf(_L("Current emulator configuration is: %d"), ldd.GetConfig());
    81 
    82 	test.Next(_L("Test generating key event"));
    83 	test(ldd.GenerateKeyEvent()==KErrNone);
    84 
    85 	TRequestStatus status;
    86 	test.Console()->Read(status);
    87 	User::WaitForRequest(status);
    88 
    89 	if (test.Console()->KeyCode() == EKeyScreenDimension0)
    90 		{
    91 		test.Printf(_L("EKeyScreenDimension0 (0x%04x)\r\n"), test.Console()->KeyCode());
    92 		// wait for the key-up code
    93 		test.Console()->Read(status);
    94 		User::WaitForRequest(status);
    95 
    96 		test(test.Console()->KeyCode() == EKeyScreenDimension0);
    97 		}
    98 	else if (test.Console()->KeyCode()==EKeyScreenDimension1)
    99 		{
   100 		test.Printf(_L("EKeyScreenDimension1 (0x%04x)\r\n"), test.Console()->KeyCode());
   101 		// wait for the key-up code
   102 		test.Console()->Read(status);
   103 		User::WaitForRequest(status);
   104 
   105 		test(test.Console()->KeyCode() == EKeyScreenDimension1);
   106 		}
   107 	else if (test.Console()->KeyCode() == EKeyScreenDimension2)
   108 		{
   109 		test.Printf(_L("EKeyScreenDimension2 (0x%04x)\r\n"), test.Console()->KeyCode());
   110 		// wait for the key-up code
   111 		test.Console()->Read(status);
   112 		User::WaitForRequest(status);
   113 
   114 		test(test.Console()->KeyCode() == EKeyScreenDimension2);
   115 		}
   116 	else if (test.Console()->KeyCode() == EKeyScreenDimension3)
   117 		{
   118 		test.Printf(_L("EKeyScreenDimension3 (0x%04x)\r\n"), test.Console()->KeyCode());
   119 		// wait for the key-up code
   120 		test.Console()->Read(status);
   121 		User::WaitForRequest(status);
   122 
   123 		test(test.Console()->KeyCode() == EKeyScreenDimension3);
   124 		}
   125 	else
   126 		{
   127 		test.Printf(_L("Key: %5d (0x%04x)\r\n"),test.Console()->KeyCode(),test.Console()->KeyCode());
   128 		test(EFalse);
   129 		}
   130 
   131 	test.Next(_L("Close"));
   132 	ldd.Close();
   133 
   134 	test.Next(_L("Unload"));
   135 	r = RGuiConfigTest::Unload();
   136 	test(r==KErrNone);
   137 
   138 	test.End();
   139 	}
   140 
   141 GLDEF_C TInt E32Main()
   142 //
   143 // Test LDD static data
   144 //
   145     {
   146 	test.Title();
   147 	test.Start(_L("Test emulator GUI configuration API"));
   148 
   149 	DoTest(KLddFileName);
   150 
   151 	test.End();
   152 	return(KErrNone);
   153     }
   154