|
1 // Copyright (c) 2006-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 "Symbian Foundation License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // This contains CTestAppLoaderKeyEvents |
|
15 // |
|
16 // |
|
17 |
|
18 // USER includes |
|
19 #include "TestAppLoaderKeyEvents.h" |
|
20 |
|
21 // EPOC includes |
|
22 #include <w32std.h> |
|
23 |
|
24 /*@{*/ |
|
25 const TInt KDelayMultiplier = 1000; |
|
26 |
|
27 /// Parameters |
|
28 _LIT(KKey, "key%d"); |
|
29 _LIT(KDelay, "delay%d"); |
|
30 |
|
31 /// Key codes |
|
32 _LIT(KKeyNull, "EKeyNull"); |
|
33 _LIT(KKeyDevice0, "EKeyDevice0"); |
|
34 _LIT(KKeyDevice1, "EKeyDevice1"); |
|
35 /*@}*/ |
|
36 |
|
37 // constructor |
|
38 CTestAppLoaderKeyEvents::CTestAppLoaderKeyEvents() |
|
39 : CTestAppLoaderBase() |
|
40 { |
|
41 SetTestStepName(_L("KeyEvents")); |
|
42 } |
|
43 |
|
44 TBool CTestAppLoaderKeyEvents::GetKeyCodeFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TKeyCode& aResult, TStdScanCode& aScanCode) |
|
45 { |
|
46 TPtrC str; |
|
47 TBool ret=GetStringFromConfig(aSectName, aKeyName, str); |
|
48 |
|
49 if ( ret ) |
|
50 { |
|
51 if ( str==KKeyNull ) |
|
52 { |
|
53 aResult=EKeyNull; |
|
54 aScanCode=EStdKeyNull; |
|
55 } |
|
56 else if ( str==KKeyDevice0 ) |
|
57 { |
|
58 aResult=EKeyDevice0; |
|
59 aScanCode=EStdKeyDevice0; |
|
60 } |
|
61 else if ( str==KKeyDevice1 ) |
|
62 { |
|
63 aResult=EKeyDevice1; |
|
64 aScanCode=EStdKeyDevice1; |
|
65 } |
|
66 } |
|
67 |
|
68 return ret; |
|
69 } |
|
70 |
|
71 // Each test step must supply a implementation for doTestStepL |
|
72 enum TVerdict CTestAppLoaderKeyEvents::doTestStepL( void ) |
|
73 { |
|
74 // Printing to the console and log file |
|
75 INFO_PRINTF1(_L("TEST-> KEY EVENTS")); |
|
76 |
|
77 RWsSession ws; |
|
78 User::LeaveIfError(ws.Connect()); |
|
79 CleanupClosePushL(ws); |
|
80 TBuf<KMaxTestExecuteCommandLength> tempStore; |
|
81 TInt index=0; |
|
82 TBool moreData=ETrue; |
|
83 TKeyCode keyCode; |
|
84 TStdScanCode scanCode; |
|
85 TInt delay; |
|
86 while ( moreData ) |
|
87 { |
|
88 tempStore.Format(KKey(), ++index); |
|
89 if ( GetKeyCodeFromConfig(ConfigSection(), tempStore, keyCode, scanCode) ) |
|
90 { |
|
91 TKeyEvent event = {keyCode, scanCode, 0, 0}; |
|
92 ws.SimulateKeyEvent(event); |
|
93 ws.Flush(); |
|
94 |
|
95 tempStore.Format(KDelay(), index); |
|
96 if ( GetIntFromConfig(ConfigSection(), tempStore, delay) ) |
|
97 { |
|
98 User::After(delay*KDelayMultiplier); |
|
99 } |
|
100 } |
|
101 else |
|
102 { |
|
103 moreData=EFalse; |
|
104 } |
|
105 } |
|
106 CleanupStack::PopAndDestroy(&ws); |
|
107 |
|
108 // test steps return a result |
|
109 return TestStepResult(); |
|
110 } |