From 838f3284963c00dc4407cff5c35ff823b0d3123c Mon Sep 17 00:00:00 2001 From: jkobus Date: Tue, 27 Jan 2015 10:47:52 +0100 Subject: Fix the invocation order of entering() and page callback Task-number: QTIFW-620 Change-Id: I1a40aae35dc1c259a96043a1056aa631bf7279b2 Reviewed-by: Niels Weber Reviewed-by: Kai Koehne --- .../installer/scriptengine/data/enteringpage.qs | 44 +++++++++++++++ tests/auto/installer/scriptengine/scriptengine.qrc | 1 + .../installer/scriptengine/tst_scriptengine.cpp | 64 ++++++++++++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 tests/auto/installer/scriptengine/data/enteringpage.qs (limited to 'tests') diff --git a/tests/auto/installer/scriptengine/data/enteringpage.qs b/tests/auto/installer/scriptengine/data/enteringpage.qs new file mode 100644 index 000000000..96d7f9013 --- /dev/null +++ b/tests/auto/installer/scriptengine/data/enteringpage.qs @@ -0,0 +1,44 @@ +/************************************************************************** +** +** Copyright (C) 2015 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.EnteringPageCallback = function() +{ + var page = gui.pageWidgetByObjectName("EnteringPage"); + page.callbackInvoked(); +} + diff --git a/tests/auto/installer/scriptengine/scriptengine.qrc b/tests/auto/installer/scriptengine/scriptengine.qrc index 06829326e..d630f3196 100644 --- a/tests/auto/installer/scriptengine/scriptengine.qrc +++ b/tests/auto/installer/scriptengine/scriptengine.qrc @@ -5,6 +5,7 @@ data/component2.qs data/broken_connect.qs data/dynamicpage.qs + data/enteringpage.qs data/form.ui data/userinterface.qs diff --git a/tests/auto/installer/scriptengine/tst_scriptengine.cpp b/tests/auto/installer/scriptengine/tst_scriptengine.cpp index 12915e30a..09785850e 100644 --- a/tests/auto/installer/scriptengine/tst_scriptengine.cpp +++ b/tests/auto/installer/scriptengine/tst_scriptengine.cpp @@ -96,6 +96,55 @@ private: QWidget *m_widget; }; +class EnteringPage : public PackageManagerPage +{ + Q_OBJECT + Q_PROPERTY(QStringList invocationOrder READ invocationOrder) +public: + explicit EnteringPage(PackageManagerCore *core) + : PackageManagerPage(core) + { + setObjectName(QLatin1String("EnteringPage")); + } + QStringList invocationOrder() const { + return m_invocationOrder; + } +public slots: + Q_INVOKABLE void enteringInvoked() { + m_invocationOrder << QLatin1String("Entering"); + } + Q_INVOKABLE void callbackInvoked() { + m_invocationOrder << QLatin1String("Callback"); + } + +protected: + void entering() { + enteringInvoked(); + } +private: + QStringList m_invocationOrder; +}; + +class EnteringGui : public PackageManagerGui +{ + Q_OBJECT +public: + explicit EnteringGui(PackageManagerCore *core) + : PackageManagerGui(core) + {} + + EnteringPage *enteringPage() const { + return m_enteringPage; + } + + void init() { + m_enteringPage = new EnteringPage(packageManagerCore()); + setPage(0, m_enteringPage); + } +private: + EnteringPage *m_enteringPage; +}; + class EmitSignalObject : public QObject { Q_OBJECT @@ -377,6 +426,21 @@ private slots: QCOMPARE(gui.widget()->property("complete").toString(), QString("true")); } + void checkEnteringCalledBeforePageCallback() + { + EnteringGui gui(&m_core); + gui.init(); + setExpectedScriptOutput("Loaded control script \":///data/enteringpage.qs\" "); + gui.loadControlScript(":///data/enteringpage.qs"); + gui.show(); + + EnteringPage *enteringPage = gui.enteringPage(); + + QStringList expectedOrder; + expectedOrder << QLatin1String("Entering") << QLatin1String("Callback"); + QCOMPARE(enteringPage->invocationOrder(), expectedOrder); + } + private: void setExpectedScriptOutput(const char *message) { -- cgit v1.2.3