aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-09-02 17:28:05 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-09-02 17:28:16 +0200
commitfba02cc8ae7fb71abb927a06a8e480f7909dc029 (patch)
treed32e2c1f0070ab49fc85cdc89b744f9925b4e614 /tests/auto
parentf6c3ecdb0646a4d83be5c07dd5369d0b0350260c (diff)
parent33904b63ce9971efc3763a0048a084ec3324dfc4 (diff)
Merge remote-tracking branch 'origin/5.7' into 5.8
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/controls/data/tst_container.qml85
-rw-r--r--tests/auto/controls/data/tst_control.qml29
-rw-r--r--tests/auto/controls/data/tst_popup.qml10
-rw-r--r--tests/auto/controls/data/tst_scrollindicator.qml34
-rw-r--r--tests/auto/controls/data/tst_switch.qml11
-rw-r--r--tests/auto/drawer/tst_drawer.cpp3
-rw-r--r--tests/auto/qquickmaterialstyle/data/tst_material.qml29
7 files changed, 198 insertions, 3 deletions
diff --git a/tests/auto/controls/data/tst_container.qml b/tests/auto/controls/data/tst_container.qml
new file mode 100644
index 00000000..d1ff54e0
--- /dev/null
+++ b/tests/auto/controls/data/tst_container.qml
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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.2
+import QtTest 1.0
+import QtQuick.Controls 2.0
+import QtQuick.Templates 2.0 as T
+
+TestCase {
+ id: testCase
+ width: 400
+ height: 400
+ visible: true
+ when: windowShown
+ name: "Container"
+
+ Component {
+ id: container
+ Container { }
+ }
+
+ Component {
+ id: rectangle
+ Rectangle { }
+ }
+
+ function test_implicitSize() {
+ var control = container.createObject(testCase)
+ verify(control)
+
+ compare(control.implicitWidth, 0)
+ compare(control.implicitHeight, 0)
+
+ control.contentItem = rectangle.createObject(control, {implicitWidth: 10, implicitHeight: 20})
+ compare(control.implicitWidth, 10)
+ compare(control.implicitHeight, 20)
+
+ control.background = rectangle.createObject(control, {implicitWidth: 20, implicitHeight: 30})
+ compare(control.implicitWidth, 20)
+ compare(control.implicitHeight, 30)
+
+ control.padding = 100
+ compare(control.implicitWidth, 210)
+ compare(control.implicitHeight, 220)
+
+ control.destroy()
+ }
+}
diff --git a/tests/auto/controls/data/tst_control.qml b/tests/auto/controls/data/tst_control.qml
index fc839493..0061440b 100644
--- a/tests/auto/controls/data/tst_control.qml
+++ b/tests/auto/controls/data/tst_control.qml
@@ -53,7 +53,12 @@ TestCase {
Component {
id: component
- T.Control { }
+ Control { }
+ }
+
+ Component {
+ id: rectangle
+ Rectangle { }
}
Component {
@@ -877,4 +882,26 @@ TestCase {
control.destroy()
}
+
+ function test_implicitSize() {
+ var control = component.createObject(testCase)
+ verify(control)
+
+ compare(control.implicitWidth, 0)
+ compare(control.implicitHeight, 0)
+
+ control.contentItem = rectangle.createObject(control, {implicitWidth: 10, implicitHeight: 20})
+ compare(control.implicitWidth, 10)
+ compare(control.implicitHeight, 20)
+
+ control.background = rectangle.createObject(control, {implicitWidth: 20, implicitHeight: 30})
+ compare(control.implicitWidth, 20)
+ compare(control.implicitHeight, 30)
+
+ control.padding = 100
+ compare(control.implicitWidth, 210)
+ compare(control.implicitHeight, 220)
+
+ control.destroy()
+ }
}
diff --git a/tests/auto/controls/data/tst_popup.qml b/tests/auto/controls/data/tst_popup.qml
index 759d6988..52c24c86 100644
--- a/tests/auto/controls/data/tst_popup.qml
+++ b/tests/auto/controls/data/tst_popup.qml
@@ -1159,17 +1159,23 @@ TestCase {
tryCompare(window.plainPopup, "visible", true)
compare(window.overlay.children.length, countBefore + 1) // only popup added, no overlays involved
+ window.plainPopup.modal = true
+ compare(window.overlay.children.length, countBefore + 2) // overlay added
+
window.plainPopup.close()
tryCompare(window.plainPopup, "visible", false)
- compare(window.overlay.children.length, countBefore) // only popup removed, no overlays involved
+ compare(window.overlay.children.length, countBefore) // popup + overlay removed
window.modalPopupWithoutDim.open()
tryCompare(window.modalPopupWithoutDim, "visible", true)
compare(window.overlay.children.length, countBefore + 1) // only popup added, no overlays involved
+ window.modalPopupWithoutDim.dim = true
+ compare(window.overlay.children.length, countBefore + 2) // overlay added
+
window.modalPopupWithoutDim.close()
tryCompare(window.modalPopupWithoutDim, "visible", false)
- compare(window.overlay.children.length, countBefore) // only popup added, no overlays involved
+ compare(window.overlay.children.length, countBefore) // popup + overlay removed
window.destroy()
}
diff --git a/tests/auto/controls/data/tst_scrollindicator.qml b/tests/auto/controls/data/tst_scrollindicator.qml
index 00730bf4..551247f6 100644
--- a/tests/auto/controls/data/tst_scrollindicator.qml
+++ b/tests/auto/controls/data/tst_scrollindicator.qml
@@ -157,4 +157,38 @@ TestCase {
ignoreWarning(Qt.resolvedUrl("tst_scrollindicator.qml") + ":45:1: QML TestCase: ScrollIndicator must be attached to a Flickable")
testCase.ScrollIndicator.vertical = null
}
+
+ function test_overshoot() {
+ var container = flickable.createObject(testCase)
+ verify(container)
+ waitForRendering(container)
+
+ var vertical = scrollIndicator.createObject(container, {size: 0.5})
+ container.ScrollIndicator.vertical = vertical
+
+ var horizontal = scrollIndicator.createObject(container, {size: 0.5})
+ container.ScrollIndicator.horizontal = horizontal
+
+ // negative vertical overshoot (pos < 0)
+ vertical.position = -0.1
+ compare(vertical.contentItem.y, vertical.topPadding)
+ compare(vertical.contentItem.height, 0.4 * vertical.availableHeight)
+
+ // positive vertical overshoot (pos + size > 1)
+ vertical.position = 0.8
+ compare(vertical.contentItem.y, vertical.topPadding + 0.8 * vertical.availableHeight)
+ compare(vertical.contentItem.height, 0.2 * vertical.availableHeight)
+
+ // negative horizontal overshoot (pos < 0)
+ horizontal.position = -0.1
+ compare(horizontal.contentItem.x, horizontal.leftPadding)
+ compare(horizontal.contentItem.width, 0.4 * horizontal.availableWidth)
+
+ // positive horizontal overshoot (pos + size > 1)
+ horizontal.position = 0.8
+ compare(horizontal.contentItem.x, horizontal.leftPadding + 0.8 * horizontal.availableWidth)
+ compare(horizontal.contentItem.width, 0.2 * horizontal.availableWidth)
+
+ container.destroy()
+ }
}
diff --git a/tests/auto/controls/data/tst_switch.qml b/tests/auto/controls/data/tst_switch.qml
index b75e2713..ec609ca6 100644
--- a/tests/auto/controls/data/tst_switch.qml
+++ b/tests/auto/controls/data/tst_switch.qml
@@ -263,4 +263,15 @@ TestCase {
compare(control.baselineOffset, control.contentItem.y + control.contentItem.baselineOffset)
control.destroy()
}
+
+ function test_focus() {
+ var control = swtch.createObject(testCase)
+ verify(control)
+
+ verify(!control.activeFocus)
+ mouseClick(control.indicator)
+ verify(control.activeFocus)
+
+ control.destroy()
+ }
}
diff --git a/tests/auto/drawer/tst_drawer.cpp b/tests/auto/drawer/tst_drawer.cpp
index 0507d01e..0b334387 100644
--- a/tests/auto/drawer/tst_drawer.cpp
+++ b/tests/auto/drawer/tst_drawer.cpp
@@ -98,7 +98,10 @@ void tst_Drawer::position()
QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, from);
QTest::mouseMove(window, to);
QCOMPARE(drawer->position(), position);
+
+ // moved half-way open at almost infinite speed => snap to open
QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, to);
+ QTRY_COMPARE(drawer->position(), 1.0);
}
void tst_Drawer::dragMargin_data()
diff --git a/tests/auto/qquickmaterialstyle/data/tst_material.qml b/tests/auto/qquickmaterialstyle/data/tst_material.qml
index 8eb6933c..9411891f 100644
--- a/tests/auto/qquickmaterialstyle/data/tst_material.qml
+++ b/tests/auto/qquickmaterialstyle/data/tst_material.qml
@@ -74,6 +74,11 @@ TestCase {
}
Component {
+ id: applicationWindow
+ ApplicationWindow { }
+ }
+
+ Component {
id: styledWindow
Window {
Material.theme: Material.Dark
@@ -600,4 +605,28 @@ TestCase {
window.destroy()
}
+
+ function test_buttonBackground() {
+ var appWindow = applicationWindow.createObject(testCase)
+ verify(appWindow)
+ appWindow.visible = true
+
+ var childButton = button.createObject(appWindow)
+ verify(childButton)
+
+ var buttonBackgroundColor = childButton.background.color
+ appWindow.Material.background = "red"
+ // We wait the length of the color animation to be sure that it hasn't actually changed.
+ wait(400)
+ // We want childButton.Material.background to be equal to appWindow.Material.background,
+ // because we want the color to propagate to items that might actually use it...
+ // but Button doesn't use the background color unless explicitly set,
+ // so we compare the actual background rect color instead.
+ compare(childButton.background.color, buttonBackgroundColor)
+
+ childButton.Material.background = "#0000ff"
+ tryCompare(childButton.background, "color", "#0000ff")
+
+ appWindow.destroy()
+ }
}