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 test library.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <hbinstance.h>
|
|
19 |
#include <hbview.h>
|
|
20 |
#include <QVariant>
|
|
21 |
#include <QList>
|
|
22 |
|
|
23 |
#include <caentry.h>
|
|
24 |
#include <caquery.h>
|
|
25 |
#include <caicondescription.h>
|
|
26 |
#include <caservice.h>
|
|
27 |
|
|
28 |
#include <hsapp_defs.h>
|
|
29 |
#include "t_hsmenuclientplugin.h"
|
|
30 |
#include "hsmenuclient.h"
|
|
31 |
|
|
32 |
const QString hsItemId("id");
|
|
33 |
|
|
34 |
// ---------------------------------------------------------------------------
|
|
35 |
// ---------------------------------------------------------------------------
|
|
36 |
//
|
|
37 |
void HsMenuClientPluginTest::initTestCase()
|
|
38 |
{
|
|
39 |
mCaServicePrivateMock = &CaServicePrivate::instance();
|
|
40 |
// mainWindow();
|
|
41 |
}
|
|
42 |
|
|
43 |
// ---------------------------------------------------------------------------
|
|
44 |
// ---------------------------------------------------------------------------
|
|
45 |
//
|
|
46 |
void HsMenuClientPluginTest::init()
|
|
47 |
{
|
|
48 |
mCaServicePrivateMock->clearAll();
|
|
49 |
}
|
|
50 |
|
|
51 |
|
|
52 |
// ---------------------------------------------------------------------------
|
|
53 |
// ---------------------------------------------------------------------------
|
|
54 |
//
|
|
55 |
void HsMenuClientPluginTest::cleanupTestCase()
|
|
56 |
{
|
|
57 |
|
|
58 |
// delete mainWindow();
|
|
59 |
|
|
60 |
}
|
|
61 |
|
|
62 |
void HsMenuClientPluginTest::cleanup()
|
|
63 |
{
|
|
64 |
mCaServicePrivateMock->clearAll();
|
|
65 |
qApp->processEvents();
|
|
66 |
}
|
|
67 |
|
|
68 |
void HsMenuClientPluginTest::testCreateEntry()
|
|
69 |
{
|
|
70 |
#ifdef Q_OS_SYMBIAN
|
|
71 |
#ifdef UT_MEMORY_CHECK
|
|
72 |
__UHEAP_MARK;
|
|
73 |
#endif//UT_MEMORY_CHECK
|
|
74 |
#endif//Q_OS_SYMBIAN
|
|
75 |
{
|
|
76 |
QList<QVariantMap> list;
|
|
77 |
QMap<QString, QVariant> map;
|
|
78 |
map[hsItemName] = "ModuleTestTApp";
|
|
79 |
map[hsItemDescription] = "Unit test app for HsClientPlugin";
|
|
80 |
|
|
81 |
map[hsitemLaunchUri] = "appto://2002DCEC?";
|
|
82 |
map[hsitemPublisherId] = "tappModuleTest";
|
|
83 |
map[hsItemWidgetUri] = "hsclockwidgetplugin";
|
|
84 |
|
|
85 |
map[hsIconFileName] = "Z:\\private\\20022F35\\import\\widgetregistry\\20022F6C\\tclock.png";
|
|
86 |
map[hsIconName] = "qtg_large_applications_user";
|
|
87 |
map[hsIconApplicationId] = "268458321";
|
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
HsMenuClient *publisher = new HsMenuClient();
|
|
92 |
QVERIFY(publisher->add(map));
|
|
93 |
|
|
94 |
QSharedPointer<CaEntry> res_entry = mCaServicePrivateMock->mCreatedEntries[0];
|
|
95 |
|
|
96 |
|
|
97 |
QCOMPARE(res_entry->entryTypeName(),
|
|
98 |
QString(Hs::templatedApplicationTypeName));
|
|
99 |
QCOMPARE(res_entry->role(), ItemEntryRole);
|
|
100 |
QCOMPARE(res_entry->text(), map[hsItemName].toString());
|
|
101 |
QCOMPARE(res_entry->description(), map[hsItemDescription].toString());
|
|
102 |
|
|
103 |
QCOMPARE(res_entry->attributes().count(), 3);
|
|
104 |
QCOMPARE(res_entry->attribute(hsitemLaunchUri), map[hsitemLaunchUri].toString());
|
|
105 |
QCOMPARE(res_entry->attribute(hsitemPublisherId), map[hsitemPublisherId].toString());
|
|
106 |
QCOMPARE(res_entry->attribute(hsItemWidgetUri), map[hsItemWidgetUri].toString());
|
|
107 |
|
|
108 |
// icon
|
|
109 |
QCOMPARE(res_entry->iconDescription().filename(), map[hsIconFileName].toString());
|
|
110 |
QCOMPARE(res_entry->iconDescription().skinId(),map[hsIconName].toString());
|
|
111 |
QCOMPARE(res_entry->iconDescription().applicationId(), map[hsIconApplicationId].toString());
|
|
112 |
|
|
113 |
QCOMPARE(res_entry->flags(), VisibleEntryFlag); // Visible by default, entry not removable
|
|
114 |
|
|
115 |
delete publisher;
|
|
116 |
|
|
117 |
}
|
|
118 |
#ifdef Q_OS_SYMBIAN
|
|
119 |
#ifdef UT_MEMORY_CHECK
|
|
120 |
__UHEAP_MARKEND;
|
|
121 |
#endif//UT_MEMORY_CHECK
|
|
122 |
#endif//Q_OS_SYMBIAN
|
|
123 |
}
|
|
124 |
|
|
125 |
void HsMenuClientPluginTest::testCreateLocalizedEntry()
|
|
126 |
{
|
|
127 |
#ifdef Q_OS_SYMBIAN
|
|
128 |
#ifdef UT_MEMORY_CHECK
|
|
129 |
__UHEAP_MARK;
|
|
130 |
#endif//UT_MEMORY_CHECK
|
|
131 |
#endif//Q_OS_SYMBIAN
|
|
132 |
{
|
|
133 |
QList<QVariantMap> list;
|
|
134 |
QMap<QString, QVariant> map;
|
|
135 |
QString testName("Games");
|
|
136 |
QString testDesc("");
|
|
137 |
map[hsItemName] = "ModuleTestTApp";
|
|
138 |
map[hsItemLocName] = "loc://emailTest/txt_applib_dblist_games";
|
|
139 |
map[hsItemDescription] = "Unit test app for HsClientPlugin";
|
|
140 |
map[hsItemLocDescription] = "loc://emailTest/txt_applib_subtitle_office";
|
|
141 |
|
|
142 |
map[hsitemLaunchUri] = "appto://2002DCEC?";
|
|
143 |
map[hsitemPublisherId] = "tappModuleTest";
|
|
144 |
map[hsItemWidgetUri] = "hsclockwidgetplugin";
|
|
145 |
|
|
146 |
map[hsIconFileName] = "Z:\\private\\20022F35\\import\\widgetregistry\\20022F6C\\tclock.png";
|
|
147 |
map[hsIconName] = "qtg_large_applications_user";
|
|
148 |
map[hsIconApplicationId] = "268458321";
|
|
149 |
|
|
150 |
|
|
151 |
|
|
152 |
HsMenuClient *publisher = new HsMenuClient();
|
|
153 |
QVERIFY(publisher->add(map));
|
|
154 |
|
|
155 |
QSharedPointer<CaEntry> res_entry = mCaServicePrivateMock->mCreatedEntries[0];
|
|
156 |
|
|
157 |
|
|
158 |
QCOMPARE(res_entry->entryTypeName(),
|
|
159 |
QString(Hs::templatedApplicationTypeName));
|
|
160 |
QCOMPARE(res_entry->role(), ItemEntryRole);
|
|
161 |
QCOMPARE(res_entry->text(), map[hsItemLocName].toString());
|
|
162 |
QCOMPARE(res_entry->description(), map[hsItemLocDescription].toString());
|
|
163 |
|
|
164 |
QCOMPARE(res_entry->attribute(hsitemLaunchUri), map[hsitemLaunchUri].toString());
|
|
165 |
QCOMPARE(res_entry->attribute(hsitemPublisherId), map[hsitemPublisherId].toString());
|
|
166 |
QCOMPARE(res_entry->attribute(hsItemWidgetUri), map[hsItemWidgetUri].toString());
|
|
167 |
|
|
168 |
// icon
|
|
169 |
QCOMPARE(res_entry->iconDescription().filename(), map[hsIconFileName].toString());
|
|
170 |
QCOMPARE(res_entry->iconDescription().skinId(),map[hsIconName].toString());
|
|
171 |
QCOMPARE(res_entry->iconDescription().applicationId(), map[hsIconApplicationId].toString());
|
|
172 |
|
|
173 |
QCOMPARE(res_entry->flags(), VisibleEntryFlag); // Visible by default, entry not removable
|
|
174 |
|
|
175 |
delete publisher;
|
|
176 |
|
|
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 |
void HsMenuClientPluginTest::testUpdateEntry()
|
|
186 |
{
|
|
187 |
#ifdef Q_OS_SYMBIAN
|
|
188 |
#ifdef UT_MEMORY_CHECK
|
|
189 |
__UHEAP_MARK;
|
|
190 |
#endif//UT_MEMORY_CHECK
|
|
191 |
#endif//Q_OS_SYMBIAN
|
|
192 |
{
|
|
193 |
QMap<QString, QVariant> map;
|
|
194 |
map[hsItemId] = 1; // entry id == 1, entry to update
|
|
195 |
|
|
196 |
map[hsItemName] = "UpdatedName";
|
|
197 |
map[hsItemDescription] = "UpdatedDescription";
|
|
198 |
|
|
199 |
map[hsitemLaunchUri] = "appto://102828D6?";
|
|
200 |
map[hsitemPublisherId] = "tappModuleTestUpdated";
|
|
201 |
map[hsItemWidgetUri] = "hsclockwidgetpluginUpdated";
|
|
202 |
|
|
203 |
map[hsIconFileName] = "Z:\\private\\20022F35\\import\\widgetregistry\\20022F6C\\UpdatedClockIcon.png";
|
|
204 |
map[hsIconName] = "qtg_large_applications_user_updated";
|
|
205 |
map[hsIconApplicationId] = "123458321";
|
|
206 |
|
|
207 |
// create original entry to be updated
|
|
208 |
mCaServicePrivateMock->AddEntriesForUpdate();
|
|
209 |
|
|
210 |
QScopedPointer<HsMenuClient> publisher (new HsMenuClient());
|
|
211 |
QVERIFY(publisher->add(map));
|
|
212 |
|
|
213 |
// from mock
|
|
214 |
QSharedPointer<CaEntry> res_entry = mCaServicePrivateMock->mCreatedEntries[1];
|
|
215 |
|
|
216 |
QCOMPARE(res_entry->entryTypeName(),
|
|
217 |
QString(Hs::templatedApplicationTypeName));
|
|
218 |
QCOMPARE(res_entry->role(), ItemEntryRole);
|
|
219 |
QCOMPARE(res_entry->flags(), VisibleEntryFlag); // Visible by default, entry not removable
|
|
220 |
|
|
221 |
QCOMPARE(res_entry->text(), map[hsItemName].toString());
|
|
222 |
QCOMPARE(res_entry->description(), map[hsItemDescription].toString());
|
|
223 |
QCOMPARE(res_entry->attributes().count(), 3);
|
|
224 |
QCOMPARE(res_entry->attribute(hsitemLaunchUri), map[hsitemLaunchUri].toString());
|
|
225 |
QCOMPARE(res_entry->attribute(hsitemPublisherId), map[hsitemPublisherId].toString());
|
|
226 |
QCOMPARE(res_entry->attribute(hsItemWidgetUri), map[hsItemWidgetUri].toString());
|
|
227 |
|
|
228 |
// icon
|
|
229 |
QCOMPARE(res_entry->iconDescription().filename(), map[hsIconFileName].toString());
|
|
230 |
QCOMPARE(res_entry->iconDescription().skinId(),map[hsIconName].toString());
|
|
231 |
QCOMPARE(res_entry->iconDescription().applicationId(), map[hsIconApplicationId].toString());
|
|
232 |
}
|
|
233 |
#ifdef Q_OS_SYMBIAN
|
|
234 |
#ifdef UT_MEMORY_CHECK
|
|
235 |
__UHEAP_MARKEND;
|
|
236 |
#endif//UT_MEMORY_CHECK
|
|
237 |
#endif//Q_OS_SYMBIAN
|
|
238 |
}
|
|
239 |
|
|
240 |
void HsMenuClientPluginTest::testRemoveEntry()
|
|
241 |
{
|
|
242 |
#ifdef Q_OS_SYMBIAN
|
|
243 |
#ifdef UT_MEMORY_CHECK
|
|
244 |
__UHEAP_MARK;
|
|
245 |
#endif//UT_MEMORY_CHECK
|
|
246 |
#endif//Q_OS_SYMBIAN
|
|
247 |
{
|
|
248 |
QMap<QString, QVariant> map;
|
|
249 |
map[hsItemName] = "ModuleTestTApp";
|
|
250 |
map[hsitemLaunchUri] = "appto://2002DCEC?";
|
|
251 |
map[hsitemPublisherId] = "tappModuleTest";
|
|
252 |
map[hsItemDescription] = "Unit test app for HsClientPlugin";
|
|
253 |
map[hsIconApplicationId] = "268458321";
|
|
254 |
|
|
255 |
HsMenuClient *publisher = new HsMenuClient();
|
|
256 |
bool result = publisher->remove(map);
|
|
257 |
QVERIFY(!result);
|
|
258 |
|
|
259 |
mCaServicePrivateMock->mEntryToRemove = -1;
|
|
260 |
map[hsItemId] = 1; // entry id == 1
|
|
261 |
result = publisher->remove(map);
|
|
262 |
QCOMPARE(mCaServicePrivateMock->mEntryToRemove, map[hsItemId].toInt());
|
|
263 |
delete publisher;
|
|
264 |
}
|
|
265 |
#ifdef Q_OS_SYMBIAN
|
|
266 |
#ifdef UT_MEMORY_CHECK
|
|
267 |
__UHEAP_MARKEND;
|
|
268 |
#endif//UT_MEMORY_CHECK
|
|
269 |
#endif//Q_OS_SYMBIAN
|
|
270 |
}
|
|
271 |
|
|
272 |
void HsMenuClientPluginTest::testListEntry()
|
|
273 |
{
|
|
274 |
#ifdef Q_OS_SYMBIAN
|
|
275 |
#ifdef UT_MEMORY_CHECK
|
|
276 |
__UHEAP_MARK;
|
|
277 |
#endif//UT_MEMORY_CHECK
|
|
278 |
#endif//Q_OS_SYMBIAN
|
|
279 |
{
|
|
280 |
QMap<QString, QVariant> map;
|
|
281 |
map[hsItemName] = "Name";
|
|
282 |
map[hsItemDescription] = "Description";
|
|
283 |
|
|
284 |
map[hsitemLaunchUri] = "appto://102828D6?";
|
|
285 |
map[hsitemPublisherId] = "tappModuleTest";
|
|
286 |
map[hsItemWidgetUri] = "hsclockwidgetplugin";
|
|
287 |
map[hsIconFileName] = "Z:\\private\\20022F35\\import\\widgetregistry\\20022F6C\\clockIcon.png";
|
|
288 |
map[hsIconName] = "qtg_large_applications_user";
|
|
289 |
map[hsIconApplicationId] = "223458321";
|
|
290 |
|
|
291 |
HsMenuClient *publisher = new HsMenuClient();
|
|
292 |
QList<QVariantMap> list;
|
|
293 |
list = publisher->getList(map);
|
|
294 |
|
|
295 |
// verify query passed to GetEntries
|
|
296 |
QCOMPARE(mCaServicePrivateMock->mQueryPassedToGetList->flagsOn(), VisibleEntryFlag);
|
|
297 |
QCOMPARE(mCaServicePrivateMock->mQueryPassedToGetList->entryRoles(), ItemEntryRole);
|
|
298 |
QCOMPARE(mCaServicePrivateMock->mQueryPassedToGetList->entryTypeNames(),
|
|
299 |
QStringList(Hs::templatedApplicationTypeName));
|
|
300 |
|
|
301 |
QCOMPARE(mCaServicePrivateMock->mQueryPassedToGetList->attribute(hsItemName), QString()); // not used
|
|
302 |
QCOMPARE(mCaServicePrivateMock->mQueryPassedToGetList->attribute(hsItemDescription), QString()); // not used
|
|
303 |
|
|
304 |
QCOMPARE(mCaServicePrivateMock->mQueryPassedToGetList->attribute(hsitemLaunchUri),
|
|
305 |
map.value(hsitemLaunchUri).toString());
|
|
306 |
QCOMPARE(mCaServicePrivateMock->mQueryPassedToGetList->attribute(hsitemPublisherId),
|
|
307 |
map.value(hsitemPublisherId).toString());
|
|
308 |
QCOMPARE(mCaServicePrivateMock->mQueryPassedToGetList->attribute(hsItemWidgetUri),
|
|
309 |
map.value(hsItemWidgetUri).toString());
|
|
310 |
QCOMPARE(mCaServicePrivateMock->mQueryPassedToGetList->attribute(hsIconFileName),
|
|
311 |
map.value(hsIconFileName).toString());
|
|
312 |
QCOMPARE(mCaServicePrivateMock->mQueryPassedToGetList->attribute(hsIconName),
|
|
313 |
map.value(hsIconName).toString());
|
|
314 |
QCOMPARE(mCaServicePrivateMock->mQueryPassedToGetList->attribute(hsIconApplicationId),
|
|
315 |
map.value(hsIconApplicationId).toString());
|
|
316 |
|
|
317 |
// Verify if all values are added to the map
|
|
318 |
QVERIFY(list.count() == 2);
|
|
319 |
QSharedPointer<CaEntry> res_entry = mCaServicePrivateMock->mReturnedEntries[0];
|
|
320 |
QCOMPARE(res_entry->id(), list.at(0).value(hsItemId).toInt());
|
|
321 |
QCOMPARE(res_entry->text(), list.at(0).value(hsItemName).toString());
|
|
322 |
QCOMPARE(res_entry->description(), list.at(0).value(hsItemDescription).toString());
|
|
323 |
QCOMPARE(res_entry->attribute(hsitemLaunchUri), list.at(0).value(hsitemLaunchUri).toString());
|
|
324 |
QCOMPARE(res_entry->attribute(hsitemPublisherId), list.at(0).value(hsitemPublisherId).toString());
|
|
325 |
QCOMPARE(res_entry->attribute(hsItemWidgetUri), list.at(0).value(hsItemWidgetUri).toString());
|
|
326 |
QCOMPARE(res_entry->iconDescription().filename(), list.at(0).value(hsIconFileName).toString());
|
|
327 |
QCOMPARE(res_entry->iconDescription().skinId(),list.at(0).value(hsIconName).toString());
|
|
328 |
QCOMPARE(res_entry->iconDescription().applicationId(), list.at(0).value(hsIconApplicationId).toString());
|
|
329 |
|
|
330 |
res_entry = mCaServicePrivateMock->mReturnedEntries[1];
|
|
331 |
QCOMPARE(res_entry->id(), list.at(1).value(hsItemId).toInt());
|
|
332 |
QCOMPARE(res_entry->text(), list.at(1).value(hsItemName).toString());
|
|
333 |
QCOMPARE(res_entry->description(), list.at(1).value(hsItemDescription).toString());
|
|
334 |
QCOMPARE(res_entry->attribute(hsitemLaunchUri), list.at(1).value(hsitemLaunchUri).toString());
|
|
335 |
QCOMPARE(res_entry->attribute(hsitemPublisherId), list.at(1).value(hsitemPublisherId).toString());
|
|
336 |
QCOMPARE(res_entry->attribute(hsItemWidgetUri), list.at(1).value(hsItemWidgetUri).toString());
|
|
337 |
QCOMPARE(res_entry->iconDescription().filename(), list.at(1).value(hsIconFileName).toString());
|
|
338 |
QCOMPARE(res_entry->iconDescription().skinId(),list.at(1).value(hsIconName).toString());
|
|
339 |
QCOMPARE(res_entry->iconDescription().applicationId(), list.at(1).value(hsIconApplicationId).toString());
|
|
340 |
delete publisher;
|
|
341 |
}
|
|
342 |
#ifdef Q_OS_SYMBIAN
|
|
343 |
#ifdef UT_MEMORY_CHECK
|
|
344 |
__UHEAP_MARKEND;
|
|
345 |
#endif//UT_MEMORY_CHECK
|
|
346 |
#endif//Q_OS_SYMBIAN
|
|
347 |
}
|
|
348 |
|
|
349 |
QTEST_MAIN(HsMenuClientPluginTest)
|