@@ -62,7 +62,14 @@ public:
62 return QString();
62 return QString();
64 unity::shell::application::ApplicationInfoInterface *get(int index) const { return m_list.at(index); }
64 unity::shell::application::ApplicationInfoInterface *get(int index) const { return m_list.at(index); }
65− unity::shell::application::ApplicationInfoInterface *findApplication(const QString &) const { return nullptr; }
65+ unity::shell::application::ApplicationInfoInterface *findApplication(const QString &appId) const {
66+ Q_FOREACH(MockApp* app, m_list) {
67+ if (app->appId() == appId) {
66 unity::shell::application::ApplicationInfoInterface *startApplication(const QString &, const QStringList &) { return nullptr; }
73 unity::shell::application::ApplicationInfoInterface *startApplication(const QString &, const QStringList &) { return nullptr; }
67 bool stopApplication(const QString &) { return false; }
74 bool stopApplication(const QString &) { return false; }
68 bool focusApplication(const QString &appId) {
75 bool focusApplication(const QString &appId) {
@@ -151,9 +158,59 @@ private Q_SLOTS:
151 QCOMPARE(launcherModel->get(1)->pinned(), false);
158 QCOMPARE(launcherModel->get(1)->pinned(), false);
161+ void testRemove_data() {
163+ QTest::addColumn<bool>("pinned");
164+ QTest::addColumn<bool>("running");
166+ // Needs to kepp the item as long as running and needs to remove it when app is closed
167+ QTest::newRow("non-pinned, running") << false << true;
169+ // Needs to kepp the item as long as running and needs to remove it when app is closed
170+ QTest::newRow("pinned, running") << true << false;
172+ // Needs to kepp the item as long as running and needs to remove it when app is closed
173+ QTest::newRow("pinned, non-running") << true << false;
154 void testRemove() {
176 void testRemove() {
177+ QFETCH(bool, pinned);
178+ QFETCH(bool, running);
180+ // In the beginning we always have to items
155 QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
181 QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
183+ // pin one if required
185+ launcherModel->pin(launcherModel->get(1)->appId());
188+ // stop it if required
190+ appManager->removeApplication(1);
156− launcherModel->requestRemove(launcherModel->get(0)->appId());
194+ launcherModel->requestRemove(launcherModel->get(1)->appId());
197+ // bot apps are running, both apps must still be here
198+ QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
200+ // Item must be unpinned now
201+ QCOMPARE(launcherModel->get(1)->pinned(), false);
203+ } else if (pinned) {
204+ // Item 1 must go away, item 0 is here to stay
205+ QCOMPARE(launcherModel->rowCount(QModelIndex()), 1);
208+ // done our checks. now stop the app if was still running
210+ appManager->removeApplication(1);
213+ // It needs to go away in any case now
157 QCOMPARE(launcherModel->rowCount(QModelIndex()), 1);
214 QCOMPARE(launcherModel->rowCount(QModelIndex()), 1);
@@ -181,6 +238,13 @@ private Q_SLOTS:
182 // quicklist needs to transform to remove item. trigger it and check it item goes away
239 // quicklist needs to transform to remove item. trigger it and check it item goes away
183 launcherModel->quickListActionInvoked(launcherModel->get(0)->appId(), pinActionIndex);
240 launcherModel->quickListActionInvoked(launcherModel->get(0)->appId(), pinActionIndex);
241+ QCOMPARE(launcherModel->get(0)->pinned(), false);
243+ // still needs to be here as the app is still here
244+ QCOMPARE(launcherModel->rowCount(QModelIndex()), 2);
246+ appManager->removeApplication(0);
247+ // Now it needs to go away
184 QCOMPARE(launcherModel->rowCount(QModelIndex()), 1);
248 QCOMPARE(launcherModel->rowCount(QModelIndex()), 1);