on xenial help sign in
adjust tests
commit7ce17f4cb185f13f2e872aed2a8474f778345fc4 authorMichael Zanetti <michael.zanetti@canonical.com> dateWed 4 Sep 2013, 12:21 (13 years ago) parenta1187e4
3 files changed+34−20
plugins/Unity/Launcher/backend/launcherbackend.cpp+10−5 tests/plugins/Unity/Launcher/CMakeLists.txt+10 tests/plugins/Unity/Launcher/launcherbackendtest.cpp+14−15
plugins/Unity/Launcher/backend/launcherbackend.cpp+10−5
@@ -266,11 +266,16 @@ QString LauncherBackend::findDesktopFile(const QString &appId) const
266266 searchDirs << "/usr/share/applications";
267267
268268// FIXME: Right now the appId can be (or rather is) a full path
269−// to a .desktop file. This will change in the future. Remove this
270−// once the ApplicationManager has been switched over to use appIds.
269+// to a .desktop file. This will change in the future.
270+// Once the ApplicationManager has been switched over to use appIds,
271+// remove this chop() and enable the ifdef to only search the current
272+// working dir for testing. Also, this is the place to add the search
273+// paths for click apps in the next step.
274+ if (helper.endsWith(".desktop")) {
275+ helper.chop(8);
276+ }
277+//#ifdef LAUNCHER_TESTING
271278 searchDirs << "";
272−//#if LAUNCHER_TESTING
273−// searchDirs << "";
274279//#endif
275280
276281 do {
@@ -279,7 +284,7 @@ QString LauncherBackend::findDesktopFile(const QString &appId) const
279284 }
280285
281286 Q_FOREACH(const QString &searchDir, searchDirs) {
282− QFileInfo fileInfo(QDir(searchDir), helper);
287+ QFileInfo fileInfo(QDir(searchDir), helper + ".desktop");
283288 if (fileInfo.exists()) {
284289 return fileInfo.absoluteFilePath();
285290 }
tests/plugins/Unity/Launcher/CMakeLists.txt+10
@@ -10,6 +10,7 @@ include_directories(
1010
1111add_definitions(-DSM_BUSNAME=sessionBus)
1212add_definitions(-DSRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")
13+add_definitions(-DLAUNCHER_TESTING)
1314
1415set(testCommand ${CMAKE_CURRENT_BINARY_DIR}/launcherbackendtestExec
1516 -o ${CMAKE_BINARY_DIR}/launcherbackendtest.xml,xunitxml
@@ -24,3 +25,12 @@ add_executable(launcherbackendtestExec
2425 )
2526target_link_libraries(launcherbackendtestExec ${GSETTINGS_QT_LDFLAGS})
2627qt5_use_modules(launcherbackendtestExec Test Core DBus)
28+
29+# copy .desktop files into build directory for shadow builds
30+file(GLOB DESKTOP_FILES *.desktop)
31+
32+foreach(DESKTOP_FILE ${DESKTOP_FILES})
33+ file(COPY "${DESKTOP_FILE}"
34+ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
35+ )
36+endforeach()
tests/plugins/Unity/Launcher/launcherbackendtest.cpp+14−15
@@ -20,7 +20,6 @@
2020#include "launcherbackend.h"
2121
2222#include <QtTest>
23−#include <QDebug>
2423
2524class LauncherBackendTest : public QObject
2625{
@@ -31,29 +30,29 @@ private Q_SLOTS:
3130 {
3231 LauncherBackend backend(false);
3332
34− backend.setStoredApplications(QStringList() << "relative.path" << "/full/path");
35− QCOMPARE(backend.storedApplications(), QStringList() << "relative.path" << "/full/path");
33+ backend.setStoredApplications(QStringList() << "rel-icon.desktop" << "abs-icon" << "invalid");
34+ QCOMPARE(backend.storedApplications(), QStringList() << "rel-icon.desktop" << "abs-icon");
3635 }
3736
3837 void testPinning()
3938 {
4039 LauncherBackend backend(false);
4140
42− backend.setStoredApplications(QStringList() << "one" << "two");
43− QCOMPARE(backend.isPinned("one"), false);
44− QCOMPARE(backend.isPinned("two"), false);
41+ backend.setStoredApplications(QStringList() << "rel-icon" << "abs-icon");
42+ QCOMPARE(backend.isPinned("rel-icon"), false);
43+ QCOMPARE(backend.isPinned("abs-icon"), false);
4544
46− backend.setPinned("two", true);
47− QCOMPARE(backend.isPinned("two"), true);
45+ backend.setPinned("rel-icon", true);
46+ QCOMPARE(backend.isPinned("rel-icon"), true);
4847
49− backend.setStoredApplications(QStringList() << "one" << "two" << "three");
50− QCOMPARE(backend.isPinned("two"), true);
51− QCOMPARE(backend.isPinned("three"), false);
48+ backend.setStoredApplications(QStringList() << "rel-icon" << "abs-icon" << "no-name");
49+ QCOMPARE(backend.isPinned("rel-icon"), true);
50+ QCOMPARE(backend.isPinned("no-name"), false);
5251
53− backend.setPinned("three", true);
54− backend.setStoredApplications(QStringList() << "one" << "two");
55− QCOMPARE(backend.isPinned("two"), true);
56− QCOMPARE(backend.isPinned("three"), false); // doesn't exist anymore!
52+ backend.setPinned("no-name", true);
53+ backend.setStoredApplications(QStringList() << "rel-icon" << "abs-icon");
54+ QCOMPARE(backend.isPinned("rel-icon"), true);
55+ QCOMPARE(backend.isPinned("no-name"), false); // doesn't exist anymore!
5756 }
5857};
5958