|
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 api in eiklbbut.h
|
|
|
15 |
*
|
|
|
16 |
*/
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
// [INCLUDE FILES]
|
|
|
21 |
#include <e32svr.h>
|
|
|
22 |
#include <stifparser.h>
|
|
|
23 |
#include <stiftestinterface.h>
|
|
|
24 |
#include <testsdkbuttons.rsg>
|
|
|
25 |
#include <w32std.h>
|
|
|
26 |
#include <coedef.h>
|
|
|
27 |
#include <s32file.h>
|
|
|
28 |
#include <s32mem.h>
|
|
|
29 |
#include <coecobs.h>
|
|
|
30 |
|
|
|
31 |
#include "testsdkbuttons.h"
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
// CONSTANTS
|
|
|
35 |
const TInt KArraySize = 10;
|
|
|
36 |
|
|
|
37 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
|
38 |
|
|
|
39 |
// -----------------------------------------------------------------------------
|
|
|
40 |
// CTestSDKButtons::TestLabelBtConstructorL
|
|
|
41 |
// -----------------------------------------------------------------------------
|
|
|
42 |
//
|
|
|
43 |
TInt CTestSDKButtons::TestLabelBtConstructorL( CStifItemParser& /*aItem*/ )
|
|
|
44 |
{
|
|
|
45 |
CEikLabeledButton* labelbutton = new ( ELeave ) CEikLabeledButton;
|
|
|
46 |
CleanupStack::PushL( labelbutton );
|
|
|
47 |
STIF_ASSERT_NOT_NULL( labelbutton );
|
|
|
48 |
CleanupStack::PopAndDestroy();
|
|
|
49 |
|
|
|
50 |
return KErrNone;
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
// -----------------------------------------------------------------------------
|
|
|
54 |
// CTestSDKButtons::TestLabelBtConstructL
|
|
|
55 |
// -----------------------------------------------------------------------------
|
|
|
56 |
//
|
|
|
57 |
TInt CTestSDKButtons::TestLabelBtConstructL( CStifItemParser& /*aItem*/ )
|
|
|
58 |
{
|
|
|
59 |
TInt hotKeyCode = 1;
|
|
|
60 |
TInt flags = 1;
|
|
|
61 |
CEikLabeledButton* labelbutton = new ( ELeave ) CEikLabeledButton;
|
|
|
62 |
CleanupStack::PushL( labelbutton );
|
|
|
63 |
CEikCommandButton* commandbutton = new( ELeave )CEikCommandButton();
|
|
|
64 |
CleanupStack::PushL( commandbutton );
|
|
|
65 |
labelbutton->ConstructL( commandbutton, hotKeyCode, flags );
|
|
|
66 |
CleanupStack::Pop( commandbutton );
|
|
|
67 |
CleanupStack::PopAndDestroy( labelbutton );
|
|
|
68 |
|
|
|
69 |
return KErrNone;
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
// -----------------------------------------------------------------------------
|
|
|
73 |
// CTestSDKButtons::TestLabelBtConstructFromResourceL
|
|
|
74 |
// -----------------------------------------------------------------------------
|
|
|
75 |
//
|
|
|
76 |
TInt CTestSDKButtons::TestLabelBtConstructFromResourceL( CStifItemParser& /*aItem*/ )
|
|
|
77 |
{
|
|
|
78 |
CEikLabeledButton* labelbutton = new ( ELeave ) CEikLabeledButton;
|
|
|
79 |
CleanupStack::PushL( labelbutton );
|
|
|
80 |
TResourceReader reader;
|
|
|
81 |
CCoeEnv::Static()->CreateResourceReaderLC( reader, R_LABELBUTTON );
|
|
|
82 |
labelbutton->ConstructFromResourceL( reader );
|
|
|
83 |
|
|
|
84 |
CleanupStack::PopAndDestroy( 2 );
|
|
|
85 |
|
|
|
86 |
return KErrNone;
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
// -----------------------------------------------------------------------------
|
|
|
90 |
// CTestSDKButtons::TestLabelBtButtonoL
|
|
|
91 |
// -----------------------------------------------------------------------------
|
|
|
92 |
//
|
|
|
93 |
TInt CTestSDKButtons::TestLabelBtButtonoL( CStifItemParser& /*aItem*/ )
|
|
|
94 |
{
|
|
|
95 |
TInt hotKeyCode = 1;
|
|
|
96 |
TInt flags = 1;
|
|
|
97 |
CEikLabeledButton* labelbutton = new ( ELeave ) CEikLabeledButton;
|
|
|
98 |
CleanupStack::PushL( labelbutton );
|
|
|
99 |
CEikCommandButton* commandbutton = new( ELeave )CEikCommandButton();
|
|
|
100 |
CleanupStack::PushL( commandbutton );
|
|
|
101 |
labelbutton->ConstructL( commandbutton, hotKeyCode, flags );
|
|
|
102 |
CleanupStack::Pop( commandbutton );
|
|
|
103 |
|
|
|
104 |
CEikCommandButtonBase* temp = NULL;
|
|
|
105 |
temp = labelbutton->Button();
|
|
|
106 |
STIF_ASSERT_NOT_NULL( temp );
|
|
|
107 |
|
|
|
108 |
CleanupStack::PopAndDestroy( labelbutton );
|
|
|
109 |
|
|
|
110 |
return KErrNone;
|
|
|
111 |
}
|
|
|
112 |
|
|
|
113 |
// -----------------------------------------------------------------------------
|
|
|
114 |
// CTestSDKButtons::TestLabelBtLabelL
|
|
|
115 |
// -----------------------------------------------------------------------------
|
|
|
116 |
//
|
|
|
117 |
TInt CTestSDKButtons::TestLabelBtLabelL( CStifItemParser& /*aItem*/ )
|
|
|
118 |
{
|
|
|
119 |
TInt hotKeyCode = 1;
|
|
|
120 |
TInt flags = 1;
|
|
|
121 |
CEikLabeledButton* labelbutton = new ( ELeave ) CEikLabeledButton;
|
|
|
122 |
CleanupStack::PushL( labelbutton );
|
|
|
123 |
CEikCommandButton* commandButton = new( ELeave )CEikCommandButton();
|
|
|
124 |
CleanupStack::PushL( commandButton );
|
|
|
125 |
labelbutton->ConstructL( commandButton, hotKeyCode, flags );
|
|
|
126 |
CleanupStack::Pop( commandButton );
|
|
|
127 |
|
|
|
128 |
CEikLabel* temp = NULL;
|
|
|
129 |
temp = labelbutton->Label();
|
|
|
130 |
STIF_ASSERT_NOT_NULL( temp );
|
|
|
131 |
|
|
|
132 |
CleanupStack::PopAndDestroy( labelbutton );
|
|
|
133 |
|
|
|
134 |
return KErrNone;
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
// -----------------------------------------------------------------------------
|
|
|
138 |
// CTestSDKButtons::TestLabelBtHotKeyFunctionsL
|
|
|
139 |
// -----------------------------------------------------------------------------
|
|
|
140 |
//
|
|
|
141 |
TInt CTestSDKButtons::TestLabelBtHotKeyFunctionsL( CStifItemParser& /*aItem*/ )
|
|
|
142 |
{
|
|
|
143 |
TInt hotKeyCode = 97;
|
|
|
144 |
TInt flags = 1;
|
|
|
145 |
CEikLabeledButton* labelbutton = new ( ELeave ) CEikLabeledButton;
|
|
|
146 |
CleanupStack::PushL( labelbutton );
|
|
|
147 |
CEikCommandButton* commandButton = new( ELeave )CEikCommandButton();
|
|
|
148 |
CleanupStack::PushL( commandButton );
|
|
|
149 |
labelbutton->ConstructL( commandButton, hotKeyCode, flags );
|
|
|
150 |
CleanupStack::Pop( commandButton );
|
|
|
151 |
labelbutton->HotKeyCode();
|
|
|
152 |
labelbutton->ShowsHotKey();
|
|
|
153 |
labelbutton->PlainHotKey();
|
|
|
154 |
|
|
|
155 |
hotKeyCode++;
|
|
|
156 |
labelbutton->UpdateHotKey( hotKeyCode, CEikLabeledButton::EPlainHotKey );
|
|
|
157 |
STIF_ASSERT_EQUALS( hotKeyCode, labelbutton->HotKeyCode() );
|
|
|
158 |
STIF_ASSERT_FALSE( labelbutton->ShowsHotKey() );
|
|
|
159 |
STIF_ASSERT_TRUE( labelbutton->PlainHotKey() );
|
|
|
160 |
|
|
|
161 |
|
|
|
162 |
CleanupStack::PopAndDestroy( labelbutton );
|
|
|
163 |
|
|
|
164 |
return KErrNone;
|
|
|
165 |
}
|
|
|
166 |
|
|
|
167 |
// -----------------------------------------------------------------------------
|
|
|
168 |
// CTestSDKButtons::TestLabelBtAnimateL
|
|
|
169 |
// -----------------------------------------------------------------------------
|
|
|
170 |
//
|
|
|
171 |
TInt CTestSDKButtons::TestLabelBtAnimateL( CStifItemParser& /*aItem*/ )
|
|
|
172 |
{
|
|
|
173 |
CEikLabeledButton* labelbutton = new ( ELeave ) CEikLabeledButton;
|
|
|
174 |
CleanupStack::PushL( labelbutton );
|
|
|
175 |
TResourceReader reader;
|
|
|
176 |
CCoeEnv::Static()->CreateResourceReaderLC( reader, R_LABELBUTTON );
|
|
|
177 |
labelbutton->ConstructFromResourceL( reader );
|
|
|
178 |
|
|
|
179 |
labelbutton->Animate();
|
|
|
180 |
|
|
|
181 |
CleanupStack::PopAndDestroy( 2 );
|
|
|
182 |
|
|
|
183 |
return KErrNone;
|
|
|
184 |
}
|
|
|
185 |
|
|
|
186 |
// -----------------------------------------------------------------------------
|
|
|
187 |
// CTestSDKButtons::TestLabelBtOfferKeyEvnetL
|
|
|
188 |
// -----------------------------------------------------------------------------
|
|
|
189 |
//
|
|
|
190 |
TInt CTestSDKButtons::TestLabelBtOfferKeyEvnetL( CStifItemParser& /*aItem*/ )
|
|
|
191 |
{
|
|
|
192 |
CEikLabeledButton* labelbutton = new ( ELeave ) CEikLabeledButton;
|
|
|
193 |
CleanupStack::PushL( labelbutton );
|
|
|
194 |
labelbutton->SetContainerWindowL( *iContainer );
|
|
|
195 |
TResourceReader reader;
|
|
|
196 |
CCoeEnv::Static()->CreateResourceReaderLC( reader, R_LABELBUTTON );
|
|
|
197 |
labelbutton->ConstructFromResourceL( reader );
|
|
|
198 |
TKeyEvent keyevent = { EKeyEnter, EStdKeyEnter, 0, 0 };
|
|
|
199 |
TEventCode type = EEventKey;
|
|
|
200 |
TKeyResponse result = labelbutton->OfferKeyEventL( keyevent, type );
|
|
|
201 |
STIF_ASSERT_EQUALS( EKeyWasNotConsumed, result );
|
|
|
202 |
|
|
|
203 |
TPointerEvent event;
|
|
|
204 |
labelbutton->HandlePointerEventL( event );
|
|
|
205 |
|
|
|
206 |
CleanupStack::PopAndDestroy( 2 );
|
|
|
207 |
|
|
|
208 |
return KErrNone;
|
|
|
209 |
}
|
|
|
210 |
|
|
|
211 |
// -----------------------------------------------------------------------------
|
|
|
212 |
// CTestSDKButtons::TestLabelBtSetContainerWindowL
|
|
|
213 |
// -----------------------------------------------------------------------------
|
|
|
214 |
//
|
|
|
215 |
TInt CTestSDKButtons::TestLabelBtSetContainerWindowL( CStifItemParser& /*aItem*/ )
|
|
|
216 |
{
|
|
|
217 |
CEikLabeledButton* labelbutton = new ( ELeave ) CEikLabeledButton;
|
|
|
218 |
CleanupStack::PushL( labelbutton );
|
|
|
219 |
labelbutton->SetContainerWindowL( *iContainer );
|
|
|
220 |
TResourceReader reader;
|
|
|
221 |
CCoeEnv::Static()->CreateResourceReaderLC( reader, R_LABELBUTTON );
|
|
|
222 |
labelbutton->ConstructFromResourceL( reader );
|
|
|
223 |
|
|
|
224 |
CleanupStack::PopAndDestroy( 2 );
|
|
|
225 |
|
|
|
226 |
return KErrNone;
|
|
|
227 |
}
|
|
|
228 |
|
|
|
229 |
// -----------------------------------------------------------------------------
|
|
|
230 |
// CTestSDKButtons::TestLabelBtMiniSizeL
|
|
|
231 |
// -----------------------------------------------------------------------------
|
|
|
232 |
//
|
|
|
233 |
TInt CTestSDKButtons::TestLabelBtMiniSizeL( CStifItemParser& /*aItem*/ )
|
|
|
234 |
{
|
|
|
235 |
CEikLabeledButton* labelbutton = new ( ELeave ) CEikLabeledButton;
|
|
|
236 |
CleanupStack::PushL( labelbutton );
|
|
|
237 |
labelbutton->SetContainerWindowL( *iContainer );
|
|
|
238 |
TResourceReader reader;
|
|
|
239 |
CCoeEnv::Static()->CreateResourceReaderLC( reader, R_LABELBUTTON );
|
|
|
240 |
labelbutton->ConstructFromResourceL( reader );
|
|
|
241 |
TSize size( 0, 0 );
|
|
|
242 |
size = labelbutton->MinimumSize();
|
|
|
243 |
STIF_ASSERT_NOT_EQUALS( 0, size.iWidth );
|
|
|
244 |
STIF_ASSERT_NOT_EQUALS( 0, size.iHeight );
|
|
|
245 |
CleanupStack::PopAndDestroy( 2 );
|
|
|
246 |
|
|
|
247 |
return KErrNone;
|
|
|
248 |
}
|
|
|
249 |
|
|
|
250 |
// -----------------------------------------------------------------------------
|
|
|
251 |
// CTestSDKButtons::TestLabelBtSetdimL
|
|
|
252 |
// -----------------------------------------------------------------------------
|
|
|
253 |
//
|
|
|
254 |
TInt CTestSDKButtons::TestLabelBtSetdimL( CStifItemParser& /*aItem*/ )
|
|
|
255 |
{
|
|
|
256 |
CEikLabeledButton* labelbutton = new ( ELeave ) CEikLabeledButton;
|
|
|
257 |
CleanupStack::PushL( labelbutton );
|
|
|
258 |
labelbutton->SetContainerWindowL( *iContainer );
|
|
|
259 |
TResourceReader reader;
|
|
|
260 |
CCoeEnv::Static()->CreateResourceReaderLC( reader, R_LABELBUTTON );
|
|
|
261 |
labelbutton->ConstructFromResourceL( reader );
|
|
|
262 |
labelbutton->SetDimmed( EFalse );
|
|
|
263 |
|
|
|
264 |
CleanupStack::PopAndDestroy( 2 );
|
|
|
265 |
|
|
|
266 |
return KErrNone;
|
|
|
267 |
}
|
|
|
268 |
|
|
|
269 |
// -----------------------------------------------------------------------------
|
|
|
270 |
// CTestSDKButtons::TestLabelBtHandleResourceChangeL
|
|
|
271 |
// -----------------------------------------------------------------------------
|
|
|
272 |
//
|
|
|
273 |
TInt CTestSDKButtons::TestLabelBtHandleResourceChangeL( CStifItemParser& /*aItem*/ )
|
|
|
274 |
{
|
|
|
275 |
CEikLabeledButton* labelbutton = new ( ELeave ) CEikLabeledButton;
|
|
|
276 |
CleanupStack::PushL( labelbutton );
|
|
|
277 |
labelbutton->SetContainerWindowL( *iContainer );
|
|
|
278 |
TResourceReader reader;
|
|
|
279 |
CCoeEnv::Static()->CreateResourceReaderLC( reader, R_LABELBUTTON );
|
|
|
280 |
labelbutton->ConstructFromResourceL( reader );
|
|
|
281 |
TInt type = 0;
|
|
|
282 |
labelbutton->HandleResourceChange( type );
|
|
|
283 |
|
|
|
284 |
CleanupStack::PopAndDestroy( 2 );
|
|
|
285 |
|
|
|
286 |
return KErrNone;
|
|
|
287 |
}
|
|
|
288 |
|
|
|
289 |
// -----------------------------------------------------------------------------
|
|
|
290 |
// CTestSDKButtons::TestLabelBtInputCapabilitiesL
|
|
|
291 |
// -----------------------------------------------------------------------------
|
|
|
292 |
//
|
|
|
293 |
TInt CTestSDKButtons::TestLabelBtInputCapabilitiesL( CStifItemParser& /*aItem*/ )
|
|
|
294 |
{
|
|
|
295 |
CEikLabeledButton* labelbutton = new ( ELeave ) CEikLabeledButton;
|
|
|
296 |
CleanupStack::PushL( labelbutton );
|
|
|
297 |
labelbutton->SetContainerWindowL( *iContainer );
|
|
|
298 |
TResourceReader reader;
|
|
|
299 |
CCoeEnv::Static()->CreateResourceReaderLC( reader, R_LABELBUTTON );
|
|
|
300 |
labelbutton->ConstructFromResourceL( reader );
|
|
|
301 |
labelbutton->InputCapabilities();
|
|
|
302 |
|
|
|
303 |
CleanupStack::PopAndDestroy( 2 );
|
|
|
304 |
|
|
|
305 |
return KErrNone;
|
|
|
306 |
}
|
|
|
307 |
|
|
|
308 |
// -----------------------------------------------------------------------------
|
|
|
309 |
// CTestSDKButtons::TestLabelBtGetColorUseListL
|
|
|
310 |
// -----------------------------------------------------------------------------
|
|
|
311 |
//
|
|
|
312 |
TInt CTestSDKButtons::TestLabelBtGetColorUseListL( CStifItemParser& /*aItem*/ )
|
|
|
313 |
{
|
|
|
314 |
CEikLabeledButton* labelbutton = new ( ELeave ) CEikLabeledButton;
|
|
|
315 |
CleanupStack::PushL( labelbutton );
|
|
|
316 |
labelbutton->SetContainerWindowL( *iContainer );
|
|
|
317 |
TResourceReader reader;
|
|
|
318 |
CCoeEnv::Static()->CreateResourceReaderLC( reader, R_LABELBUTTON );
|
|
|
319 |
labelbutton->ConstructFromResourceL( reader );
|
|
|
320 |
CArrayFixFlat<TCoeColorUse>* array = new (ELeave) CArrayFixFlat<TCoeColorUse>( KArraySize );
|
|
|
321 |
CleanupStack::PushL( array );
|
|
|
322 |
labelbutton->GetColorUseListL( *array );
|
|
|
323 |
STIF_ASSERT_EQUALS( 0, array->Count() );
|
|
|
324 |
|
|
|
325 |
CleanupStack::PopAndDestroy( 3 );
|
|
|
326 |
|
|
|
327 |
return KErrNone;
|
|
|
328 |
}
|
|
|
329 |
// -----------------------------------------------------------------------------
|
|
|
330 |
// CTestSDKButtons::TestLabelBtWriteInternalStateL
|
|
|
331 |
// -----------------------------------------------------------------------------
|
|
|
332 |
//
|
|
|
333 |
TInt CTestSDKButtons::TestLabelBtWriteInternalStateL( CStifItemParser& /*aItem*/ )
|
|
|
334 |
{
|
|
|
335 |
class CTestEikLabeledButton : public MCoeControlObserver, public CEikLabeledButton
|
|
|
336 |
{
|
|
|
337 |
public:
|
|
|
338 |
/*Constructor*/
|
|
|
339 |
CTestEikLabeledButton(){}
|
|
|
340 |
/*Deconstructor*/
|
|
|
341 |
~CTestEikLabeledButton(){}
|
|
|
342 |
void DoWriteInternalStateL( RWriteStream aStream )
|
|
|
343 |
{
|
|
|
344 |
WriteInternalStateL( aStream );
|
|
|
345 |
}
|
|
|
346 |
public:
|
|
|
347 |
/**
|
|
|
348 |
* From CCoeControl
|
|
|
349 |
* Returns the number of component controls
|
|
|
350 |
* @return Number of component controls
|
|
|
351 |
*/
|
|
|
352 |
TInt CountComponentControls() const{ return 0; }
|
|
|
353 |
|
|
|
354 |
/**
|
|
|
355 |
* From CCoeControl
|
|
|
356 |
* Return a pointer to the component control at the give index.
|
|
|
357 |
* @return Pointer to the conponent control.No ownership is transferred
|
|
|
358 |
*/
|
|
|
359 |
CCoeControl* ComponentControl(TInt /*aIndex*/) const{ return NULL; }
|
|
|
360 |
/**
|
|
|
361 |
* From CCoeControl
|
|
|
362 |
*/
|
|
|
363 |
void SizeChanged(){}
|
|
|
364 |
/**
|
|
|
365 |
* From CCoeControl
|
|
|
366 |
*/
|
|
|
367 |
void Reserved_2(){}
|
|
|
368 |
/**
|
|
|
369 |
* from MCoeControlObserver
|
|
|
370 |
*/
|
|
|
371 |
void HandleControlEventL(CCoeControl* /*aControl*/,
|
|
|
372 |
TCoeEvent /*aEventType*/){}
|
|
|
373 |
};
|
|
|
374 |
|
|
|
375 |
CTestEikLabeledButton* labelbutton = new ( ELeave ) CTestEikLabeledButton;
|
|
|
376 |
CleanupStack::PushL( labelbutton );
|
|
|
377 |
labelbutton->SetContainerWindowL( *iContainer );
|
|
|
378 |
TResourceReader reader;
|
|
|
379 |
CCoeEnv::Static()->CreateResourceReaderLC( reader, R_LABELBUTTON );
|
|
|
380 |
labelbutton->ConstructFromResourceL( reader );
|
|
|
381 |
const TInt KHBufSize = 4096;
|
|
|
382 |
HBufC8* buf = HBufC8::NewL( KHBufSize );
|
|
|
383 |
CleanupStack::PushL( buf );
|
|
|
384 |
TPtr8 ptr = buf->Des();
|
|
|
385 |
RDesWriteStream stream;
|
|
|
386 |
CleanupClosePushL( stream );
|
|
|
387 |
stream.Open( ptr );
|
|
|
388 |
labelbutton->DoWriteInternalStateL( stream );
|
|
|
389 |
stream.CommitL();
|
|
|
390 |
stream.Close();
|
|
|
391 |
|
|
|
392 |
CleanupStack::PopAndDestroy( 4 );// labelbutton, reader, buf, stream
|
|
|
393 |
|
|
|
394 |
return KErrNone;
|
|
|
395 |
|
|
|
396 |
}
|
|
|
397 |
|
|
|
398 |
// End of file
|
|
|
399 |
|