90
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 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: Main test class for hsHomeScreenStatePlugin library.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <hbmainwindow.h>
|
|
19 |
#include <hbinstance.h>
|
|
20 |
#include <hbview.h>
|
|
21 |
#include <hblistview.h>
|
|
22 |
#include <hblistviewitem.h>
|
|
23 |
#include <HbMenu>
|
|
24 |
#include <HbAction>
|
|
25 |
#include <qscopedpointer>
|
|
26 |
|
|
27 |
#include "caentry.h"
|
|
28 |
#include "caitemmodel.h"
|
|
29 |
#include "hsmenuview.h"
|
|
30 |
#include "hsmenuviewbuilder.h"
|
|
31 |
#include "hsmenumodewrapper.h"
|
|
32 |
#include "hsmenuevent.h"
|
|
33 |
#include "hsallcollectionsstate.h"
|
|
34 |
#include "hsmenueventtransition.h"
|
|
35 |
#include "hsmainwindow.h"
|
97
|
36 |
#include "hsscene.h"
|
90
|
37 |
|
|
38 |
#include "t_hsaddtohomescreenmockstate.h"
|
|
39 |
#include "t_hsmockmodel.h"
|
|
40 |
#include "t_allcollectionsstate.h"
|
|
41 |
|
97
|
42 |
// ---------------------------------------------------------------------------
|
|
43 |
//
|
|
44 |
// ---------------------------------------------------------------------------
|
|
45 |
//
|
90
|
46 |
class HsMainWindowMock : public HsMainWindow
|
|
47 |
{
|
|
48 |
virtual void setCurrentView(HbView *view);
|
|
49 |
|
|
50 |
};
|
|
51 |
|
97
|
52 |
// ---------------------------------------------------------------------------
|
|
53 |
//
|
|
54 |
// ---------------------------------------------------------------------------
|
|
55 |
//
|
90
|
56 |
void HsMainWindowMock::setCurrentView(HbView *view)
|
|
57 |
{
|
|
58 |
Q_UNUSED(view);
|
|
59 |
// do nothing
|
|
60 |
}
|
|
61 |
|
97
|
62 |
// ---------------------------------------------------------------------------
|
|
63 |
//
|
|
64 |
// ---------------------------------------------------------------------------
|
|
65 |
//
|
90
|
66 |
void MenuStatesTest::initTestCase()
|
|
67 |
{
|
|
68 |
// mWindow = NULL;
|
|
69 |
}
|
|
70 |
|
97
|
71 |
// ---------------------------------------------------------------------------
|
|
72 |
//
|
|
73 |
// ---------------------------------------------------------------------------
|
|
74 |
//
|
90
|
75 |
void MenuStatesTest::init()
|
|
76 |
{
|
|
77 |
// mWindow = new HbMainWindow;
|
|
78 |
}
|
|
79 |
|
97
|
80 |
// ---------------------------------------------------------------------------
|
|
81 |
//
|
|
82 |
// ---------------------------------------------------------------------------
|
|
83 |
//
|
90
|
84 |
void MenuStatesTest::cleanup()
|
|
85 |
{
|
|
86 |
qApp->processEvents();
|
|
87 |
// delete mWindow;
|
|
88 |
// mWindow = NULL;
|
|
89 |
}
|
|
90 |
|
|
91 |
// ---------------------------------------------------------------------------
|
97
|
92 |
//
|
90
|
93 |
// ---------------------------------------------------------------------------
|
|
94 |
//
|
|
95 |
void MenuStatesTest::construction()
|
|
96 |
{
|
|
97 |
#ifdef Q_OS_SYMBIAN
|
|
98 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
99 |
#ifdef UT_MEMORY_CHECK
|
|
100 |
__UHEAP_MARK;
|
|
101 |
#endif//UT_MEMORY_CHECK
|
|
102 |
#endif//Q_OS_SYMBIAN
|
|
103 |
{
|
|
104 |
HsMenuViewBuilder builder;
|
|
105 |
HsMenuModeWrapper menuMode;
|
|
106 |
HsMainWindowMock mainWindow;
|
|
107 |
QState *parent = new QState;
|
|
108 |
|
|
109 |
HsAllCollectionsState *allCollectionsState =
|
|
110 |
new HsAllCollectionsState(builder,
|
|
111 |
menuMode,
|
|
112 |
mainWindow,
|
|
113 |
parent);
|
|
114 |
|
|
115 |
QCOMPARE(allCollectionsState->mBackKeyAction,
|
|
116 |
allCollectionsState->mMenuView->view()->navigationAction());
|
|
117 |
|
|
118 |
QVERIFY(allCollectionsState->mModel !=
|
|
119 |
static_cast<HsMenuItemModel *>(0));
|
|
120 |
delete parent;
|
|
121 |
}
|
|
122 |
#ifdef Q_OS_SYMBIAN
|
|
123 |
#ifdef UT_MEMORY_CHECK
|
|
124 |
__UHEAP_MARKEND;
|
|
125 |
#endif//UT_MEMORY_CHECK
|
|
126 |
#endif//Q_OS_SYMBIAN
|
|
127 |
}
|
|
128 |
|
|
129 |
// ---------------------------------------------------------------------------
|
97
|
130 |
//
|
90
|
131 |
// ---------------------------------------------------------------------------
|
|
132 |
//
|
|
133 |
void MenuStatesTest::addModeEnteredExited()
|
|
134 |
{
|
|
135 |
#ifdef Q_OS_SYMBIAN
|
|
136 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
137 |
#ifdef UT_MEMORY_CHECK
|
|
138 |
__UHEAP_MARK;
|
|
139 |
#endif//UT_MEMORY_CHECK
|
|
140 |
#endif//Q_OS_SYMBIAN
|
|
141 |
{
|
|
142 |
HsMenuViewBuilder builder;
|
|
143 |
HsMenuModeWrapper menuMode;
|
|
144 |
QState *parent = new QState;
|
|
145 |
HsMainWindowMock mainWindow;
|
|
146 |
HsAllCollectionsState *allCollectionsState =
|
|
147 |
new HsAllCollectionsState(
|
|
148 |
builder, menuMode, mainWindow, parent);
|
|
149 |
|
|
150 |
allCollectionsState->mMenuMode->setHsMenuMode(Hs::AddHsMenuMode);
|
|
151 |
allCollectionsState->addModeEntered();
|
|
152 |
|
|
153 |
QCOMPARE(allCollectionsState->mMenuMode->getHsMenuMode(),
|
|
154 |
Hs::AddHsMenuMode);
|
|
155 |
delete parent;
|
|
156 |
}
|
|
157 |
#ifdef Q_OS_SYMBIAN
|
|
158 |
#ifdef UT_MEMORY_CHECK
|
|
159 |
__UHEAP_MARKEND;
|
|
160 |
#endif//UT_MEMORY_CHECK
|
|
161 |
#endif//Q_OS_SYMBIAN
|
|
162 |
}
|
|
163 |
|
|
164 |
// ---------------------------------------------------------------------------
|
97
|
165 |
//
|
90
|
166 |
// ---------------------------------------------------------------------------
|
|
167 |
//
|
|
168 |
void MenuStatesTest::normalModeEnteredExited()
|
|
169 |
{
|
|
170 |
#ifdef Q_OS_SYMBIAN
|
|
171 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
172 |
#ifdef UT_MEMORY_CHECK
|
|
173 |
__UHEAP_MARK;
|
|
174 |
#endif//UT_MEMORY_CHECK
|
|
175 |
#endif//Q_OS_SYMBIAN
|
|
176 |
{
|
|
177 |
HsMenuViewBuilder builder;
|
|
178 |
HsMenuModeWrapper menuMode;
|
|
179 |
HsMainWindowMock mainWindow;
|
|
180 |
QState *parent = new QState;
|
|
181 |
HsAllCollectionsState *allCollectionsState = new HsAllCollectionsState(
|
|
182 |
builder, menuMode, mainWindow, parent);
|
|
183 |
|
|
184 |
allCollectionsState->mMenuMode->setHsMenuMode(Hs::NormalHsMenuMode);
|
|
185 |
allCollectionsState->normalModeEntered();
|
|
186 |
QCOMPARE(allCollectionsState->mMenuMode->getHsMenuMode(),
|
|
187 |
Hs::NormalHsMenuMode);
|
|
188 |
allCollectionsState->normalModeExited();
|
|
189 |
QCOMPARE(allCollectionsState->mMenuMode->getHsMenuMode(),
|
|
190 |
Hs::NormalHsMenuMode);
|
|
191 |
delete parent;
|
|
192 |
}
|
|
193 |
#ifdef Q_OS_SYMBIAN
|
|
194 |
#ifdef UT_MEMORY_CHECK
|
|
195 |
__UHEAP_MARKEND;
|
|
196 |
#endif//UT_MEMORY_CHECK
|
|
197 |
#endif//Q_OS_SYMBIAN
|
|
198 |
}
|
|
199 |
|
|
200 |
// ---------------------------------------------------------------------------
|
97
|
201 |
//
|
90
|
202 |
// ---------------------------------------------------------------------------
|
|
203 |
//
|
|
204 |
void MenuStatesTest::createNewCollection()
|
|
205 |
{
|
|
206 |
#ifdef Q_OS_SYMBIAN
|
|
207 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
208 |
#ifdef UT_MEMORY_CHECK
|
|
209 |
__UHEAP_MARK;
|
|
210 |
#endif//UT_MEMORY_CHECK
|
|
211 |
#endif//Q_OS_SYMBIAN
|
|
212 |
{
|
|
213 |
HsMenuViewBuilder builder;
|
|
214 |
HsMenuModeWrapper menuMode;
|
|
215 |
HsMainWindowMock mainWindow;
|
|
216 |
QStateMachine *machine = new QStateMachine(0);
|
|
217 |
|
|
218 |
HsAllCollectionsState *allCollectionsState =
|
|
219 |
new HsAllCollectionsState(builder, menuMode, mainWindow, machine);
|
|
220 |
|
|
221 |
machine->setInitialState(allCollectionsState);
|
|
222 |
|
|
223 |
AddToHomeScreenMockState *mockState = new AddToHomeScreenMockState(machine);
|
|
224 |
|
|
225 |
// create a transition to the new child state which will be triggered by
|
|
226 |
// an event with specified operation type
|
|
227 |
HsMenuEventTransition *newCollectionTransition = new HsMenuEventTransition(
|
|
228 |
HsMenuEvent::CreateCollection, allCollectionsState, mockState);
|
|
229 |
|
|
230 |
allCollectionsState->addTransition(newCollectionTransition);
|
|
231 |
|
|
232 |
allCollectionsState->scrollToBeginning();
|
|
233 |
allCollectionsState->stateEntered();
|
|
234 |
|
|
235 |
machine->start();
|
|
236 |
qApp->sendPostedEvents();
|
|
237 |
|
|
238 |
allCollectionsState->createNewCollection();
|
|
239 |
qApp->sendPostedEvents();
|
|
240 |
QVERIFY(mockState->enteredValue());
|
|
241 |
qApp->removePostedEvents(0);
|
|
242 |
machine->stop();
|
|
243 |
delete machine;
|
|
244 |
}
|
|
245 |
#ifdef Q_OS_SYMBIAN
|
|
246 |
#ifdef UT_MEMORY_CHECK
|
|
247 |
__UHEAP_MARKEND;
|
|
248 |
#endif//UT_MEMORY_CHECK
|
|
249 |
#endif//Q_OS_SYMBIAN
|
|
250 |
}
|
|
251 |
|
|
252 |
// ---------------------------------------------------------------------------
|
97
|
253 |
//
|
90
|
254 |
// ---------------------------------------------------------------------------
|
|
255 |
//
|
|
256 |
void MenuStatesTest::createArrangeCollection()
|
|
257 |
{
|
|
258 |
#ifdef Q_OS_SYMBIAN
|
|
259 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
260 |
#ifdef UT_MEMORY_CHECK
|
|
261 |
__UHEAP_MARK;
|
|
262 |
#endif//UT_MEMORY_CHECK
|
|
263 |
#endif//Q_OS_SYMBIAN
|
|
264 |
{
|
|
265 |
HsMenuViewBuilder builder;
|
|
266 |
HsMenuModeWrapper menuMode;
|
|
267 |
HsMainWindowMock mainWindow;
|
|
268 |
QStateMachine *machine = new QStateMachine(0);
|
|
269 |
HsAllCollectionsState *allCollectionsState =
|
|
270 |
new HsAllCollectionsState(builder, menuMode, mainWindow, machine);
|
|
271 |
|
|
272 |
machine->setInitialState(allCollectionsState);
|
|
273 |
|
|
274 |
AddToHomeScreenMockState *mockState = new AddToHomeScreenMockState(machine);
|
|
275 |
|
|
276 |
// create a transition to the new child state which will be triggered by
|
|
277 |
// an event with specified operation type
|
|
278 |
HsMenuEventTransition *transition = new HsMenuEventTransition(
|
|
279 |
HsMenuEvent::ArrangeAllCollections, allCollectionsState, mockState);
|
|
280 |
|
|
281 |
allCollectionsState->addTransition(transition);
|
|
282 |
|
|
283 |
allCollectionsState->scrollToBeginning();
|
|
284 |
allCollectionsState->stateEntered();
|
|
285 |
machine->start();
|
|
286 |
qApp->sendPostedEvents();
|
|
287 |
|
|
288 |
allCollectionsState->createArrangeCollection();
|
|
289 |
qApp->sendPostedEvents();
|
|
290 |
|
|
291 |
QVERIFY(mockState->enteredValue());
|
|
292 |
qApp->removePostedEvents(0);
|
|
293 |
machine->stop();
|
|
294 |
|
|
295 |
delete machine;
|
|
296 |
}
|
|
297 |
#ifdef Q_OS_SYMBIAN
|
|
298 |
#ifdef UT_MEMORY_CHECK
|
|
299 |
__UHEAP_MARKEND;
|
|
300 |
#endif//UT_MEMORY_CHECK
|
|
301 |
#endif//Q_OS_SYMBIAN
|
|
302 |
}
|
|
303 |
|
|
304 |
// ---------------------------------------------------------------------------
|
97
|
305 |
//
|
90
|
306 |
// ---------------------------------------------------------------------------
|
|
307 |
//
|
|
308 |
void MenuStatesTest::listItemActivated()
|
|
309 |
{
|
|
310 |
#ifdef Q_OS_SYMBIAN
|
|
311 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
312 |
#ifdef UT_MEMORY_CHECK
|
|
313 |
__UHEAP_MARK;
|
|
314 |
#endif//UT_MEMORY_CHECK
|
|
315 |
#endif//Q_OS_SYMBIAN
|
|
316 |
{
|
|
317 |
HsMenuViewBuilder builder;
|
|
318 |
HsMenuModeWrapper menuMode;
|
|
319 |
HsMainWindowMock mainWindow;
|
|
320 |
QStateMachine *machine = new QStateMachine(0);
|
|
321 |
QState *parent = new QState(machine);
|
|
322 |
|
|
323 |
HsAllCollectionsState *allCollectionsState =
|
|
324 |
new HsAllCollectionsState(builder, menuMode, mainWindow, parent);
|
|
325 |
|
|
326 |
allCollectionsState->scrollToBeginning();
|
|
327 |
allCollectionsState->stateEntered();
|
|
328 |
|
|
329 |
QVERIFY(allCollectionsState->mModel != NULL);
|
|
330 |
QModelIndex applicationModelIndex =
|
|
331 |
allCollectionsState->mModel->index(0, 0);
|
|
332 |
|
|
333 |
allCollectionsState->openCollection(applicationModelIndex);
|
|
334 |
|
|
335 |
allCollectionsState->stateExited();
|
|
336 |
|
|
337 |
qApp->processEvents();
|
|
338 |
delete machine;
|
|
339 |
}
|
|
340 |
#ifdef Q_OS_SYMBIAN
|
|
341 |
#ifdef UT_MEMORY_CHECK
|
|
342 |
__UHEAP_MARKEND;
|
|
343 |
#endif//UT_MEMORY_CHECK
|
|
344 |
#endif//Q_OS_SYMBIAN
|
|
345 |
}
|
|
346 |
|
|
347 |
// ---------------------------------------------------------------------------
|
97
|
348 |
//
|
90
|
349 |
// ---------------------------------------------------------------------------
|
97
|
350 |
//
|
90
|
351 |
void MenuStatesTest::listItemLongPressed()
|
|
352 |
{
|
|
353 |
#ifdef Q_OS_SYMBIAN
|
|
354 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
355 |
#ifdef UT_MEMORY_CHECK
|
|
356 |
__UHEAP_MARK;
|
|
357 |
#endif//UT_MEMORY_CHECK
|
|
358 |
#endif//Q_OS_SYMBIAN
|
|
359 |
{
|
|
360 |
HsMenuViewBuilder builder;
|
|
361 |
HsMenuModeWrapper menuMode;
|
|
362 |
HsMainWindowMock mainWindow;
|
|
363 |
|
|
364 |
QStateMachine *machine = new QStateMachine(0);
|
|
365 |
QState *parent = new QState(machine);
|
|
366 |
|
|
367 |
HsAllCollectionsState *allCollectionsState =
|
|
368 |
new HsAllCollectionsState(builder, menuMode, mainWindow, parent);
|
|
369 |
|
|
370 |
allCollectionsState->scrollToBeginning();
|
|
371 |
allCollectionsState->stateEntered();
|
|
372 |
|
|
373 |
HbAbstractViewItem *item = new HbListViewItem;
|
|
374 |
|
|
375 |
item->setModelIndex(allCollectionsState->mModel->index(0,0));
|
|
376 |
|
|
377 |
allCollectionsState->showContextMenu(item ,
|
|
378 |
QPointF(50,50));
|
|
379 |
|
|
380 |
uint flags = allCollectionsState->mModel->data(allCollectionsState->mModel->index(0, 0),
|
|
381 |
CaItemModel::FlagsRole).value<EntryFlags> ();
|
|
382 |
|
|
383 |
if (flags & RemovableEntryFlag) {
|
|
384 |
QCOMPARE(allCollectionsState->mContextMenu->actions().length(), 4);
|
|
385 |
} else {
|
|
386 |
QCOMPARE(allCollectionsState->mContextMenu->actions().length(), 2);
|
|
387 |
}
|
|
388 |
|
|
389 |
|
|
390 |
QVERIFY(allCollectionsState->mContextMenu->testAttribute(Qt::WA_DeleteOnClose));
|
|
391 |
|
|
392 |
qApp->processEvents();
|
|
393 |
|
|
394 |
allCollectionsState->stateExited();
|
|
395 |
|
|
396 |
qApp->processEvents();
|
|
397 |
delete machine;
|
|
398 |
delete item;
|
|
399 |
}
|
|
400 |
#ifdef Q_OS_SYMBIAN
|
|
401 |
#ifdef UT_MEMORY_CHECK
|
|
402 |
__UHEAP_MARKEND;
|
|
403 |
#endif//UT_MEMORY_CHECK
|
|
404 |
#endif//Q_OS_SYMBIAN
|
|
405 |
}
|
|
406 |
|
|
407 |
// ---------------------------------------------------------------------------
|
97
|
408 |
//
|
90
|
409 |
// ---------------------------------------------------------------------------
|
|
410 |
//
|
|
411 |
void MenuStatesTest::contextMenuAction()
|
|
412 |
{
|
|
413 |
#ifdef Q_OS_SYMBIAN
|
|
414 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
415 |
#ifdef UT_MEMORY_CHECK
|
|
416 |
__UHEAP_MARK;
|
|
417 |
#endif//UT_MEMORY_CHECK
|
|
418 |
#endif//Q_OS_SYMBIAN
|
|
419 |
{
|
|
420 |
QScopedPointer<QStateMachine> machine(new QStateMachine(0));
|
|
421 |
|
98
|
422 |
QScopedPointer<HbMainWindow> window(new HbMainWindow);
|
|
423 |
HsScene::setInstance( new HsScene(window.data()) );
|
90
|
424 |
|
|
425 |
HsMenuViewBuilder builder;
|
|
426 |
HsMenuModeWrapper menuMode;
|
98
|
427 |
HsMainWindow mainWindow;
|
90
|
428 |
|
|
429 |
QScopedPointer<HsAllCollectionsState> allCollectionsState (new HsAllCollectionsState(
|
|
430 |
builder, menuMode, mainWindow, machine.data()));
|
|
431 |
|
|
432 |
|
|
433 |
// we will start from all apps view
|
|
434 |
machine->setInitialState(allCollectionsState.data());
|
|
435 |
|
|
436 |
// create a state which is to be reached when add-to-home-screen
|
|
437 |
// event is triggered
|
|
438 |
AddToHomeScreenMockState addToHomeScreenState(machine.data());
|
|
439 |
|
|
440 |
// create a transition to the new child state which will be triggered by
|
|
441 |
// an event with specified operation type
|
|
442 |
HsMenuEventTransition addToHomeScreenTransition(
|
|
443 |
HsMenuEvent::AddToHomeScreen, allCollectionsState.data(), &addToHomeScreenState);
|
|
444 |
|
|
445 |
// prepare the state graph
|
|
446 |
allCollectionsState->addTransition(&addToHomeScreenTransition);
|
|
447 |
|
|
448 |
// MockModel object is to provide CaEntry representing widget
|
|
449 |
// the object will be deleted on destruction of allAppsState
|
|
450 |
MockModel *allCollectionsMockModel = new MockModel;
|
|
451 |
allCollectionsState->mModel = allCollectionsMockModel;
|
|
452 |
allCollectionsState->mMenuView->setModel(allCollectionsMockModel);
|
|
453 |
|
|
454 |
machine->start();
|
|
455 |
qApp->sendPostedEvents();
|
|
456 |
|
|
457 |
HbAction *action = new HbAction("test_addtohomescreen");
|
|
458 |
action->setData(Hs::AddToHomeScreenContextAction);
|
|
459 |
allCollectionsState->mContextModelIndex = allCollectionsMockModel->fixedIndex();
|
|
460 |
|
|
461 |
allCollectionsState->contextMenuAction(action);
|
|
462 |
|
|
463 |
qApp->sendPostedEvents();
|
|
464 |
|
|
465 |
QVERIFY(addToHomeScreenState.enteredValue());
|
|
466 |
|
|
467 |
machine->stop();
|
|
468 |
qApp->removePostedEvents(0);
|
|
469 |
|
|
470 |
allCollectionsState->stateExited();
|
|
471 |
|
|
472 |
qApp->processEvents();
|
|
473 |
|
|
474 |
delete action;
|
|
475 |
}
|
|
476 |
#ifdef Q_OS_SYMBIAN
|
|
477 |
#ifdef UT_MEMORY_CHECK
|
|
478 |
__UHEAP_MARKEND;
|
|
479 |
#endif//UT_MEMORY_CHECK
|
|
480 |
#endif//Q_OS_SYMBIAN
|
|
481 |
}
|
|
482 |
|
|
483 |
// ---------------------------------------------------------------------------
|
97
|
484 |
//
|
90
|
485 |
// ---------------------------------------------------------------------------
|
97
|
486 |
//
|
90
|
487 |
void MenuStatesTest::addModeSlots()
|
|
488 |
{
|
|
489 |
#ifdef Q_OS_SYMBIAN
|
|
490 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
491 |
#ifdef UT_MEMORY_CHECK
|
|
492 |
__UHEAP_MARK;
|
|
493 |
#endif//UT_MEMORY_CHECK
|
|
494 |
#endif//Q_OS_SYMBIAN
|
|
495 |
{
|
|
496 |
HsMenuViewBuilder builder;
|
|
497 |
QScopedPointer<QStateMachine> machine(new QStateMachine(0));
|
|
498 |
HsMenuModeWrapper menuMode;
|
|
499 |
HsMainWindowMock mainWindow;
|
|
500 |
menuMode.setHsMenuMode(Hs::AddHsMenuMode);
|
|
501 |
QScopedPointer<HsAllCollectionsState> allCollectionsState(
|
|
502 |
new HsAllCollectionsState(builder, menuMode, mainWindow, machine.data()));
|
|
503 |
|
|
504 |
{
|
|
505 |
// we will start from all apps view
|
|
506 |
machine->setInitialState(allCollectionsState.data());
|
|
507 |
|
|
508 |
// create a state which is to be reached when add-to-home-screen
|
|
509 |
// event is triggered
|
|
510 |
AddToHomeScreenMockState addToHomeScreenState(machine.data());
|
|
511 |
|
|
512 |
// create a transition to the new child state which will be triggered by
|
|
513 |
// an event with specified operation type
|
|
514 |
HsMenuEventTransition addToHomeScreenTransition(
|
|
515 |
HsMenuEvent::AddToHomeScreen, allCollectionsState.data(), &addToHomeScreenState);
|
|
516 |
|
|
517 |
// prepare the state graph
|
|
518 |
allCollectionsState->addTransition(&addToHomeScreenTransition);
|
|
519 |
|
|
520 |
// MockModel object is to provide CaEntry representing widget
|
|
521 |
// the object will be deleted on destruction of allAppsState
|
|
522 |
allCollectionsState->scrollToBeginning();
|
|
523 |
allCollectionsState->stateEntered();
|
|
524 |
|
|
525 |
machine->start();
|
|
526 |
qApp->sendPostedEvents();
|
97
|
527 |
|
90
|
528 |
allCollectionsState->addActivated(allCollectionsState->mModel->index(0,0));
|
|
529 |
|
|
530 |
qApp->sendPostedEvents();
|
|
531 |
|
|
532 |
QVERIFY(addToHomeScreenState.enteredValue());
|
|
533 |
machine->stop();
|
|
534 |
qApp->removePostedEvents(0);
|
|
535 |
}
|
|
536 |
}
|
|
537 |
#ifdef Q_OS_SYMBIAN
|
|
538 |
#ifdef UT_MEMORY_CHECK
|
|
539 |
__UHEAP_MARKEND;
|
|
540 |
#endif//UT_MEMORY_CHECK
|
|
541 |
#endif//Q_OS_SYMBIAN
|
|
542 |
}
|
|
543 |
|
|
544 |
// ---------------------------------------------------------------------------
|
97
|
545 |
//
|
90
|
546 |
// ---------------------------------------------------------------------------
|
|
547 |
//
|
|
548 |
#ifdef Q_OS_SYMBIAN
|
|
549 |
void MenuStatesTest::openTaskSwitcher()
|
|
550 |
{
|
|
551 |
#ifdef Q_OS_SYMBIAN
|
|
552 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
553 |
#ifdef UT_MEMORY_CHECK
|
|
554 |
__UHEAP_MARK;
|
|
555 |
#endif//UT_MEMORY_CHECK
|
|
556 |
#endif//Q_OS_SYMBIAN
|
|
557 |
{
|
|
558 |
HsMenuViewBuilder builder;
|
|
559 |
HsMenuModeWrapper menuMode;
|
|
560 |
HsMainWindowMock mainWindow;
|
|
561 |
QStateMachine *machine = new QStateMachine(0);
|
|
562 |
QState *parent = new QState(machine);
|
|
563 |
menuMode.setHsMenuMode(Hs::AddHsMenuMode);
|
|
564 |
HsAllCollectionsState *allCollectionsState =
|
|
565 |
new HsAllCollectionsState(builder, menuMode, mainWindow, parent);
|
|
566 |
|
|
567 |
QVERIFY(allCollectionsState->openTaskSwitcher());
|
|
568 |
delete machine;
|
|
569 |
}
|
|
570 |
#ifdef Q_OS_SYMBIAN
|
|
571 |
#ifdef UT_MEMORY_CHECK
|
|
572 |
__UHEAP_MARKEND;
|
|
573 |
#endif//UT_MEMORY_CHECK
|
|
574 |
#endif//Q_OS_SYMBIAN
|
|
575 |
}
|
|
576 |
#endif//Q_OS_SYMBIAN
|
|
577 |
|
|
578 |
QTEST_MAIN(MenuStatesTest)
|
|
579 |
|