|
45
|
1 |
/*
|
|
|
2 |
* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
3 |
* All rights reserved.
|
|
|
4 |
* This component and the accompanying materials are made available
|
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
|
6 |
* which accompanies this distribution, and is available
|
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
|
8 |
*
|
|
|
9 |
* Initial Contributors:
|
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
|
11 |
*
|
|
|
12 |
* Contributors:
|
|
|
13 |
*
|
|
|
14 |
* Description: test eikhkeyt.h
|
|
|
15 |
*
|
|
|
16 |
*/
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
/*
|
|
|
21 |
* [INCLUDE FILES] - do not remove
|
|
|
22 |
*/
|
|
|
23 |
#include <e32svr.h>
|
|
|
24 |
#include <stifparser.h>
|
|
|
25 |
#include <stiftestinterface.h>
|
|
|
26 |
#include <eikhkeyt.h>
|
|
|
27 |
#include <testsdkeikhkeyt.rsg>
|
|
|
28 |
#include <coemain.h>
|
|
|
29 |
#include <barsread.h>
|
|
|
30 |
|
|
|
31 |
#include "testsdkeikhkeyt.h"
|
|
|
32 |
|
|
|
33 |
const TInt KZero = 0;
|
|
|
34 |
const TInt KOne = 1;
|
|
|
35 |
const TInt KTwo = 2;
|
|
|
36 |
const TInt KThree = 3;
|
|
|
37 |
|
|
|
38 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
|
39 |
|
|
|
40 |
// -----------------------------------------------------------------------------
|
|
|
41 |
// CTestSDKEIKHKEYT::Delete
|
|
|
42 |
// Delete here all resources allocated and opened from test methods.
|
|
|
43 |
// Called from destructor.
|
|
|
44 |
// -----------------------------------------------------------------------------
|
|
|
45 |
//
|
|
|
46 |
void CTestSDKEIKHKEYT::Delete()
|
|
|
47 |
{
|
|
|
48 |
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
// -----------------------------------------------------------------------------
|
|
|
52 |
// CTestSDKEIKHKEYT::RunMethodL
|
|
|
53 |
// Run specified method. Contains also table of test mothods and their names.
|
|
|
54 |
// -----------------------------------------------------------------------------
|
|
|
55 |
//
|
|
|
56 |
TInt CTestSDKEIKHKEYT::RunMethodL(
|
|
|
57 |
CStifItemParser& aItem )
|
|
|
58 |
{
|
|
|
59 |
|
|
|
60 |
static TStifFunctionInfo const KFunctions[] =
|
|
|
61 |
{
|
|
|
62 |
ENTRY( "TestEHKEYCEikHotKeyTableL",
|
|
|
63 |
CTestSDKEIKHKEYT::TestEHKEYCEikHotKeyTableL ),
|
|
|
64 |
ENTRY( "TestEHKEYAddItemL", CTestSDKEIKHKEYT::TestEHKEYAddItemL ),
|
|
|
65 |
ENTRY( "TestEHKEYCommandIdFromHotKeyL",
|
|
|
66 |
CTestSDKEIKHKEYT::TestEHKEYCommandIdFromHotKeyL ),
|
|
|
67 |
ENTRY( "TestEHKEYHotKeyFromCommandIdL",
|
|
|
68 |
CTestSDKEIKHKEYT::TestEHKEYHotKeyFromCommandIdL ),
|
|
|
69 |
ENTRY( "TestEHKEYRemoveItemL",
|
|
|
70 |
CTestSDKEIKHKEYT::TestEHKEYRemoveItemL ),
|
|
|
71 |
ENTRY( "TestEHKEYConstructFromResourceL",
|
|
|
72 |
CTestSDKEIKHKEYT::TestEHKEYConstructFromResourceL ),
|
|
|
73 |
ENTRY( "TestEHKEYResetL", CTestSDKEIKHKEYT::TestEHKEYResetL ),
|
|
|
74 |
ENTRY( "TestEHKEYDestructorL", CTestSDKEIKHKEYT::TestEHKEYDestructorL ),
|
|
|
75 |
|
|
|
76 |
};
|
|
|
77 |
|
|
|
78 |
const TInt count = sizeof( KFunctions ) /
|
|
|
79 |
sizeof( TStifFunctionInfo );
|
|
|
80 |
|
|
|
81 |
return RunInternalL( KFunctions, count, aItem );
|
|
|
82 |
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
// -----------------------------------------------------------------------------
|
|
|
86 |
// CTestSDKEIKHKEYT::TestEHKEYCEikHotKeyTable
|
|
|
87 |
// -----------------------------------------------------------------------------
|
|
|
88 |
//
|
|
|
89 |
TInt CTestSDKEIKHKEYT::TestEHKEYCEikHotKeyTableL( CStifItemParser& /*aItem*/ )
|
|
|
90 |
{
|
|
|
91 |
CEikHotKeyTable* hotkeytable = new (ELeave) CEikHotKeyTable;
|
|
|
92 |
CleanupStack::PushL( hotkeytable );
|
|
|
93 |
STIF_ASSERT_NOT_NULL( hotkeytable );
|
|
|
94 |
CleanupStack::PopAndDestroy( hotkeytable );
|
|
|
95 |
|
|
|
96 |
return KErrNone;
|
|
|
97 |
}
|
|
|
98 |
|
|
|
99 |
// -----------------------------------------------------------------------------
|
|
|
100 |
// CTestSDKCFD::TestEHKEYAddItemL
|
|
|
101 |
// -----------------------------------------------------------------------------
|
|
|
102 |
//
|
|
|
103 |
TInt CTestSDKEIKHKEYT::TestEHKEYAddItemL( CStifItemParser& /*aItem*/ )
|
|
|
104 |
{
|
|
|
105 |
CEikHotKeyTable* hotkeytableptr = new( ELeave ) CEikHotKeyTable;
|
|
|
106 |
CleanupStack::PushL( hotkeytableptr );
|
|
|
107 |
|
|
|
108 |
TInt commandId( KOne );
|
|
|
109 |
TInt keycode( KTwo );
|
|
|
110 |
TInt modifiers( KZero );
|
|
|
111 |
hotkeytableptr->AddItemL( commandId, keycode, modifiers );
|
|
|
112 |
|
|
|
113 |
TBool flag;
|
|
|
114 |
TInt returnkeycode;
|
|
|
115 |
flag = hotkeytableptr->HotKeyFromCommandId( commandId, returnkeycode,
|
|
|
116 |
modifiers );
|
|
|
117 |
STIF_ASSERT_TRUE( flag );
|
|
|
118 |
STIF_ASSERT_EQUALS( keycode, returnkeycode );
|
|
|
119 |
|
|
|
120 |
TInt returncommandId;
|
|
|
121 |
returncommandId = hotkeytableptr->CommandIdFromHotKey( keycode, modifiers );
|
|
|
122 |
STIF_ASSERT_EQUALS( commandId, returncommandId );
|
|
|
123 |
CleanupStack::PopAndDestroy( hotkeytableptr );
|
|
|
124 |
|
|
|
125 |
return KErrNone;
|
|
|
126 |
}
|
|
|
127 |
|
|
|
128 |
// -----------------------------------------------------------------------------
|
|
|
129 |
// CTestSDKCFD::TestEHKEYCommandIdFromHotKey
|
|
|
130 |
// -----------------------------------------------------------------------------
|
|
|
131 |
//
|
|
|
132 |
TInt CTestSDKEIKHKEYT::TestEHKEYCommandIdFromHotKeyL( CStifItemParser& /*aItem*/ )
|
|
|
133 |
{
|
|
|
134 |
CEikHotKeyTable* hotkeytableptr = new( ELeave ) CEikHotKeyTable;
|
|
|
135 |
CleanupStack::PushL( hotkeytableptr );
|
|
|
136 |
|
|
|
137 |
TInt commandId( KOne);
|
|
|
138 |
TInt keycode( KTwo );
|
|
|
139 |
TInt modifiers( KZero );
|
|
|
140 |
hotkeytableptr->AddItemL( commandId, keycode, modifiers );
|
|
|
141 |
|
|
|
142 |
TInt commandId2( KTwo );
|
|
|
143 |
TInt keycode2( KThree );
|
|
|
144 |
TInt modifiers2( KZero );
|
|
|
145 |
hotkeytableptr->AddItemL( commandId2, keycode2, modifiers2 );
|
|
|
146 |
|
|
|
147 |
TInt returncommandId;
|
|
|
148 |
TInt returncommandId2;
|
|
|
149 |
returncommandId = hotkeytableptr->CommandIdFromHotKey( keycode, modifiers );
|
|
|
150 |
returncommandId2 = hotkeytableptr->CommandIdFromHotKey( keycode2,
|
|
|
151 |
modifiers2 );
|
|
|
152 |
STIF_ASSERT_NOT_EQUALS( returncommandId, returncommandId2 );
|
|
|
153 |
CleanupStack::PopAndDestroy( hotkeytableptr );
|
|
|
154 |
|
|
|
155 |
return KErrNone;
|
|
|
156 |
}
|
|
|
157 |
|
|
|
158 |
// -----------------------------------------------------------------------------
|
|
|
159 |
// CTestSDKCFD::TestEHKEYHotKeyFromCommandId
|
|
|
160 |
// -----------------------------------------------------------------------------
|
|
|
161 |
//
|
|
|
162 |
TInt CTestSDKEIKHKEYT::TestEHKEYHotKeyFromCommandIdL( CStifItemParser& /*aItem*/ )
|
|
|
163 |
{
|
|
|
164 |
CEikHotKeyTable* hotkeytableptr;
|
|
|
165 |
hotkeytableptr = new( ELeave ) CEikHotKeyTable;
|
|
|
166 |
CleanupStack::PushL( hotkeytableptr );
|
|
|
167 |
|
|
|
168 |
TInt commandId( KOne );
|
|
|
169 |
TInt keycode( KTwo );
|
|
|
170 |
TInt modifiers( KZero );
|
|
|
171 |
hotkeytableptr->AddItemL( commandId, keycode, modifiers );
|
|
|
172 |
|
|
|
173 |
TInt commandId2( KTwo );
|
|
|
174 |
TInt keycode2( KThree );
|
|
|
175 |
TInt modifiers2( KZero );
|
|
|
176 |
hotkeytableptr->AddItemL( commandId2, keycode2, modifiers2 );
|
|
|
177 |
|
|
|
178 |
TInt returnkeycode;
|
|
|
179 |
TInt returnkeycode2;
|
|
|
180 |
TBool flag;
|
|
|
181 |
TBool flag2;
|
|
|
182 |
flag = hotkeytableptr->HotKeyFromCommandId( commandId, returnkeycode,
|
|
|
183 |
modifiers );
|
|
|
184 |
STIF_ASSERT_TRUE( flag );
|
|
|
185 |
flag2 = hotkeytableptr->HotKeyFromCommandId( commandId2, returnkeycode2,
|
|
|
186 |
modifiers2 );
|
|
|
187 |
STIF_ASSERT_TRUE( flag2 );
|
|
|
188 |
STIF_ASSERT_NOT_EQUALS( returnkeycode, returnkeycode2 );
|
|
|
189 |
|
|
|
190 |
CleanupStack::PopAndDestroy( hotkeytableptr );
|
|
|
191 |
return KErrNone;
|
|
|
192 |
}
|
|
|
193 |
|
|
|
194 |
// -----------------------------------------------------------------------------
|
|
|
195 |
// CTestSDKCFD::TestEHKEYRemoveItem
|
|
|
196 |
// -----------------------------------------------------------------------------
|
|
|
197 |
//
|
|
|
198 |
TInt CTestSDKEIKHKEYT::TestEHKEYRemoveItemL( CStifItemParser& /*aItem*/ )
|
|
|
199 |
{
|
|
|
200 |
CEikHotKeyTable* hotkeytableptr = new( ELeave ) CEikHotKeyTable;
|
|
|
201 |
CleanupStack::PushL( hotkeytableptr );
|
|
|
202 |
|
|
|
203 |
TInt commandId( KOne );
|
|
|
204 |
TInt keycode( KTwo );
|
|
|
205 |
TInt modifiers( KZero );
|
|
|
206 |
hotkeytableptr->AddItemL( commandId, keycode, modifiers );
|
|
|
207 |
|
|
|
208 |
TBool flag;
|
|
|
209 |
TInt returnkeycode;
|
|
|
210 |
TInt returncommandId;
|
|
|
211 |
flag = hotkeytableptr->HotKeyFromCommandId( commandId, returnkeycode,
|
|
|
212 |
modifiers );
|
|
|
213 |
returncommandId = hotkeytableptr->CommandIdFromHotKey( keycode, modifiers );
|
|
|
214 |
|
|
|
215 |
STIF_ASSERT_TRUE( flag );
|
|
|
216 |
STIF_ASSERT_EQUALS( keycode, returnkeycode );
|
|
|
217 |
STIF_ASSERT_EQUALS( commandId, returncommandId );
|
|
|
218 |
|
|
|
219 |
hotkeytableptr->RemoveItem( commandId );
|
|
|
220 |
returnkeycode = 0;
|
|
|
221 |
|
|
|
222 |
flag = hotkeytableptr->HotKeyFromCommandId( commandId, returnkeycode,
|
|
|
223 |
modifiers );
|
|
|
224 |
returncommandId = hotkeytableptr->CommandIdFromHotKey( keycode, modifiers );
|
|
|
225 |
STIF_ASSERT_FALSE( flag );
|
|
|
226 |
STIF_ASSERT_NOT_EQUALS( keycode, returnkeycode );
|
|
|
227 |
STIF_ASSERT_NOT_EQUALS( commandId, returncommandId );
|
|
|
228 |
CleanupStack::PopAndDestroy( hotkeytableptr );
|
|
|
229 |
|
|
|
230 |
return KErrNone;
|
|
|
231 |
}
|
|
|
232 |
|
|
|
233 |
// -----------------------------------------------------------------------------
|
|
|
234 |
// CTestSDKCFD::TestEHKEYConstructFromResourceL
|
|
|
235 |
// -----------------------------------------------------------------------------
|
|
|
236 |
//
|
|
|
237 |
TInt CTestSDKEIKHKEYT::TestEHKEYConstructFromResourceL( CStifItemParser& /*aItem*/ )
|
|
|
238 |
{
|
|
|
239 |
CEikHotKeyTable* hotkeytableptr = new( ELeave ) CEikHotKeyTable;
|
|
|
240 |
CleanupStack::PushL( hotkeytableptr );
|
|
|
241 |
|
|
|
242 |
hotkeytableptr->ConstructFromResourceL( R_TEST_HOTKEYS );
|
|
|
243 |
|
|
|
244 |
TResourceReader reader;
|
|
|
245 |
CCoeEnv::Static()->CreateResourceReaderLC(reader,R_TEST_HOTKEYS);
|
|
|
246 |
|
|
|
247 |
TInt numberPlain( KZero );
|
|
|
248 |
numberPlain = reader.ReadInt16();
|
|
|
249 |
if( numberPlain )
|
|
|
250 |
{
|
|
|
251 |
const SEikHotKey* ptr=(const SEikHotKey*)reader.Ptr();
|
|
|
252 |
reader.Advance(numberPlain*sizeof(SEikHotKey));
|
|
|
253 |
TBool flag(EFalse);
|
|
|
254 |
TInt keycode( KZero );
|
|
|
255 |
TInt commandId( KZero );
|
|
|
256 |
TInt modifires( KZero );
|
|
|
257 |
commandId = ptr->iCommandId;
|
|
|
258 |
flag = hotkeytableptr->HotKeyFromCommandId( commandId, keycode, modifires );
|
|
|
259 |
STIF_ASSERT_TRUE( flag );
|
|
|
260 |
}
|
|
|
261 |
|
|
|
262 |
TInt numberCtrl( KZero );
|
|
|
263 |
numberCtrl = reader.ReadInt16();
|
|
|
264 |
if( numberCtrl )
|
|
|
265 |
{
|
|
|
266 |
const SEikHotKey* ptr=(const SEikHotKey*)reader.Ptr();
|
|
|
267 |
reader.Advance(numberCtrl*sizeof(SEikHotKey));
|
|
|
268 |
TBool flag(EFalse);
|
|
|
269 |
TInt keycode( KZero );
|
|
|
270 |
TInt commandId( KZero );
|
|
|
271 |
TInt modifires(EModifierCtrl);
|
|
|
272 |
commandId = ptr->iCommandId;
|
|
|
273 |
flag = hotkeytableptr->HotKeyFromCommandId( commandId, keycode, modifires );
|
|
|
274 |
STIF_ASSERT_TRUE( flag );
|
|
|
275 |
}
|
|
|
276 |
|
|
|
277 |
TInt numberShiftCtrl( KZero );
|
|
|
278 |
numberShiftCtrl = reader.ReadInt16();
|
|
|
279 |
if( numberShiftCtrl )
|
|
|
280 |
{
|
|
|
281 |
const SEikHotKey* ptr=(const SEikHotKey*)reader.Ptr();
|
|
|
282 |
reader.Advance(numberShiftCtrl*sizeof(SEikHotKey));
|
|
|
283 |
TBool flag(EFalse);
|
|
|
284 |
TInt keycode( KZero );
|
|
|
285 |
TInt commandId( KZero );
|
|
|
286 |
TInt modifires(EModifierShift|EModifierCtrl);
|
|
|
287 |
commandId = ptr->iCommandId;
|
|
|
288 |
flag = hotkeytableptr->HotKeyFromCommandId( commandId, keycode, modifires );
|
|
|
289 |
STIF_ASSERT_TRUE( flag );
|
|
|
290 |
}
|
|
|
291 |
|
|
|
292 |
CleanupStack::PopAndDestroy( KTwo );//reader, hotkeytableptr
|
|
|
293 |
return KErrNone;
|
|
|
294 |
}
|
|
|
295 |
|
|
|
296 |
// -----------------------------------------------------------------------------
|
|
|
297 |
// CTestSDKCFD::TestEHKEYReset
|
|
|
298 |
// -----------------------------------------------------------------------------
|
|
|
299 |
//
|
|
|
300 |
TInt CTestSDKEIKHKEYT::TestEHKEYResetL( CStifItemParser& /*aItem*/ )
|
|
|
301 |
{
|
|
|
302 |
CEikHotKeyTable* hotkeytableptr = new( ELeave ) CEikHotKeyTable;
|
|
|
303 |
CleanupStack::PushL( hotkeytableptr );
|
|
|
304 |
|
|
|
305 |
TInt commandId( KOne );
|
|
|
306 |
TInt keycode( KTwo );
|
|
|
307 |
TInt modifiers( KZero );
|
|
|
308 |
hotkeytableptr->AddItemL( commandId, keycode, modifiers );
|
|
|
309 |
|
|
|
310 |
TInt commandId2( KTwo );
|
|
|
311 |
TInt keycode2( KThree );
|
|
|
312 |
TInt modifiers2( KZero );
|
|
|
313 |
hotkeytableptr->AddItemL( commandId2, keycode2, modifiers2 );
|
|
|
314 |
|
|
|
315 |
hotkeytableptr->Reset();
|
|
|
316 |
|
|
|
317 |
TBool flag;
|
|
|
318 |
TInt returnkeycode( KZero );
|
|
|
319 |
TInt returncommandId( KZero );
|
|
|
320 |
flag = hotkeytableptr->HotKeyFromCommandId( commandId, returnkeycode,
|
|
|
321 |
modifiers );
|
|
|
322 |
returncommandId = hotkeytableptr->CommandIdFromHotKey( keycode, modifiers );
|
|
|
323 |
STIF_ASSERT_FALSE( flag );
|
|
|
324 |
STIF_ASSERT_NOT_EQUALS( keycode, returnkeycode );
|
|
|
325 |
STIF_ASSERT_NOT_EQUALS( commandId, returncommandId );
|
|
|
326 |
|
|
|
327 |
flag = ETrue;
|
|
|
328 |
flag = hotkeytableptr->HotKeyFromCommandId( commandId2, returnkeycode,
|
|
|
329 |
modifiers2 );
|
|
|
330 |
returncommandId = hotkeytableptr->CommandIdFromHotKey( keycode2,
|
|
|
331 |
modifiers2 );
|
|
|
332 |
STIF_ASSERT_FALSE( flag );
|
|
|
333 |
STIF_ASSERT_NOT_EQUALS( keycode2, returnkeycode );
|
|
|
334 |
STIF_ASSERT_NOT_EQUALS( commandId2, returncommandId );
|
|
|
335 |
CleanupStack::PopAndDestroy( hotkeytableptr );
|
|
|
336 |
|
|
|
337 |
return KErrNone;
|
|
|
338 |
|
|
|
339 |
}
|
|
|
340 |
|
|
|
341 |
// -----------------------------------------------------------------------------
|
|
|
342 |
// CTestSDKCFD::TestEHKEYDestructor
|
|
|
343 |
// -----------------------------------------------------------------------------
|
|
|
344 |
//
|
|
|
345 |
TInt CTestSDKEIKHKEYT::TestEHKEYDestructorL( CStifItemParser& /*aItem*/ )
|
|
|
346 |
{
|
|
|
347 |
CEikHotKeyTable* hotkeytableptr = new( ELeave ) CEikHotKeyTable;
|
|
|
348 |
CleanupStack::PushL( hotkeytableptr );
|
|
|
349 |
STIF_ASSERT_NOT_NULL( hotkeytableptr );
|
|
|
350 |
CleanupStack::Pop( hotkeytableptr );
|
|
|
351 |
delete hotkeytableptr;
|
|
|
352 |
|
|
|
353 |
return KErrNone;
|
|
|
354 |
}
|
|
|
355 |
|
|
|
356 |
/*
|
|
|
357 |
* [End of File] - Do not remove
|
|
|
358 |
*/
|