diff options
author | Jeremy Katz <jeremy@panix.com> | 2016-06-22 12:12:06 -0700 |
---|---|---|
committer | Jeremy Katz <jeremy@panix.com> | 2016-07-20 09:49:51 +0000 |
commit | a717da9bb7e7e5e1b84008ba59559ce6d8d5dbcc (patch) | |
tree | ad7739aee13901e37f00b1680ed252c6b544282c /tests | |
parent | bc7d95510fd509535b2bfa3c715937b3c3d56507 (diff) |
Enable loading styles from multiple import paths
Import was previously allowed from two locations:
* qrc:/QtQuick/VirtualKeyboard/content/styles/
* The first import path containing
QtQuick/VirtualKeyboard/Styles/
This prevents an application-supplied style outside of
these locations from being used, even if the style name is unique.
[ChangeLog] Added support for styles in any Qml import path
under the directory QtQuick/VirtualKeyboard/Styles/<style>
Change-Id: Ie6034709182f182efacb0317e49d095d51ced5a6
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/auto.pro | 1 | ||||
-rw-r--r-- | tests/auto/styles/data/QtQuick/VirtualKeyboard/Styles/test/style.qml | 36 | ||||
-rw-r--r-- | tests/auto/styles/data/tst_styles.qml | 61 | ||||
-rw-r--r-- | tests/auto/styles/styles.pro | 23 | ||||
-rw-r--r-- | tests/auto/styles/tst_styles.cpp | 36 |
5 files changed, 157 insertions, 0 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 47f3c50a..508e6f97 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -2,4 +2,5 @@ TEMPLATE = subdirs SUBDIRS += \ inputpanel \ + styles \ diff --git a/tests/auto/styles/data/QtQuick/VirtualKeyboard/Styles/test/style.qml b/tests/auto/styles/data/QtQuick/VirtualKeyboard/Styles/test/style.qml new file mode 100644 index 00000000..efb8e3bd --- /dev/null +++ b/tests/auto/styles/data/QtQuick/VirtualKeyboard/Styles/test/style.qml @@ -0,0 +1,36 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Jeremy Katz +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Virtual Keyboard module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.VirtualKeyboard 2.1 +import QtQuick.VirtualKeyboard.Styles 2.1 + +KeyboardStyle { + +} diff --git a/tests/auto/styles/data/tst_styles.qml b/tests/auto/styles/data/tst_styles.qml new file mode 100644 index 00000000..0b4d3b37 --- /dev/null +++ b/tests/auto/styles/data/tst_styles.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Jeremy Katz +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Virtual Keyboard module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtTest 1.0 +import QtQuick 2.0 +import QtQuick.VirtualKeyboard.Settings 2.0 + +Item { + + TestCase { + id: testcase + name: "tst_styles" + + function test_style_data() { + return [ + { tag: "default", result: "default"}, + { tag: "retro", result: "retro"}, // in-source alternate style + { tag: "test", result: "test"} // out-of-source alternate style + ]; + } + + function test_style(data) { + VirtualKeyboardSettings.styleName = data.tag; + compare(VirtualKeyboardSettings.styleName, data.result, + "Failed setting VirtualKeyboardSettings.styleName to " + data.result); + } + + function test_unknownStyle() { + var previous = VirtualKeyboardSettings.styleName; + VirtualKeyboardSettings.styleName = "bogus"; + compare(VirtualKeyboardSettings.styleName, previous, + "Unknown style names should be ignored"); + } + } +} diff --git a/tests/auto/styles/styles.pro b/tests/auto/styles/styles.pro new file mode 100644 index 00000000..eda24717 --- /dev/null +++ b/tests/auto/styles/styles.pro @@ -0,0 +1,23 @@ +TEMPLATE = app +TARGET = tst_styles + +QT += testlib +CONFIG += qmltestcase console + +static { + QT += svg + QTPLUGIN += qtvirtualkeyboardplugin +} + +SOURCES += $$PWD/tst_styles.cpp + +TESTDATA = $$PWD/data/* +DEFINES += TESTDATA_DIR=\\\"$$_PRO_FILE_PWD_/data\\\" + +OTHER_FILES += \ + $$PWD/data/tst_styles.qml \ + +DISTFILES += \ + data/tst_styles.qml \ + data/QtQuick/VirtualKeyboard/Styles/test/style.qml \ + diff --git a/tests/auto/styles/tst_styles.cpp b/tests/auto/styles/tst_styles.cpp new file mode 100644 index 00000000..3d2a329f --- /dev/null +++ b/tests/auto/styles/tst_styles.cpp @@ -0,0 +1,36 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Jeremy Katz +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Virtual Keyboard module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtQuickTest/quicktest.h> +#include <QByteArray> + +static bool s_configImport = qputenv("QML2_IMPORT_PATH", TESTDATA_DIR); +static bool s_configIM = qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard")); + +QUICK_TEST_MAIN(styles) |