2 * Copyright 2013 Canonical Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 * Michael Terry <michael.terry@canonical.com>
20#include "launcherbackend.h"
25class LauncherBackendTest : public QObject
32 LauncherBackend backend(false);
34 backend.setStoredApplications(QStringList() << "relative.path" << "/full/path");
35 QCOMPARE(backend.storedApplications(), QStringList() << "/usr/share/applications/relative.path" << "/full/path");
37 QCOMPARE(backend.desktopFile("one.desktop"), QString("/usr/share/applications/one.desktop"));
38 QCOMPARE(backend.desktopFile("two"), QString("/usr/share/applications/two"));
39 QCOMPARE(backend.desktopFile("/full"), QString("/full"));
41 QCOMPARE(backend.desktopFile("/usr/share/applications/one.desktop"), QString("/usr/share/applications/one.desktop"));
44 void testDesktopReading()
46 LauncherBackend backend(false);
48 QCOMPARE(backend.displayName(SRCDIR "/rel-icon.desktop"), QString("Relative Icon"));
49 QCOMPARE(backend.icon(SRCDIR "/rel-icon.desktop"), QString("image://gicon/rel-icon"));
51 QCOMPARE(backend.displayName(SRCDIR "/abs-icon.desktop"), QString("Absolute Icon"));
52 QCOMPARE(backend.icon(SRCDIR "/abs-icon.desktop"), QString("/path/to/icon.png"));
54 QCOMPARE(backend.displayName(SRCDIR "/no-icon.desktop"), QString("No Icon"));
55 QCOMPARE(backend.icon(SRCDIR "/no-icon.desktop"), QString(""));
57 QCOMPARE(backend.displayName(SRCDIR "/no-name.desktop"), QString(""));
58 QCOMPARE(backend.icon(SRCDIR "/no-name.desktop"), QString("image://gicon/no-name"));
60 QCOMPARE(backend.displayName(SRCDIR "/no-exist.desktop"), QString(""));
61 QCOMPARE(backend.icon(SRCDIR "/no-exist.desktop"), QString(""));
66 LauncherBackend backend(false);
68 // Confirm that default entries are all pinned
69 auto defaultApps = backend.storedApplications();
70 QVERIFY(defaultApps.size() > 0);
71 for (auto app: defaultApps) {
72 QCOMPARE(backend.isPinned(app), true);
75 backend.setStoredApplications(QStringList() << "one" << "two");
76 QCOMPARE(backend.isPinned("one"), false);
77 QCOMPARE(backend.isPinned("two"), false);
79 backend.setPinned("two", true);
80 QCOMPARE(backend.isPinned("two"), true);
82 backend.setStoredApplications(QStringList() << "one" << "two" << "three");
83 QCOMPARE(backend.isPinned("two"), true);
84 QCOMPARE(backend.isPinned("three"), false);
86 backend.setPinned("three", true);
87 backend.setStoredApplications(QStringList() << "one" << "two");
88 QCOMPARE(backend.isPinned("two"), true);
89 QCOMPARE(backend.isPinned("three"), false); // doesn't exist anymore!
93QTEST_GUILESS_MAIN(LauncherBackendTest)
94#include "launcherbackendtest.moc"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list