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 <qscopedpointer>
|
|
24 |
#include <hbaction.h>
|
|
25 |
#include <hbgridview.h>
|
|
26 |
#include <hbgroupbox.h>
|
|
27 |
#include <hbtoolbar.h>
|
|
28 |
#include <qsortfilterproxymodel.h>
|
|
29 |
#include <HbShrinkingVkbHost>
|
|
30 |
|
|
31 |
#include "caentry.h"
|
|
32 |
#include "caitemmodel.h"
|
|
33 |
#include "hsmenuview.h"
|
|
34 |
#include "hsmenuevent.h"
|
|
35 |
#include "hsmenuviewbuilder.h"
|
|
36 |
#include "hssearchviewbuilder.h"
|
|
37 |
#include "hsmenueventtransition.h"
|
|
38 |
#include "hsallcollectionsstate.h"
|
|
39 |
#include "hsapplibrarystate.h"
|
|
40 |
#include "hsallappsstate.h"
|
|
41 |
#include "hslistviewitem.h"
|
97
|
42 |
#include "hsscene.h"
|
90
|
43 |
|
|
44 |
#include "t_hsaddtohomescreenmockstate.h"
|
|
45 |
#include "t_hsmockmodel.h"
|
|
46 |
#include "t_menuviewbuilder.h"
|
|
47 |
|
|
48 |
|
97
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
//
|
|
51 |
// ---------------------------------------------------------------------------
|
|
52 |
//
|
90
|
53 |
void MenuStatesTest::cleanup()
|
|
54 |
{
|
|
55 |
qApp->processEvents();
|
|
56 |
}
|
|
57 |
|
97
|
58 |
// ---------------------------------------------------------------------------
|
|
59 |
//
|
|
60 |
// ---------------------------------------------------------------------------
|
|
61 |
//
|
90
|
62 |
class HsMainWindowMock : public HsMainWindow
|
|
63 |
{
|
|
64 |
virtual void setCurrentView(HbView *view);
|
|
65 |
|
|
66 |
};
|
|
67 |
|
97
|
68 |
// ---------------------------------------------------------------------------
|
|
69 |
//
|
|
70 |
// ---------------------------------------------------------------------------
|
|
71 |
//
|
90
|
72 |
void HsMainWindowMock::setCurrentView(HbView *view)
|
|
73 |
{
|
|
74 |
Q_UNUSED(view);
|
|
75 |
// do nothing
|
|
76 |
}
|
|
77 |
|
97
|
78 |
// ---------------------------------------------------------------------------
|
|
79 |
//
|
|
80 |
// ---------------------------------------------------------------------------
|
|
81 |
//
|
90
|
82 |
class HsMainWindowSpy: public HsMainWindow
|
|
83 |
{
|
|
84 |
public:
|
|
85 |
virtual void setCurrentView(HbView *view)
|
|
86 |
{
|
|
87 |
mSwitchedToView = view;
|
|
88 |
}
|
|
89 |
|
|
90 |
HbView *mSwitchedToView;
|
|
91 |
|
|
92 |
HsMainWindowSpy(): mSwitchedToView(NULL) {};
|
|
93 |
};
|
|
94 |
|
97
|
95 |
// ---------------------------------------------------------------------------
|
|
96 |
//
|
|
97 |
// ---------------------------------------------------------------------------
|
|
98 |
//
|
90
|
99 |
void MenuStatesTest::HsMenuViewBuilder_construction()
|
|
100 |
{
|
|
101 |
const HsMenuViewBuilder builder;
|
|
102 |
QList<QAction *> expectedActionList;
|
|
103 |
expectedActionList << builder.allAppsAction();
|
|
104 |
expectedActionList << builder.allCollectionsAction();
|
|
105 |
expectedActionList << builder.searchAction();
|
97
|
106 |
expectedActionList << builder.toolBarExtensionAction();
|
90
|
107 |
|
|
108 |
QList<QAction *> actualActionList(builder.toolBar()->actions());
|
|
109 |
|
|
110 |
QCOMPARE(actualActionList, expectedActionList);
|
|
111 |
|
|
112 |
}
|
|
113 |
|
97
|
114 |
// ---------------------------------------------------------------------------
|
|
115 |
//
|
|
116 |
// ---------------------------------------------------------------------------
|
|
117 |
//
|
90
|
118 |
void MenuStatesTest::HsMenuViewBuilder_view()
|
|
119 |
{
|
|
120 |
HsMenuViewBuilder builder;
|
|
121 |
const HbView *view = builder.currentView();
|
|
122 |
|
|
123 |
builder.setStateContext(HsAllAppsContext);
|
|
124 |
builder.setOperationalContext(HsItemViewContext);
|
|
125 |
|
|
126 |
view = builder.currentView();
|
|
127 |
|
|
128 |
QVERIFY(view != NULL);
|
|
129 |
QCOMPARE(view->objectName(), QString("view"));
|
|
130 |
QString title = view->title();
|
|
131 |
QCOMPARE(title, hbTrId("txt_applib_title_applications"));
|
|
132 |
|
|
133 |
view = builder.currentView();
|
|
134 |
|
|
135 |
builder.setOperationalContext(HsEmptyLabelContext);
|
|
136 |
QVERIFY(view != NULL);
|
|
137 |
QCOMPARE(view->objectName(), QString("view"));
|
|
138 |
title = view->title();
|
|
139 |
QCOMPARE(title, hbTrId("txt_applib_title_applications"));
|
|
140 |
}
|
|
141 |
|
97
|
142 |
// ---------------------------------------------------------------------------
|
|
143 |
//
|
|
144 |
// ---------------------------------------------------------------------------
|
|
145 |
//
|
90
|
146 |
void MenuStatesTest::HsMenuViewBuilder_listView()
|
|
147 |
{
|
|
148 |
HsMenuViewBuilder builder;
|
|
149 |
builder.setStateContext(HsAllAppsContext);
|
|
150 |
builder.setOperationalContext(HsItemViewContext);
|
|
151 |
|
|
152 |
const HbAbstractItemView *const itemView = builder.currentListView();
|
|
153 |
|
|
154 |
QVERIFY(itemView);
|
|
155 |
QVERIFY(itemView->inherits("HbListView"));
|
|
156 |
QVERIFY(itemView->itemRecycling());
|
|
157 |
const bool visible = itemView->property("visible").toBool();
|
|
158 |
QVERIFY(visible);
|
|
159 |
}
|
|
160 |
|
97
|
161 |
// ---------------------------------------------------------------------------
|
|
162 |
//
|
|
163 |
// ---------------------------------------------------------------------------
|
|
164 |
//
|
90
|
165 |
void MenuStatesTest::HsMenuViewBuilder_label()
|
|
166 |
{
|
|
167 |
HsMenuViewBuilder builder;
|
|
168 |
|
|
169 |
const HbGroupBox *const allAppsLabel = builder.currentViewLabel();
|
|
170 |
|
97
|
171 |
QVERIFY(allAppsLabel != NULL);
|
90
|
172 |
|
|
173 |
builder.setStateContext(HsInstalledAppsContext);
|
|
174 |
|
|
175 |
const HbGroupBox *const collectionLabel = builder.currentViewLabel();
|
|
176 |
|
|
177 |
QVERIFY(collectionLabel != NULL);
|
|
178 |
QVERIFY(collectionLabel->isVisible());
|
|
179 |
QCOMPARE(collectionLabel->fontSpec().role(), HbFontSpec::Title);
|
|
180 |
QCOMPARE(collectionLabel->marqueeHeading(), true);
|
|
181 |
}
|
|
182 |
|
97
|
183 |
// ---------------------------------------------------------------------------
|
|
184 |
//
|
|
185 |
// ---------------------------------------------------------------------------
|
|
186 |
//
|
90
|
187 |
void MenuStatesTest::HsMenuViewBuilder_allAppsAction()
|
|
188 |
{
|
|
189 |
const HsMenuViewBuilder builder;
|
|
190 |
const HbAction *const action = builder.allAppsAction();
|
|
191 |
|
|
192 |
QVERIFY(action != NULL);
|
|
193 |
QCOMPARE(action->icon().iconName(),
|
|
194 |
QString("qtg_mono_applications_all"));
|
|
195 |
|
|
196 |
}
|
|
197 |
|
97
|
198 |
// ---------------------------------------------------------------------------
|
|
199 |
//
|
|
200 |
// ---------------------------------------------------------------------------
|
|
201 |
//
|
90
|
202 |
void MenuStatesTest::HsMenuViewBuilder_allCollectionsAction()
|
|
203 |
{
|
|
204 |
const HsMenuViewBuilder builder;
|
|
205 |
const HbAction *const action = builder.allCollectionsAction();
|
|
206 |
|
|
207 |
QVERIFY(action != NULL);
|
|
208 |
QCOMPARE(action->icon().iconName(),
|
|
209 |
QString("qtg_mono_applications_collections"));
|
|
210 |
}
|
|
211 |
|
97
|
212 |
// ---------------------------------------------------------------------------
|
|
213 |
//
|
|
214 |
// ---------------------------------------------------------------------------
|
|
215 |
//
|
90
|
216 |
void MenuStatesTest::HsMenuViewBuilder_searchAction()
|
|
217 |
{
|
|
218 |
const HsMenuViewBuilder builder;
|
|
219 |
const HbAction *const action = builder.searchAction();
|
|
220 |
|
|
221 |
QVERIFY(action != NULL);
|
|
222 |
QCOMPARE(action->icon().iconName(),
|
|
223 |
QString("qtg_mono_search"));
|
|
224 |
}
|
|
225 |
|
97
|
226 |
// ---------------------------------------------------------------------------
|
|
227 |
//
|
|
228 |
// ---------------------------------------------------------------------------
|
|
229 |
//
|
90
|
230 |
void MenuStatesTest::HsMenuViewBuilder_oviStoreAction()
|
|
231 |
{
|
|
232 |
const HsMenuViewBuilder builder;
|
|
233 |
const HbAction *const action = builder.oviStoreAction();
|
|
234 |
|
|
235 |
QVERIFY(action != NULL);
|
|
236 |
QCOMPARE(action->icon().iconName(),
|
|
237 |
QString("qtg_mono_ovistore"));
|
|
238 |
}
|
|
239 |
|
97
|
240 |
// ---------------------------------------------------------------------------
|
|
241 |
//
|
|
242 |
// ---------------------------------------------------------------------------
|
|
243 |
//
|
90
|
244 |
void MenuStatesTest::HsMenuViewBuilder_operatorAction()
|
|
245 |
{
|
|
246 |
const HsMenuViewBuilder builder;
|
|
247 |
const HbAction *const action = builder.operatorAction();
|
|
248 |
|
|
249 |
QVERIFY(action != NULL);
|
|
250 |
//we do not have operator icon name
|
|
251 |
//QCOMPARE(action->icon().iconName(),
|
|
252 |
// QString("qtg_mono_store"));
|
|
253 |
}
|
|
254 |
|
97
|
255 |
// ---------------------------------------------------------------------------
|
|
256 |
//
|
|
257 |
// ---------------------------------------------------------------------------
|
|
258 |
//
|
90
|
259 |
void MenuStatesTest::HsMenuViewBuilder_toolBar()
|
|
260 |
{
|
|
261 |
HsMenuViewBuilder builder;
|
|
262 |
HbToolBar *toolBar = builder.toolBar();
|
|
263 |
|
|
264 |
QVERIFY(toolBar != 0);
|
|
265 |
QCOMPARE(toolBar->orientation(), Qt::Horizontal);
|
|
266 |
|
|
267 |
const QList<QAction *> actions = toolBar->actions();
|
|
268 |
|
97
|
269 |
QCOMPARE(actions.count(), 4);
|
90
|
270 |
QCOMPARE(actions.at(0),
|
|
271 |
static_cast<QAction *>(builder.allAppsAction()));
|
|
272 |
QCOMPARE(actions.at(1),
|
|
273 |
static_cast<QAction *>(builder.allCollectionsAction()));
|
|
274 |
QCOMPARE(actions.at(2),
|
|
275 |
static_cast<QAction *>(builder.searchAction()));
|
|
276 |
QCOMPARE(toolBar, builder.currentView()->toolBar());
|
|
277 |
}
|
|
278 |
|
97
|
279 |
// ---------------------------------------------------------------------------
|
|
280 |
//
|
|
281 |
// ---------------------------------------------------------------------------
|
|
282 |
//
|
90
|
283 |
void MenuStatesTest::HsMenuViewBuilder_toolBarExtension()
|
|
284 |
{
|
|
285 |
HsMenuViewBuilder builder;
|
|
286 |
HbToolBarExtension *toolBarExtension = builder.toolBarExtension();
|
|
287 |
|
|
288 |
QVERIFY(toolBarExtension);
|
|
289 |
}
|
|
290 |
|
|
291 |
// ---------------------------------------------------------------------------
|
97
|
292 |
//
|
90
|
293 |
// ---------------------------------------------------------------------------
|
|
294 |
//
|
|
295 |
void MenuStatesTest::MenuView_slots()
|
|
296 |
{
|
|
297 |
#ifdef Q_OS_SYMBIAN
|
|
298 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
299 |
#ifdef UT_MEMORY_CHECK
|
|
300 |
__UHEAP_MARK;
|
|
301 |
#endif//UT_MEMORY_CHECK
|
|
302 |
#endif//Q_OS_SYMBIAN
|
|
303 |
{
|
|
304 |
HsMenuViewBuilder builder;
|
|
305 |
HsMainWindowMock mainWindow;
|
|
306 |
HsMenuView menuView(builder, HsAllAppsContext, mainWindow);
|
|
307 |
|
|
308 |
connect(&menuView,
|
|
309 |
SIGNAL(activated(QModelIndex)),
|
|
310 |
this,
|
|
311 |
SLOT(testslot_activated(QModelIndex)));
|
|
312 |
connect(&menuView,
|
|
313 |
SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
|
|
314 |
this,
|
|
315 |
SLOT(testslot_longpressed(HbAbstractViewItem *, QPointF)));
|
|
316 |
|
|
317 |
emit menuView.activated(QModelIndex());
|
|
318 |
|
|
319 |
QScopedPointer<HbListViewItem> item(new HbListViewItem());
|
|
320 |
|
|
321 |
emit menuView.longPressed(item.data(), QPoint(50,50));
|
|
322 |
|
|
323 |
QCOMPARE(mIndex, QModelIndex());
|
|
324 |
QVERIFY(item.data() == mItem);
|
|
325 |
QCOMPARE(mPoint.x(), double(50));
|
|
326 |
QCOMPARE(mPoint.y(), double(50));
|
|
327 |
|
|
328 |
disconnect(&menuView,
|
|
329 |
SIGNAL(activated(QModelIndex)),
|
|
330 |
this,
|
|
331 |
SLOT(testslot_activated(QModelIndex)));
|
|
332 |
disconnect(&menuView,
|
|
333 |
SIGNAL(longPressed(HbAbstractViewItem *, QPointF)),
|
|
334 |
this,
|
|
335 |
SLOT(testslot_longpressed(HbAbstractViewItem *, QPointF)));
|
|
336 |
}
|
|
337 |
#ifdef Q_OS_SYMBIAN
|
|
338 |
#ifdef UT_MEMORY_CHECK
|
|
339 |
__UHEAP_MARKEND;
|
|
340 |
#endif//UT_MEMORY_CHECK
|
|
341 |
#endif//Q_OS_SYMBIAN
|
|
342 |
}
|
|
343 |
|
|
344 |
// ---------------------------------------------------------------------------
|
97
|
345 |
//
|
90
|
346 |
// ---------------------------------------------------------------------------
|
|
347 |
//
|
|
348 |
void MenuStatesTest::HsMenuView_scrolling()
|
|
349 |
{
|
|
350 |
#ifdef Q_OS_SYMBIAN
|
|
351 |
#ifdef UT_MEMORY_CHECK
|
|
352 |
__UHEAP_MARK;
|
|
353 |
#endif//UT_MEMORY_CHECK
|
|
354 |
#endif//Q_OS_SYMBIAN
|
|
355 |
{
|
97
|
356 |
QFAIL("! Due to bug in hb wk36 we are forced to skip this test !");
|
|
357 |
QScopedPointer<HbMainWindow> window(new HbMainWindow);
|
|
358 |
HsScene::setInstance( new HsScene(window.data()) );
|
|
359 |
|
90
|
360 |
HsMenuViewBuilder builder;
|
|
361 |
HsMenuModeWrapper menuMode;
|
|
362 |
HsMainWindow mainWindow;
|
|
363 |
|
|
364 |
QScopedPointer<QState> parent(new QState);
|
|
365 |
|
|
366 |
|
|
367 |
HsAllAppsState *allAppsState = new HsAllAppsState(builder,
|
|
368 |
menuMode, mainWindow, parent.data());
|
|
369 |
|
97
|
370 |
window->addView(builder.currentView());
|
90
|
371 |
|
|
372 |
|
|
373 |
QVERIFY(allAppsState->mModel != 0);
|
|
374 |
const int rowCount = allAppsState->mModel->rowCount();
|
|
375 |
QVERIFY(rowCount > 0);
|
|
376 |
|
|
377 |
allAppsState->scrollToBeginning();
|
|
378 |
allAppsState->stateEntered();
|
|
379 |
qApp->processEvents();
|
|
380 |
|
|
381 |
const int expectedRow(0);
|
|
382 |
|
|
383 |
QVERIFY(allAppsState->mMenuView->listView() != NULL);
|
|
384 |
QVERIFY(allAppsState->mMenuView->listView()->visibleItems().count() >= 1);
|
|
385 |
|
|
386 |
int actualRow =
|
|
387 |
allAppsState->mMenuView->listView()->visibleItems().at(0)->modelIndex().row();
|
|
388 |
|
|
389 |
QCOMPARE(actualRow, expectedRow);
|
|
390 |
|
|
391 |
allAppsState->mMenuView->scrollToRow(rowCount -1);
|
|
392 |
|
|
393 |
actualRow =
|
|
394 |
allAppsState->mMenuView->listView()->visibleItems().at(0)->modelIndex().row();
|
|
395 |
|
|
396 |
QVERIFY(actualRow != expectedRow);
|
|
397 |
qApp->processEvents();
|
|
398 |
|
|
399 |
allAppsState->mMenuView->scrollToRow(expectedRow);
|
|
400 |
|
|
401 |
actualRow =
|
|
402 |
allAppsState->mMenuView->listView()->visibleItems().at(0)->modelIndex().row();
|
|
403 |
|
|
404 |
QCOMPARE(actualRow, expectedRow);
|
|
405 |
qApp->processEvents();
|
|
406 |
|
97
|
407 |
allAppsState->stateExited();
|
90
|
408 |
|
|
409 |
qApp->processEvents();
|
|
410 |
}
|
|
411 |
#ifdef Q_OS_SYMBIAN
|
|
412 |
#ifdef UT_MEMORY_CHECK
|
|
413 |
__UHEAP_MARKEND;
|
|
414 |
#endif//UT_MEMORY_CHECK
|
|
415 |
#endif//Q_OS_SYMBIAN
|
|
416 |
}
|
|
417 |
|
|
418 |
// ---------------------------------------------------------------------------
|
97
|
419 |
//
|
90
|
420 |
// ---------------------------------------------------------------------------
|
|
421 |
//
|
|
422 |
void MenuStatesTest::MenuView_toolBarExtension()
|
|
423 |
{
|
|
424 |
#ifdef Q_OS_SYMBIAN
|
|
425 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
426 |
#ifdef UT_MEMORY_CHECK
|
|
427 |
__UHEAP_MARK;
|
|
428 |
#endif//UT_MEMORY_CHECK
|
|
429 |
#endif//Q_OS_SYMBIAN
|
|
430 |
{
|
|
431 |
HsMenuViewBuilder menuViewBuilder;
|
|
432 |
HbToolBarExtension *toolBarExtension = menuViewBuilder.toolBarExtension();
|
|
433 |
QVERIFY(toolBarExtension != NULL);
|
|
434 |
}
|
|
435 |
#ifdef Q_OS_SYMBIAN
|
|
436 |
#ifdef UT_MEMORY_CHECK
|
|
437 |
__UHEAP_MARKEND;
|
|
438 |
#endif//UT_MEMORY_CHECK
|
|
439 |
#endif//Q_OS_SYMBIAN
|
|
440 |
}
|
|
441 |
|
|
442 |
// ---------------------------------------------------------------------------
|
97
|
443 |
//
|
90
|
444 |
// ---------------------------------------------------------------------------
|
|
445 |
//
|
|
446 |
void MenuStatesTest::MenuView_reset()
|
|
447 |
{
|
|
448 |
#ifdef Q_OS_SYMBIAN
|
|
449 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
450 |
#ifdef UT_MEMORY_CHECK
|
|
451 |
__UHEAP_MARK;
|
|
452 |
#endif//UT_MEMORY_CHECK
|
|
453 |
#endif//Q_OS_SYMBIAN
|
|
454 |
{
|
|
455 |
HsMenuViewBuilder builder;
|
|
456 |
HsMainWindowMock mainWindow;
|
|
457 |
HsMenuView menuView(builder, HsCollectionContext, mainWindow);
|
|
458 |
|
|
459 |
QVERIFY(menuView.viewLabel() != 0);
|
|
460 |
|
|
461 |
const QString headingLabel("abcd");
|
|
462 |
|
|
463 |
QScopedPointer<HbAction> backSteppingAction(new HbAction(Hb::BackNaviAction));
|
|
464 |
backSteppingAction->setObjectName("backSteppingAction");
|
|
465 |
|
|
466 |
menuView.viewLabel()->setHeading(headingLabel);
|
|
467 |
menuView.view()->setNavigationAction(backSteppingAction.data());
|
|
468 |
|
|
469 |
menuView.reset(HsEmptyLabelContext);
|
|
470 |
|
|
471 |
QCOMPARE(menuView.mBuilder.mStateContext, HsCollectionContext);
|
|
472 |
QCOMPARE(menuView.mBuilder.mOperationalContext, HsEmptyLabelContext);
|
|
473 |
|
|
474 |
QCOMPARE(menuView.view()->navigationAction()->objectName(),
|
|
475 |
backSteppingAction->objectName());
|
|
476 |
|
|
477 |
QVERIFY(menuView.viewLabel());
|
|
478 |
QCOMPARE(menuView.viewLabel()->heading(), headingLabel);
|
|
479 |
}
|
|
480 |
#ifdef Q_OS_SYMBIAN
|
|
481 |
#ifdef UT_MEMORY_CHECK
|
|
482 |
__UHEAP_MARKEND;
|
|
483 |
#endif//UT_MEMORY_CHECK
|
|
484 |
#endif//Q_OS_SYMBIAN
|
|
485 |
}
|
|
486 |
|
|
487 |
// ---------------------------------------------------------------------------
|
97
|
488 |
//
|
90
|
489 |
// ---------------------------------------------------------------------------
|
|
490 |
//
|
|
491 |
void MenuStatesTest::testslot_activated(const QModelIndex &aIndex)
|
|
492 |
{
|
|
493 |
mIndex = aIndex;
|
|
494 |
}
|
97
|
495 |
|
90
|
496 |
// ---------------------------------------------------------------------------
|
97
|
497 |
//
|
90
|
498 |
// ---------------------------------------------------------------------------
|
|
499 |
//
|
|
500 |
void MenuStatesTest::testslot_longpressed(HbAbstractViewItem *item,
|
|
501 |
const QPointF &coords)
|
|
502 |
{
|
|
503 |
mPoint = coords;
|
|
504 |
mItem = item;
|
|
505 |
}
|
|
506 |
|
|
507 |
// ---------------------------------------------------------------------------
|
97
|
508 |
//
|
90
|
509 |
// ---------------------------------------------------------------------------
|
|
510 |
//
|
|
511 |
void MenuStatesTest::HsListViewItem_updateChildItems()
|
|
512 |
{
|
|
513 |
#ifdef Q_OS_SYMBIAN
|
|
514 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
515 |
#ifdef UT_MEMORY_CHECK
|
|
516 |
__UHEAP_MARK;
|
|
517 |
#endif//UT_MEMORY_CHECK
|
|
518 |
#endif//Q_OS_SYMBIAN
|
|
519 |
{
|
|
520 |
HsMenuViewBuilder builder;
|
|
521 |
HsMenuModeWrapper menuMode;
|
|
522 |
HsMainWindowMock mainWindow;
|
|
523 |
QScopedPointer<HsAllAppsState> allAppsState(new HsAllAppsState(
|
|
524 |
builder, menuMode, mainWindow, 0));
|
|
525 |
|
97
|
526 |
HsMenuItemModel *model = allAppsState->mModel;
|
90
|
527 |
|
|
528 |
QVERIFY(model != static_cast<HsMenuItemModel *>(0));
|
|
529 |
QVERIFY(model->rowCount() > 0);
|
|
530 |
QModelIndex itemModelIndex = model->index(0, 0);
|
|
531 |
|
|
532 |
QScopedPointer<HsListViewItem> listViewItem(new HsListViewItem);
|
|
533 |
|
|
534 |
listViewItem->setModelIndex(itemModelIndex);
|
|
535 |
|
|
536 |
|
|
537 |
QCOMPARE((int)listViewItem->progress,0);
|
|
538 |
QCOMPARE(listViewItem->isProgress,false);
|
|
539 |
listViewItem->updateChildItems();
|
|
540 |
QCOMPARE((int)listViewItem->progress,0);
|
|
541 |
QCOMPARE(listViewItem->isProgress,false);
|
|
542 |
}
|
|
543 |
#ifdef Q_OS_SYMBIAN
|
|
544 |
#ifdef UT_MEMORY_CHECK
|
|
545 |
__UHEAP_MARKEND;
|
|
546 |
#endif//UT_MEMORY_CHECK
|
|
547 |
#endif//Q_OS_SYMBIAN
|
|
548 |
}
|
97
|
549 |
|
90
|
550 |
// ---------------------------------------------------------------------------
|
97
|
551 |
//
|
90
|
552 |
// ---------------------------------------------------------------------------
|
|
553 |
//
|
|
554 |
void MenuStatesTest::HsListViewItem_createItem()
|
|
555 |
{
|
|
556 |
#ifdef Q_OS_SYMBIAN
|
|
557 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
558 |
#ifdef UT_MEMORY_CHECK
|
|
559 |
__UHEAP_MARK;
|
|
560 |
#endif//UT_MEMORY_CHECK
|
|
561 |
#endif//Q_OS_SYMBIAN
|
|
562 |
{
|
|
563 |
QScopedPointer<HsListViewItem> listViewItem(new HsListViewItem);
|
|
564 |
|
|
565 |
QCOMPARE((HbAbstractViewItem*)listViewItem.data() ,listViewItem->prototype() );
|
|
566 |
QScopedPointer<HbAbstractViewItem> newItem( listViewItem->createItem() );
|
|
567 |
|
|
568 |
QCOMPARE(newItem->prototype(), (HbAbstractViewItem*)listViewItem.data() );
|
|
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 |
}
|
97
|
576 |
|
90
|
577 |
// ---------------------------------------------------------------------------
|
97
|
578 |
//
|
90
|
579 |
// ---------------------------------------------------------------------------
|
|
580 |
//
|
|
581 |
void MenuStatesTest::HsListViewItem_polish()
|
|
582 |
{
|
|
583 |
#ifdef Q_OS_SYMBIAN
|
|
584 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
585 |
#ifdef UT_MEMORY_CHECK
|
|
586 |
__UHEAP_MARK;
|
|
587 |
#endif//UT_MEMORY_CHECK
|
|
588 |
#endif//Q_OS_SYMBIAN
|
|
589 |
{
|
|
590 |
QScopedPointer<HsListViewItem> listViewItem(new HsListViewItem);
|
|
591 |
HbStyleParameters styleParam;
|
|
592 |
|
|
593 |
bool expectedVal = false;
|
|
594 |
listViewItem->isProgress = expectedVal;
|
|
595 |
listViewItem->polish(styleParam);
|
|
596 |
QVariant property = listViewItem->property("progress");
|
|
597 |
bool val = property.value<bool>();
|
|
598 |
|
|
599 |
QCOMPARE(val, expectedVal);
|
|
600 |
|
|
601 |
expectedVal = true;
|
|
602 |
listViewItem->isProgress = expectedVal;
|
|
603 |
listViewItem->polish(styleParam);
|
|
604 |
property = listViewItem->property("progress");
|
|
605 |
val = property.value<bool>();
|
|
606 |
|
|
607 |
QCOMPARE(val, expectedVal);
|
|
608 |
}
|
|
609 |
#ifdef Q_OS_SYMBIAN
|
|
610 |
#ifdef UT_MEMORY_CHECK
|
|
611 |
__UHEAP_MARKEND;
|
|
612 |
#endif//UT_MEMORY_CHECK
|
|
613 |
#endif//Q_OS_SYMBIAN
|
|
614 |
}
|
|
615 |
|
|
616 |
// ---------------------------------------------------------------------------
|
97
|
617 |
//
|
90
|
618 |
// ---------------------------------------------------------------------------
|
|
619 |
//
|
|
620 |
void MenuStatesTest::HsProgressBar_timerEvent()
|
|
621 |
{
|
|
622 |
#ifdef Q_OS_SYMBIAN
|
|
623 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
624 |
#ifdef UT_MEMORY_CHECK
|
|
625 |
__UHEAP_MARK;
|
|
626 |
#endif//UT_MEMORY_CHECK
|
|
627 |
#endif//Q_OS_SYMBIAN
|
|
628 |
{
|
|
629 |
HsProgressBar bar;
|
|
630 |
QTimerEvent event(0);
|
|
631 |
bar.timerEvent(&event);
|
|
632 |
QCOMPARE(bar.mTimerId, 0);
|
|
633 |
int val = bar.progressValue();
|
|
634 |
bar.mTargetValue = 1;
|
|
635 |
bar.timerEvent(&event);
|
|
636 |
QCOMPARE(bar.progressValue(), val + 1);
|
|
637 |
}
|
|
638 |
#ifdef Q_OS_SYMBIAN
|
|
639 |
#ifdef UT_MEMORY_CHECK
|
|
640 |
__UHEAP_MARKEND;
|
|
641 |
#endif//UT_MEMORY_CHECK
|
|
642 |
#endif//Q_OS_SYMBIAN
|
|
643 |
}
|
|
644 |
|
|
645 |
// ---------------------------------------------------------------------------
|
97
|
646 |
//
|
90
|
647 |
// ---------------------------------------------------------------------------
|
|
648 |
//
|
|
649 |
void MenuStatesTest::HsProgressBar_setTargetProgressValue()
|
|
650 |
{
|
|
651 |
#ifdef Q_OS_SYMBIAN
|
|
652 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
653 |
#ifdef UT_MEMORY_CHECK
|
|
654 |
__UHEAP_MARK;
|
|
655 |
#endif//UT_MEMORY_CHECK
|
|
656 |
#endif//Q_OS_SYMBIAN
|
|
657 |
{
|
|
658 |
HsProgressBar bar;
|
|
659 |
bar.setTargetProgressValue(0);
|
|
660 |
QCOMPARE(bar.mTargetValue, 0);
|
|
661 |
bar.setTargetProgressValue(1);
|
|
662 |
QCOMPARE(bar.mTargetValue, 1);
|
|
663 |
QVERIFY(bar.mTimerId);
|
|
664 |
}
|
|
665 |
#ifdef Q_OS_SYMBIAN
|
|
666 |
#ifdef UT_MEMORY_CHECK
|
|
667 |
__UHEAP_MARKEND;
|
|
668 |
#endif//UT_MEMORY_CHECK
|
|
669 |
#endif//Q_OS_SYMBIAN
|
|
670 |
}
|
|
671 |
|
97
|
672 |
// ---------------------------------------------------------------------------
|
|
673 |
//
|
|
674 |
// ---------------------------------------------------------------------------
|
|
675 |
//
|
90
|
676 |
void MenuStatesTest::MenuView_showHideSearchPanel()
|
|
677 |
{
|
|
678 |
HsMenuViewBuilder builder;
|
|
679 |
HsMainWindowSpy window;
|
|
680 |
HsMenuView menuView(builder, HsAllAppsContext, window);
|
|
681 |
|
|
682 |
menuView.showSearchPanel();
|
|
683 |
HbView *originatingView = menuView.view();
|
|
684 |
QVERIFY(window.mSwitchedToView != originatingView);
|
|
685 |
menuView.hideSearchPanel();
|
|
686 |
QVERIFY(window.mSwitchedToView == originatingView);
|
|
687 |
}
|
|
688 |
|
|
689 |
|
|
690 |
QTEST_MAIN(MenuStatesTest)
|