aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2016-02-11 13:09:48 +0100
committerLiang Qi <liang.qi@theqtcompany.com>2016-02-18 12:53:28 +0000
commita40591931dd372829982055d4000c5caf3df9d07 (patch)
tree9a60890e99b1017433ae433049005953935dca98 /tests
parent3cba8b19c4e67cbcd6977bf141d7ddf2e54aae85 (diff)
Controls: fix font inheritance for popups
QQuickPopup is a QObject, not a QQuickControl. Then need to make QQuickPopup::popupItem() inherit its font from QQuickPopup::parentItem(). Task-number: QTBUG-50984 Change-Id: I7f417474172b533b744eb668a0476cdcbabba868 Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/controls/data/tst_combobox.qml91
-rw-r--r--tests/auto/controls/data/tst_popup.qml139
2 files changed, 230 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml
index 55ac3e8d..b112f20c 100644
--- a/tests/auto/controls/data/tst_combobox.qml
+++ b/tests/auto/controls/data/tst_combobox.qml
@@ -626,4 +626,95 @@ TestCase {
control.destroy()
}
+
+ Component {
+ id: component
+ Pane {
+ id: panel
+ property alias button: _button;
+ property alias combobox: _combobox;
+ font.pixelSize: 30
+ Column {
+ Button {
+ id: _button
+ text: "Button"
+ font.pixelSize: 20
+ }
+ ComboBox {
+ id: _combobox
+ model: ["ComboBox", "With"]
+ delegate: ItemDelegate {
+ width: _combobox.width
+ text: _combobox.textRole ? (Array.isArray(_combobox.model) ? modelData[_combobox.textRole] : model[_combobox.textRole]) : modelData
+ objectName: "delegate"
+ checkable: true
+ autoExclusive: true
+ checked: _combobox.currentIndex === index
+ highlighted: _combobox.highlightedIndex === index
+ pressed: highlighted && _combobox.pressed
+ }
+ }
+ }
+ }
+ }
+
+ function getChild(control, objname, idx) {
+ var index = idx
+ for (var i = index+1; i < control.children.length; i++)
+ {
+ if (control.children[i].objectName === objname) {
+ index = i
+ break
+ }
+ }
+ return index
+ }
+
+ function test_font() { // QTBUG_50984
+ var control = component.createObject(window.contentItem)
+ verify(control)
+ verify(control.button)
+ verify(control.combobox)
+
+ waitForRendering(control)
+
+ control.forceActiveFocus()
+ verify(control.activeFocus)
+
+ compare(control.font.pixelSize, 30)
+ compare(control.button.font.pixelSize, 20)
+ compare(control.combobox.font.pixelSize, 30)
+
+ verify(control.combobox.popup)
+ var popup = control.combobox.popup
+ popup.open()
+
+ verify(popup.contentItem)
+
+ var listview = popup.contentItem
+ verify(listview.contentItem)
+ waitForRendering(listview)
+
+ var idx1 = getChild(listview.contentItem, "delegate", -1)
+ compare(listview.contentItem.children[idx1].font.pixelSize, 30)
+ var idx2 = getChild(listview.contentItem, "delegate", idx1)
+ compare(listview.contentItem.children[idx2].font.pixelSize, 30)
+
+ control.font.pixelSize = control.font.pixelSize + 10
+ compare(control.combobox.font.pixelSize, 40)
+ waitForRendering(listview)
+ compare(listview.contentItem.children[idx1].font.pixelSize, 40)
+ compare(listview.contentItem.children[idx2].font.pixelSize, 40)
+
+ control.combobox.font.pixelSize = control.combobox.font.pixelSize + 5
+ compare(control.combobox.font.pixelSize, 45)
+ waitForRendering(listview)
+
+ idx1 = getChild(listview.contentItem, "delegate", -1)
+ compare(listview.contentItem.children[idx1].font.pixelSize, 45)
+ idx2 = getChild(listview.contentItem, "delegate", idx1)
+ compare(listview.contentItem.children[idx2].font.pixelSize, 45)
+
+ control.destroy()
+ }
}
diff --git a/tests/auto/controls/data/tst_popup.qml b/tests/auto/controls/data/tst_popup.qml
new file mode 100644
index 00000000..68cd7d85
--- /dev/null
+++ b/tests/auto/controls/data/tst_popup.qml
@@ -0,0 +1,139 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtTest 1.0
+import Qt.labs.controls 1.0
+
+TestCase {
+ id: testCase
+ width: 480
+ height: 360
+ visible: true
+ when: windowShown
+ name: "Control"
+
+ function getChild(control, objname, idx) {
+ var index = idx
+ for (var i = index+1; i < control.children.length; i++)
+ {
+ if (control.children[i].objectName === objname) {
+ index = i
+ break
+ }
+ }
+ return index
+ }
+
+ Component {
+ id: component
+ Pane {
+ id: panel
+ property alias button: _button;
+ property alias popup: _popup;
+ property alias listview: _listview
+ font.pixelSize: 30
+ Column {
+ Button {
+ id: _button
+ text: "Button"
+ font.pixelSize: 20
+
+ Popup {
+ id: _popup
+ y: button.height
+ implicitHeight: Math.min(396, _listview.contentHeight)
+ contentItem: ListView {
+ id: _listview
+ height: _button.height * 20
+ model: 2
+ delegate: Button {
+ objectName: "delegate"
+ width: _button.width
+ height: _button.height
+ text: "N: " + index
+ checkable: true
+ autoExclusive: true
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ function test_font() { // QTBUG_50984
+ var control = component.createObject(testCase)
+ verify(control)
+ verify(control.button)
+ verify(control.popup)
+ verify(control.listview)
+
+ waitForRendering(control)
+
+ control.forceActiveFocus()
+ verify(control.activeFocus)
+
+ compare(control.font.pixelSize, 30)
+ compare(control.button.font.pixelSize, 20)
+
+ var popup = control.popup
+ popup.open()
+
+ verify(popup.contentItem)
+
+ var listview = popup.contentItem
+ verify(listview.contentItem)
+ waitForRendering(listview)
+
+ var idx1 = getChild(listview.contentItem, "delegate", -1)
+ compare(listview.contentItem.children[idx1].font.pixelSize, 20)
+ var idx2 = getChild(listview.contentItem, "delegate", idx1)
+ compare(listview.contentItem.children[idx2].font.pixelSize, 20)
+
+ control.button.font.pixelSize = control.button.font.pixelSize + 10
+ compare(control.button.font.pixelSize, 30)
+ waitForRendering(listview)
+ compare(listview.contentItem.children[idx1].font.pixelSize, 30)
+ compare(listview.contentItem.children[idx2].font.pixelSize, 30)
+
+ control.destroy()
+ }
+}