|
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 AknKeyLock.h |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // [INCLUDE FILES] |
|
21 #include <e32svr.h> |
|
22 #include <stifparser.h> |
|
23 #include <stiftestinterface.h> |
|
24 #include <aknkeylock.h> |
|
25 |
|
26 #include "testsdkkeylock.h" |
|
27 // ============================ MEMBER FUNCTIONS =============================== |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // CTestSDKKeyLock::Delete |
|
31 // Delete here all resources allocated and opened from test methods. |
|
32 // Called from destructor. |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 void CTestSDKKeyLock::Delete() |
|
36 { |
|
37 |
|
38 } |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CTestSDKKeyLock::RunMethodL |
|
42 // Run specified method. Contains also table of test mothods and their names. |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 TInt CTestSDKKeyLock::RunMethodL( CStifItemParser& aItem ) |
|
46 { |
|
47 static TStifFunctionInfo const KFunctions[] = |
|
48 { |
|
49 ENTRY( "TestKLConnectL", CTestSDKKeyLock::TestKLConnectL ), |
|
50 ENTRY( "TestKLEnableKeyLockL", CTestSDKKeyLock::TestKLEnableKeyLockL ), |
|
51 ENTRY( "TestKLDisableKeyLockL", CTestSDKKeyLock::TestKLDisableKeyLockL ), |
|
52 ENTRY( "TestKLIsKeyLockEnabledL", CTestSDKKeyLock::TestKLIsKeyLockEnabledL ), |
|
53 ENTRY( "TestKLEnableSoftNotificationsL", CTestSDKKeyLock::TestKLEnableSoftNotificationsL ), |
|
54 ENTRY( "TestKLOfferKeyLockL", CTestSDKKeyLock::TestKLOfferKeyLockL ), |
|
55 ENTRY( "TestKLCancelAllNotificationsL", CTestSDKKeyLock::TestKLCancelAllNotificationsL ), |
|
56 ENTRY( "TestKLDisableWithoutNoteL", CTestSDKKeyLock::TestKLDisableWithoutNoteL ), |
|
57 ENTRY( "TestKLEnableWithoutNoteL", CTestSDKKeyLock::TestKLEnableWithoutNoteL ), |
|
58 ENTRY( "TestKLEnableAutoLockEmulationL", CTestSDKKeyLock::TestKLEnableAutoLockEmulationL ), |
|
59 }; |
|
60 |
|
61 const TInt count = sizeof( KFunctions ) / sizeof( TStifFunctionInfo ); |
|
62 |
|
63 return RunInternalL( KFunctions, count, aItem ); |
|
64 |
|
65 } |
|
66 |
|
67 // ============================ MEMBER FUNCTIONS =============================== |
|
68 |
|
69 // =========================== CLASS RAKNKEYLOCK2 ============================== |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CTestSDKKeyLock::TestKLConnectL |
|
72 // ----------------------------------------------------------------------------- |
|
73 TInt CTestSDKKeyLock::TestKLConnectL( CStifItemParser& /*aItem*/ ) |
|
74 { |
|
75 RAknKeyLock connect; |
|
76 CleanupClosePushL( connect ); |
|
77 STIF_ASSERT_EQUALS( KErrNone, connect.Connect() ); |
|
78 |
|
79 STIF_ASSERT_NOT_NULL( &connect ); |
|
80 |
|
81 connect.EnableKeyLock(); |
|
82 STIF_ASSERT_TRUE( connect.IsKeyLockEnabled() ); |
|
83 connect.DisableKeyLock(); |
|
84 STIF_ASSERT_FALSE( connect.IsKeyLockEnabled() ); |
|
85 |
|
86 CleanupStack::PopAndDestroy( &connect ); |
|
87 |
|
88 return KErrNone; |
|
89 } |
|
90 |
|
91 // =========================== CLASS RAKNKEYLOCK =============================== |
|
92 // ----------------------------------------------------------------------------- |
|
93 // CTestSDKKeyLock::TestKLEnableKeyLockL |
|
94 // ----------------------------------------------------------------------------- |
|
95 TInt CTestSDKKeyLock::TestKLEnableKeyLockL( CStifItemParser& /*aItem*/ ) |
|
96 { |
|
97 RAknKeyLock enablekeylock; |
|
98 CleanupClosePushL( enablekeylock ); |
|
99 STIF_ASSERT_NOT_LEAVES( enablekeylock.Connect() ); |
|
100 |
|
101 STIF_ASSERT_NOT_NULL( &enablekeylock ); |
|
102 |
|
103 STIF_ASSERT_FALSE( enablekeylock.IsKeyLockEnabled() ); |
|
104 enablekeylock.EnableKeyLock(); |
|
105 STIF_ASSERT_TRUE( enablekeylock.IsKeyLockEnabled() ); |
|
106 enablekeylock.DisableKeyLock(); |
|
107 STIF_ASSERT_FALSE( enablekeylock.IsKeyLockEnabled() ); |
|
108 |
|
109 CleanupStack::PopAndDestroy( &enablekeylock ); |
|
110 |
|
111 return KErrNone; |
|
112 } |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CTestSDKKeyLock::TestKLDisableKeyLockL |
|
116 // ----------------------------------------------------------------------------- |
|
117 TInt CTestSDKKeyLock::TestKLDisableKeyLockL( CStifItemParser& /*aItem*/ ) |
|
118 { |
|
119 RAknKeyLock disablekeylock; |
|
120 CleanupClosePushL( disablekeylock ); |
|
121 STIF_ASSERT_NOT_LEAVES( disablekeylock.Connect() ); |
|
122 |
|
123 STIF_ASSERT_NOT_NULL( &disablekeylock ); |
|
124 |
|
125 STIF_ASSERT_FALSE( disablekeylock.IsKeyLockEnabled() ); |
|
126 disablekeylock.EnableKeyLock(); |
|
127 STIF_ASSERT_TRUE( disablekeylock.IsKeyLockEnabled() ); |
|
128 disablekeylock.DisableKeyLock(); |
|
129 STIF_ASSERT_FALSE( disablekeylock.IsKeyLockEnabled() ); |
|
130 |
|
131 CleanupStack::PopAndDestroy( &disablekeylock ); |
|
132 |
|
133 return KErrNone; |
|
134 } |
|
135 |
|
136 // ----------------------------------------------------------------------------- |
|
137 // CTestSDKKeyLock::TestKLIsKeyLockEnabledL |
|
138 // ----------------------------------------------------------------------------- |
|
139 TInt CTestSDKKeyLock::TestKLIsKeyLockEnabledL( CStifItemParser& /*aItem*/ ) |
|
140 { |
|
141 RAknKeyLock iskeylockenabled; |
|
142 CleanupClosePushL( iskeylockenabled ); |
|
143 STIF_ASSERT_NOT_LEAVES( iskeylockenabled.Connect() ); |
|
144 |
|
145 STIF_ASSERT_NOT_NULL( &iskeylockenabled ); |
|
146 |
|
147 STIF_ASSERT_FALSE( iskeylockenabled.IsKeyLockEnabled() ); |
|
148 iskeylockenabled.EnableKeyLock(); |
|
149 STIF_ASSERT_TRUE( iskeylockenabled.IsKeyLockEnabled() ); |
|
150 iskeylockenabled.DisableKeyLock(); |
|
151 STIF_ASSERT_FALSE( iskeylockenabled.IsKeyLockEnabled() ); |
|
152 |
|
153 CleanupStack::PopAndDestroy( &iskeylockenabled ); |
|
154 |
|
155 return KErrNone; |
|
156 } |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // CTestSDKKeyLock::TestKLEnableSoftNotificationsL |
|
160 // ----------------------------------------------------------------------------- |
|
161 TInt CTestSDKKeyLock::TestKLEnableSoftNotificationsL( CStifItemParser& /*aItem*/ ) |
|
162 { |
|
163 RAknKeyLock enablesoftnotifications; |
|
164 CleanupClosePushL( enablesoftnotifications ); |
|
165 STIF_ASSERT_NOT_LEAVES( enablesoftnotifications.Connect() ); |
|
166 |
|
167 STIF_ASSERT_NOT_NULL( &enablesoftnotifications ); |
|
168 |
|
169 enablesoftnotifications.EnableKeyLock(); |
|
170 STIF_ASSERT_TRUE( enablesoftnotifications.IsKeyLockEnabled() ); |
|
171 |
|
172 TBool enable = EFalse; |
|
173 enablesoftnotifications.EnableSoftNotifications( enable ); |
|
174 |
|
175 enablesoftnotifications.DisableKeyLock(); |
|
176 STIF_ASSERT_FALSE( enablesoftnotifications.IsKeyLockEnabled() ); |
|
177 |
|
178 CleanupStack::PopAndDestroy( &enablesoftnotifications ); |
|
179 |
|
180 return KErrNone; |
|
181 } |
|
182 |
|
183 // ----------------------------------------------------------------------------- |
|
184 // CTestSDKKeyLock::TestKLOfferKeyLockL |
|
185 // ----------------------------------------------------------------------------- |
|
186 TInt CTestSDKKeyLock::TestKLOfferKeyLockL( CStifItemParser& /*aItem*/ ) |
|
187 { |
|
188 RAknKeyLock offerkeylock; |
|
189 CleanupClosePushL( offerkeylock ); |
|
190 STIF_ASSERT_NOT_LEAVES( offerkeylock.Connect() ); |
|
191 |
|
192 STIF_ASSERT_NOT_NULL( &offerkeylock ); |
|
193 |
|
194 offerkeylock.EnableKeyLock(); |
|
195 STIF_ASSERT_TRUE( offerkeylock.IsKeyLockEnabled() ); |
|
196 |
|
197 offerkeylock.OfferKeyLock(); |
|
198 |
|
199 offerkeylock.DisableKeyLock(); |
|
200 STIF_ASSERT_FALSE( offerkeylock.IsKeyLockEnabled() ); |
|
201 |
|
202 CleanupStack::PopAndDestroy( &offerkeylock ); |
|
203 |
|
204 return KErrNone; |
|
205 } |
|
206 |
|
207 // ----------------------------------------------------------------------------- |
|
208 // CTestSDKKeyLock::TestKLCancelAllNotificationsL |
|
209 // ----------------------------------------------------------------------------- |
|
210 TInt CTestSDKKeyLock::TestKLCancelAllNotificationsL( CStifItemParser& /*aItem*/ ) |
|
211 { |
|
212 RAknKeyLock cancelallnotifications; |
|
213 CleanupClosePushL( cancelallnotifications ); |
|
214 STIF_ASSERT_NOT_LEAVES( cancelallnotifications.Connect() ); |
|
215 |
|
216 STIF_ASSERT_NOT_NULL( &cancelallnotifications ); |
|
217 |
|
218 cancelallnotifications.EnableKeyLock(); |
|
219 STIF_ASSERT_TRUE( cancelallnotifications.IsKeyLockEnabled() ); |
|
220 |
|
221 TBool enable = ETrue; |
|
222 cancelallnotifications.EnableSoftNotifications( enable ); |
|
223 |
|
224 cancelallnotifications.CancelAllNotifications(); |
|
225 |
|
226 cancelallnotifications.DisableKeyLock(); |
|
227 STIF_ASSERT_FALSE( cancelallnotifications.IsKeyLockEnabled() ); |
|
228 |
|
229 CleanupStack::PopAndDestroy( &cancelallnotifications ); |
|
230 |
|
231 return KErrNone; |
|
232 } |
|
233 |
|
234 // ----------------------------------------------------------------------------- |
|
235 // CTestSDKKeyLock::TestKLEnableWithoutNoteL |
|
236 // ----------------------------------------------------------------------------- |
|
237 TInt CTestSDKKeyLock::TestKLEnableWithoutNoteL( CStifItemParser& /*aItem*/ ) |
|
238 { |
|
239 RAknKeyLock enablewithoutnote; |
|
240 CleanupClosePushL( enablewithoutnote ); |
|
241 STIF_ASSERT_NOT_LEAVES( enablewithoutnote.Connect() ); |
|
242 |
|
243 STIF_ASSERT_NOT_NULL( &enablewithoutnote ); |
|
244 |
|
245 enablewithoutnote.EnableWithoutNote(); |
|
246 STIF_ASSERT_TRUE( enablewithoutnote.IsKeyLockEnabled() ); |
|
247 |
|
248 enablewithoutnote.DisableWithoutNote(); |
|
249 STIF_ASSERT_FALSE( enablewithoutnote.IsKeyLockEnabled() ); |
|
250 |
|
251 CleanupStack::PopAndDestroy( &enablewithoutnote ); |
|
252 |
|
253 return KErrNone; |
|
254 } |
|
255 |
|
256 // ----------------------------------------------------------------------------- |
|
257 // CTestSDKKeyLock::TestKLDisableWithoutNoteL |
|
258 // ----------------------------------------------------------------------------- |
|
259 TInt CTestSDKKeyLock::TestKLDisableWithoutNoteL( CStifItemParser& /*aItem*/ ) |
|
260 { |
|
261 RAknKeyLock disablewithoutnote; |
|
262 CleanupClosePushL( disablewithoutnote ); |
|
263 STIF_ASSERT_NOT_LEAVES( disablewithoutnote.Connect() ); |
|
264 |
|
265 STIF_ASSERT_NOT_NULL( &disablewithoutnote ); |
|
266 |
|
267 disablewithoutnote.EnableWithoutNote(); |
|
268 STIF_ASSERT_TRUE( disablewithoutnote.IsKeyLockEnabled() ); |
|
269 |
|
270 disablewithoutnote.DisableWithoutNote(); |
|
271 STIF_ASSERT_FALSE( disablewithoutnote.IsKeyLockEnabled() ); |
|
272 |
|
273 CleanupStack::PopAndDestroy( &disablewithoutnote ); |
|
274 |
|
275 return KErrNone; |
|
276 } |
|
277 |
|
278 // ----------------------------------------------------------------------------- |
|
279 // CTestSDKKeyLock::TestKLEnableAutoLockEmulationL |
|
280 // ----------------------------------------------------------------------------- |
|
281 TInt CTestSDKKeyLock::TestKLEnableAutoLockEmulationL( CStifItemParser& /*aItem*/ ) |
|
282 { |
|
283 RAknKeyLock enableautolockemulation; |
|
284 CleanupClosePushL( enableautolockemulation ); |
|
285 STIF_ASSERT_NOT_LEAVES( enableautolockemulation.Connect() ); |
|
286 |
|
287 STIF_ASSERT_NOT_NULL( &enableautolockemulation ); |
|
288 |
|
289 enableautolockemulation.EnableAutoLockEmulation(); |
|
290 enableautolockemulation.EnableSoftNotifications( EFalse ); |
|
291 |
|
292 CleanupStack::PopAndDestroy( &enableautolockemulation ); |
|
293 |
|
294 return KErrNone; |
|
295 } |
|
296 |