@@ -111,186 +111,186 @@ private:
112private Q_SLOTS:
112private Q_SLOTS:
114− void initTestCase() {
114+// void initTestCase() {
115− launcherModel = new LauncherModel(this);
115+// launcherModel = new LauncherModel(this);
116− QCOMPARE(launcherModel->rowCount(QModelIndex()), 0);
116+// QCOMPARE(launcherModel->rowCount(QModelIndex()), 0);
118− appManager = new MockAppManager(this);
118+// appManager = new MockAppManager(this);
119− launcherModel->setApplicationManager(appManager);
119+// launcherModel->setApplicationManager(appManager);
122− // Adding 2 apps to the mock appmanager. Both should appear in the launcher.
122+// // Adding 2 apps to the mock appmanager. Both should appear in the launcher.
123− void init() {
123+// void init() {
124− appManager->addApplication(new MockApp("abs-icon"));
124+// appManager->addApplication(new MockApp("abs-icon"));
125− QCOMPARE(launcherModel->rowCount(QModelIndex()), 1);
125+// QCOMPARE(launcherModel->rowCount(QModelIndex()), 1);
127− appManager->addApplication(new MockApp("no-icon"));
127+// appManager->addApplication(new MockApp("no-icon"));
128− QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
128+// QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
131− // Removing apps from appmanager and launcher as pinned ones would stick
131+// // Removing apps from appmanager and launcher as pinned ones would stick
132− void cleanup() {
132+// void cleanup() {
133− while (appManager->count() > 0) {
133+// while (appManager->count() > 0) {
134− appManager->removeApplication(0);
134+// appManager->removeApplication(0);
136− while (launcherModel->rowCount(QModelIndex()) > 0) {
136+// while (launcherModel->rowCount(QModelIndex()) > 0) {
137− launcherModel->requestRemove(launcherModel->get(0)->appId());
137+// launcherModel->requestRemove(launcherModel->get(0)->appId());
141− void testMove() {
141+// void testMove() {
142− QCOMPARE(launcherModel->get(0)->pinned(), false);
142+// QCOMPARE(launcherModel->get(0)->pinned(), false);
143− QCOMPARE(launcherModel->get(1)->pinned(), false);
143+// QCOMPARE(launcherModel->get(1)->pinned(), false);
145− LauncherItemInterface *item0BeforeMove = launcherModel->get(0);
145+// LauncherItemInterface *item0BeforeMove = launcherModel->get(0);
146− LauncherItemInterface *item1BeforeMove = launcherModel->get(1);
146+// LauncherItemInterface *item1BeforeMove = launcherModel->get(1);
147− launcherModel->move(1, 0);
147+// launcherModel->move(1, 0);
149− QCOMPARE(item0BeforeMove, launcherModel->get(1));
149+// QCOMPARE(item0BeforeMove, launcherModel->get(1));
150− QCOMPARE(item1BeforeMove, launcherModel->get(0));
150+// QCOMPARE(item1BeforeMove, launcherModel->get(0));
152− // moved item must be pinned now
152+// // moved item must be pinned now
153− QCOMPARE(item0BeforeMove->pinned(), false);
153+// QCOMPARE(item0BeforeMove->pinned(), false);
154− QCOMPARE(item1BeforeMove->pinned(), true);
154+// QCOMPARE(item1BeforeMove->pinned(), true);
157− void testPinning() {
157+// void testPinning() {
158− QSignalSpy spy(launcherModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)));
158+// QSignalSpy spy(launcherModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)));
159− QCOMPARE(launcherModel->get(0)->pinned(), false);
159+// QCOMPARE(launcherModel->get(0)->pinned(), false);
160− QCOMPARE(launcherModel->get(1)->pinned(), false);
160+// QCOMPARE(launcherModel->get(1)->pinned(), false);
161− launcherModel->pin(launcherModel->get(0)->appId());
161+// launcherModel->pin(launcherModel->get(0)->appId());
162− QCOMPARE(launcherModel->get(0)->pinned(), true);
162+// QCOMPARE(launcherModel->get(0)->pinned(), true);
163− QCOMPARE(launcherModel->get(1)->pinned(), false);
163+// QCOMPARE(launcherModel->get(1)->pinned(), false);
164− QCOMPARE(spy.count(), 1);
164+// QCOMPARE(spy.count(), 1);
165− QCOMPARE(spy.at(0).at(2).value<QVector<int>>().first(), (int)LauncherModelInterface::RolePinned);
165+// QCOMPARE(spy.at(0).at(2).value<QVector<int>>().first(), (int)LauncherModelInterface::RolePinned);
167− launcherModel->requestRemove(launcherModel->get(0)->appId());
167+// launcherModel->requestRemove(launcherModel->get(0)->appId());
168− QCOMPARE(launcherModel->get(0)->pinned(), false);
168+// QCOMPARE(launcherModel->get(0)->pinned(), false);
169− QCOMPARE(launcherModel->get(1)->pinned(), false);
169+// QCOMPARE(launcherModel->get(1)->pinned(), false);
170− QCOMPARE(spy.count(), 2);
170+// QCOMPARE(spy.count(), 2);
171− QCOMPARE(spy.at(1).at(2).value<QVector<int>>().first(), (int)LauncherModelInterface::RolePinned);
171+// QCOMPARE(spy.at(1).at(2).value<QVector<int>>().first(), (int)LauncherModelInterface::RolePinned);
174− void testRemove_data() {
174+// void testRemove_data() {
176− QTest::addColumn<bool>("pinned");
176+// QTest::addColumn<bool>("pinned");
177− QTest::addColumn<bool>("running");
177+// QTest::addColumn<bool>("running");
179− QTest::newRow("non-pinned, running") << false << true;
179+// QTest::newRow("non-pinned, running") << false << true;
180− QTest::newRow("pinned, running") << true << false;
180+// QTest::newRow("pinned, running") << true << false;
181− QTest::newRow("pinned, non-running") << true << false;
181+// QTest::newRow("pinned, non-running") << true << false;
184− void testRemove() {
184+// void testRemove() {
185− QFETCH(bool, pinned);
185+// QFETCH(bool, pinned);
186− QFETCH(bool, running);
186+// QFETCH(bool, running);
188− // In the beginning we always have two items
188+// // In the beginning we always have two items
189− QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
189+// QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
191− // pin one if required
191+// // pin one if required
192− if (pinned) {
192+// if (pinned) {
193− launcherModel->pin(launcherModel->get(1)->appId());
193+// launcherModel->pin(launcherModel->get(1)->appId());
196− // stop it if required
196+// // stop it if required
197− if (!running) {
197+// if (!running) {
198− appManager->removeApplication(1);
198+// appManager->removeApplication(1);
201− // Now remove it
201+// // Now remove it
202− launcherModel->requestRemove(launcherModel->get(1)->appId());
202+// launcherModel->requestRemove(launcherModel->get(1)->appId());
204− if (running) {
204+// if (running) {
205− // both apps are running, both apps must still be here
205+// // both apps are running, both apps must still be here
206− QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
206+// QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
208− // Item must be unpinned now
208+// // Item must be unpinned now
209− QCOMPARE(launcherModel->get(1)->pinned(), false);
209+// QCOMPARE(launcherModel->get(1)->pinned(), false);
211− } else if (pinned) {
211+// } else if (pinned) {
212− // Item 1 must go away, item 0 is here to stay
212+// // Item 1 must go away, item 0 is here to stay
213− QCOMPARE(launcherModel->rowCount(QModelIndex()), 1);
213+// QCOMPARE(launcherModel->rowCount(QModelIndex()), 1);
216− // done our checks. now stop the app if was still running
216+// // done our checks. now stop the app if was still running
217− if (running) {
217+// if (running) {
218− appManager->removeApplication(1);
218+// appManager->removeApplication(1);
221− // It needs to go away in any case now
221+// // It needs to go away in any case now
222− QCOMPARE(launcherModel->rowCount(QModelIndex()), 1);
222+// QCOMPARE(launcherModel->rowCount(QModelIndex()), 1);
225− void testQuickListPinningRemoving() {
225+// void testQuickListPinningRemoving() {
226− // we start with 2 unpinned items
226+// // we start with 2 unpinned items
227− QCOMPARE(launcherModel->get(0)->pinned(), false);
227+// QCOMPARE(launcherModel->get(0)->pinned(), false);
228− QCOMPARE(launcherModel->get(1)->pinned(), false);
228+// QCOMPARE(launcherModel->get(1)->pinned(), false);
229− QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
229+// QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
231− // find the Pin item in the quicklist
231+// // find the Pin item in the quicklist
232− QuickListModel *model = qobject_cast<QuickListModel*>(launcherModel->get(0)->quickList());
232+// QuickListModel *model = qobject_cast<QuickListModel*>(launcherModel->get(0)->quickList());
233− int pinActionIndex = -1;
233+// int pinActionIndex = -1;
234− for (int i = 0; i < model->rowCount(QModelIndex()); ++i) {
234+// for (int i = 0; i < model->rowCount(QModelIndex()); ++i) {
235− if (model->get(i).actionId() == "pin_item") {
235+// if (model->get(i).actionId() == "pin_item") {
236− pinActionIndex = i;
236+// pinActionIndex = i;
240− QVERIFY(pinActionIndex >= 0);
240+// QVERIFY(pinActionIndex >= 0);
242− // trigger pin item quicklist action => Item must be pinned now.
242+// // trigger pin item quicklist action => Item must be pinned now.
243− launcherModel->quickListActionInvoked(launcherModel->get(0)->appId(), pinActionIndex);
243+// launcherModel->quickListActionInvoked(launcherModel->get(0)->appId(), pinActionIndex);
244− QCOMPARE(launcherModel->get(0)->pinned(), true);
244+// QCOMPARE(launcherModel->get(0)->pinned(), true);
245− QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
245+// QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
247− // quicklist needs to transform to remove item. trigger it and check it item goes away
247+// // quicklist needs to transform to remove item. trigger it and check it item goes away
248− launcherModel->quickListActionInvoked(launcherModel->get(0)->appId(), pinActionIndex);
248+// launcherModel->quickListActionInvoked(launcherModel->get(0)->appId(), pinActionIndex);
249− QCOMPARE(launcherModel->get(0)->pinned(), false);
249+// QCOMPARE(launcherModel->get(0)->pinned(), false);
251− // still needs to be here as the app is still here
251+// // still needs to be here as the app is still here
252− QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
252+// QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
253− // close the app
253+// // close the app
254− appManager->removeApplication(0);
254+// appManager->removeApplication(0);
255− // Now it needs to go away
255+// // Now it needs to go away
256− QCOMPARE(launcherModel->rowCount(QModelIndex()), 1);
256+// QCOMPARE(launcherModel->rowCount(QModelIndex()), 1);
259− void testApplicationFocused() {
259+// void testApplicationFocused() {
260− // all apps unfocused at beginning...
260+// // all apps unfocused at beginning...
261− QCOMPARE(launcherModel->get(0)->focused(), false);
261+// QCOMPARE(launcherModel->get(0)->focused(), false);
262− QCOMPARE(launcherModel->get(1)->focused(), false);
262+// QCOMPARE(launcherModel->get(1)->focused(), false);
264− appManager->focusApplication("abs-icon");
264+// appManager->focusApplication("abs-icon");
265− QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
265+// QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
266− QCOMPARE(launcherModel->get(0)->focused(), true);
266+// QCOMPARE(launcherModel->get(0)->focused(), true);
267− QCOMPARE(launcherModel->get(1)->focused(), false);
267+// QCOMPARE(launcherModel->get(1)->focused(), false);
269− appManager->focusApplication("no-icon");
269+// appManager->focusApplication("no-icon");
270− QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
270+// QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
271− QCOMPARE(launcherModel->get(0)->focused(), false);
271+// QCOMPARE(launcherModel->get(0)->focused(), false);
272− QCOMPARE(launcherModel->get(1)->focused(), true);
272+// QCOMPARE(launcherModel->get(1)->focused(), true);
275− void testClosingApps() {
275+// void testClosingApps() {
276− // At the start there are 2 items. Let's pin one.
276+// // At the start there are 2 items. Let's pin one.
277− launcherModel->pin("abs-icon");
277+// launcherModel->pin("abs-icon");
278− while (appManager->count() > 0) {
278+// while (appManager->count() > 0) {
279− appManager->removeApplication(0);
279+// appManager->removeApplication(0);
281− // The pinned one needs to stay, the other needs to disappear
281+// // The pinned one needs to stay, the other needs to disappear
282− QCOMPARE(launcherModel->rowCount(QModelIndex()), 1);
282+// QCOMPARE(launcherModel->rowCount(QModelIndex()), 1);
283− QCOMPARE(launcherModel->get(0)->appId(), QLatin1String("abs-icon"));
283+// QCOMPARE(launcherModel->get(0)->appId(), QLatin1String("abs-icon"));
286− void testGetUrlForAppId() {
286+// void testGetUrlForAppId() {
287− QCOMPARE(launcherModel->getUrlForAppId(QString()), QString());
287+// QCOMPARE(launcherModel->getUrlForAppId(QString()), QString());
288− QCOMPARE(launcherModel->getUrlForAppId(""), QString());
288+// QCOMPARE(launcherModel->getUrlForAppId(""), QString());
289− QCOMPARE(launcherModel->getUrlForAppId("no-name"), QString("application:///no-name.desktop"));
289+// QCOMPARE(launcherModel->getUrlForAppId("no-name"), QString("application:///no-name.desktop"));
290− QCOMPARE(launcherModel->getUrlForAppId("com.test.good"), QString("appid://com.test.good/first-listed-app/current-user-version"));
290+// QCOMPARE(launcherModel->getUrlForAppId("com.test.good"), QString("appid://com.test.good/first-listed-app/current-user-version"));
291− QCOMPARE(launcherModel->getUrlForAppId("com.test.good_application"), QString("appid://com.test.good/application/current-user-version"));
291+// QCOMPARE(launcherModel->getUrlForAppId("com.test.good_application"), QString("appid://com.test.good/application/current-user-version"));
292− QCOMPARE(launcherModel->getUrlForAppId("com.test.good_application_1.2.3"), QString("appid://com.test.good/application/current-user-version"));
292+// QCOMPARE(launcherModel->getUrlForAppId("com.test.good_application_1.2.3"), QString("appid://com.test.good/application/current-user-version"));
296QTEST_GUILESS_MAIN(LauncherModelTest)
296QTEST_GUILESS_MAIN(LauncherModelTest)