diff --git a/autotests/providertest.cpp b/autotests/providertest.cpp index 2f5dc1c..dfd8709 100644 --- a/autotests/providertest.cpp +++ b/autotests/providertest.cpp @@ -1,380 +1,380 @@ /* Copyright (C) 2016 Volker Krause Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include #include #include #include #include #include #include #include #include #include using namespace KUserFeedback; class ProviderTest : public QObject { Q_OBJECT private slots: void initTestCase() { QCoreApplication::setOrganizationName(QStringLiteral("KDE")); QCoreApplication::setOrganizationDomain(QStringLiteral("kde.org")); QCoreApplication::setApplicationName(QStringLiteral("providertest")); QStandardPaths::setTestModeEnabled(true); } void init() { QSettings s(QCoreApplication::organizationName(), QStringLiteral("UserFeedback"));; s.beginGroup(QLatin1String("UserFeedback")); s.remove(QLatin1String("LastEncouragement")); s.remove(QLatin1String("Enabled")); } void testProductId() { Provider p; QCOMPARE(p.productIdentifier(), QLatin1String("org.kde.providertest")); } void testNoTelemetry() { Provider provider; provider.setProductIdentifier(QStringLiteral("org.kde.UserFeedback.UnitTestProduct")); provider.addDataSource(new ScreenInfoSource); provider.addDataSource(new PlatformInfoSource); provider.setTelemetryMode(Provider::NoTelemetry); QByteArray b; QMetaObject::invokeMethod(&provider, "jsonData", Q_RETURN_ARG(QByteArray, b), Q_ARG(KUserFeedback::Provider::TelemetryMode, provider.telemetryMode())); b.replace('\n', ""); QCOMPARE(b.constData(), "{}"); } void testLoadStore() { { Provider p; p.setTelemetryMode(Provider::NoTelemetry); p.setSurveyInterval(-1); } { Provider p; QCOMPARE(p.telemetryMode(), Provider::NoTelemetry); QCOMPARE(p.surveyInterval(), -1); p.setTelemetryMode(Provider::DetailedSystemInformation); p.setSurveyInterval(90); } { Provider p; QCOMPARE(p.telemetryMode(), Provider::DetailedSystemInformation); QCOMPARE(p.surveyInterval(), 90); } } void testEncouragement() { { QSettings s(QCoreApplication::organizationName(), QStringLiteral("UserFeedback.org.kde.providertest"));; s.beginGroup(QLatin1String("UserFeedback")); s.remove(QLatin1String("LastEncouragement")); } { Provider p; QSignalSpy spy(&p, SIGNAL(showEncouragementMessage())); QVERIFY(spy.isValid()); p.setEncouragementDelay(0); QVERIFY(!spy.wait(10)); p.setApplicationStartsUntilEncouragement(0); p.setApplicationUsageTimeUntilEncouragement(0); QVERIFY(spy.wait(10)); QCOMPARE(spy.count(), 1); } { Provider p; QSignalSpy spy(&p, SIGNAL(showEncouragementMessage())); QVERIFY(spy.isValid()); p.setEncouragementDelay(0); p.setApplicationStartsUntilEncouragement(0); p.setApplicationUsageTimeUntilEncouragement(0); QVERIFY(!spy.wait(10)); } } void testEncouragementDelay() { { QSettings s(QCoreApplication::organizationName(), QStringLiteral("UserFeedback.org.kde.providertest"));; s.beginGroup(QLatin1String("UserFeedback")); s.remove(QLatin1String("LastEncouragement")); } { Provider p; QSignalSpy spy(&p, SIGNAL(showEncouragementMessage())); QVERIFY(spy.isValid()); p.setEncouragementDelay(1); p.setApplicationStartsUntilEncouragement(0); p.setApplicationUsageTimeUntilEncouragement(0); QVERIFY(!spy.wait(10)); QVERIFY(spy.wait(1200)); QCOMPARE(spy.count(), 1); } } void testNoEncouragementWithAllFeedbackEnabled() { { QSettings s(QCoreApplication::organizationName(), QStringLiteral("UserFeedback.org.kde.providertest"));; s.beginGroup(QLatin1String("UserFeedback")); s.remove(QLatin1String("LastEncouragement")); } { Provider p; p.addDataSource(new PlatformInfoSource); p.setSurveyInterval(0); p.setTelemetryMode(Provider::BasicSystemInformation); QSignalSpy spy(&p, SIGNAL(showEncouragementMessage())); QVERIFY(spy.isValid()); p.setEncouragementDelay(0); p.setApplicationStartsUntilEncouragement(0); p.setApplicationUsageTimeUntilEncouragement(0); QVERIFY(!spy.wait(10)); QCOMPARE(spy.count(), 0); } } void testEncouragementRepetition() { { QSettings s(QCoreApplication::organizationName(), QStringLiteral("UserFeedback.org.kde.providertest"));; s.beginGroup(QLatin1String("UserFeedback")); s.setValue(QLatin1String("LastEncouragement"), QDateTime::currentDateTime().addSecs(-24 * 60 * 60 + 1)); } { Provider p; p.setSurveyInterval(-1); p.setTelemetryMode(Provider::NoTelemetry); QSignalSpy spy(&p, SIGNAL(showEncouragementMessage())); QVERIFY(spy.isValid()); p.setEncouragementDelay(0); p.setApplicationStartsUntilEncouragement(0); p.setEncouragementInterval(1); QVERIFY(spy.wait(1000)); QCOMPARE(spy.count(), 1); } { QSettings s(QCoreApplication::organizationName(), QStringLiteral("UserFeedback.org.kde.providertest"));; s.beginGroup(QLatin1String("UserFeedback")); s.setValue(QLatin1String("LastEncouragement"), QDateTime::currentDateTime().addSecs(-24 * 60 * 60 - 1)); } { Provider p; p.setSurveyInterval(90); p.setTelemetryMode(Provider::BasicSystemInformation); QSignalSpy spy(&p, SIGNAL(showEncouragementMessage())); QVERIFY(spy.isValid()); p.setEncouragementDelay(0); p.setApplicationStartsUntilEncouragement(0); p.setEncouragementInterval(1); QVERIFY(!spy.wait(10)); } } void testGlobalEncouragementCoordination() { { QSettings s(QCoreApplication::organizationName(), QStringLiteral("UserFeedback.org.kde.providertest"));; s.beginGroup(QLatin1String("UserFeedback")); s.remove(QLatin1String("LastEncouragement")); } { Provider p; p.setSurveyInterval(-1); p.setTelemetryMode(Provider::NoTelemetry); QSignalSpy spy(&p, SIGNAL(showEncouragementMessage())); QVERIFY(spy.isValid()); p.setEncouragementDelay(0); p.setApplicationStartsUntilEncouragement(0); p.setEncouragementInterval(1); QVERIFY(spy.wait(1000)); QCOMPARE(spy.count(), 1); } // would qualify for encouragement, but global coordination should prevent it { QSettings s(QCoreApplication::organizationName(), QStringLiteral("UserFeedback.org.kde.providertest"));; s.beginGroup(QLatin1String("UserFeedback")); s.remove(QLatin1String("LastEncouragement")); } { Provider p; p.setSurveyInterval(-1); p.setTelemetryMode(Provider::NoTelemetry); QSignalSpy spy(&p, SIGNAL(showEncouragementMessage())); QVERIFY(spy.isValid()); p.setEncouragementDelay(0); p.setApplicationStartsUntilEncouragement(0); p.setEncouragementInterval(1); QVERIFY(!spy.wait(100)); } } void testMultipleProviders() { { Provider p0; p0.setTelemetryMode(Provider::BasicUsageStatistics); // triggers store, so we want to avoid that below } int c1 = -1; { Provider p1; auto s1 = new StartCountSource; s1->setTelemetryMode(Provider:: BasicUsageStatistics); p1.addDataSource(s1); c1 = s1->data().toMap().value(QLatin1String("value")).toInt(); int c2 = -1; { Provider p2; auto s2 = new StartCountSource; s2->setTelemetryMode(Provider::BasicUsageStatistics); p2.addDataSource(s2); c2 = s2->data().toMap().value(QLatin1String("value")).toInt(); } QVERIFY(c2 == c1 + 1); } Provider p3; auto s3 = new StartCountSource; s3->setTelemetryMode(Provider::BasicUsageStatistics); p3.addDataSource(s3); int c3 = s3->data().toMap().value(QLatin1String("value")).toInt(); QVERIFY(c3 == c1 + 2); } void testProductIdChange() { { Provider p0; } int c1 = -1; { Provider p1; auto s1 = new StartCountSource; s1->setTelemetryMode(Provider::BasicUsageStatistics); p1.addDataSource(s1); p1.setSurveyInterval(90); const auto c0 = s1->data().toMap().value(QLatin1String("value")).toInt(); p1.setProductIdentifier(QStringLiteral("org.kde.some.other.test")); p1.setSurveyInterval(-1); p1.setSurveyInterval(1); c1 = s1->data().toMap().value(QLatin1String("value")).toInt(); QVERIFY(c0 != c1); } { Provider p2; auto s2 = new StartCountSource; s2->setTelemetryMode(Provider::BasicUsageStatistics); p2.addDataSource(s2); p2.setProductIdentifier(QStringLiteral("org.kde.some.other.test")); QCOMPARE(p2.surveyInterval(), 1); const auto c2 = s2->data().toMap().value(QLatin1String("value")).toInt(); QCOMPARE(c1 + 1, c2); } } void testGlobalKillSwitch() { { Provider p1; QVERIFY(p1.isEnabled()); p1.setEnabled(false); QVERIFY(!p1.isEnabled()); } Provider p2; QVERIFY(!p2.isEnabled()); // check encouragements are disabled { QSettings s(QCoreApplication::organizationName(), QStringLiteral("UserFeedback.org.kde.providertest"));; s.beginGroup(QLatin1String("UserFeedback")); s.remove(QLatin1String("LastEncouragement")); } { Provider p; p.setSurveyInterval(-1); p.setTelemetryMode(Provider::NoTelemetry); QSignalSpy spy(&p, SIGNAL(showEncouragementMessage())); QVERIFY(spy.isValid()); p.setEncouragementDelay(0); p.setApplicationStartsUntilEncouragement(0); p.setEncouragementInterval(1); QVERIFY(!spy.wait(100)); } } void testDataSourceLookup() { Provider p; auto screenInfoDataSource = new ScreenInfoSource; auto screenInfoDataSourceId = screenInfoDataSource->id(); auto platformInfoDataSource = new PlatformInfoSource; auto platformInfoDataSourceId = platformInfoDataSource->id(); p.addDataSource(screenInfoDataSource); p.addDataSource(platformInfoDataSource); QCOMPARE(screenInfoDataSource, p.dataSource(screenInfoDataSourceId)); QCOMPARE(platformInfoDataSource, p.dataSource(platformInfoDataSourceId)); QVERIFY(!p.dataSource(QStringLiteral("SomeInvalidId"))); } }; -QTEST_MAIN(ProviderTest) +QTEST_GUILESS_MAIN(ProviderTest) #include "providertest.moc" diff --git a/autotests/surveyprovidertest.cpp b/autotests/surveyprovidertest.cpp index af2624c..f6c033c 100644 --- a/autotests/surveyprovidertest.cpp +++ b/autotests/surveyprovidertest.cpp @@ -1,130 +1,130 @@ /* Copyright (C) 2017 Volker Krause Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include #include #include #include #include #include #include #include #include using namespace KUserFeedback; class SurveyProviderTest : public QObject { Q_OBJECT private slots: void initTestCase() { qRegisterMetaType(); QCoreApplication::setOrganizationName(QStringLiteral("KDE")); QCoreApplication::setOrganizationDomain(QStringLiteral("kde.org")); QCoreApplication::setApplicationName(QStringLiteral("surveyprovidertest")); QStandardPaths::setTestModeEnabled(true); } void testSurveySelect() { { QSettings s(QCoreApplication::organizationName(), QStringLiteral("UserFeedback.org.kde.surveyprovidertest"));; s.beginGroup(QLatin1String("UserFeedback")); s.remove(QLatin1String("LastSurvey")); s.remove(QLatin1String("CompletedSurveys")); } { QSettings s(QCoreApplication::organizationName(), QStringLiteral("UserFeedback"));; s.beginGroup(QLatin1String("UserFeedback")); s.remove(QLatin1String("LastSurvey")); } SurveyInfo s1; s1.setUuid(QUuid::createUuid()); s1.setUrl(QUrl(QStringLiteral("https://www.kde.org"))); QVERIFY(s1.isValid()); Provider p; p.setSurveyInterval(90); QSignalSpy spy(&p, SIGNAL(surveyAvailable(KUserFeedback::SurveyInfo))); QVERIFY(spy.isValid()); // global kill switch prevents survey bool rv = false; p.setEnabled(false); QMetaObject::invokeMethod(&p, "selectSurvey", Q_RETURN_ARG(bool, rv), Q_ARG(KUserFeedback::SurveyInfo, s1)); QVERIFY(!rv); QVERIFY(spy.isEmpty()); p.setEnabled(true); QMetaObject::invokeMethod(&p, "selectSurvey", Q_RETURN_ARG(bool, rv), Q_ARG(KUserFeedback::SurveyInfo, s1)); QVERIFY(rv); QCOMPARE(spy.size(), 1); // again, not completed yet QMetaObject::invokeMethod(&p, "selectSurvey", Q_RETURN_ARG(bool, rv), Q_ARG(KUserFeedback::SurveyInfo, s1)); QVERIFY(rv); QCOMPARE(spy.size(), 2); spy.clear(); // survey completed, should no longer be accepted p.surveyCompleted(s1); QMetaObject::invokeMethod(&p, "selectSurvey", Q_RETURN_ARG(bool, rv), Q_ARG(KUserFeedback::SurveyInfo, s1)); QVERIFY(!rv); QVERIFY(spy.isEmpty()); SurveyInfo s2; s2.setUuid(QUuid::createUuid()); s2.setUrl(QUrl(QStringLiteral("https://www.kde.org/survey2"))); QVERIFY(s2.isValid()); // next survey, but interval hasn't passed yet p.setSurveyInterval(90); QMetaObject::invokeMethod(&p, "selectSurvey", Q_RETURN_ARG(bool, rv), Q_ARG(KUserFeedback::SurveyInfo, s2)); QVERIFY(!rv); QVERIFY(spy.isEmpty()); // survey interval passed p.setSurveyInterval(0); QMetaObject::invokeMethod(&p, "selectSurvey", Q_RETURN_ARG(bool, rv), Q_ARG(KUserFeedback::SurveyInfo, s2)); QVERIFY(rv); // global survey coordination prevents next survey p.setSurveyInterval(90); { QSettings s(QCoreApplication::organizationName(), QStringLiteral("UserFeedback.org.kde.surveyprovidertest"));; s.beginGroup(QLatin1String("UserFeedback")); s.remove(QLatin1String("LastSurvey")); s.remove(QLatin1String("CompletedSurveys")); } QMetaObject::invokeMethod(&p, "selectSurvey", Q_RETURN_ARG(bool, rv), Q_ARG(KUserFeedback::SurveyInfo, s1)); QVERIFY(!rv); } }; -QTEST_MAIN(SurveyProviderTest) +QTEST_GUILESS_MAIN(SurveyProviderTest) #include "surveyprovidertest.moc" diff --git a/autotests/surveytargetexpressiontest.cpp b/autotests/surveytargetexpressiontest.cpp index 40f0220..a3e525c 100644 --- a/autotests/surveytargetexpressiontest.cpp +++ b/autotests/surveytargetexpressiontest.cpp @@ -1,171 +1,171 @@ /* Copyright (C) 2017 Volker Krause Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include #include #include #include #include #include using namespace KUserFeedback; class SurveyTargetExpressionTest: public QObject, public SurveyTargetExpressionDataProvider { Q_OBJECT private: QHash m_sourceData; QVariant sourceData(const QString &sourceName) const override { return m_sourceData.value(sourceName); } private slots: void testValidParse_data() { QTest::addColumn("input"); QTest::newRow("01") << QStringLiteral("true == 12.3"); QTest::newRow("02") << QStringLiteral("42 >= false"); QTest::newRow("03") << QStringLiteral("(42 >= 12.3)"); QTest::newRow("04") << QStringLiteral("(42 >= 12.3) && (42 < 23)"); QTest::newRow("05") << QStringLiteral("(42 >= 12.3 && 42 < 23) || true != false"); QTest::newRow("06") << QStringLiteral("42 >= 12.3E-1 && 42 < 23.1e12 || true != false && -3.2 == .3"); QTest::newRow("07") << QStringLiteral("\"a\" == \"\\\"b\\\"\""); QTest::newRow("08") << QStringLiteral("\"true\" == \"\" || \"&&\" != \"()\""); QTest::newRow("09") << QStringLiteral("usageTime.value > 3600"); QTest::newRow("10") << QStringLiteral("3600 <= usageTime.value"); QTest::newRow("11") << QStringLiteral("startCount.value != usageTime.value"); QTest::newRow("12") << QStringLiteral("screens[0].dpi <= 240"); QTest::newRow("13") << QStringLiteral("views[\"view1\"].ratio > 1"); } void testValidParse() { QFETCH(QString, input); SurveyTargetExpressionParser p; QVERIFY(p.parse(input)); QVERIFY(p.expression()); qDebug() << p.expression(); } void testInvalidParse_data() { QTest::addColumn("input"); QTest::newRow("01") << QStringLiteral("true && 12.3"); QTest::newRow("02") << QStringLiteral("42 || false"); QTest::newRow("03") << QStringLiteral("(42)"); QTest::newRow("04") << QStringLiteral("true == 12.3 >= 24 < (false)"); QTest::newRow("05") << QStringLiteral("screen[0] == 4"); QTest::newRow("06") << QStringLiteral("screen[false] == 4"); QTest::newRow("07") << QStringLiteral("screen[false].dpi == 4"); QTest::newRow("08") << QStringLiteral("screen[].dpi == 4"); QTest::newRow("08") << QStringLiteral("screen[].dpi == 4"); QTest::newRow("09") << QStringLiteral("screen[\"key\"] == 4"); QTest::newRow("10") << QStringLiteral("\"\\\"\" == \"\\\""); } void testInvalidParse() { QFETCH(QString, input); SurveyTargetExpressionParser p; QVERIFY(!p.parse(input)); } void testEval_data() { QTest::addColumn("input"); QTest::addColumn("expected"); QTest::newRow("01") << QStringLiteral("1 >= 2") << false; QTest::newRow("02") << QStringLiteral("1 < 2.0") << true; QTest::newRow("03") << QStringLiteral("true != false") << true; QTest::newRow("04") << QStringLiteral("\"abc\" == \"abc\"") << true; QTest::newRow("05") << QStringLiteral("1.0 > 1.5 || 1.0 <= 1.5") << true; QTest::newRow("06") << QStringLiteral("1.0 >= 1.5 && 1.0 < 1.5") << false; QTest::newRow("07") << QStringLiteral("3600 <= usageTime.value") << true; QTest::newRow("08") << QStringLiteral("3600 <= usageTime.value || 42 < lazy_eval.non_existing") << true; QTest::newRow("09") << QStringLiteral("screens[1].dpi <= 240") << true; QTest::newRow("10") << QStringLiteral("screens[2].dpi <= 240") << false; QTest::newRow("11") << QStringLiteral("screens.size == 2") << true; QTest::newRow("12") << QStringLiteral("1 == \"1\"") << false; QTest::newRow("13") << QStringLiteral("\"1\" == 1") << false; QTest::newRow("14") << QStringLiteral("screens[0].size == 1920") << true; QTest::newRow("15") << QStringLiteral("views[\"view2\"].ratio > 0.35") << true; QTest::newRow("16") << QStringLiteral("views[\"view3\"].size == \"???\"") << true; QTest::newRow("17") << QStringLiteral("views[\"view4\"].ratio > 0.35") << false; QTest::newRow("18") << QStringLiteral("views.size == 3") << true; QTest::newRow("19") << QStringLiteral("test.string == \"a\\\"b\\nc\\\\d\\te\\\\f\"") << true; QTest::newRow("20") << QStringLiteral("views[\"\"].ratio > 0.35") << false; QTest::newRow("21") << QStringLiteral("\"\" == \"\"") << true; QTest::newRow("22") << QStringLiteral("views.view1 == 2") << false; QTest::newRow("23") << QStringLiteral("views.non_existing == false") << false; QTest::newRow("24") << QStringLiteral("1 == 1 || 2 == 2 && 3 != 3") << true; QTest::newRow("25") << QStringLiteral("(1 == 1 || 2 == 2) && 3 != 3") << false; QTest::newRow("26") << QStringLiteral("1 == 1 && 2 == 2 || 3 != 3") << true; QTest::newRow("27") << QStringLiteral("1 == 1 && 2 == 2 || 3 == 3 && 4!=4") << true; } void testEval() { QFETCH(QString, input); QFETCH(bool, expected); QVariantMap m; m.insert(QLatin1String("value"), 3600); m_sourceData.insert(QLatin1String("usageTime"), m); m.clear(); m.insert(QLatin1String("dpi"), 200); m.insert(QLatin1String("size"), 1920); QVariantList l; l.push_back(m); l.push_back(m); m_sourceData.insert(QLatin1String("screens"), l); m.clear(); m.insert(QLatin1String("ratio"), 0.4); m.insert(QLatin1String("size"), QLatin1String("???")); QVariantMap m2; m2.insert(QLatin1String("view1"), m); m2.insert(QLatin1String("view2"), m); m2.insert(QLatin1String("view3"), m); m_sourceData.insert(QLatin1String("views"), m2); m.clear(); m.insert(QLatin1String("string"), QLatin1String("a\"b\nc\\d\te\\f")); m_sourceData.insert(QLatin1String("test"), m); SurveyTargetExpressionParser p; QVERIFY(p.parse(input)); QVERIFY(p.expression()); qDebug() << p.expression(); SurveyTargetExpressionEvaluator eval; eval.setDataProvider(this); QCOMPARE(eval.evaluate(p.expression()), expected); } }; -QTEST_MAIN(SurveyTargetExpressionTest) +QTEST_GUILESS_MAIN(SurveyTargetExpressionTest) #include "surveytargetexpressiontest.moc"