Changeset View
Changeset View
Standalone View
Standalone View
runners/services/autotests/servicerunnertest.cpp
Show All 32 Lines | |||||
33 | { | 33 | { | ||
34 | Q_OBJECT | 34 | Q_OBJECT | ||
35 | private Q_SLOTS: | 35 | private Q_SLOTS: | ||
36 | void initTestCase(); | 36 | void initTestCase(); | ||
37 | void cleanupTestCase(); | 37 | void cleanupTestCase(); | ||
38 | 38 | | |||
39 | void testChromeAppsRelevance(); | 39 | void testChromeAppsRelevance(); | ||
40 | void testKonsoleVsYakuakeComment(); | 40 | void testKonsoleVsYakuakeComment(); | ||
41 | void testSystemSettings(); | ||||
41 | }; | 42 | }; | ||
42 | 43 | | |||
43 | void ServiceRunnerTest::initTestCase() | 44 | void ServiceRunnerTest::initTestCase() | ||
44 | { | 45 | { | ||
45 | QStandardPaths::setTestModeEnabled(true); | 46 | QStandardPaths::setTestModeEnabled(true); | ||
46 | 47 | | |||
47 | auto appsPath = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation); | 48 | auto appsPath = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation); | ||
48 | QDir(appsPath).removeRecursively(); | 49 | QDir(appsPath).removeRecursively(); | ||
49 | QVERIFY(QDir().mkpath(appsPath)); | 50 | QVERIFY(QDir().mkpath(appsPath)); | ||
50 | auto fixtureDir = QDir(QFINDTESTDATA("fixtures")); | 51 | auto fixtureDir = QDir(QFINDTESTDATA("fixtures")); | ||
51 | for(auto fileInfo : fixtureDir.entryInfoList(QDir::Files)) { | 52 | for(auto fileInfo : fixtureDir.entryInfoList(QDir::Files)) { | ||
52 | auto source = fileInfo.absoluteFilePath(); | 53 | auto source = fileInfo.absoluteFilePath(); | ||
53 | auto target = appsPath + QDir::separator() + fileInfo.fileName(); | 54 | auto target = appsPath + QDir::separator() + fileInfo.fileName(); | ||
54 | QVERIFY2(QFile::copy(fileInfo.absoluteFilePath(), target), | 55 | QVERIFY2(QFile::copy(fileInfo.absoluteFilePath(), target), | ||
55 | qPrintable(QString("can't copy %1 => %2").arg(source, target))); | 56 | qPrintable(QString("can't copy %1 => %2").arg(source, target))); | ||
56 | } | 57 | } | ||
57 | 58 | | |||
58 | setlocale(LC_ALL, "C.utf8"); | 59 | setlocale(LC_ALL, "C.utf8"); | ||
59 | 60 | | |||
60 | KSycoca::self()->ensureCacheValid(); | 61 | KSycoca::self()->ensureCacheValid(); | ||
62 | | ||||
63 | // Make sure noDisplay behaves consistently WRT OnlyShowIn etc. | ||||
64 | QVERIFY(setenv("XDG_CURRENT_DESKTOP", "KDE", 1) == 0); | ||||
65 | // NOTE: noDisplay also includes X-KDE-OnlyShowOnQtPlatforms which is a bit harder to fake | ||||
66 | // and not currently under testing anyway. | ||||
61 | } | 67 | } | ||
62 | 68 | | |||
63 | void ServiceRunnerTest::cleanupTestCase() | 69 | void ServiceRunnerTest::cleanupTestCase() | ||
64 | { | 70 | { | ||
65 | } | 71 | } | ||
66 | 72 | | |||
67 | void ServiceRunnerTest::testChromeAppsRelevance() | 73 | void ServiceRunnerTest::testChromeAppsRelevance() | ||
68 | { | 74 | { | ||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | 122 | } else if (match.text() == "Yakuake ServiceRunnerTest") { | |||
118 | QCOMPARE(match.relevance(), 0.59); | 124 | QCOMPARE(match.relevance(), 0.59); | ||
119 | yakuakeFound = true; | 125 | yakuakeFound = true; | ||
120 | } | 126 | } | ||
121 | } | 127 | } | ||
122 | QVERIFY(konsoleFound); | 128 | QVERIFY(konsoleFound); | ||
123 | QVERIFY(yakuakeFound); | 129 | QVERIFY(yakuakeFound); | ||
124 | } | 130 | } | ||
125 | 131 | | |||
132 | void ServiceRunnerTest::testSystemSettings() | ||||
133 | { | ||||
134 | // In 5.9.0 'System Settings' suddenly didn't come back as a match for 'settings' anymore. | ||||
135 | // Sytem Settings has a noKDE version and a KDE version, if the noKDE version is encountered | ||||
136 | // first it will be added to the seen cache, however disqualification of already seen items | ||||
137 | // may then also disqualify the KDE version of system settings on account of having already | ||||
138 | // seen it. This test makes sure we find the right version. | ||||
139 | ServiceRunner runner(this, QVariantList()); | ||||
140 | Plasma::RunnerContext context; | ||||
141 | context.setQuery("settings"); | ||||
142 | | ||||
143 | runner.match(context); | ||||
144 | | ||||
145 | bool systemSettingsFound = false; | ||||
146 | bool foreignSystemSettingsFound = false; | ||||
147 | for (auto match : context.matches()) { | ||||
148 | qDebug() << "matched" << match.text(); | ||||
149 | if (match.text() == "System Settings ServiceRunnerTest") { | ||||
150 | systemSettingsFound = true; | ||||
151 | } | ||||
152 | if (match.text() == "KDE System Settings ServiceRunnerTest") { | ||||
153 | foreignSystemSettingsFound = true; | ||||
154 | } | ||||
155 | } | ||||
156 | QVERIFY(systemSettingsFound); | ||||
157 | QVERIFY(!foreignSystemSettingsFound); | ||||
158 | } | ||||
159 | | ||||
126 | QTEST_MAIN(ServiceRunnerTest) | 160 | QTEST_MAIN(ServiceRunnerTest) | ||
127 | 161 | | |||
128 | #include "servicerunnertest.moc" | 162 | #include "servicerunnertest.moc" |