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 "t_hsmenuworkerstateplugin.h"
|
|
19 |
|
|
20 |
#include <QStateMachine>
|
|
21 |
#include <HbMainwindow>
|
|
22 |
#include <HbDialog>
|
|
23 |
#include <HbAction>
|
|
24 |
#include <HbLabel>
|
|
25 |
#include <HbWidget>
|
|
26 |
#include <HbScrollarea>
|
|
27 |
#include <HbMessageBox>
|
|
28 |
|
|
29 |
#include <hsmenueventfactory.h>
|
|
30 |
#include <hsconfiguration.h>
|
|
31 |
#include "hscontentservice.h"
|
|
32 |
#include "hsshortcutservice.h"
|
|
33 |
#include "hsmenuworkerstate.h"
|
|
34 |
#include "hspreviewhswidgetstate.h"
|
|
35 |
#include "hsapp_defs.h"
|
|
36 |
#include "hspage.h"
|
|
37 |
#include "hsscene.h"
|
|
38 |
#include "HsWidgetHost.h"
|
|
39 |
|
|
40 |
// ---------------------------------------------------------------------------
|
97
|
41 |
//
|
90
|
42 |
// ---------------------------------------------------------------------------
|
|
43 |
//
|
|
44 |
void MenuStatesTest::HsPreviewHSWidgetState_construction()
|
|
45 |
{
|
|
46 |
#ifdef Q_OS_SYMBIAN
|
|
47 |
#ifdef UT_MEMORY_CHECK
|
|
48 |
__UHEAP_MARK;
|
|
49 |
#endif//UT_MEMORY_CHECK
|
|
50 |
#endif//Q_OS_SYMBIAN
|
|
51 |
{
|
|
52 |
QState *parent = new QState();
|
|
53 |
|
|
54 |
HsPreviewHSWidgetState *as1 = new HsPreviewHSWidgetState(parent);
|
|
55 |
|
|
56 |
HsPreviewHSWidgetState *as2 = new HsPreviewHSWidgetState(parent);
|
|
57 |
|
|
58 |
QString on1 = as1->objectName();
|
|
59 |
QString on2 = as2->objectName();
|
|
60 |
QVERIFY(on1 == on2);
|
|
61 |
}
|
|
62 |
#ifdef Q_OS_SYMBIAN
|
|
63 |
#ifdef UT_MEMORY_CHECK
|
|
64 |
__UHEAP_MARKEND;
|
|
65 |
#endif//UT_MEMORY_CHECK
|
|
66 |
#endif//Q_OS_SYMBIAN
|
|
67 |
}
|
|
68 |
|
|
69 |
// ---------------------------------------------------------------------------
|
97
|
70 |
//
|
90
|
71 |
// ---------------------------------------------------------------------------
|
|
72 |
//
|
|
73 |
void MenuStatesTest::HsPreviewHSWidgetState_showMessageWidgetCorrupted()
|
|
74 |
{
|
|
75 |
#ifdef Q_OS_SYMBIAN
|
|
76 |
#ifdef UT_MEMORY_CHECK
|
|
77 |
__UHEAP_MARK;
|
|
78 |
#endif//UT_MEMORY_CHECK
|
|
79 |
#endif//Q_OS_SYMBIAN
|
|
80 |
{
|
|
81 |
QState *parent = new QState();
|
|
82 |
HsPreviewHSWidgetState *as1 = new HsPreviewHSWidgetState(parent);
|
|
83 |
as1->showMessageWidgetCorrupted();
|
|
84 |
checkDialogController();
|
|
85 |
|
|
86 |
delete parent;
|
|
87 |
}
|
|
88 |
#ifdef Q_OS_SYMBIAN
|
|
89 |
#ifdef UT_MEMORY_CHECK
|
|
90 |
__UHEAP_MARKEND;
|
|
91 |
#endif//UT_MEMORY_CHECK
|
|
92 |
#endif//Q_OS_SYMBIAN
|
|
93 |
}
|
|
94 |
|
|
95 |
// ---------------------------------------------------------------------------
|
97
|
96 |
//
|
90
|
97 |
// ---------------------------------------------------------------------------
|
|
98 |
//
|
|
99 |
void MenuStatesTest::HsPreviewHSWidgetState_onEntry()
|
|
100 |
{
|
|
101 |
#ifdef Q_OS_SYMBIAN
|
|
102 |
#ifdef UT_MEMORY_CHECK
|
|
103 |
__UHEAP_MARK;
|
|
104 |
#endif//UT_MEMORY_CHECK
|
|
105 |
#endif//Q_OS_SYMBIAN
|
|
106 |
{
|
|
107 |
QState *parent = new QState();
|
|
108 |
HsPreviewHSWidgetState *as1 = new HsPreviewHSWidgetState(parent);
|
|
109 |
|
|
110 |
QVariantMap params;
|
|
111 |
params.insert(Hs::itemIdKey, 2);
|
|
112 |
params.insert(
|
|
113 |
Hs::widgetUriAttributeName,
|
|
114 |
QString("test_uri"));
|
|
115 |
params.insert(
|
|
116 |
Hs::widgetLibraryAttributeName,
|
|
117 |
QString("test_library"));
|
|
118 |
params.insert(Hs::entryTypeNameKey, Hs::widgetTypeName);
|
|
119 |
|
|
120 |
QScopedPointer<QEvent> event (new HsMenuEvent(
|
|
121 |
HsMenuEvent::PreviewHSWidget, params));
|
|
122 |
|
|
123 |
mFinishedEmited = false; //test slot
|
|
124 |
|
|
125 |
as1->onEntry(event.data());
|
|
126 |
|
|
127 |
QCOMPARE(params.value(Hs::itemIdKey).toInt(), as1->mEntryId);
|
|
128 |
|
|
129 |
checkDialogController();
|
|
130 |
|
|
131 |
delete as1;
|
|
132 |
delete parent;
|
|
133 |
}
|
|
134 |
#ifdef Q_OS_SYMBIAN
|
|
135 |
#ifdef UT_MEMORY_CHECK
|
|
136 |
__UHEAP_MARKEND;
|
|
137 |
#endif//UT_MEMORY_CHECK
|
|
138 |
#endif//Q_OS_SYMBIAN
|
|
139 |
}
|
|
140 |
|
|
141 |
// ---------------------------------------------------------------------------
|
97
|
142 |
//
|
90
|
143 |
// ---------------------------------------------------------------------------
|
|
144 |
//
|
|
145 |
void MenuStatesTest::HsPreviewHSWidgetState_buildPreviewDialog()
|
|
146 |
{
|
|
147 |
#ifdef Q_OS_SYMBIAN
|
|
148 |
#ifdef UT_MEMORY_CHECK
|
|
149 |
__UHEAP_MARK;
|
|
150 |
#endif//UT_MEMORY_CHECK
|
|
151 |
#endif//Q_OS_SYMBIAN
|
|
152 |
{
|
|
153 |
HsPreviewHSWidgetState previewWidgetState;
|
|
154 |
|
|
155 |
CaEntry entry;
|
|
156 |
entry.setText("entry text");
|
|
157 |
|
|
158 |
QScopedPointer<HbDialog> previewDialog(
|
|
159 |
previewWidgetState.buildPreviewDialog(entry));
|
|
160 |
|
|
161 |
QVERIFY(previewDialog != NULL);
|
|
162 |
QVERIFY(previewDialog->actions()[0]->parent() == previewDialog.data());
|
|
163 |
QVERIFY(previewDialog->actions()[1]->parent() == previewDialog.data());
|
|
164 |
|
|
165 |
QVERIFY(previewDialog->testAttribute(Qt::WA_DeleteOnClose));
|
|
166 |
HbLabel *const headingLabel(qobject_cast<HbLabel*>(
|
|
167 |
previewDialog->headingWidget()));
|
|
168 |
QCOMPARE(headingLabel->plainText(), entry.text());
|
|
169 |
}
|
|
170 |
#ifdef Q_OS_SYMBIAN
|
|
171 |
#ifdef UT_MEMORY_CHECK
|
|
172 |
__UHEAP_MARKEND;
|
|
173 |
#endif//UT_MEMORY_CHECK
|
|
174 |
#endif//Q_OS_SYMBIAN
|
|
175 |
}
|
|
176 |
|
|
177 |
// ---------------------------------------------------------------------------
|
97
|
178 |
//
|
90
|
179 |
// ---------------------------------------------------------------------------
|
|
180 |
//
|
|
181 |
void MenuStatesTest::HsPreviewHSWidgetState_addToHomeScreen()
|
|
182 |
{
|
|
183 |
#ifdef Q_OS_SYMBIAN
|
|
184 |
#ifdef UT_MEMORY_CHECK
|
|
185 |
__UHEAP_MARK;
|
|
186 |
#endif//UT_MEMORY_CHECK
|
|
187 |
#endif//Q_OS_SYMBIAN
|
|
188 |
{
|
|
189 |
QState *parent = new QState();
|
|
190 |
HsConfiguration::setInstance(new HsConfiguration);
|
|
191 |
HsPreviewHSWidgetState *as1 = new HsPreviewHSWidgetState(parent);
|
|
192 |
|
|
193 |
QScopedPointer<HsPage> page(new HsPage);
|
|
194 |
HsScene::instance()->addPage(page.data());
|
|
195 |
page.take();
|
|
196 |
HsScene::instance()->load();
|
|
197 |
|
|
198 |
as1->addToHomeScreen();
|
|
199 |
|
|
200 |
QCOMPARE(HsContentService::instance()->mParams.size(), 2);
|
|
201 |
QCOMPARE(HsContentService::instance()->mParams[Hs::uri], QVariant(QString()));
|
|
202 |
QVERIFY(HsContentService::instance()->mParams[Hs::homescreenData].isNull());
|
|
203 |
delete as1;
|
|
204 |
delete parent;
|
|
205 |
}
|
|
206 |
#ifdef Q_OS_SYMBIAN
|
|
207 |
#ifdef UT_MEMORY_CHECK
|
|
208 |
__UHEAP_MARKEND;
|
|
209 |
#endif//UT_MEMORY_CHECK
|
|
210 |
#endif//Q_OS_SYMBIAN
|
|
211 |
}
|