|
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 |
|
19 #include "t_hsmenuworkerstateplugin.h" |
|
20 |
|
21 #include <QStateMachine> |
|
22 #include <HbMainwindow> |
|
23 #include <HbDialog> |
|
24 #include <HbAction> |
|
25 #include <HbLabel> |
|
26 #include <HbWidget> |
|
27 #include <HbScrollarea> |
|
28 #include <HbMessageBox> |
|
29 |
|
30 #include <hsmenueventfactory.h> |
|
31 #include <hsconfiguration.h> |
|
32 #include "hscontentservice.h" |
|
33 #include "hsshortcutservice.h" |
|
34 #include "hsmenuworkerstate.h" |
|
35 #include "hspreviewhswidgetstate.h" |
|
36 #include "hsapp_defs.h" |
|
37 #include "hspage.h" |
|
38 #include "hsscene.h" |
|
39 #include "HsWidgetHost.h" |
|
40 |
|
41 // --------------------------------------------------------------------------- |
|
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 |
|
70 // --------------------------------------------------------------------------- |
|
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 |
|
96 // --------------------------------------------------------------------------- |
|
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 // --------------------------------------------------------------------------- |
|
142 // --------------------------------------------------------------------------- |
|
143 // |
|
144 void MenuStatesTest::HsPreviewHSWidgetState_buildPreviewDialog() |
|
145 { |
|
146 #ifdef Q_OS_SYMBIAN |
|
147 #ifdef UT_MEMORY_CHECK |
|
148 __UHEAP_MARK; |
|
149 #endif//UT_MEMORY_CHECK |
|
150 #endif//Q_OS_SYMBIAN |
|
151 { |
|
152 HsPreviewHSWidgetState previewWidgetState; |
|
153 |
|
154 CaEntry entry; |
|
155 entry.setText("entry text"); |
|
156 |
|
157 QScopedPointer<HbDialog> previewDialog( |
|
158 previewWidgetState.buildPreviewDialog(entry)); |
|
159 |
|
160 QVERIFY(previewDialog != NULL); |
|
161 QVERIFY(previewDialog->actions()[0]->parent() == previewDialog.data()); |
|
162 QVERIFY(previewDialog->actions()[1]->parent() == previewDialog.data()); |
|
163 |
|
164 QVERIFY(previewDialog->testAttribute(Qt::WA_DeleteOnClose)); |
|
165 HbLabel *const headingLabel(qobject_cast<HbLabel*>( |
|
166 previewDialog->headingWidget())); |
|
167 QCOMPARE(headingLabel->plainText(), entry.text()); |
|
168 } |
|
169 #ifdef Q_OS_SYMBIAN |
|
170 #ifdef UT_MEMORY_CHECK |
|
171 __UHEAP_MARKEND; |
|
172 #endif//UT_MEMORY_CHECK |
|
173 #endif//Q_OS_SYMBIAN |
|
174 } |
|
175 |
|
176 // --------------------------------------------------------------------------- |
|
177 // --------------------------------------------------------------------------- |
|
178 // |
|
179 void MenuStatesTest::HsPreviewHSWidgetState_addToHomeScreen() |
|
180 { |
|
181 #ifdef Q_OS_SYMBIAN |
|
182 #ifdef UT_MEMORY_CHECK |
|
183 __UHEAP_MARK; |
|
184 #endif//UT_MEMORY_CHECK |
|
185 #endif//Q_OS_SYMBIAN |
|
186 { |
|
187 QState *parent = new QState(); |
|
188 HsConfiguration::setInstance(new HsConfiguration); |
|
189 HsPreviewHSWidgetState *as1 = new HsPreviewHSWidgetState(parent); |
|
190 |
|
191 QScopedPointer<HsPage> page(new HsPage); |
|
192 HsScene::instance()->addPage(page.data()); |
|
193 page.take(); |
|
194 HsScene::instance()->load(); |
|
195 |
|
196 as1->addToHomeScreen(); |
|
197 |
|
198 QCOMPARE(HsContentService::instance()->mParams.size(), 2); |
|
199 QCOMPARE(HsContentService::instance()->mParams[Hs::uri], QVariant(QString())); |
|
200 QVERIFY(HsContentService::instance()->mParams[Hs::homescreenData].isNull()); |
|
201 delete as1; |
|
202 delete parent; |
|
203 } |
|
204 #ifdef Q_OS_SYMBIAN |
|
205 #ifdef UT_MEMORY_CHECK |
|
206 __UHEAP_MARKEND; |
|
207 #endif//UT_MEMORY_CHECK |
|
208 #endif//Q_OS_SYMBIAN |
|
209 } |