From 047bdf90db4d00d0462b9faf2044070be4a0e682 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Mon, 3 Jul 2017 08:41:03 +0200 Subject: testlib: add key sequence function [ChangeLog][QtQuick][QtTest] Added keySequence() function in TestCase. Task-number: QTBUG-53381 Change-Id: Iea25410d40fc0745e16a10c1af35ec81c4c83668 Reviewed-by: Edward Welbourne Reviewed-by: Shawn Rutledge Reviewed-by: Mitch Curtis --- tests/auto/qmltest/qmltest.pro | 1 + tests/auto/qmltest/shortcut/shortcut.pro | 1 + tests/auto/qmltest/shortcut/tst_shortcut.qml | 70 ++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 tests/auto/qmltest/shortcut/shortcut.pro create mode 100644 tests/auto/qmltest/shortcut/tst_shortcut.qml (limited to 'tests') diff --git a/tests/auto/qmltest/qmltest.pro b/tests/auto/qmltest/qmltest.pro index 8ad1541cbc..45f240e1d1 100644 --- a/tests/auto/qmltest/qmltest.pro +++ b/tests/auto/qmltest/qmltest.pro @@ -22,6 +22,7 @@ SUBDIRS += \ rectangle \ selftests \ shadersource \ + shortcut \ stability \ statemachine \ text \ diff --git a/tests/auto/qmltest/shortcut/shortcut.pro b/tests/auto/qmltest/shortcut/shortcut.pro new file mode 100644 index 0000000000..a7938e7003 --- /dev/null +++ b/tests/auto/qmltest/shortcut/shortcut.pro @@ -0,0 +1 @@ +CONFIG += qmltestcase diff --git a/tests/auto/qmltest/shortcut/tst_shortcut.qml b/tests/auto/qmltest/shortcut/tst_shortcut.qml new file mode 100644 index 0000000000..62b335be48 --- /dev/null +++ b/tests/auto/qmltest/shortcut/tst_shortcut.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** 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: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.8 +import QtQuick.Window 2.2 +import QtTest 1.2 + +TestCase { + name: "ShortCut" + when: windowShown + + Shortcut { + id: shortcut + property bool everActivated: false + sequence: StandardKey.NextChild + onActivated: everActivated = true + } + + Shortcut { + id: shortcut2 + property bool everActivated: false + sequence: "Ctrl+E,Ctrl+W" + onActivated: everActivated = true + } + + function test_shortcut() { + keySequence(StandardKey.NextChild) + verify(shortcut.everActivated); + + keySequence("Ctrl+E,Ctrl+W") + verify(shortcut2.everActivated); + } +} -- cgit v1.2.3