diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/auto.pro | 1 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_scrollview.qml | 49 | ||||
-rw-r--r-- | tests/auto/designer/designer.pro | 9 | ||||
-rw-r--r-- | tests/auto/designer/tst_designer.cpp | 161 | ||||
-rw-r--r-- | tests/auto/qquickiconlabel/tst_qquickiconlabel.cpp | 5 |
5 files changed, 225 insertions, 0 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index d4e0c604..d528b848 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -5,6 +5,7 @@ SUBDIRS += \ controls \ cursor \ customization \ + designer \ focus \ font \ palette \ diff --git a/tests/auto/controls/data/tst_scrollview.qml b/tests/auto/controls/data/tst_scrollview.qml index 7581b8c6..4d5b1e5b 100644 --- a/tests/auto/controls/data/tst_scrollview.qml +++ b/tests/auto/controls/data/tst_scrollview.qml @@ -118,6 +118,22 @@ TestCase { } Component { + id: emptyFlickable + ScrollView { + Flickable { + } + } + } + + Component { + id: labelComponent + Label { + text: "ABC" + font.pixelSize: 512 + } + } + + Component { id: scrollableListView ScrollView { ListView { @@ -241,6 +257,39 @@ TestCase { compare(control.contentHeight, listview.contentHeight) } + function test_flickableWithExplicitContentSize() { + var control = createTemporaryObject(emptyFlickable, testCase) + verify(control) + + var flickable = control.contentItem + verify(flickable.hasOwnProperty("contentX")) + verify(flickable.hasOwnProperty("contentY")) + + var flickableContentSize = 1000; + flickable.contentWidth = flickableContentSize; + flickable.contentHeight = flickableContentSize; + + compare(flickable.contentWidth, flickableContentSize) + compare(flickable.contentHeight, flickableContentSize) + compare(control.implicitWidth, flickableContentSize) + compare(control.implicitHeight, flickableContentSize) + compare(control.contentWidth, flickableContentSize) + compare(control.contentHeight, flickableContentSize) + + // Add a single child to the flickable. This should not + // trick ScrollView into taking the implicit size of + // the child as content size, since the flickable + // already has an explicit content size. + labelComponent.createObject(flickable); + + compare(flickable.contentWidth, flickableContentSize) + compare(flickable.contentHeight, flickableContentSize) + compare(control.implicitWidth, flickableContentSize) + compare(control.implicitHeight, flickableContentSize) + compare(control.contentWidth, flickableContentSize) + compare(control.contentHeight, flickableContentSize) + } + function test_mouse() { var control = createTemporaryObject(scrollView, testCase, {width: 200, height: 200, contentHeight: 400}) verify(control) diff --git a/tests/auto/designer/designer.pro b/tests/auto/designer/designer.pro new file mode 100644 index 00000000..68fbc747 --- /dev/null +++ b/tests/auto/designer/designer.pro @@ -0,0 +1,9 @@ +TEMPLATE = app +TARGET = tst_designer + +QT += quick quick-private quickcontrols2 testlib +CONFIG += testcase +macos:CONFIG -= app_bundle + +SOURCES += \ + $$PWD/tst_designer.cpp diff --git a/tests/auto/designer/tst_designer.cpp b/tests/auto/designer/tst_designer.cpp new file mode 100644 index 00000000..2c67c2c6 --- /dev/null +++ b/tests/auto/designer/tst_designer.cpp @@ -0,0 +1,161 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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:LGPL3$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest> +#include <QtQuick> + +#include <QtQuickControls2> +#include <QQmlComponent> +#include <QDir> + +#include <private/qquickdesignersupportitems_p.h> + +class tst_Designer : public QObject +{ + Q_OBJECT + +private slots: + void initTestCase(); + + void test_controls(); + void test_controls_data(); +}; + + +void tst_Designer::initTestCase() +{ +} + +void doComponentCompleteRecursive(QObject *object) +{ + if (object) { + QQuickItem *item = qobject_cast<QQuickItem*>(object); + + if (item && DesignerSupport::isComponentComplete(item)) + return; + + DesignerSupport::emitComponentCompleteSignalForAttachedProperty(qobject_cast<QQuickItem*>(object)); + + QList<QObject*> childList = object->children(); + + if (item) { + for (QQuickItem *childItem : item->childItems()) { + if (!childList.contains(childItem)) + childList.append(childItem); + } + } + + for (QObject *child : childList) + doComponentCompleteRecursive(child); + + if (item) { + static_cast<QQmlParserStatus*>(item)->componentComplete(); + } else { + QQmlParserStatus *qmlParserStatus = dynamic_cast< QQmlParserStatus*>(object); + if (qmlParserStatus) + qmlParserStatus->componentComplete(); + } + } +} + + +void tst_Designer::test_controls() +{ + QFETCH(QString, type); + + const QByteArray before("import QtQuick 2.10\n" + "import QtQuick.Controls 2.3\n" + "Item {\n"); + + QByteArray source = before; + source.append(type); + + const QByteArray after(" {" + "}\n" + "}\n"); + + source.append(after); + + QQmlEngine engine; + QQmlComponent component(&engine); + + { + ComponentCompleteDisabler disableComponentComplete; + component.setData(source, QUrl::fromLocalFile(QDir::current().absolutePath())); + } + + QObject *root = component.create(); + QVERIFY(root); + doComponentCompleteRecursive(root); +} + +void tst_Designer::test_controls_data() +{ + QTest::addColumn<QString>("type"); + + QTest::newRow("type") << "SpinBox"; + QTest::newRow("type") << "Switch"; + QTest::newRow("type") << "ComboBox"; + QTest::newRow("type") << "CheckBox"; + QTest::newRow("type") << "Button"; + QTest::newRow("type") << "DelayButton"; + QTest::newRow("type") << "Dial"; + QTest::newRow("type") << "Frame"; + QTest::newRow("type") << "GroupBox"; + QTest::newRow("type") << "Label"; + QTest::newRow("type") << "Page"; + QTest::newRow("type") << "Pane"; + QTest::newRow("type") << "ProgressBar"; + QTest::newRow("type") << "RadioButton"; + QTest::newRow("type") << "RangeSlider"; + QTest::newRow("type") << "RoundButton"; + QTest::newRow("type") << "ScrollView"; + QTest::newRow("type") << "Slider"; + QTest::newRow("type") << "StackView"; + QTest::newRow("type") << "SwipeView"; + QTest::newRow("type") << "Switch"; + QTest::newRow("type") << "TabBar"; + QTest::newRow("type") << "TabButton"; + QTest::newRow("type") << "TextArea"; + QTest::newRow("type") << "TextField"; + QTest::newRow("type") << "ToolBar"; + QTest::newRow("type") << "ToolButton"; + QTest::newRow("type") << "Tumbler"; +} + +QTEST_MAIN(tst_Designer) + +#include "tst_designer.moc" diff --git a/tests/auto/qquickiconlabel/tst_qquickiconlabel.cpp b/tests/auto/qquickiconlabel/tst_qquickiconlabel.cpp index 1f00d8e7..0ecc95c5 100644 --- a/tests/auto/qquickiconlabel/tst_qquickiconlabel.cpp +++ b/tests/auto/qquickiconlabel/tst_qquickiconlabel.cpp @@ -216,6 +216,11 @@ void tst_qquickiconlabel::display() QCOMPARE(label->implicitHeight(), qMax(icon->implicitHeight(), text->implicitHeight()) + verticalPadding); break; } + + if (text) + QCOMPARE(label->baselineOffset(), text->y() + text->baselineOffset()); + else + QCOMPARE(label->baselineOffset(), 0); } } |