|
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\d_guiconfig.cpp |
|
15 // LDD for testing emulator GUI config API |
|
16 // |
|
17 // |
|
18 |
|
19 #include <kernel/kernel.h> |
|
20 #include <wins/winsgui.h> |
|
21 #include <e32keys.h> |
|
22 #include "d_guiconfig.h" |
|
23 |
|
24 const TInt KMajorVersionNumber=0; |
|
25 const TInt KMinorVersionNumber=1; |
|
26 const TInt KBuildVersionNumber=1; |
|
27 |
|
28 class DTest; |
|
29 |
|
30 class DTestFactory : public DLogicalDevice |
|
31 // |
|
32 // Test LDD factory |
|
33 // |
|
34 { |
|
35 public: |
|
36 DTestFactory(); |
|
37 virtual TInt Install(); //overriding pure virtual |
|
38 virtual void GetCaps(TDes8& aDes) const; //overriding pure virtual |
|
39 virtual TInt Create(DLogicalChannelBase*& aChannel); //overriding pure virtual |
|
40 }; |
|
41 |
|
42 class DTest : public DLogicalChannelBase |
|
43 // |
|
44 // Test logical channel |
|
45 // |
|
46 { |
|
47 public: |
|
48 virtual ~DTest(); |
|
49 protected: |
|
50 virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); |
|
51 virtual TInt Request(TInt aFunction, TAny* a1, TAny* a2); |
|
52 }; |
|
53 |
|
54 DECLARE_STANDARD_LDD() |
|
55 { |
|
56 return new DTestFactory; |
|
57 } |
|
58 |
|
59 DTestFactory::DTestFactory() |
|
60 // |
|
61 // Constructor |
|
62 // |
|
63 { |
|
64 iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber); |
|
65 //iParseMask=0;//No units, no info, no PDD |
|
66 //iUnitsMask=0;//Only one thing |
|
67 } |
|
68 |
|
69 TInt DTestFactory::Create(DLogicalChannelBase*& aChannel) |
|
70 // |
|
71 // Create a new DTest on this logical device |
|
72 // |
|
73 { |
|
74 aChannel=new DTest; |
|
75 return aChannel?KErrNone:KErrNoMemory; |
|
76 } |
|
77 |
|
78 TInt DTestFactory::Install() |
|
79 // |
|
80 // Install the LDD - overriding pure virtual |
|
81 // |
|
82 { |
|
83 return SetName(&KLddName); |
|
84 } |
|
85 |
|
86 void DTestFactory::GetCaps(TDes8& aDes) const |
|
87 // |
|
88 // Get capabilities - overriding pure virtual |
|
89 // |
|
90 { |
|
91 TCapsTestV01 b; |
|
92 b.iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber); |
|
93 Kern::InfoCopy(aDes,(TUint8*)&b,sizeof(b)); |
|
94 } |
|
95 |
|
96 TInt DTest::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& aVer) |
|
97 // |
|
98 // Create channel |
|
99 // |
|
100 { |
|
101 |
|
102 if (!Kern::QueryVersionSupported(TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber),aVer)) |
|
103 return KErrNotSupported; |
|
104 return KErrNone; |
|
105 } |
|
106 |
|
107 DTest::~DTest() |
|
108 // |
|
109 // Destructor |
|
110 // |
|
111 { |
|
112 } |
|
113 |
|
114 TInt DTest::Request(TInt aFunction, TAny* a1, TAny* a2) |
|
115 { |
|
116 (void)a1; |
|
117 (void)a2; |
|
118 TInt r=KErrNone; |
|
119 switch (aFunction) |
|
120 { |
|
121 case RGuiConfigTest::EGetConfig: |
|
122 { |
|
123 r = WinsGui::CurrentConfiguration(); |
|
124 break; |
|
125 } |
|
126 case RGuiConfigTest::EGenerateKeyEvent: |
|
127 { |
|
128 r = WinsGui::CurrentConfiguration(); |
|
129 |
|
130 TRawEvent eventDown, eventUp; |
|
131 eventDown.Set(TRawEvent::EKeyDown, (EKeyScreenDimension0 + r)<<16); |
|
132 eventUp.Set(TRawEvent::EKeyUp, (EKeyScreenDimension0 + r)<<16); |
|
133 |
|
134 NKern::ThreadEnterCS(); |
|
135 r = Kern::AddEvent(eventDown); |
|
136 if (r == KErrNone) |
|
137 r = Kern::AddEvent(eventUp); |
|
138 NKern::ThreadLeaveCS(); |
|
139 break; |
|
140 } |
|
141 default: |
|
142 { |
|
143 r=KErrNotSupported; |
|
144 break; |
|
145 } |
|
146 } |
|
147 return r; |
|
148 } |
|
149 |