Changeset View
Changeset View
Standalone View
Standalone View
runners/services/autotests/servicerunnertest.cpp
Show All 35 Lines | 35 | { | |||
---|---|---|---|---|---|
36 | Q_OBJECT | 36 | Q_OBJECT | ||
37 | private Q_SLOTS: | 37 | private Q_SLOTS: | ||
38 | void initTestCase(); | 38 | void initTestCase(); | ||
39 | void cleanupTestCase(); | 39 | void cleanupTestCase(); | ||
40 | 40 | | |||
41 | void testChromeAppsRelevance(); | 41 | void testChromeAppsRelevance(); | ||
42 | void testKonsoleVsYakuakeComment(); | 42 | void testKonsoleVsYakuakeComment(); | ||
43 | void testSystemSettings(); | 43 | void testSystemSettings(); | ||
44 | void testFlatpakConflict(); | ||||
44 | }; | 45 | }; | ||
45 | 46 | | |||
46 | void ServiceRunnerTest::initTestCase() | 47 | void ServiceRunnerTest::initTestCase() | ||
47 | { | 48 | { | ||
48 | QStandardPaths::setTestModeEnabled(true); | 49 | QStandardPaths::setTestModeEnabled(true); | ||
49 | 50 | | |||
50 | auto appsPath = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation); | 51 | auto appsPath = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation); | ||
51 | QDir(appsPath).removeRecursively(); | 52 | QDir(appsPath).removeRecursively(); | ||
▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Line(s) | 150 | for (auto match : context.matches()) { | |||
154 | if (match.text() == QLatin1String("KDE System Settings ServiceRunnerTest")) { | 155 | if (match.text() == QLatin1String("KDE System Settings ServiceRunnerTest")) { | ||
155 | foreignSystemSettingsFound = true; | 156 | foreignSystemSettingsFound = true; | ||
156 | } | 157 | } | ||
157 | } | 158 | } | ||
158 | QVERIFY(systemSettingsFound); | 159 | QVERIFY(systemSettingsFound); | ||
159 | QVERIFY(!foreignSystemSettingsFound); | 160 | QVERIFY(!foreignSystemSettingsFound); | ||
160 | } | 161 | } | ||
161 | 162 | | |||
163 | void ServiceRunnerTest::testFlatpakConflict() | ||||
164 | { | ||||
165 | // flatpaks have additional noise in their Exec lines that can mess with | ||||
166 | // finding results. | ||||
167 | // When looking for 'ding' we'll have the actual ding application as well | ||||
168 | // as konversation flatpak matching. Konversation can match because its | ||||
169 | // Exec contains an argument --forwarDING. | ||||
170 | ServiceRunner runner(this, QVariantList()); | ||||
171 | Plasma::RunnerContext context; | ||||
172 | context.setQuery(QStringLiteral("ding")); | ||||
173 | | ||||
174 | runner.match(context); | ||||
175 | | ||||
176 | bool dingFound = false; | ||||
177 | bool konversationFound = false; | ||||
178 | for (auto match : context.matches()) { | ||||
179 | qDebug() << "matched" << match.text(); | ||||
180 | if (match.text() == QLatin1String("Ding: Dictionary English-German")) { | ||||
181 | dingFound = true; | ||||
182 | } | ||||
183 | if (match.text() == QLatin1String("Konversation Flatpak")) { | ||||
184 | konversationFound = true; | ||||
185 | } | ||||
186 | } | ||||
187 | QVERIFY(dingFound); | ||||
188 | QVERIFY(!konversationFound); | ||||
189 | } | ||||
190 | | ||||
191 | | ||||
162 | QTEST_MAIN(ServiceRunnerTest) | 192 | QTEST_MAIN(ServiceRunnerTest) | ||
163 | 193 | | |||
164 | #include "servicerunnertest.moc" | 194 | #include "servicerunnertest.moc" |