diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-04-21 11:29:35 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-04-21 14:08:48 +0000 |
commit | 00e81ce7a2a2b2f376a105089c861b1a0802c8dc (patch) | |
tree | 1389c2fb83d3c3cb93eebd4531a0f13c6c006821 /tests/auto/drawer | |
parent | 231b97436c62091d85405dc513a878c361ddf38a (diff) |
Fix QQuickDrawerPrivate::positionAt()
The position on the right and bottom edges is relative to the size of
the window, not the drawer itself.
Change-Id: Ia1d7418d4091a3a9e26f691bd75448023e0ca1cf
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'tests/auto/drawer')
-rw-r--r-- | tests/auto/drawer/data/applicationwindow.qml | 55 | ||||
-rw-r--r-- | tests/auto/drawer/drawer.pro | 14 | ||||
-rw-r--r-- | tests/auto/drawer/tst_drawer.cpp | 95 |
3 files changed, 164 insertions, 0 deletions
diff --git a/tests/auto/drawer/data/applicationwindow.qml b/tests/auto/drawer/data/applicationwindow.qml new file mode 100644 index 00000000..66e7e9df --- /dev/null +++ b/tests/auto/drawer/data/applicationwindow.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** 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.6 +import Qt.labs.controls 1.0 + +ApplicationWindow { + width: 400 + height: 400 + + property alias drawer: drawer + + Drawer { + id: drawer + width: 200 + height: 200 + } +} diff --git a/tests/auto/drawer/drawer.pro b/tests/auto/drawer/drawer.pro new file mode 100644 index 00000000..95ed44e9 --- /dev/null +++ b/tests/auto/drawer/drawer.pro @@ -0,0 +1,14 @@ +CONFIG += testcase +TARGET = tst_drawer +SOURCES += tst_drawer.cpp + +osx:CONFIG -= app_bundle + +QT += core-private gui-private qml-private quick-private testlib quicktemplates2-private + +include (../shared/util.pri) + +TESTDATA = data/* + +OTHER_FILES += \ + data/* diff --git a/tests/auto/drawer/tst_drawer.cpp b/tests/auto/drawer/tst_drawer.cpp new file mode 100644 index 00000000..557064a6 --- /dev/null +++ b/tests/auto/drawer/tst_drawer.cpp @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** 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: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/qtest.h> +#include <QtTest/qsignalspy.h> +#include "../shared/util.h" +#include "../shared/visualtestutil.h" + +#include <QtQuickTemplates2/private/qquickapplicationwindow_p.h> +#include <QtQuickTemplates2/private/qquickdrawer_p.h> + +using namespace QQuickVisualTestUtil; + +class tst_Drawer : public QQmlDataTest +{ + Q_OBJECT + +private slots: + void position_data(); + void position(); +}; + +void tst_Drawer::position_data() +{ + QTest::addColumn<Qt::Edge>("edge"); + QTest::addColumn<QPoint>("from"); + QTest::addColumn<QPoint>("to"); + QTest::addColumn<qreal>("position"); + + QTest::newRow("top") << Qt::TopEdge << QPoint(100, 0) << QPoint(100, 100) << qreal(0.5); + QTest::newRow("left") << Qt::LeftEdge << QPoint(0, 100) << QPoint(100, 100) << qreal(0.5); + QTest::newRow("right") << Qt::RightEdge << QPoint(399, 100) << QPoint(300, 100) << qreal(0.5); + QTest::newRow("bottom") << Qt::BottomEdge << QPoint(100, 399) << QPoint(100, 300) << qreal(0.5); +} + +void tst_Drawer::position() +{ + QFETCH(Qt::Edge, edge); + QFETCH(QPoint, from); + QFETCH(QPoint, to); + QFETCH(qreal, position); + + QQuickApplicationHelper helper(this, QStringLiteral("applicationwindow.qml")); + + QQuickApplicationWindow *window = helper.window; + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickDrawer *drawer = helper.window->property("drawer").value<QQuickDrawer*>(); + QVERIFY(drawer); + drawer->setEdge(edge); + + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, from); + QTest::mouseMove(window, to); + QCOMPARE(drawer->position(), position); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, to); +} + +QTEST_MAIN(tst_Drawer) + +#include "tst_drawer.moc" |