diff options
author | Kai Koehne <kai.koehne@theqtcompany.com> | 2015-01-19 14:21:33 +0100 |
---|---|---|
committer | Kai Koehne <kai.koehne@theqtcompany.com> | 2015-01-20 16:09:57 +0100 |
commit | 36a9594bce7b6e0be22446734dede93a31e95ed3 (patch) | |
tree | 925d95de0cc7fffaf6433ea4239b2a135804efae /tests/auto | |
parent | 1b632baad6090403da17cdde411bf7fa511b1da2 (diff) |
Make sure widgets from .ui files are properly registered to engine
Make the QWidget representing a UI file known to the engine, so that
e.g. child objects can be always accessed :
component.userInterface("RegisterFileCheckBoxForm").RegisterFileCheckBox.checked;
This worked reliably only if the .ui file has been shown to the user,
which might not always been the case.
Change-Id: I7a87773e29f6210ab7160d8e33c41f6ebeeb82d6
Reviewed-by: Jarek Kobus <jaroslaw.kobus@theqtcompany.com>
Diffstat (limited to 'tests/auto')
4 files changed, 50 insertions, 0 deletions
diff --git a/tests/auto/installer/scriptengine/data/form.ui b/tests/auto/installer/scriptengine/data/form.ui new file mode 100644 index 000000000..4814f708f --- /dev/null +++ b/tests/auto/installer/scriptengine/data/form.ui @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>form</class> + <widget class="QWidget" name="form"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <widget class="QCheckBox" name="checkBox"> + <property name="geometry"> + <rect> + <x>90</x> + <y>90</y> + <width>78</width> + <height>19</height> + </rect> + </property> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </widget> + <resources/> + <connections/> +</ui> diff --git a/tests/auto/installer/scriptengine/data/userinterface.qs b/tests/auto/installer/scriptengine/data/userinterface.qs new file mode 100644 index 000000000..8aed71630 --- /dev/null +++ b/tests/auto/installer/scriptengine/data/userinterface.qs @@ -0,0 +1,5 @@ +function Component() +{ + // check that the .ui file has been properly loaded + console.log("checked: " + component.userInterface("form").checkBox.checked); +} diff --git a/tests/auto/installer/scriptengine/scriptengine.qrc b/tests/auto/installer/scriptengine/scriptengine.qrc index caffe3627..06829326e 100644 --- a/tests/auto/installer/scriptengine/scriptengine.qrc +++ b/tests/auto/installer/scriptengine/scriptengine.qrc @@ -5,5 +5,7 @@ <file>data/component2.qs</file> <file>data/broken_connect.qs</file> <file>data/dynamicpage.qs</file> + <file>data/form.ui</file> + <file>data/userinterface.qs</file> </qresource> </RCC> diff --git a/tests/auto/installer/scriptengine/tst_scriptengine.cpp b/tests/auto/installer/scriptengine/tst_scriptengine.cpp index 10fa9b79e..12915e30a 100644 --- a/tests/auto/installer/scriptengine/tst_scriptengine.cpp +++ b/tests/auto/installer/scriptengine/tst_scriptengine.cpp @@ -305,6 +305,17 @@ private slots: } } + void loadComponentUserInterfaces() + { + try { + setExpectedScriptOutput("\"checked: false\""); + m_component->loadUserInterfaces(QDir(":///data"), QStringList() << QLatin1String("form.ui")); + m_component->loadComponentScript(":///data/userinterface.qs"); + } catch (const Error &error) { + QFAIL(qPrintable(error.message())); + } + } + void loadSimpleAutoRunScript() { try { |