diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/installer/componentmodel/componentmodel.pro | 2 | ||||
-rw-r--r-- | tests/auto/installer/installer.pro | 2 | ||||
-rw-r--r-- | tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp | 16 | ||||
-rw-r--r-- | tests/auto/installer/scriptengine/data/auto-install.qs (renamed from tests/auto/installer/installerscriptengine/data/auto-install.qs) | 0 | ||||
-rw-r--r-- | tests/auto/installer/scriptengine/data/component1.qs (renamed from tests/auto/installer/installerscriptengine/data/component1.qs) | 0 | ||||
-rw-r--r-- | tests/auto/installer/scriptengine/data/component2.qs (renamed from tests/auto/installer/installerscriptengine/data/component2.qs) | 0 | ||||
-rw-r--r-- | tests/auto/installer/scriptengine/scriptengine.pro (renamed from tests/auto/installer/installerscriptengine/installerscriptengine.pro) | 4 | ||||
-rw-r--r-- | tests/auto/installer/scriptengine/scriptengine.qrc (renamed from tests/auto/installer/installerscriptengine/installerscriptengine.qrc) | 0 | ||||
-rw-r--r-- | tests/auto/installer/scriptengine/tst_scriptengine.cpp (renamed from tests/auto/installer/installerscriptengine/tst_installerscriptengine.cpp) | 63 |
9 files changed, 46 insertions, 41 deletions
diff --git a/tests/auto/installer/componentmodel/componentmodel.pro b/tests/auto/installer/componentmodel/componentmodel.pro index 442986a96..7e18ff1ba 100644 --- a/tests/auto/installer/componentmodel/componentmodel.pro +++ b/tests/auto/installer/componentmodel/componentmodel.pro @@ -1,7 +1,7 @@ include(../../qttest.pri) QT -= gui -QT += network xml +QT += network xml script SOURCES += tst_componentmodel.cpp diff --git a/tests/auto/installer/installer.pro b/tests/auto/installer/installer.pro index 351ecae06..df2630166 100644 --- a/tests/auto/installer/installer.pro +++ b/tests/auto/installer/installer.pro @@ -8,4 +8,4 @@ SUBDIRS += \ messageboxhandler \ extractarchiveoperationtest \ lib7zfacade \ - installerscriptengine + scriptengine diff --git a/tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp b/tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp index f705154b5..604b8e0a0 100644 --- a/tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp +++ b/tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp @@ -1,5 +1,7 @@ -#include "messageboxhandler.h" -#include "qinstallerglobal.h" +#include <messageboxhandler.h> +#include <qinstallerglobal.h> +#include <scriptengine.h> +#include <packagemanagercore.h> #include <QTest> #include <QMetaEnum> @@ -43,23 +45,24 @@ private slots: if (enumValue == QMessageBox::LastButton) break; } - QInstaller::registerMessageBox(&m_scriptEngine); } void testScriptButtonValues() { + PackageManagerCore core; + ScriptEngine scriptEngine(&core); QMapIterator<QMessageBox::StandardButton, QString> i(m_standardButtonValueMap); while (i.hasNext()) { i.next(); QString scriptString = QString::fromLatin1("QMessageBox.%1").arg(i.value()); - QScriptValue scriptValue(m_scriptEngine.evaluate(scriptString)); + QScriptValue scriptValue(scriptEngine.evaluate(scriptString)); QVERIFY2(!scriptValue.isUndefined(), qPrintable( QString::fromLatin1("It seems that %1 is undefined.").arg(scriptString))); qint32 evaluatedValue = scriptValue.toInt32(); - QVERIFY2(!m_scriptEngine.hasUncaughtException(), qPrintable( - QInstaller::uncaughtExceptionString(&m_scriptEngine))); + QVERIFY2(!scriptEngine.hasUncaughtException(), qPrintable( + QInstaller::uncaughtExceptionString(&scriptEngine))); QCOMPARE(static_cast<QMessageBox::StandardButton>(evaluatedValue), i.key()); } @@ -109,7 +112,6 @@ private slots: private: QMap<QMessageBox::StandardButton, QString> m_standardButtonValueMap; int m_maxStandardButtons; - QScriptEngine m_scriptEngine; }; QTEST_MAIN(tst_MessageBoxHandler) diff --git a/tests/auto/installer/installerscriptengine/data/auto-install.qs b/tests/auto/installer/scriptengine/data/auto-install.qs index 26937fc05..26937fc05 100644 --- a/tests/auto/installer/installerscriptengine/data/auto-install.qs +++ b/tests/auto/installer/scriptengine/data/auto-install.qs diff --git a/tests/auto/installer/installerscriptengine/data/component1.qs b/tests/auto/installer/scriptengine/data/component1.qs index af81f5747..af81f5747 100644 --- a/tests/auto/installer/installerscriptengine/data/component1.qs +++ b/tests/auto/installer/scriptengine/data/component1.qs diff --git a/tests/auto/installer/installerscriptengine/data/component2.qs b/tests/auto/installer/scriptengine/data/component2.qs index b27e45c83..b27e45c83 100644 --- a/tests/auto/installer/installerscriptengine/data/component2.qs +++ b/tests/auto/installer/scriptengine/data/component2.qs diff --git a/tests/auto/installer/installerscriptengine/installerscriptengine.pro b/tests/auto/installer/scriptengine/scriptengine.pro index 055efc12a..a7b2bd157 100644 --- a/tests/auto/installer/installerscriptengine/installerscriptengine.pro +++ b/tests/auto/installer/scriptengine/scriptengine.pro @@ -5,7 +5,7 @@ greaterThan(QT_MAJOR_VERSION, 4) { QT += widgets } -SOURCES += tst_installerscriptengine.cpp +SOURCES += tst_scriptengine.cpp RESOURCES += \ - installerscriptengine.qrc + scriptengine.qrc diff --git a/tests/auto/installer/installerscriptengine/installerscriptengine.qrc b/tests/auto/installer/scriptengine/scriptengine.qrc index d38168175..d38168175 100644 --- a/tests/auto/installer/installerscriptengine/installerscriptengine.qrc +++ b/tests/auto/installer/scriptengine/scriptengine.qrc diff --git a/tests/auto/installer/installerscriptengine/tst_installerscriptengine.cpp b/tests/auto/installer/scriptengine/tst_scriptengine.cpp index 4d629e08f..af1dbf377 100644 --- a/tests/auto/installer/installerscriptengine/tst_installerscriptengine.cpp +++ b/tests/auto/installer/scriptengine/tst_scriptengine.cpp @@ -2,12 +2,12 @@ #include <errors.h> #include <packagemanagercore.h> #include <packagemanagergui.h> +#include <scriptengine.h> #include <QTest> #include <QSet> #include <QFile> #include <QString> -#include <QScriptEngine> using namespace QInstaller; @@ -35,7 +35,7 @@ public: }; -class tst_InstallerScriptEngine : public QObject +class tst_ScriptEngine : public QObject { Q_OBJECT @@ -51,7 +51,7 @@ private slots: m_component->setValue("Default", "Script"); m_component->setValue(scName, "component.test.name"); - m_scriptEngine = m_component->scriptEngine(); + m_scriptEngine = m_core.scriptEngine(); } void testScriptPrint() @@ -59,7 +59,7 @@ private slots: setExpectedScriptOutput("test"); m_scriptEngine->evaluate("print(\"test\");"); if (m_scriptEngine->hasUncaughtException()) { - QFAIL(qPrintable(QString::fromLatin1("installerScriptEngine hasUncaughtException:\n %1").arg( + QFAIL(qPrintable(QString::fromLatin1("ScriptEngine hasUncaughtException:\n %1").arg( uncaughtExceptionString(m_scriptEngine)))); } } @@ -69,7 +69,7 @@ private slots: setExpectedScriptOutput("object"); m_scriptEngine->evaluate("print(typeof installer)"); if (m_scriptEngine->hasUncaughtException()) { - QFAIL(qPrintable(QString::fromLatin1("installerScriptEngine hasUncaughtException:\n %1").arg( + QFAIL(qPrintable(QString::fromLatin1("ScriptEngine hasUncaughtException:\n %1").arg( uncaughtExceptionString(m_scriptEngine)))); } } @@ -82,7 +82,7 @@ private slots: setExpectedScriptOutput("component.test.name"); m_scriptEngine->evaluate(printComponentNameScript); if (m_scriptEngine->hasUncaughtException()) { - QFAIL(qPrintable(QString::fromLatin1("installerScriptEngine hasUncaughtException:\n %1").arg( + QFAIL(qPrintable(QString::fromLatin1("ScriptEngine hasUncaughtException:\n %1").arg( uncaughtExceptionString(m_scriptEngine)))); } } @@ -140,14 +140,15 @@ private slots: Component testComponent(&core); const QString debugMesssage( - "create Error-Exception: \"Exception while loading the component script: :///data/component2.qs\n\n" + "create Error-Exception: \"Exception while loading the component script: ':///data/component2.qs\n\n" "ReferenceError: Can't find variable: broken\n\n" "Backtrace:\n" #if QT_VERSION < 0x050000 - "\t<anonymous>()@:///data/component2.qs:5\" "); + "\t<anonymous>()@:///data/component2.qs:5'\" "); #else "\tComponent() at :///data/component2.qs:5\n" - "\t<global>() at -1\" "); + "\t<anonymous>() at :///data/component2.qs:7\n" + "\t<global>() at :///data/component2.qs:7'\" "); #endif try { // ignore Output from script @@ -161,25 +162,27 @@ private slots: void loadSimpleAutoRunScript() { - TestGui testGui(&m_core); - setExpectedScriptOutput("Loaded control script \":///data/auto-install.qs\" "); - testGui.loadControlScript(":///data/auto-install.qs"); - QCOMPARE(m_core.value("GuiTestValue"), QString("hello")); - - testGui.show(); - // show event calls automatically the first callback which does not exist - setExpectedScriptOutput("Control script callback \"IntroductionPageCallback\" does not exist. "); - // give some time to the event triggering mechanism - qApp->processEvents(); - - setExpectedScriptOutput("Calling control script callback \"ComponentSelectionPageCallback\" "); - // inside the auto-install script we are clicking the next button, with a not existing button - QTest::ignoreMessage(QtWarningMsg, "Button with type: \"unknown button\" not found! "); - testGui.callProtectedDelayedControlScriptExecution(PackageManagerCore::ComponentSelection); - - setExpectedScriptOutput("Calling control script callback \"FinishedPageCallback\" "); - setExpectedScriptOutput("FinishedPageCallback - OK"); - testGui.callProtectedDelayedControlScriptExecution(PackageManagerCore::InstallationFinished); + try { + TestGui testGui(&m_core); + setExpectedScriptOutput("Loaded control script \":///data/auto-install.qs\" "); + testGui.loadControlScript(":///data/auto-install.qs"); + QCOMPARE(m_core.value("GuiTestValue"), QString("hello")); + + testGui.show(); + // show event calls automatically the first callback which does not exist + setExpectedScriptOutput("Control script callback \"IntroductionPageCallback\" does not exist. "); + // give some time to the event triggering mechanism + qApp->processEvents(); + + // inside the auto-install script we are clicking the next button, with a not existing button + QTest::ignoreMessage(QtWarningMsg, "Button with type: \"unknown button\" not found! "); + testGui.callProtectedDelayedControlScriptExecution(PackageManagerCore::ComponentSelection); + + setExpectedScriptOutput("FinishedPageCallback - OK"); + testGui.callProtectedDelayedControlScriptExecution(PackageManagerCore::InstallationFinished); + } catch (const Error &error) { + QFAIL(qPrintable(error.message())); + } } private: @@ -197,6 +200,6 @@ private: }; -QTEST_MAIN(tst_InstallerScriptEngine) +QTEST_MAIN(tst_ScriptEngine) -#include "tst_installerscriptengine.moc" +#include "tst_scriptengine.moc" |