|
1 // Copyright (c) 2010 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\digitiser\d_kerneldigitisertest.cpp |
|
15 // LDD for testing class TRawEvent digitiser kernel side entries |
|
16 // |
|
17 // |
|
18 |
|
19 #include <kernel/kernel.h> |
|
20 |
|
21 #include "d_kerneldigitisertest.h" |
|
22 |
|
23 class DKLDDFactory : public DLogicalDevice |
|
24 // |
|
25 // Test LDD factory |
|
26 // |
|
27 { |
|
28 public: |
|
29 DKLDDFactory(); |
|
30 virtual TInt Install(); //overriding pure virtual |
|
31 virtual void GetCaps(TDes8& aDes) const; //overriding pure virtual |
|
32 virtual TInt Create(DLogicalChannelBase*& aChannel); //overriding pure virtual |
|
33 }; |
|
34 |
|
35 class DKLDDChannel : public DLogicalChannelBase |
|
36 // |
|
37 // Test logical channel |
|
38 // |
|
39 { |
|
40 public: |
|
41 virtual ~DKLDDChannel(); |
|
42 protected: |
|
43 virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); |
|
44 virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2); |
|
45 }; |
|
46 |
|
47 |
|
48 DECLARE_STANDARD_LDD() |
|
49 { |
|
50 return new DKLDDFactory; |
|
51 } |
|
52 |
|
53 // |
|
54 // Constructor |
|
55 // |
|
56 DKLDDFactory::DKLDDFactory() |
|
57 { |
|
58 } |
|
59 |
|
60 TInt DKLDDFactory::Create(DLogicalChannelBase*& aChannel) |
|
61 { |
|
62 // |
|
63 // Create new channel |
|
64 // |
|
65 aChannel=new DKLDDChannel; |
|
66 return aChannel?KErrNone:KErrNoMemory; |
|
67 } |
|
68 |
|
69 TInt DKLDDFactory::Install() |
|
70 // |
|
71 // Install the LDD - overriding pure virtual |
|
72 { |
|
73 return SetName(&KLddName); |
|
74 } |
|
75 |
|
76 void DKLDDFactory::GetCaps(TDes8& /*aDes*/) const |
|
77 // |
|
78 // Get capabilities - overriding pure virtual |
|
79 // |
|
80 { |
|
81 } |
|
82 |
|
83 TInt DKLDDChannel::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/) |
|
84 // |
|
85 // Create channel |
|
86 // |
|
87 { |
|
88 return KErrNone; |
|
89 } |
|
90 |
|
91 DKLDDChannel::~DKLDDChannel() |
|
92 // |
|
93 // Destructor |
|
94 // |
|
95 { |
|
96 } |
|
97 |
|
98 TInt DKLDDChannel::Request(TInt aReqNo, TAny* a1, TAny* /*a2*/) |
|
99 { |
|
100 TInt r=KErrNone; |
|
101 TestTRawDigitiserEvent theEventObj; |
|
102 |
|
103 switch(aReqNo) |
|
104 { |
|
105 case RTestDigitiserLdd::EStartTest: |
|
106 kumemget(&theEventObj,a1,sizeof(TestTRawDigitiserEvent)); |
|
107 theEventObj.TestEvents(); |
|
108 break; |
|
109 |
|
110 default: |
|
111 r=KErrNotSupported; |
|
112 break; |
|
113 } |
|
114 |
|
115 return r; |
|
116 } |
|
117 |
|
118 |
|
119 // |
|
120 // class TestTRawDigitiserEvent kernel side implementations |
|
121 // |
|
122 |
|
123 TestTRawDigitiserEvent::TestTRawDigitiserEvent() |
|
124 {} |
|
125 |
|
126 TestTRawDigitiserEvent::TestTRawDigitiserEvent(TRawEvent::TType aType,TInt aX,TInt aY,TInt aZ,TInt aScanCode,TInt aPhi,TInt aTheta,TInt aAlpha,TUint8 aPointerNumber,TUint8 aTip) |
|
127 :iType(aType),iX(aX),iY(aY),iZ(aZ),iScanCode(aScanCode),iPhi(aPhi),iTheta(aTheta),iAlpha(aAlpha),iPointerNumber(aPointerNumber),iTip(aTip) |
|
128 {} |
|
129 |
|
130 TInt TestTRawDigitiserEvent::TestEvents() |
|
131 { |
|
132 if(!(iDigitiser3DEvent.Type()==0)) |
|
133 {Kern::Printf("failed check at line %d, %S",__LINE__,__FILE__); return KErrArgument;} |
|
134 iDigitiser3DEvent.Set(iType); |
|
135 if(!(iDigitiser3DEvent.Type()==iType)) |
|
136 {Kern::Printf("failed check at line %d, %S",__LINE__,__FILE__); return KErrArgument;} |
|
137 iDigitiser3DEvent.SetPointerNumber(iPointerNumber); |
|
138 if(!(iPointerNumber == iDigitiser3DEvent.PointerNumber())) |
|
139 {Kern::Printf("failed check at line %d, %S",__LINE__,__FILE__); return KErrArgument;} |
|
140 iDigitiser3DEvent.Set(iType,iScanCode); |
|
141 //Set the Type temporarily to get through the assertion |
|
142 iDigitiser3DEvent.Set(TRawEvent::EKeyDown); |
|
143 if(!(iScanCode==iDigitiser3DEvent.ScanCode())) |
|
144 {Kern::Printf("failed check at line %d, %S",__LINE__,__FILE__); return KErrArgument;} |
|
145 iDigitiser3DEvent.Set(iType,iX,iY); |
|
146 //Set the Type temporarily to get through the assertion |
|
147 iDigitiser3DEvent.Set(TRawEvent::EPointerMove); |
|
148 if(!( (iX==iDigitiser3DEvent.Pos().iX) && (iY==iDigitiser3DEvent.Pos().iY) )) |
|
149 {Kern::Printf("failed check at line %d, %S",__LINE__,__FILE__); return KErrArgument;} |
|
150 iDigitiser3DEvent.Set(iType,iX,iY,iZ); |
|
151 //Set the Type temporarily to get through the assertion |
|
152 iDigitiser3DEvent.Set(TRawEvent::EPointerMove); |
|
153 if(!((iX==iDigitiser3DEvent.Pos3D().iX) && (iY==iDigitiser3DEvent.Pos3D().iY) && (iZ==iDigitiser3DEvent.Pos3D().iZ) )) |
|
154 {Kern::Printf("failed check at line %d, %S",__LINE__,__FILE__); return KErrArgument;} |
|
155 iDigitiser3DEvent.SetTip(iTip); |
|
156 if(!(TBool(iTip) == iDigitiser3DEvent.IsTip())) |
|
157 {Kern::Printf("failed check at line %d, %S",__LINE__,__FILE__); return KErrArgument;} |
|
158 iDigitiser3DEvent.SetTilt(iType,iPhi,iTheta); |
|
159 //Set the Type temporarily to get through the assertion |
|
160 iDigitiser3DEvent.Set(TRawEvent::EPointer3DTilt); |
|
161 TAngle3D rawEventAnge3D=iDigitiser3DEvent.Tilt(); |
|
162 if(!((rawEventAnge3D.iPhi==iPhi) && (rawEventAnge3D.iTheta==iTheta))) |
|
163 {Kern::Printf("failed check at line %d, %S",__LINE__,__FILE__); return KErrArgument;} |
|
164 iDigitiser3DEvent.SetRotation(iType,iAlpha); |
|
165 //Set the Type temporarily to get through the assertion |
|
166 iDigitiser3DEvent.Set(TRawEvent::EPointer3DRotation); |
|
167 if(!(iAlpha == iDigitiser3DEvent.Rotation())) |
|
168 {Kern::Printf("failed check at line %d, %S",__LINE__,__FILE__); return KErrArgument;} |
|
169 iDigitiser3DEvent.Set(iType,iX+1,iY+1,iZ+1,iPhi+1,iTheta+1,iAlpha+1); |
|
170 //Set the Type temporarily to get through the assertion |
|
171 iDigitiser3DEvent.Set(TRawEvent::EPointer3DTiltAndMove); |
|
172 if(!( ((iX+1)==iDigitiser3DEvent.Pos3D().iX) && ((iY+1)==iDigitiser3DEvent.Pos3D().iY) && ((iZ+1)==iDigitiser3DEvent.Pos3D().iZ))) |
|
173 {Kern::Printf("failed check at line %d, %S",__LINE__,__FILE__); return KErrArgument;} |
|
174 rawEventAnge3D=iDigitiser3DEvent.Tilt(); |
|
175 if(!((rawEventAnge3D.iPhi==iPhi+1) &&(rawEventAnge3D.iTheta==iTheta+1))) |
|
176 {Kern::Printf("failed check at line %d, %S",__LINE__,__FILE__); return KErrArgument;} |
|
177 if(!((iAlpha+1) == iDigitiser3DEvent.Rotation())) |
|
178 {Kern::Printf("failed check at line %d, %S",__LINE__,__FILE__); return KErrArgument;} |
|
179 #ifndef __X86GMP__ |
|
180 iDigitiser3DEvent.Set(iType,iX+2,iY+2,iZ+2,static_cast<TUint8>(iPointerNumber+1)); |
|
181 //Set the Type temporarily to get through the assertion |
|
182 iDigitiser3DEvent.Set(TRawEvent::EPointer3DTiltAndMove); |
|
183 if(!(((iX+2)==iDigitiser3DEvent.Pos3D().iX) && ((iY+2)==iDigitiser3DEvent.Pos3D().iY) && ((iZ+2)==iDigitiser3DEvent.Pos3D().iZ))) |
|
184 {Kern::Printf("failed check at line %d, %S",__LINE__,__FILE__); return KErrArgument;} |
|
185 if(!((iPointerNumber+1) == iDigitiser3DEvent.PointerNumber())) |
|
186 {Kern::Printf("failed check at line %d, %S",__LINE__,__FILE__); return KErrArgument;} |
|
187 #endif //__X86GMP__ |
|
188 |
|
189 NKern::ThreadEnterCS(); |
|
190 // queue the event |
|
191 Kern::AddEvent(iDigitiser3DEvent); |
|
192 NKern::ThreadLeaveCS(); |
|
193 return KErrNone; |
|
194 } |