90
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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 <QStateMachine>
|
|
19 |
|
|
20 |
#include <HbDialog>
|
|
21 |
#include <HbMainWindow>
|
|
22 |
#include <hbmainwindow.h>
|
|
23 |
|
|
24 |
#include "t_hsmenuworkerstateplugin.h"
|
|
25 |
|
|
26 |
#include "hsaddtohomescreenstate.h"
|
|
27 |
#include "hsshortcutservice.h"
|
|
28 |
#include "hsdialogcontroller.h"
|
|
29 |
|
97
|
30 |
// ---------------------------------------------------------------------------
|
|
31 |
//
|
|
32 |
// ---------------------------------------------------------------------------
|
|
33 |
//
|
90
|
34 |
void MenuStatesTest::initTestCase()
|
|
35 |
{
|
|
36 |
#ifdef Q_OS_SYMBIAN
|
|
37 |
startThread();
|
|
38 |
QDir::setCurrent("C:/");
|
|
39 |
#endif //Q_OS_SYMBIAN
|
|
40 |
mStateMachine = new QStateMachine;
|
|
41 |
mShortcutService = QSharedPointer<HsShortcutService>
|
|
42 |
(HsShortcutService::instance(mStateMachine/*,0*/));
|
|
43 |
mWindow = new HbMainWindow();
|
|
44 |
}
|
97
|
45 |
|
90
|
46 |
// ---------------------------------------------------------------------------
|
97
|
47 |
//
|
90
|
48 |
// ---------------------------------------------------------------------------
|
|
49 |
//
|
|
50 |
void MenuStatesTest::cleanupTestCase()
|
|
51 |
{
|
|
52 |
#ifdef Q_OS_SYMBIAN
|
|
53 |
stopThread();
|
|
54 |
#endif //Q_OS_SYMBIAN
|
|
55 |
delete mStateMachine;
|
97
|
56 |
//QWARN ( "Due to bug in hb wk36 we are we have to avoid deleting "
|
|
57 |
// "HbMainWindow, remove comment when fixed" )
|
|
58 |
/* delete mWindow;
|
|
59 |
mWindow = NULL;*/
|
90
|
60 |
}
|
|
61 |
|
97
|
62 |
// ---------------------------------------------------------------------------
|
|
63 |
//
|
|
64 |
// ---------------------------------------------------------------------------
|
|
65 |
//
|
90
|
66 |
void MenuStatesTest::cleanup()
|
|
67 |
{
|
|
68 |
qApp->processEvents();
|
|
69 |
}
|
|
70 |
|
|
71 |
// ---------------------------------------------------------------------------
|
97
|
72 |
//
|
90
|
73 |
// ---------------------------------------------------------------------------
|
97
|
74 |
//
|
90
|
75 |
int threadFunction(void *params)
|
|
76 |
{
|
|
77 |
Q_UNUSED(params);
|
|
78 |
#ifdef Q_OS_SYMBIAN
|
|
79 |
while (ETrue) {
|
|
80 |
User::ResetInactivityTime();//it should help for Viewserver11 panic
|
|
81 |
User::After(5000000);
|
|
82 |
}
|
|
83 |
#endif //Q_OS_SYMBIAN
|
|
84 |
return 0;
|
|
85 |
}
|
|
86 |
|
|
87 |
// ---------------------------------------------------------------------------
|
97
|
88 |
//
|
90
|
89 |
// ---------------------------------------------------------------------------
|
|
90 |
//
|
|
91 |
void MenuStatesTest::startThread()
|
|
92 |
{
|
|
93 |
#ifdef Q_OS_SYMBIAN
|
|
94 |
User::LeaveIfError(iThread.Create(
|
|
95 |
_L("thread_kill_viewsrv11"),
|
|
96 |
threadFunction,
|
|
97 |
16384,
|
|
98 |
4000,
|
|
99 |
4000,
|
|
100 |
NULL));
|
|
101 |
iThread.Resume();
|
|
102 |
#endif //Q_OS_SYMBIAN
|
|
103 |
}
|
97
|
104 |
|
90
|
105 |
// ---------------------------------------------------------------------------
|
97
|
106 |
//
|
90
|
107 |
// ---------------------------------------------------------------------------
|
|
108 |
//
|
|
109 |
void MenuStatesTest::stopThread()
|
|
110 |
{
|
|
111 |
#ifdef Q_OS_SYMBIAN
|
|
112 |
iThread.Close();
|
|
113 |
QTest::qWait(3000);
|
|
114 |
#endif //Q_OS_SYMBIAN
|
|
115 |
}
|
|
116 |
|
|
117 |
// ---------------------------------------------------------------------------
|
97
|
118 |
//
|
90
|
119 |
// ---------------------------------------------------------------------------
|
|
120 |
//
|
|
121 |
void MenuStatesTest::testSlot(HbAction* finished)
|
|
122 |
{
|
|
123 |
Q_UNUSED(finished)
|
|
124 |
mFinishedEmited = true;
|
|
125 |
}
|
|
126 |
|
|
127 |
// ---------------------------------------------------------------------------
|
97
|
128 |
//
|
90
|
129 |
// ---------------------------------------------------------------------------
|
|
130 |
//
|
|
131 |
int MenuStatesTest::testExitSlot()
|
|
132 |
{
|
|
133 |
mFinishedEmited = true;
|
|
134 |
return 0;
|
|
135 |
}
|
|
136 |
|
97
|
137 |
// ---------------------------------------------------------------------------
|
|
138 |
//
|
|
139 |
// ---------------------------------------------------------------------------
|
|
140 |
//
|
90
|
141 |
void MenuStatesTest::checkDialogController()
|
|
142 |
{
|
|
143 |
|
|
144 |
QGraphicsScene *scene = mWindow->scene();
|
|
145 |
QGraphicsItem *focusItem = scene->focusItem();
|
|
146 |
QPointer<HbDialog> dialog =
|
|
147 |
qobject_cast<HbDialog*>(focusItem->toGraphicsObject());
|
|
148 |
|
|
149 |
QVERIFY(!dialog.isNull());
|
|
150 |
|
|
151 |
QPointer<HsDialogController> controller(NULL);
|
|
152 |
|
|
153 |
foreach (QObject* obj, dialog->children())
|
|
154 |
{
|
|
155 |
controller = qobject_cast<HsDialogController*>(obj);
|
|
156 |
|
|
157 |
if (!controller.isNull())
|
|
158 |
{
|
|
159 |
break;
|
|
160 |
}
|
|
161 |
}
|
|
162 |
|
|
163 |
QVERIFY(!controller.isNull());
|
|
164 |
|
|
165 |
QSignalSpy spy(controller.data(), SIGNAL(dialogCompleted()));
|
|
166 |
controller->dismissDialog();
|
|
167 |
|
|
168 |
QTest::qWait(1000);
|
|
169 |
|
|
170 |
QVERIFY(dialog.isNull());
|
|
171 |
QVERIFY(controller.isNull());
|
|
172 |
QCOMPARE(spy.count(), 1);
|
|
173 |
}
|
|
174 |
|
|
175 |
QTEST_MAIN(MenuStatesTest)
|