|
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 AknNumEdwin.h |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // [INCLUDE FILES] |
|
21 |
|
22 #include <AknNumEdwin.h> |
|
23 #include <barsread.h> |
|
24 #include <coemain.h> |
|
25 #include <coeaui.h> |
|
26 #include <AknsConstants.h> |
|
27 #include <akndef.h> |
|
28 #include <testsdkeditors.rsg> |
|
29 |
|
30 #include "testsdkeditors.h" |
|
31 #include "testsdkeditorscontrol.h" |
|
32 |
|
33 const TInt KMaxInteger = 100; |
|
34 const TInt KMaxChar = 5; |
|
35 |
|
36 // ============================ MEMBER FUNCTIONS =============================== |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CTestSDKEditors::TestIENewL |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 TInt CTestSDKEditors::TestIENewL( CStifItemParser& /*aItem*/ ) |
|
43 { |
|
44 CAknIntegerEdwin* integerEdwin = CAknIntegerEdwin::NewL( 0, KMaxInteger, KMaxChar ); |
|
45 CleanupStack::PushL( integerEdwin ); |
|
46 STIF_ASSERT_NOT_NULL( integerEdwin ); |
|
47 |
|
48 CleanupStack::PopAndDestroy( integerEdwin ); |
|
49 |
|
50 return KErrNone; |
|
51 |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CTestSDKEditors::TestIEConstructFromResourceL |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 TInt CTestSDKEditors::TestIEConstructFromResourceL( CStifItemParser& /*aItem*/ ) |
|
59 { |
|
60 CAknIntegerEdwin* integerEdwin = CAknIntegerEdwin::NewL( 0, KMaxInteger, KMaxChar ); |
|
61 CleanupStack::PushL( integerEdwin ); |
|
62 STIF_ASSERT_NOT_NULL( integerEdwin ); |
|
63 |
|
64 TResourceReader reader; |
|
65 CCoeEnv::Static()->CreateResourceReaderLC( reader, R_TESTSDK_IEEDITOR ); |
|
66 integerEdwin->ConstructFromResourceL( reader ); |
|
67 CleanupStack::PopAndDestroy(); |
|
68 |
|
69 CleanupStack::PopAndDestroy( integerEdwin ); |
|
70 |
|
71 return KErrNone; |
|
72 |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CTestSDKEditors::TestIEConstructL |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 TInt CTestSDKEditors::TestIEConstructL( CStifItemParser& /*aItem*/ ) |
|
80 { |
|
81 CAknIntegerEdwin* integerEdwin = CAknIntegerEdwin::NewL( 0, KMaxInteger, KMaxChar ); |
|
82 CleanupStack::PushL( integerEdwin ); |
|
83 STIF_ASSERT_NOT_NULL( integerEdwin ); |
|
84 |
|
85 integerEdwin->ConstructL( 0, KMaxInteger, KMaxChar ); |
|
86 |
|
87 CleanupStack::PopAndDestroy( integerEdwin ); |
|
88 |
|
89 return KErrNone; |
|
90 |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CTestSDKEditors::TestIESetValueL |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 TInt CTestSDKEditors::TestIESetValueL( CStifItemParser& /*aItem*/ ) |
|
98 { |
|
99 CAknIntegerEdwin* integerEdwin = CAknIntegerEdwin::NewL( 0, KMaxInteger, KMaxChar ); |
|
100 CleanupStack::PushL( integerEdwin ); |
|
101 STIF_ASSERT_NOT_NULL( integerEdwin ); |
|
102 |
|
103 integerEdwin->SetValueL( KMaxInteger ); |
|
104 |
|
105 CleanupStack::PopAndDestroy( integerEdwin ); |
|
106 |
|
107 return KErrNone; |
|
108 |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CTestSDKEditors::TestIESetUnsetValueL |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 TInt CTestSDKEditors::TestIESetUnsetValueL( CStifItemParser& /*aItem*/ ) |
|
116 { |
|
117 CAknIntegerEdwin* integerEdwin = CAknIntegerEdwin::NewL( 0, KMaxInteger, KMaxChar ); |
|
118 CleanupStack::PushL( integerEdwin ); |
|
119 STIF_ASSERT_NOT_NULL( integerEdwin ); |
|
120 |
|
121 integerEdwin->SetUnsetValue( 0 ); |
|
122 |
|
123 CleanupStack::PopAndDestroy( integerEdwin ); |
|
124 |
|
125 return KErrNone; |
|
126 |
|
127 } |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
|
130 // CTestSDKEditors::TestIEGetTextAsIntegerL |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 TInt CTestSDKEditors::TestIEGetTextAsIntegerL( CStifItemParser& /*aItem*/ ) |
|
134 { |
|
135 CAknIntegerEdwin* integerEdwin = CAknIntegerEdwin::NewL( 0, KMaxInteger, KMaxChar ); |
|
136 CleanupStack::PushL( integerEdwin ); |
|
137 STIF_ASSERT_NOT_NULL( integerEdwin ); |
|
138 |
|
139 integerEdwin->SetValueL( KMaxInteger ); |
|
140 TInt valueGet; |
|
141 STIF_ASSERT_TRUE( CAknNumericEdwin ::EValueValid == integerEdwin->GetTextAsInteger( valueGet ) ); |
|
142 STIF_ASSERT_TRUE( valueGet == KMaxInteger ); |
|
143 |
|
144 CleanupStack::PopAndDestroy( integerEdwin ); |
|
145 |
|
146 return KErrNone; |
|
147 |
|
148 } |
|
149 |
|
150 // ----------------------------------------------------------------------------- |
|
151 // CTestSDKEditors::TestIESetMinimumIntegerValueL |
|
152 // ----------------------------------------------------------------------------- |
|
153 // |
|
154 TInt CTestSDKEditors::TestIESetMinimumIntegerValueL( CStifItemParser& /*aItem*/ ) |
|
155 { |
|
156 CAknIntegerEdwin* integerEdwin = CAknIntegerEdwin::NewL( 0, KMaxInteger, KMaxChar ); |
|
157 CleanupStack::PushL( integerEdwin ); |
|
158 STIF_ASSERT_NOT_NULL( integerEdwin ); |
|
159 |
|
160 integerEdwin->SetMinimumIntegerValue( 0 ); |
|
161 |
|
162 CleanupStack::PopAndDestroy( integerEdwin ); |
|
163 |
|
164 return KErrNone; |
|
165 |
|
166 } |
|
167 |
|
168 // ----------------------------------------------------------------------------- |
|
169 // CTestSDKEditors::TestIESetMaximumIntegerValueL |
|
170 // ----------------------------------------------------------------------------- |
|
171 // |
|
172 TInt CTestSDKEditors::TestIESetMaximumIntegerValueL( CStifItemParser& /*aItem*/ ) |
|
173 { |
|
174 CAknIntegerEdwin* integerEdwin = CAknIntegerEdwin::NewL( 0, KMaxInteger, KMaxChar ); |
|
175 CleanupStack::PushL( integerEdwin ); |
|
176 STIF_ASSERT_NOT_NULL( integerEdwin ); |
|
177 |
|
178 integerEdwin->SetMaximumIntegerValue( KMaxInteger ); |
|
179 |
|
180 CleanupStack::PopAndDestroy( integerEdwin ); |
|
181 |
|
182 return KErrNone; |
|
183 |
|
184 } |
|
185 |
|
186 // ----------------------------------------------------------------------------- |
|
187 // CTestSDKEditors::TestIEPrepareForFocusLossL |
|
188 // ----------------------------------------------------------------------------- |
|
189 // |
|
190 TInt CTestSDKEditors::TestIEPrepareForFocusLossL( CStifItemParser& /*aItem*/ ) |
|
191 { |
|
192 CAknIntegerEdwin* integerEdwin = CAknIntegerEdwin::NewL( 0, KMaxInteger, KMaxChar ); |
|
193 CleanupStack::PushL( integerEdwin ); |
|
194 STIF_ASSERT_NOT_NULL( integerEdwin ); |
|
195 |
|
196 integerEdwin->PrepareForFocusLossL(); |
|
197 |
|
198 CleanupStack::PopAndDestroy( integerEdwin ); |
|
199 |
|
200 return KErrNone; |
|
201 |
|
202 } |
|
203 |
|
204 // ----------------------------------------------------------------------------- |
|
205 // CTestSDKEditors::TestIEHandleResourceChangeL |
|
206 // ----------------------------------------------------------------------------- |
|
207 // |
|
208 TInt CTestSDKEditors::TestIEHandleResourceChangeL( CStifItemParser& /*aItem*/ ) |
|
209 { |
|
210 CAknIntegerEdwin* integerEdwin = CAknIntegerEdwin::NewL( 0, KMaxInteger, KMaxChar ); |
|
211 CleanupStack::PushL( integerEdwin ); |
|
212 STIF_ASSERT_NOT_NULL( integerEdwin ); |
|
213 |
|
214 integerEdwin->HandleResourceChange( KEikInputLanguageChange ); |
|
215 |
|
216 CleanupStack::PopAndDestroy( integerEdwin ); |
|
217 |
|
218 return KErrNone; |
|
219 |
|
220 } |
|
221 |
|
222 // ----------------------------------------------------------------------------- |
|
223 // CTestSDKEditors::TestIEOfferKeyEventL |
|
224 // ----------------------------------------------------------------------------- |
|
225 // |
|
226 TInt CTestSDKEditors::TestIEOfferKeyEventL( CStifItemParser& /*aItem*/ ) |
|
227 { |
|
228 CAknIntegerEdwin* integerEdwin = CAknIntegerEdwin::NewL( 0, KMaxInteger, KMaxChar ); |
|
229 CleanupStack::PushL( integerEdwin ); |
|
230 STIF_ASSERT_NOT_NULL( integerEdwin ); |
|
231 |
|
232 TKeyEvent keyEvent; |
|
233 keyEvent.iCode = EKeyCBA1; |
|
234 STIF_ASSERT_TRUE( EKeyWasNotConsumed == integerEdwin->OfferKeyEventL( keyEvent, EEventKeyDown ) ); |
|
235 |
|
236 CleanupStack::PopAndDestroy( integerEdwin ); |
|
237 |
|
238 return KErrNone; |
|
239 |
|
240 } |
|
241 |
|
242 // ----------------------------------------------------------------------------- |
|
243 // CTestSDKEditors::TestIEHandlePointerEventL |
|
244 // ----------------------------------------------------------------------------- |
|
245 // |
|
246 TInt CTestSDKEditors::TestIEHandlePointerEventL( CStifItemParser& /*aItem*/ ) |
|
247 { |
|
248 CTestEditorsControl* control = CTestEditorsControl::NewL(); |
|
249 CleanupStack::PushL( control ); |
|
250 STIF_ASSERT_NOT_NULL( control ); |
|
251 |
|
252 CAknIntegerEdwin* integerEdwin = CAknIntegerEdwin::NewL( 0, KMaxInteger, KMaxChar ); |
|
253 CleanupStack::PushL( integerEdwin ); |
|
254 STIF_ASSERT_NOT_NULL( integerEdwin ); |
|
255 |
|
256 integerEdwin->ConstructL( 0, KMaxInteger, KMaxChar ); |
|
257 integerEdwin->SetContainerWindowL( *control ); |
|
258 integerEdwin->CreateTextViewL(); |
|
259 |
|
260 TPointerEvent event; |
|
261 event.iType = TPointerEvent::EButton1Down; |
|
262 integerEdwin->HandlePointerEventL( event ); |
|
263 |
|
264 CleanupStack::PopAndDestroy( integerEdwin ); |
|
265 CleanupStack::PopAndDestroy( control ); |
|
266 |
|
267 return KErrNone; |
|
268 |
|
269 } |
|
270 |
|
271 // ----------------------------------------------------------------------------- |
|
272 // CTestSDKEditors::TestIECheckNumberL |
|
273 // ----------------------------------------------------------------------------- |
|
274 // |
|
275 TInt CTestSDKEditors::TestIECheckNumberL( CStifItemParser& /*aItem*/ ) |
|
276 { |
|
277 CAknIntegerEdwin* integerEdwin = CAknIntegerEdwin::NewL( 0, KMaxInteger, KMaxChar ); |
|
278 CleanupStack::PushL( integerEdwin ); |
|
279 STIF_ASSERT_NOT_NULL( integerEdwin ); |
|
280 |
|
281 integerEdwin->SetValueL( KMaxInteger ); |
|
282 STIF_ASSERT_TRUE( integerEdwin->CheckNumber() ); |
|
283 |
|
284 CleanupStack::PopAndDestroy( integerEdwin ); |
|
285 |
|
286 return KErrNone; |
|
287 |
|
288 } |