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 <hbmenu.h>
|
|
22 |
#include <hblabel.h>
|
|
23 |
#include <hblistview.h>
|
|
24 |
#include <hblistviewitem.h>
|
|
25 |
#include <hbgroupbox.h>
|
|
26 |
#include <HbAction>
|
|
27 |
#include <HbPushButton>
|
|
28 |
#include <qscopedpointer>
|
|
29 |
|
|
30 |
#include "caentry.h"
|
|
31 |
#include "caitemmodel.h"
|
|
32 |
#include "hsmenuviewbuilder.h"
|
|
33 |
#include "hsmenumodewrapper.h"
|
|
34 |
#include "hsmenuevent.h"
|
|
35 |
#include "hsmenueventtransition.h"
|
|
36 |
#include "hscollectionstate.h"
|
|
37 |
#include "hsmainwindow.h"
|
97
|
38 |
#include "hsscene.h"
|
90
|
39 |
|
|
40 |
#include "t_hsaddtohomescreenmockstate.h"
|
|
41 |
#include "t_hsmockmodel.h"
|
|
42 |
#include "t_collectionsstate.h"
|
|
43 |
|
|
44 |
Q_DECLARE_METATYPE(Hs::HsSortAttribute)
|
|
45 |
|
|
46 |
|
97
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
//
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
//
|
90
|
51 |
class HsMainWindowMock : public HsMainWindow
|
|
52 |
{
|
|
53 |
virtual void setCurrentView(HbView *view);
|
|
54 |
|
|
55 |
};
|
|
56 |
|
97
|
57 |
// ---------------------------------------------------------------------------
|
|
58 |
//
|
|
59 |
// ---------------------------------------------------------------------------
|
|
60 |
//
|
90
|
61 |
void HsMainWindowMock::setCurrentView(HbView *view)
|
|
62 |
{
|
|
63 |
Q_UNUSED(view);
|
|
64 |
// do nothing
|
|
65 |
}
|
|
66 |
|
97
|
67 |
// ---------------------------------------------------------------------------
|
|
68 |
//
|
|
69 |
// ---------------------------------------------------------------------------
|
|
70 |
//
|
90
|
71 |
void MenuStatesTest::init()
|
|
72 |
{
|
|
73 |
}
|
|
74 |
|
97
|
75 |
// ---------------------------------------------------------------------------
|
|
76 |
//
|
|
77 |
// ---------------------------------------------------------------------------
|
|
78 |
//
|
90
|
79 |
void MenuStatesTest::cleanup()
|
|
80 |
{
|
|
81 |
qApp->processEvents();
|
|
82 |
}
|
|
83 |
|
|
84 |
// ---------------------------------------------------------------------------
|
97
|
85 |
//
|
90
|
86 |
// ---------------------------------------------------------------------------
|
|
87 |
//
|
|
88 |
void MenuStatesTest::construction()
|
|
89 |
{
|
|
90 |
#ifdef Q_OS_SYMBIAN
|
|
91 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
92 |
#ifdef UT_MEMORY_CHECK
|
|
93 |
__UHEAP_MARK;
|
|
94 |
#endif//UT_MEMORY_CHECK
|
|
95 |
#endif//Q_OS_SYMBIAN
|
|
96 |
{
|
|
97 |
HsMenuViewBuilder builder;
|
|
98 |
HsMenuModeWrapper menuMode;
|
|
99 |
HsMainWindowMock mainWindow;
|
|
100 |
QScopedPointer<QState> parent(new QState);
|
|
101 |
parent->setObjectName(tr("testName1"));
|
|
102 |
|
|
103 |
HsCollectionState *collectionState =
|
|
104 |
new HsCollectionState(builder, menuMode, mainWindow, parent.data());
|
|
105 |
|
|
106 |
QCOMPARE(collectionState->mSortAttribute,
|
|
107 |
Hs::LatestOnTopHsSortAttribute);
|
|
108 |
QCOMPARE(collectionState->mCollectionId, -1);
|
|
109 |
QCOMPARE(collectionState->mModel, static_cast<HsMenuItemModel *>(0));
|
|
110 |
QCOMPARE(collectionState->objectName(),
|
|
111 |
tr("testName1/collectionstate"));
|
|
112 |
|
|
113 |
}
|
|
114 |
#ifdef Q_OS_SYMBIAN
|
|
115 |
#ifdef UT_MEMORY_CHECK
|
|
116 |
__UHEAP_MARKEND;
|
|
117 |
#endif//UT_MEMORY_CHECK
|
|
118 |
#endif//Q_OS_SYMBIAN
|
|
119 |
}
|
|
120 |
|
|
121 |
// ---------------------------------------------------------------------------
|
97
|
122 |
//
|
90
|
123 |
// ---------------------------------------------------------------------------
|
|
124 |
//
|
|
125 |
void MenuStatesTest::listItemActivated()
|
|
126 |
{
|
|
127 |
#ifdef Q_OS_SYMBIAN
|
|
128 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
129 |
#ifdef UT_MEMORY_CHECK
|
|
130 |
__UHEAP_MARK;
|
|
131 |
#endif//UT_MEMORY_CHECK
|
|
132 |
#endif//Q_OS_SYMBIAN
|
|
133 |
{
|
|
134 |
HsMenuViewBuilder builder;
|
|
135 |
HsMenuModeWrapper menuMode;
|
|
136 |
HsMainWindowMock mainWindow;
|
|
137 |
|
|
138 |
QScopedPointer<QStateMachine> machine(new QStateMachine(0));
|
|
139 |
QState *parent = new QState(machine.data());
|
|
140 |
|
|
141 |
const QString collectionName("testCollection" +
|
|
142 |
QDateTime::currentDateTime().
|
|
143 |
toString("ddmmyyyy_hh_mm_ss_zzz"));
|
|
144 |
const int collectionId = HsMenuService::createCollection(collectionName);
|
|
145 |
|
|
146 |
HsCollectionState *collectionState =
|
|
147 |
new HsCollectionState(builder, menuMode, mainWindow, parent);
|
|
148 |
|
|
149 |
collectionState->mCollectionId = collectionId;
|
|
150 |
|
|
151 |
HsMenuItemModel *const itemModel =
|
|
152 |
HsMenuService::getAllApplicationsModel(Hs::AscendingNameHsSortAttribute);
|
|
153 |
|
|
154 |
QModelIndex applicationModelIndex = itemModel->index(1, 0);
|
|
155 |
|
|
156 |
QList<int> appList;
|
|
157 |
|
|
158 |
appList << itemModel->data(applicationModelIndex, CaItemModel::IdRole).toInt();
|
|
159 |
|
|
160 |
HsMenuService::addApplicationsToCollection(appList, collectionId);
|
|
161 |
|
|
162 |
collectionState->stateEntered();
|
|
163 |
|
|
164 |
QVERIFY(collectionState->mModel != NULL);
|
|
165 |
|
|
166 |
collectionState->launchItem(applicationModelIndex);
|
|
167 |
|
|
168 |
collectionState->stateExited();
|
|
169 |
|
|
170 |
QTest::qWait(3000);
|
|
171 |
|
|
172 |
//TODO: made some utils to closing application
|
|
173 |
//HsMenuService::executeAction(appList.at(0), QString("close"));
|
|
174 |
|
|
175 |
// cleanup
|
|
176 |
HsMenuService::removeCollection(collectionId);
|
|
177 |
}
|
|
178 |
#ifdef Q_OS_SYMBIAN
|
|
179 |
#ifdef UT_MEMORY_CHECK
|
|
180 |
__UHEAP_MARKEND;
|
|
181 |
#endif//UT_MEMORY_CHECK
|
|
182 |
#endif//Q_OS_SYMBIAN
|
|
183 |
}
|
|
184 |
|
|
185 |
// ---------------------------------------------------------------------------
|
97
|
186 |
//
|
90
|
187 |
// ---------------------------------------------------------------------------
|
|
188 |
//
|
|
189 |
void MenuStatesTest::listItemLongPressed()
|
|
190 |
{
|
|
191 |
#ifdef Q_OS_SYMBIAN
|
|
192 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
193 |
#ifdef UT_MEMORY_CHECK
|
|
194 |
__UHEAP_MARK;
|
|
195 |
#endif//UT_MEMORY_CHECK
|
|
196 |
#endif//Q_OS_SYMBIAN
|
|
197 |
{
|
|
198 |
HsMenuViewBuilder builder;
|
|
199 |
HsMenuModeWrapper menuMode;
|
97
|
200 |
HsMainWindowMock mainWindow;
|
90
|
201 |
|
|
202 |
|
|
203 |
QScopedPointer<QStateMachine> machine(new QStateMachine(0));
|
|
204 |
QState *parent(new QState(machine.data()));
|
|
205 |
|
|
206 |
const QString collectionName("testCollection" +
|
|
207 |
QDateTime::currentDateTime().
|
|
208 |
toString("ddmmyyyy_hh_mm_ss_zzz"));
|
|
209 |
const int collectionId = HsMenuService::createCollection(collectionName);
|
|
210 |
|
|
211 |
HsMenuItemModel *appsModel = HsMenuService::getAllApplicationsModel();
|
97
|
212 |
QVERIFY(appsModel!=NULL);
|
90
|
213 |
QList<int> list;
|
|
214 |
list << appsModel->data(appsModel->index(0),CaItemModel::IdRole).toInt();
|
|
215 |
HsMenuService::addApplicationsToCollection(list,collectionId);
|
|
216 |
delete appsModel;
|
|
217 |
|
|
218 |
HsCollectionState *collectionState = new HsCollectionState(builder, menuMode,
|
|
219 |
mainWindow, parent);
|
97
|
220 |
QVERIFY(collectionState!=NULL);
|
90
|
221 |
collectionState->mCollectionId = collectionId;
|
|
222 |
collectionState->mCollectionType = "collection";
|
|
223 |
|
|
224 |
collectionState->stateEntered();
|
|
225 |
|
|
226 |
QScopedPointer<HbAbstractViewItem> item(new HbListViewItem);
|
|
227 |
QModelIndex itemModelIndex = collectionState->mModel->index(0, 0);
|
|
228 |
item->setModelIndex(itemModelIndex);
|
|
229 |
|
|
230 |
collectionState->showContextMenu(item.data(), QPointF(50,50));
|
|
231 |
|
|
232 |
int numberOfActions = 3;
|
|
233 |
|
|
234 |
EntryFlags rootFlags =
|
|
235 |
collectionState->mModel->root().data(CaItemModel::FlagsRole).value<
|
|
236 |
EntryFlags> ();
|
|
237 |
if (rootFlags & RemovableEntryFlag) {
|
|
238 |
numberOfActions++;
|
|
239 |
}
|
|
240 |
|
|
241 |
EntryFlags flags = item->modelIndex().data(CaItemModel::FlagsRole).value<
|
|
242 |
EntryFlags> ();
|
|
243 |
if ((flags & RemovableEntryFlag)) {
|
|
244 |
numberOfActions++;
|
|
245 |
}
|
|
246 |
|
|
247 |
QSharedPointer<const CaEntry> entry = collectionState->mModel->entry(item->modelIndex());
|
|
248 |
if (!(entry->attribute(Hs::appSettingsPlugin).isEmpty())) {
|
|
249 |
numberOfActions++;
|
|
250 |
}
|
|
251 |
|
|
252 |
QCOMPARE(collectionState->mContextMenu->actions().length(), numberOfActions);
|
|
253 |
QVERIFY(collectionState->mContextMenu->testAttribute(Qt::WA_DeleteOnClose));
|
|
254 |
|
|
255 |
collectionState->stateExited();
|
|
256 |
|
|
257 |
qApp->processEvents();
|
|
258 |
|
|
259 |
// cleanup
|
|
260 |
if (!list.isEmpty()) {
|
|
261 |
for (int i=0; i<list.count(); i++) {
|
|
262 |
HsMenuService::removeApplicationFromCollection(list[i],collectionId);
|
|
263 |
}
|
|
264 |
}
|
|
265 |
HsMenuService::removeCollection(collectionId);
|
|
266 |
}
|
|
267 |
#ifdef Q_OS_SYMBIAN
|
|
268 |
#ifdef UT_MEMORY_CHECK
|
|
269 |
__UHEAP_MARKEND;
|
|
270 |
#endif//UT_MEMORY_CHECK
|
|
271 |
#endif//Q_OS_SYMBIAN
|
|
272 |
}
|
|
273 |
|
|
274 |
// ---------------------------------------------------------------------------
|
97
|
275 |
//
|
90
|
276 |
// ---------------------------------------------------------------------------
|
|
277 |
//
|
|
278 |
void MenuStatesTest::contextMenuAction()
|
|
279 |
{
|
|
280 |
#ifdef Q_OS_SYMBIAN
|
|
281 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
282 |
#ifdef UT_MEMORY_CHECK
|
|
283 |
__UHEAP_MARK;
|
|
284 |
#endif//UT_MEMORY_CHECK
|
|
285 |
#endif//Q_OS_SYMBIAN
|
|
286 |
{
|
97
|
287 |
//QScopedPointer<HbMainWindow> window(new HbMainWindow);
|
|
288 |
//HsScene::setInstance( new HsScene(window.data()) );
|
|
289 |
|
90
|
290 |
HsMenuViewBuilder builder;
|
|
291 |
HsMenuModeWrapper menuMode;
|
|
292 |
HsMainWindowMock mainWindow;
|
|
293 |
|
|
294 |
QScopedPointer<QStateMachine> machine(new QStateMachine(0));
|
|
295 |
|
|
296 |
// we will start from collection view
|
|
297 |
|
|
298 |
const QString collectionName("testCollection" +
|
|
299 |
QDateTime::currentDateTime().toString("ddmmyyyy_hh_mm_ss_zzz"));
|
|
300 |
const int collectionId = HsMenuService::createCollection(collectionName);
|
|
301 |
|
|
302 |
HsMenuItemModel *allAppsModel = HsMenuService::getAllApplicationsModel();
|
|
303 |
QVERIFY(allAppsModel->rowCount() >= 1);
|
|
304 |
QModelIndex appIndex = allAppsModel->index(0, 0);
|
|
305 |
|
|
306 |
const int appId = allAppsModel->data(appIndex, CaItemModel::IdRole).toInt();
|
|
307 |
QList<int> appIdList;
|
|
308 |
appIdList << appId;
|
|
309 |
|
|
310 |
HsCollectionState *collectionState = new HsCollectionState(builder,
|
|
311 |
menuMode, mainWindow, machine.data());
|
|
312 |
|
|
313 |
collectionState->mCollectionId = collectionId;
|
|
314 |
HsMenuService::addApplicationsToCollection(appIdList, collectionId);
|
|
315 |
|
|
316 |
// create a state which is to be reached when add-to-home-screen
|
|
317 |
// event is triggered
|
|
318 |
AddToHomeScreenMockState *addToHomeScreenState =
|
|
319 |
new AddToHomeScreenMockState(machine.data());
|
|
320 |
|
|
321 |
// create a transition to the new child state which will be triggered by
|
|
322 |
// an event with specified operation type
|
|
323 |
HsMenuEventTransition addToHomeScreenTransition(
|
|
324 |
HsMenuEvent::AddToHomeScreen, collectionState, addToHomeScreenState);
|
|
325 |
|
|
326 |
// prepare the state graph
|
|
327 |
collectionState->addTransition(&addToHomeScreenTransition);
|
|
328 |
|
|
329 |
machine->setInitialState(collectionState);
|
|
330 |
machine->start();
|
|
331 |
qApp->sendPostedEvents();
|
|
332 |
|
|
333 |
HbAction *action = new HbAction("test_addtohomescreen");
|
|
334 |
action->setData(Hs::AddToHomeScreenContextAction);
|
|
335 |
|
|
336 |
collectionState->mContextModelIndex = collectionState->mModel->index(0,0);
|
|
337 |
|
|
338 |
collectionState->contextMenuAction(action);
|
|
339 |
|
|
340 |
qApp->sendPostedEvents();
|
|
341 |
qApp->processEvents();
|
|
342 |
|
|
343 |
QVERIFY(addToHomeScreenState->enteredValue());
|
|
344 |
|
|
345 |
machine->stop();
|
|
346 |
|
|
347 |
// cleanup
|
|
348 |
delete action;
|
|
349 |
HsMenuService::removeCollection(collectionId);
|
|
350 |
|
|
351 |
}
|
|
352 |
#ifdef Q_OS_SYMBIAN
|
|
353 |
#ifdef UT_MEMORY_CHECK
|
|
354 |
__UHEAP_MARKEND;
|
|
355 |
#endif//UT_MEMORY_CHECK
|
|
356 |
#endif//Q_OS_SYMBIAN
|
|
357 |
}
|
|
358 |
|
|
359 |
// ---------------------------------------------------------------------------
|
97
|
360 |
//
|
90
|
361 |
// ---------------------------------------------------------------------------
|
|
362 |
//
|
|
363 |
void MenuStatesTest::contextMenuConstruct()
|
|
364 |
{
|
|
365 |
#ifdef Q_OS_SYMBIAN
|
|
366 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
367 |
#ifdef UT_MEMORY_CHECK
|
|
368 |
__UHEAP_MARK;
|
|
369 |
#endif//UT_MEMORY_CHECK
|
|
370 |
#endif//Q_OS_SYMBIAN
|
|
371 |
{
|
|
372 |
HsMenuViewBuilder menuView;
|
|
373 |
HsMenuModeWrapper menuMode;
|
|
374 |
HsMainWindowMock mainWindow;
|
|
375 |
|
|
376 |
QScopedPointer<QState> parent(new QState);
|
|
377 |
|
|
378 |
const QString collectionName("testCollection" +
|
|
379 |
QDateTime::currentDateTime().
|
|
380 |
toString("ddmmyyyy_hh_mm_ss_zzz"));
|
|
381 |
|
|
382 |
const int collectionId = HsMenuService::createCollection(collectionName);
|
|
383 |
|
|
384 |
HsCollectionState *collectionState =
|
|
385 |
new HsCollectionState(menuView, menuMode, mainWindow, parent.data());
|
|
386 |
|
|
387 |
collectionState->mCollectionId = collectionId;
|
|
388 |
|
|
389 |
collectionState->stateEntered();
|
|
390 |
|
|
391 |
qApp->processEvents();
|
|
392 |
|
|
393 |
int actionsCount(
|
|
394 |
collectionState->mMenuView->view()->menu()->actions().count());
|
|
395 |
QCOMPARE(actionsCount , 5);
|
|
396 |
collectionState->stateExited();
|
|
397 |
|
|
398 |
// cleanup
|
|
399 |
HsMenuService::removeCollection(collectionId);
|
|
400 |
}
|
|
401 |
#ifdef Q_OS_SYMBIAN
|
|
402 |
#ifdef UT_MEMORY_CHECK
|
|
403 |
__UHEAP_MARKEND;
|
|
404 |
#endif//UT_MEMORY_CHECK
|
|
405 |
#endif//Q_OS_SYMBIAN
|
|
406 |
}
|
|
407 |
|
|
408 |
// ---------------------------------------------------------------------------
|
97
|
409 |
//
|
90
|
410 |
// ---------------------------------------------------------------------------
|
|
411 |
//
|
|
412 |
void MenuStatesTest::contextMenuConstructNonEmptyCollection()
|
|
413 |
{
|
|
414 |
#ifdef Q_OS_SYMBIAN
|
|
415 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
416 |
#ifdef UT_MEMORY_CHECK
|
|
417 |
__UHEAP_MARK;
|
|
418 |
#endif//UT_MEMORY_CHECK
|
|
419 |
#endif//Q_OS_SYMBIAN
|
|
420 |
{
|
|
421 |
HsMenuViewBuilder menuView;
|
|
422 |
HsMenuModeWrapper menuMode;
|
|
423 |
HsMainWindowMock mainWindow;
|
|
424 |
|
|
425 |
QScopedPointer<QState> parent(new QState);
|
|
426 |
|
|
427 |
const QString collectionName("testCollection" +
|
|
428 |
QDateTime::currentDateTime().
|
|
429 |
toString("ddmmyyyy_hh_mm_ss_zzz"));
|
|
430 |
|
|
431 |
const int collectionId = HsMenuService::createCollection(collectionName);
|
|
432 |
|
|
433 |
HsCollectionState *collectionState =
|
|
434 |
new HsCollectionState(menuView, menuMode, mainWindow, parent.data());
|
|
435 |
|
|
436 |
collectionState->mCollectionId = collectionId;
|
|
437 |
QVERIFY(HsMenuService::addApplicationsToCollection(QList<int>()<<1, collectionId));
|
|
438 |
|
|
439 |
collectionState->stateEntered();
|
|
440 |
|
|
441 |
qApp->processEvents();
|
|
442 |
|
|
443 |
const int actionsCount(
|
|
444 |
collectionState->mMenuView->view()->menu()->actions().count());
|
|
445 |
// Arrange is available inside options menu.
|
|
446 |
QCOMPARE(actionsCount , 6);
|
|
447 |
collectionState->stateExited();
|
|
448 |
|
|
449 |
// cleanup
|
|
450 |
HsMenuService::removeCollection(collectionId);
|
|
451 |
}
|
|
452 |
#ifdef Q_OS_SYMBIAN
|
|
453 |
#ifdef UT_MEMORY_CHECK
|
|
454 |
__UHEAP_MARKEND;
|
|
455 |
#endif//UT_MEMORY_CHECK
|
|
456 |
#endif//Q_OS_SYMBIAN
|
|
457 |
}
|
|
458 |
|
97
|
459 |
// ---------------------------------------------------------------------------
|
|
460 |
//
|
|
461 |
// ---------------------------------------------------------------------------
|
|
462 |
//
|
90
|
463 |
void MenuStatesTest::addAppsAction()
|
|
464 |
{
|
|
465 |
#ifdef Q_OS_SYMBIAN
|
|
466 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
467 |
#ifdef UT_MEMORY_CHECK
|
|
468 |
__UHEAP_MARK;
|
|
469 |
#endif//UT_MEMORY_CHECK
|
|
470 |
#endif//Q_OS_SYMBIAN
|
|
471 |
{
|
|
472 |
HsMenuViewBuilder builder;
|
|
473 |
HsMenuModeWrapper menuMode;
|
|
474 |
HsMainWindowMock mainWindow;
|
|
475 |
|
|
476 |
QScopedPointer<QStateMachine> machine(new QStateMachine(0));
|
|
477 |
|
|
478 |
const QString collectionName("testCollection" +
|
|
479 |
QDateTime::currentDateTime().
|
|
480 |
toString("ddmmyyyy_hh_mm_ss_zzz"));
|
|
481 |
|
|
482 |
const int collectionId =
|
|
483 |
HsMenuService::createCollection(collectionName);
|
|
484 |
|
|
485 |
HsCollectionState *collectionState =
|
|
486 |
new HsCollectionState(builder, menuMode, mainWindow, machine.data());
|
|
487 |
|
|
488 |
collectionState->mCollectionId = collectionId;
|
|
489 |
|
|
490 |
AddToHomeScreenMockState *mockState =
|
|
491 |
new AddToHomeScreenMockState(machine.data());
|
|
492 |
|
|
493 |
HsMenuEventTransition transition(
|
|
494 |
HsMenuEvent::AddAppsToCollection, collectionState, mockState);
|
|
495 |
|
|
496 |
collectionState->addTransition(&transition);
|
|
497 |
|
|
498 |
machine->setInitialState(collectionState);
|
|
499 |
machine->start();
|
|
500 |
|
|
501 |
qApp->sendPostedEvents();
|
|
502 |
qApp->processEvents();
|
|
503 |
|
|
504 |
collectionState->addAppsAction();
|
|
505 |
|
|
506 |
qApp->sendPostedEvents();
|
|
507 |
qApp->processEvents();
|
|
508 |
|
|
509 |
QVERIFY(mockState->enteredValue());
|
|
510 |
|
|
511 |
machine->stop();
|
|
512 |
|
|
513 |
// cleanup
|
|
514 |
HsMenuService::removeCollection(collectionId);
|
|
515 |
}
|
|
516 |
#ifdef Q_OS_SYMBIAN
|
|
517 |
#ifdef UT_MEMORY_CHECK
|
|
518 |
__UHEAP_MARKEND;
|
|
519 |
#endif//UT_MEMORY_CHECK
|
|
520 |
#endif//Q_OS_SYMBIAN
|
|
521 |
}
|
|
522 |
|
97
|
523 |
// ---------------------------------------------------------------------------
|
|
524 |
//
|
|
525 |
// ---------------------------------------------------------------------------
|
|
526 |
//
|
90
|
527 |
void MenuStatesTest::renameAction()
|
|
528 |
{
|
|
529 |
#ifdef Q_OS_SYMBIAN
|
|
530 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
531 |
#ifdef UT_MEMORY_CHECK
|
|
532 |
__UHEAP_MARK;
|
|
533 |
#endif//UT_MEMORY_CHECK
|
|
534 |
#endif//Q_OS_SYMBIAN
|
|
535 |
{
|
|
536 |
HsMenuViewBuilder builder;
|
|
537 |
HsMenuModeWrapper menuMode;
|
|
538 |
HsMainWindowMock mainWindow;
|
|
539 |
|
|
540 |
QScopedPointer<QStateMachine> machine(new QStateMachine(0));
|
|
541 |
|
|
542 |
const QString collectionName("testCollection" +
|
|
543 |
QDateTime::currentDateTime().
|
|
544 |
toString("ddmmyyyy_hh_mm_ss_zzz"));
|
|
545 |
|
|
546 |
const int collectionId = HsMenuService::createCollection(collectionName);
|
|
547 |
|
|
548 |
HsCollectionState *collectionState =
|
|
549 |
new HsCollectionState(builder, menuMode, mainWindow, machine.data());
|
|
550 |
|
|
551 |
|
|
552 |
collectionState->mCollectionId = collectionId;
|
|
553 |
|
|
554 |
AddToHomeScreenMockState *mockState =
|
|
555 |
new AddToHomeScreenMockState(machine.data());
|
|
556 |
|
|
557 |
HsMenuEventTransition transition(
|
|
558 |
HsMenuEvent::RenameCollection, collectionState, mockState);
|
|
559 |
|
|
560 |
collectionState->addTransition(&transition);
|
|
561 |
|
|
562 |
machine->setInitialState(collectionState);
|
|
563 |
|
|
564 |
machine->start();
|
|
565 |
|
|
566 |
qApp->sendPostedEvents();
|
|
567 |
|
|
568 |
collectionState->renameAction();
|
|
569 |
|
|
570 |
qApp->sendPostedEvents();
|
|
571 |
|
|
572 |
QVERIFY(mockState->enteredValue());
|
|
573 |
|
|
574 |
machine->stop();
|
|
575 |
|
|
576 |
// cleanup
|
|
577 |
HsMenuService::removeCollection(collectionId);
|
|
578 |
}
|
|
579 |
#ifdef Q_OS_SYMBIAN
|
|
580 |
#ifdef UT_MEMORY_CHECK
|
|
581 |
__UHEAP_MARKEND;
|
|
582 |
#endif//UT_MEMORY_CHECK
|
|
583 |
#endif//Q_OS_SYMBIAN
|
|
584 |
}
|
|
585 |
|
97
|
586 |
// ---------------------------------------------------------------------------
|
|
587 |
//
|
|
588 |
// ---------------------------------------------------------------------------
|
|
589 |
//
|
90
|
590 |
void MenuStatesTest::deleteAppsAction()
|
|
591 |
{
|
|
592 |
#ifdef Q_OS_SYMBIAN
|
|
593 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
594 |
#ifdef UT_MEMORY_CHECK
|
|
595 |
__UHEAP_MARK;
|
|
596 |
#endif//UT_MEMORY_CHECK
|
|
597 |
#endif//Q_OS_SYMBIAN
|
|
598 |
{
|
|
599 |
HsMenuViewBuilder builder;
|
|
600 |
HsMenuModeWrapper menuMode;
|
|
601 |
HsMainWindowMock mainWindow;
|
|
602 |
|
|
603 |
QScopedPointer<QStateMachine> machine(new QStateMachine(0));
|
|
604 |
|
|
605 |
const QString collectionName("testCollection" +
|
|
606 |
QDateTime::currentDateTime().
|
|
607 |
toString("ddmmyyyy_hh_mm_ss_zzz"));
|
|
608 |
|
|
609 |
const int collectionId = HsMenuService::createCollection(collectionName);
|
|
610 |
|
|
611 |
HsCollectionState *collectionState =
|
|
612 |
new HsCollectionState(builder, menuMode, mainWindow, machine.data());
|
|
613 |
|
|
614 |
collectionState->mCollectionId = collectionId;
|
|
615 |
|
|
616 |
machine->setInitialState(collectionState);
|
|
617 |
|
|
618 |
AddToHomeScreenMockState *mockState =
|
|
619 |
new AddToHomeScreenMockState(machine.data());
|
|
620 |
|
|
621 |
HsMenuEventTransition transition(
|
|
622 |
HsMenuEvent::DeleteCollection, collectionState, mockState);
|
|
623 |
|
|
624 |
collectionState->addTransition(&transition);
|
|
625 |
|
|
626 |
machine->setInitialState(collectionState);
|
|
627 |
machine->start();
|
|
628 |
qApp->sendPostedEvents();
|
|
629 |
|
|
630 |
collectionState->deleteAction();
|
|
631 |
|
|
632 |
qApp->sendPostedEvents();
|
|
633 |
|
|
634 |
QVERIFY(mockState->enteredValue());
|
|
635 |
|
|
636 |
machine->stop();
|
|
637 |
|
|
638 |
// cleanup
|
|
639 |
HsMenuService::removeCollection(collectionId);
|
|
640 |
}
|
|
641 |
#ifdef Q_OS_SYMBIAN
|
|
642 |
#ifdef UT_MEMORY_CHECK
|
|
643 |
__UHEAP_MARKEND;
|
|
644 |
#endif//UT_MEMORY_CHECK
|
|
645 |
#endif//Q_OS_SYMBIAN
|
|
646 |
}
|
|
647 |
|
97
|
648 |
// ---------------------------------------------------------------------------
|
|
649 |
//
|
|
650 |
// ---------------------------------------------------------------------------
|
|
651 |
//
|
90
|
652 |
void MenuStatesTest::updateLabel()
|
|
653 |
{
|
|
654 |
#ifdef Q_OS_SYMBIAN
|
|
655 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
656 |
#ifdef UT_MEMORY_CHECK
|
|
657 |
__UHEAP_MARK;
|
|
658 |
#endif//UT_MEMORY_CHECK
|
|
659 |
#endif//Q_OS_SYMBIAN
|
|
660 |
{
|
|
661 |
HsMenuViewBuilder builder;
|
|
662 |
HsMenuModeWrapper menuMode;
|
|
663 |
HsMainWindowMock mainWindow;
|
|
664 |
|
|
665 |
QScopedPointer<QStateMachine> machine(new QStateMachine(0));
|
|
666 |
QState *rootState = new QState(machine.data());
|
|
667 |
machine->setInitialState(rootState);
|
|
668 |
|
|
669 |
const QString collectionName("testCollection" +
|
|
670 |
QDateTime::currentDateTime().
|
|
671 |
toString("ddmmyyyy_hh_mm_ss_zzz"));
|
|
672 |
|
|
673 |
const int collectionId =
|
|
674 |
HsMenuService::createCollection(collectionName);
|
|
675 |
|
|
676 |
HsCollectionState *collectionState =
|
|
677 |
new HsCollectionState(builder, menuMode, mainWindow, rootState);
|
|
678 |
|
|
679 |
collectionState->mCollectionId = collectionId;
|
|
680 |
|
|
681 |
collectionState->mModel =
|
|
682 |
static_cast<HsMenuItemModel *>(
|
|
683 |
HsMenuService::getCollectionModel(collectionState->mCollectionId,
|
|
684 |
collectionState->mSortAttribute));
|
|
685 |
|
97
|
686 |
const QString newName(collectionName +
|
90
|
687 |
QDateTime::currentDateTime().
|
|
688 |
toString("ddmmyyyy_hh_mm_ss_zzz"));
|
|
689 |
|
|
690 |
const bool renamed = HsMenuService::renameCollection(
|
|
691 |
collectionState->mCollectionId, newName);
|
|
692 |
|
|
693 |
QVERIFY(renamed);
|
|
694 |
|
|
695 |
QTest::qWait(3000);
|
|
696 |
|
|
697 |
collectionState->updateLabel();
|
|
698 |
|
97
|
699 |
const QString label = builder.currentViewLabel()->heading();
|
90
|
700 |
|
97
|
701 |
//now label is different than collection name but should contain this name
|
|
702 |
QVERIFY(label.contains(newName));
|
90
|
703 |
|
97
|
704 |
QVERIFY(HsMenuService::renameCollection(collectionState->mCollectionId, collectionName));
|
90
|
705 |
|
|
706 |
// cleanup
|
|
707 |
HsMenuService::removeCollection(collectionId);
|
|
708 |
}
|
|
709 |
#ifdef UT_MEMORY_CHECK
|
|
710 |
__UHEAP_MARKEND;
|
|
711 |
#endif//UT_MEMORY_CHECK
|
|
712 |
}
|
|
713 |
|
|
714 |
// ---------------------------------------------------------------------------
|
97
|
715 |
//
|
90
|
716 |
// ---------------------------------------------------------------------------
|
|
717 |
//
|
|
718 |
void MenuStatesTest::addElementToHomeScreen()
|
|
719 |
{
|
|
720 |
#ifdef Q_OS_SYMBIAN
|
|
721 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
722 |
#ifdef UT_MEMORY_CHECK
|
|
723 |
__UHEAP_MARK;
|
|
724 |
#endif//UT_MEMORY_CHECK
|
|
725 |
#endif//Q_OS_SYMBIAN
|
|
726 |
{
|
|
727 |
HsMenuViewBuilder builder;
|
|
728 |
HsMenuModeWrapper menuMode;
|
|
729 |
HsMainWindowMock mainWindow;
|
|
730 |
|
|
731 |
QScopedPointer<QStateMachine> machine(new QStateMachine(0));
|
|
732 |
|
|
733 |
const QString collectionName("testCollection" +
|
|
734 |
QDateTime::currentDateTime().
|
|
735 |
toString("ddmmyyyy_hh_mm_ss_zzz"));
|
|
736 |
|
|
737 |
const int collectionId = HsMenuService::createCollection(collectionName);
|
|
738 |
HsMenuItemModel *allAppsModel = HsMenuService::getAllApplicationsModel();
|
|
739 |
QVERIFY(allAppsModel->rowCount() >= 1);
|
|
740 |
QModelIndex appIndex = allAppsModel->index(0, 0);
|
|
741 |
|
|
742 |
const int appId = allAppsModel->data(appIndex, CaItemModel::IdRole).toInt();
|
|
743 |
QList<int> appIdList;
|
|
744 |
appIdList << appId;
|
|
745 |
|
|
746 |
HsCollectionState *collectionState =
|
|
747 |
new HsCollectionState(builder, menuMode, mainWindow, machine.data());
|
|
748 |
collectionState->mCollectionId = collectionId;
|
|
749 |
|
|
750 |
HsMenuService::addApplicationsToCollection(appIdList, collectionId);
|
|
751 |
|
|
752 |
// create a state which is to be reached when add-to-home-screen
|
|
753 |
// event is triggered
|
|
754 |
AddToHomeScreenMockState *addToHomeScreenState =
|
|
755 |
new AddToHomeScreenMockState(machine.data());
|
|
756 |
|
|
757 |
// create a transition to the new child state which will be triggered by
|
|
758 |
// an event with specified operation type
|
|
759 |
HsMenuEventTransition addToHomeScreenTransition(
|
|
760 |
HsMenuEvent::AddToHomeScreen, collectionState, addToHomeScreenState);
|
|
761 |
|
|
762 |
// prepare the state graph
|
|
763 |
collectionState->addTransition(&addToHomeScreenTransition);
|
|
764 |
|
|
765 |
machine->setInitialState(collectionState);
|
|
766 |
machine->start();
|
|
767 |
qApp->processEvents();
|
|
768 |
|
|
769 |
const QModelIndex idx = collectionState->mModel->index(0);
|
|
770 |
|
|
771 |
collectionState->addToHomeScreen(idx.data(CaItemModel::IdRole).toInt());
|
|
772 |
|
|
773 |
qApp->processEvents();
|
|
774 |
|
|
775 |
QVERIFY(addToHomeScreenState->enteredValue());
|
|
776 |
|
|
777 |
machine->stop();
|
|
778 |
|
|
779 |
// cleanup
|
|
780 |
if (!appIdList.isEmpty()) {
|
|
781 |
for (int i=0; i<appIdList.count(); i++) {
|
|
782 |
HsMenuService::removeApplicationFromCollection(appIdList[i],collectionId);
|
|
783 |
}
|
|
784 |
}
|
|
785 |
HsMenuService::removeCollection(collectionId);
|
|
786 |
}
|
|
787 |
#ifdef Q_OS_SYMBIAN
|
|
788 |
#ifdef UT_MEMORY_CHECK
|
|
789 |
__UHEAP_MARKEND;
|
|
790 |
#endif//UT_MEMORY_CHECK
|
|
791 |
#endif//Q_OS_SYMBIAN
|
|
792 |
}
|
|
793 |
|
|
794 |
// ---------------------------------------------------------------------------
|
97
|
795 |
//
|
90
|
796 |
// ---------------------------------------------------------------------------
|
|
797 |
//
|
|
798 |
void MenuStatesTest::addCollectionShortcutToHomeScreenAction()
|
|
799 |
{
|
|
800 |
#ifdef Q_OS_SYMBIAN
|
|
801 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
802 |
#ifdef UT_MEMORY_CHECK
|
|
803 |
__UHEAP_MARK;
|
|
804 |
#endif//UT_MEMORY_CHECK
|
|
805 |
#endif//Q_OS_SYMBIAN
|
|
806 |
{
|
|
807 |
HsMenuViewBuilder builder;
|
|
808 |
HsMenuModeWrapper menuMode;
|
|
809 |
HsMainWindowMock mainWindow;
|
|
810 |
|
|
811 |
QScopedPointer<QStateMachine> machine(new QStateMachine(0));
|
|
812 |
|
|
813 |
// we will start from collection view
|
|
814 |
|
|
815 |
const QString collectionName("testCollection" +
|
|
816 |
QDateTime::currentDateTime().toString("ddmmyyyy_hh_mm_ss_zzz"));
|
|
817 |
|
|
818 |
const int collectionId = HsMenuService::createCollection(collectionName);
|
|
819 |
|
|
820 |
HsCollectionState *collectionState = new HsCollectionState(builder,
|
|
821 |
menuMode, mainWindow, machine.data());
|
|
822 |
collectionState->mCollectionId = collectionId;
|
|
823 |
|
|
824 |
// create a state which is to be reached when add-to-home-screen
|
|
825 |
// event is triggered
|
|
826 |
AddToHomeScreenMockState *addToHomeScreenState =
|
|
827 |
new AddToHomeScreenMockState(machine.data());
|
|
828 |
|
|
829 |
// create a transition to the new child state which will be triggered by
|
|
830 |
// an event with specified operation type
|
|
831 |
HsMenuEventTransition addToHomeScreenTransition(
|
|
832 |
HsMenuEvent::AddToHomeScreen, collectionState, addToHomeScreenState);
|
|
833 |
|
|
834 |
// prepare the state graph
|
|
835 |
collectionState->addTransition(&addToHomeScreenTransition);
|
|
836 |
|
|
837 |
|
|
838 |
machine->setInitialState(collectionState);
|
|
839 |
machine->start();
|
|
840 |
qApp->sendPostedEvents();
|
|
841 |
|
|
842 |
collectionState->addCollectionShortcutToHomeScreenAction();
|
|
843 |
qApp->sendPostedEvents();
|
|
844 |
|
|
845 |
QVERIFY(addToHomeScreenState->enteredValue());
|
|
846 |
|
|
847 |
// cleanup
|
|
848 |
HsMenuService::removeCollection(collectionId);
|
|
849 |
}
|
|
850 |
#ifdef Q_OS_SYMBIAN
|
|
851 |
#ifdef UT_MEMORY_CHECK
|
|
852 |
__UHEAP_MARKEND;
|
|
853 |
#endif//UT_MEMORY_CHECK
|
|
854 |
#endif//Q_OS_SYMBIAN
|
|
855 |
}
|
|
856 |
|
|
857 |
// ---------------------------------------------------------------------------
|
97
|
858 |
//
|
90
|
859 |
// ---------------------------------------------------------------------------
|
|
860 |
//
|
|
861 |
void MenuStatesTest::latestOnTopMenuAction()
|
|
862 |
{
|
|
863 |
#ifdef Q_OS_SYMBIAN
|
|
864 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
865 |
#ifdef UT_MEMORY_CHECK
|
|
866 |
__UHEAP_MARK;
|
|
867 |
#endif//UT_MEMORY_CHECK
|
|
868 |
#endif//Q_OS_SYMBIAN
|
|
869 |
{
|
|
870 |
HsMenuViewBuilder builder;
|
|
871 |
HsMenuModeWrapper menuMode;
|
|
872 |
HsMainWindowMock mainWindow;
|
|
873 |
|
|
874 |
QScopedPointer<QState> parent(new QState);
|
|
875 |
parent->setObjectName(tr("testName1"));
|
|
876 |
|
|
877 |
const QString collectionName("testCollection" +
|
|
878 |
QDateTime::currentDateTime().toString("ddmmyyyy_hh_mm_ss_zzz"));
|
|
879 |
const int collectionId = HsMenuService::createCollection(collectionName);
|
|
880 |
|
|
881 |
HsCollectionState *collectionState = new HsCollectionState(
|
|
882 |
builder, menuMode, mainWindow, parent.data());
|
|
883 |
collectionState->mCollectionId = collectionId;
|
|
884 |
|
|
885 |
collectionState->mSortAttribute =
|
|
886 |
Hs::OldestOnTopHsSortAttribute;
|
|
887 |
|
|
888 |
MockModel *collectionModel = new MockModel;
|
|
889 |
collectionState->mModel = collectionModel;
|
|
890 |
collectionState->mMenuView->setModel(collectionModel);
|
|
891 |
|
|
892 |
qRegisterMetaType<Hs::HsSortAttribute>(
|
|
893 |
"Hs::HsSortAttribute");
|
|
894 |
collectionState->mCollectionType = Hs::collectionDownloadedTypeName;
|
|
895 |
collectionState->setMenuOptions();
|
|
896 |
QVERIFY(collectionModel->rowCount() > 1 );
|
|
897 |
QVERIFY(collectionState->mLatestOnTopMenuAction != 0);
|
|
898 |
QVERIFY(collectionState->mOldestOnTopMenuAction != 0);
|
|
899 |
collectionState->latestOnTopMenuAction();
|
|
900 |
|
|
901 |
QCOMPARE(collectionState->mSortAttribute,
|
|
902 |
Hs::LatestOnTopHsSortAttribute);
|
|
903 |
|
|
904 |
// cleanup
|
|
905 |
HsMenuService::removeCollection(collectionId);
|
|
906 |
}
|
|
907 |
#ifdef Q_OS_SYMBIAN
|
|
908 |
#ifdef UT_MEMORY_CHECK
|
|
909 |
__UHEAP_MARKEND;
|
|
910 |
#endif//UT_MEMORY_CHECK
|
|
911 |
#endif//Q_OS_SYMBIAN
|
|
912 |
}
|
|
913 |
|
|
914 |
// ---------------------------------------------------------------------------
|
97
|
915 |
//
|
90
|
916 |
// ---------------------------------------------------------------------------
|
|
917 |
//
|
|
918 |
void MenuStatesTest::oldestOnTopMenuAction()
|
|
919 |
{
|
|
920 |
#ifdef Q_OS_SYMBIAN
|
|
921 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
922 |
#ifdef UT_MEMORY_CHECK
|
|
923 |
__UHEAP_MARK;
|
|
924 |
#endif//UT_MEMORY_CHECK
|
|
925 |
#endif//Q_OS_SYMBIAN
|
|
926 |
{
|
|
927 |
// GUI objects set up
|
|
928 |
|
|
929 |
HsMenuViewBuilder builder;
|
|
930 |
HsMenuModeWrapper menuMode;
|
|
931 |
HsMainWindowMock mainWindow;
|
|
932 |
|
|
933 |
QScopedPointer<QState> parent(new QState);
|
|
934 |
parent->setObjectName(tr("testName1"));
|
|
935 |
|
|
936 |
const QString collectionName("testCollection" +
|
|
937 |
QDateTime::currentDateTime().toString("ddmmyyyy_hh_mm_ss_zzz"));
|
|
938 |
const int collectionId = HsMenuService::createCollection(collectionName);
|
|
939 |
|
|
940 |
HsCollectionState *collectionState =
|
|
941 |
new HsCollectionState(builder, menuMode, mainWindow, parent.data());
|
|
942 |
collectionState->mCollectionId = collectionId;
|
|
943 |
|
|
944 |
collectionState->mSortAttribute =
|
|
945 |
Hs::LatestOnTopHsSortAttribute;
|
|
946 |
|
|
947 |
MockModel *collectionModel = new MockModel;
|
|
948 |
collectionState->mModel = collectionModel;
|
|
949 |
collectionState->mMenuView->setModel(collectionModel);
|
|
950 |
|
|
951 |
qRegisterMetaType<Hs::HsSortAttribute>(
|
|
952 |
"Hs::HsSortAttribute");
|
|
953 |
collectionState->mCollectionType = Hs::collectionDownloadedTypeName;
|
|
954 |
collectionState->setMenuOptions();
|
|
955 |
QVERIFY(collectionModel->rowCount() > 1 );
|
|
956 |
QVERIFY(collectionState->mLatestOnTopMenuAction != 0);
|
|
957 |
QVERIFY(collectionState->mOldestOnTopMenuAction != 0);
|
|
958 |
|
|
959 |
collectionState->oldestOnTopMenuAction();
|
|
960 |
|
|
961 |
QCOMPARE(collectionState->mSortAttribute,
|
|
962 |
Hs::OldestOnTopHsSortAttribute);
|
|
963 |
|
|
964 |
// cleanup
|
|
965 |
HsMenuService::removeCollection(collectionId);
|
|
966 |
}
|
|
967 |
#ifdef Q_OS_SYMBIAN
|
|
968 |
#ifdef UT_MEMORY_CHECK
|
|
969 |
__UHEAP_MARKEND;
|
|
970 |
#endif//UT_MEMORY_CHECK
|
|
971 |
#endif//Q_OS_SYMBIAN
|
|
972 |
}
|
|
973 |
|
|
974 |
// ---------------------------------------------------------------------------
|
97
|
975 |
//
|
90
|
976 |
// ---------------------------------------------------------------------------
|
|
977 |
//
|
|
978 |
void MenuStatesTest::createArrangeCollection()
|
|
979 |
{
|
|
980 |
#ifdef Q_OS_SYMBIAN
|
|
981 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
982 |
#ifdef UT_MEMORY_CHECK
|
|
983 |
__UHEAP_MARK;
|
|
984 |
#endif//UT_MEMORY_CHECK
|
|
985 |
#endif//Q_OS_SYMBIAN
|
|
986 |
{
|
|
987 |
HsMenuViewBuilder builder;
|
|
988 |
HsMenuModeWrapper menuMode;
|
|
989 |
HsMainWindowMock mainWindow;
|
|
990 |
QStateMachine *machine = new QStateMachine(0);
|
|
991 |
|
|
992 |
const QString collectionName("testCollection" +
|
|
993 |
QDateTime::currentDateTime().
|
|
994 |
toString("ddmmyyyy_hh_mm_ss_zzz"));
|
|
995 |
const int collectionId = HsMenuService::createCollection(collectionName);
|
|
996 |
|
|
997 |
HsCollectionState *collectionState =
|
|
998 |
new HsCollectionState(builder, menuMode, mainWindow, machine);
|
|
999 |
|
|
1000 |
collectionState->mCollectionId = collectionId;
|
|
1001 |
|
|
1002 |
machine->setInitialState(collectionState);
|
|
1003 |
|
|
1004 |
AddToHomeScreenMockState *mockState = new AddToHomeScreenMockState(machine);
|
|
1005 |
|
|
1006 |
// create a transition to the new child state which will be triggered by
|
|
1007 |
// an event with specified operation type
|
|
1008 |
HsMenuEventTransition *transition = new HsMenuEventTransition(
|
|
1009 |
HsMenuEvent::ArrangeCollection, collectionState, mockState);
|
|
1010 |
collectionState->addTransition(transition);
|
|
1011 |
|
|
1012 |
machine->start();
|
|
1013 |
qApp->sendPostedEvents();
|
|
1014 |
collectionState->createArrangeCollection();
|
|
1015 |
qApp->sendPostedEvents();
|
|
1016 |
|
|
1017 |
QVERIFY(mockState->enteredValue());
|
|
1018 |
qApp->removePostedEvents(0);
|
|
1019 |
machine->stop();
|
|
1020 |
|
|
1021 |
delete machine;
|
|
1022 |
}
|
|
1023 |
#ifdef Q_OS_SYMBIAN
|
|
1024 |
#ifdef UT_MEMORY_CHECK
|
|
1025 |
__UHEAP_MARKEND;
|
|
1026 |
#endif//UT_MEMORY_CHECK
|
|
1027 |
#endif//Q_OS_SYMBIAN
|
|
1028 |
}
|
|
1029 |
|
|
1030 |
// ---------------------------------------------------------------------------
|
97
|
1031 |
//
|
90
|
1032 |
// ---------------------------------------------------------------------------
|
|
1033 |
//
|
|
1034 |
#ifdef Q_OS_SYMBIAN
|
|
1035 |
void MenuStatesTest::openTaskSwitcher()
|
|
1036 |
{
|
|
1037 |
#ifdef Q_OS_SYMBIAN
|
|
1038 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
1039 |
#ifdef UT_MEMORY_CHECK
|
|
1040 |
__UHEAP_MARK;
|
|
1041 |
#endif//UT_MEMORY_CHECK
|
|
1042 |
#endif//Q_OS_SYMBIAN
|
|
1043 |
{
|
|
1044 |
|
|
1045 |
HsMenuViewBuilder builder;
|
|
1046 |
HsMenuModeWrapper menuMode;
|
|
1047 |
HsMainWindowMock mainWindow;
|
|
1048 |
QScopedPointer<QStateMachine> machine(new QStateMachine(0));
|
|
1049 |
HsCollectionState *collectionState =
|
|
1050 |
new HsCollectionState(builder, menuMode, mainWindow, machine.data());
|
|
1051 |
QVERIFY(collectionState->openTaskSwitcher());
|
|
1052 |
}
|
|
1053 |
#ifdef Q_OS_SYMBIAN
|
|
1054 |
#ifdef UT_MEMORY_CHECK
|
|
1055 |
__UHEAP_MARKEND;
|
|
1056 |
#endif//UT_MEMORY_CHECK
|
|
1057 |
#endif//Q_OS_SYMBIAN
|
|
1058 |
}
|
|
1059 |
#endif//Q_OS_SYMBIAN
|
|
1060 |
|
|
1061 |
// ---------------------------------------------------------------------------
|
97
|
1062 |
//
|
90
|
1063 |
// ---------------------------------------------------------------------------
|
|
1064 |
//
|
|
1065 |
void MenuStatesTest::disableSearchAction()
|
|
1066 |
{
|
|
1067 |
#ifdef Q_OS_SYMBIAN
|
|
1068 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
1069 |
#ifdef UT_MEMORY_CHECK
|
|
1070 |
__UHEAP_MARK;
|
|
1071 |
#endif//UT_MEMORY_CHECK
|
|
1072 |
#endif//Q_OS_SYMBIAN
|
|
1073 |
{
|
|
1074 |
HsMenuViewBuilder builder;
|
|
1075 |
HsMenuModeWrapper menuMode;
|
|
1076 |
HsMainWindowMock mainWindow;
|
|
1077 |
|
|
1078 |
QScopedPointer<QStateMachine> machine(new QStateMachine(0));
|
|
1079 |
|
|
1080 |
const QString collectionName("testCollection" +
|
|
1081 |
QDateTime::currentDateTime().
|
|
1082 |
toString("ddmmyyyy_hh_mm_ss_zzz"));
|
|
1083 |
|
|
1084 |
const int collectionId = HsMenuService::createCollection(collectionName);
|
|
1085 |
|
|
1086 |
HsCollectionState *collectionState =
|
|
1087 |
new HsCollectionState(builder, menuMode, mainWindow, machine.data());
|
|
1088 |
|
|
1089 |
|
|
1090 |
collectionState->mCollectionId = collectionId;
|
|
1091 |
|
|
1092 |
machine->setInitialState(collectionState);
|
|
1093 |
|
|
1094 |
machine->start();
|
|
1095 |
|
|
1096 |
qApp->sendPostedEvents();
|
|
1097 |
|
|
1098 |
collectionState->stateEntered();
|
|
1099 |
|
|
1100 |
collectionState->mMenuView->disableSearch(true);
|
|
1101 |
|
|
1102 |
QVERIFY(!collectionState->mMenuView->mBuilder.searchAction()->isEnabled());
|
|
1103 |
|
|
1104 |
collectionState->mMenuView->disableSearch(false);
|
|
1105 |
|
|
1106 |
QVERIFY(collectionState->mMenuView->mBuilder.searchAction()->isEnabled());
|
|
1107 |
|
|
1108 |
collectionState->lockSearchButton(true);
|
|
1109 |
|
|
1110 |
QVERIFY(!collectionState->mMenuView->mBuilder.searchAction()->isEnabled());
|
|
1111 |
|
|
1112 |
collectionState->lockSearchButton(false);
|
|
1113 |
|
|
1114 |
QVERIFY(collectionState->mMenuView->mBuilder.searchAction()->isEnabled());
|
|
1115 |
|
|
1116 |
collectionState->stateExited();
|
|
1117 |
|
|
1118 |
machine->stop();
|
|
1119 |
|
|
1120 |
// cleanup
|
|
1121 |
HsMenuService::removeCollection(collectionId);
|
|
1122 |
}
|
|
1123 |
#ifdef Q_OS_SYMBIAN
|
|
1124 |
#ifdef UT_MEMORY_CHECK
|
|
1125 |
__UHEAP_MARKEND;
|
|
1126 |
#endif//UT_MEMORY_CHECK
|
|
1127 |
#endif//Q_OS_SYMBIAN
|
|
1128 |
}
|
|
1129 |
QTEST_MAIN(MenuStatesTest)
|
|
1130 |
|