summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorkh1 <karsten.heimrich@digia.com>2014-10-28 16:56:06 +0100
committerKarsten Heimrich <karsten.heimrich@digia.com>2014-10-30 14:54:05 +0100
commit76cb03cb603e377d43fd959c21d928ef7cb2748f (patch)
tree5e366345ad82de79b35f095504a782813687c90b /tests
parent624adb3699af26b1bd371cccced8fcc80a9450fb (diff)
Fix regression after porting to QJSEngine.
Setting a dynamic property of a dynamic page from JS doesn't have any effect anymore, as the properties are not synced. Now we define the property directly on the JavaScript object and connect it to corresponding C++ page with static Qt properties. Task-number: QTIFW-562 Change-Id: If95222a94ebee7f8bb455792eab96c5e9bc19b86 Reviewed-by: Niels Weber <niels.weber@digia.com> Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/installer/scriptengine/data/dynamicpage.qs58
-rw-r--r--tests/auto/installer/scriptengine/scriptengine.qrc1
-rw-r--r--tests/auto/installer/scriptengine/tst_scriptengine.cpp97
3 files changed, 156 insertions, 0 deletions
diff --git a/tests/auto/installer/scriptengine/data/dynamicpage.qs b/tests/auto/installer/scriptengine/data/dynamicpage.qs
new file mode 100644
index 000000000..4ac1990c1
--- /dev/null
+++ b/tests/auto/installer/scriptengine/data/dynamicpage.qs
@@ -0,0 +1,58 @@
+/**************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Installer Framework.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+**
+** $QT_END_LICENSE$
+**
+**************************************************************************/
+
+function Controller()
+{
+}
+
+Controller.prototype.ReadAndSetValues = function()
+{
+ var widget = gui.pageWidgetByObjectName("DynamicWidget");
+ installer.setValue("DynamicWidget.final", widget.final);
+ installer.setValue("DynamicWidget.commit", widget.commit);
+ installer.setValue("DynamicWidget.complete", widget.complete);
+}
+
+Controller.prototype.UpdateAndSetValues = function ()
+{
+ var widget = gui.pageWidgetByObjectName("DynamicWidget");
+
+ widget.final = false;
+ widget.commit = false;
+ widget.complete = true;
+
+ installer.setValue("DynamicWidget.final", widget.final);
+ installer.setValue("DynamicWidget.commit", widget.commit);
+ installer.setValue("DynamicWidget.complete", widget.complete);
+}
diff --git a/tests/auto/installer/scriptengine/scriptengine.qrc b/tests/auto/installer/scriptengine/scriptengine.qrc
index 0bf683852..caffe3627 100644
--- a/tests/auto/installer/scriptengine/scriptengine.qrc
+++ b/tests/auto/installer/scriptengine/scriptengine.qrc
@@ -4,5 +4,6 @@
<file>data/component1.qs</file>
<file>data/component2.qs</file>
<file>data/broken_connect.qs</file>
+ <file>data/dynamicpage.qs</file>
</qresource>
</RCC>
diff --git a/tests/auto/installer/scriptengine/tst_scriptengine.cpp b/tests/auto/installer/scriptengine/tst_scriptengine.cpp
index 62806a2c6..d7b7aa4d0 100644
--- a/tests/auto/installer/scriptengine/tst_scriptengine.cpp
+++ b/tests/auto/installer/scriptengine/tst_scriptengine.cpp
@@ -1,3 +1,37 @@
+/**************************************************************************
+**
+** Copyright (C) 2013-2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Installer Framework.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+**
+** $QT_END_LICENSE$
+**
+**************************************************************************/
+
#include <component.h>
#include <errors.h>
#include <packagemanagercore.h>
@@ -32,6 +66,29 @@ public:
}
};
+class DynamicPageGui : public PackageManagerGui
+{
+ Q_OBJECT
+
+public:
+ explicit DynamicPageGui(PackageManagerCore *core)
+ : PackageManagerGui(core)
+ {}
+
+ void init() {
+ m_widget = new QWidget;
+ m_widget->setObjectName("Widget");
+
+ packageManagerCore()->wizardPageInsertionRequested(m_widget,
+ PackageManagerCore::Introduction);
+ }
+
+ QWidget *widget() const { return m_widget; }
+
+private:
+ QWidget *m_widget;
+};
+
class EmitSignalObject : public QObject
{
Q_OBJECT
@@ -256,6 +313,46 @@ private slots:
}
}
+ void testDynamicPage()
+ {
+ DynamicPageGui gui(&m_core);
+ gui.init();
+
+ setExpectedScriptOutput("Loaded control script \":///data/dynamicpage.qs\" ");
+ gui.loadControlScript(":///data/dynamicpage.qs");
+
+ gui.callControlScriptMethod("ReadAndSetValues");
+
+ QCOMPARE(m_core.value("DynamicWidget.final"), QString("false"));
+ QCOMPARE(gui.widget()->property("final").toString(), QString("false"));
+ QCOMPARE(m_core.value("DynamicWidget.commit"), QString("false"));
+ QCOMPARE(gui.widget()->property("commit").toString(), QString("false"));
+ QCOMPARE(m_core.value("DynamicWidget.complete"), QString("true"));
+ QCOMPARE(gui.widget()->property("complete").toString(), QString("true"));
+
+ gui.widget()->setProperty("final", true);
+ gui.widget()->setProperty("commit", true);
+ gui.widget()->setProperty("complete", false);
+
+ gui.callControlScriptMethod("ReadAndSetValues");
+
+ QCOMPARE(m_core.value("DynamicWidget.final"), QString("true"));
+ QCOMPARE(gui.widget()->property("final").toString(), QString("true"));
+ QCOMPARE(m_core.value("DynamicWidget.commit"), QString("true"));
+ QCOMPARE(gui.widget()->property("commit").toString(), QString("true"));
+ QCOMPARE(m_core.value("DynamicWidget.complete"), QString("false"));
+ QCOMPARE(gui.widget()->property("complete").toString(), QString("false"));
+
+ gui.callControlScriptMethod("UpdateAndSetValues");
+
+ QCOMPARE(m_core.value("DynamicWidget.final"), QString("false"));
+ QCOMPARE(gui.widget()->property("final").toString(), QString("false"));
+ QCOMPARE(m_core.value("DynamicWidget.commit"), QString("false"));
+ QCOMPARE(gui.widget()->property("commit").toString(), QString("false"));
+ QCOMPARE(m_core.value("DynamicWidget.complete"), QString("true"));
+ QCOMPARE(gui.widget()->property("complete").toString(), QString("true"));
+ }
+
private:
void setExpectedScriptOutput(const char *message)
{