diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/controls/data/tst_abstractbutton.qml | 8 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_dial.qml | 18 | ||||
-rw-r--r-- | tests/auto/translation/data/dialogButtonBox.qml | 61 | ||||
-rw-r--r-- | tests/auto/translation/qtbase_fr.ts | 22 | ||||
-rw-r--r-- | tests/auto/translation/translation.pro | 19 | ||||
-rw-r--r-- | tests/auto/translation/tst_translation.cpp | 100 |
6 files changed, 218 insertions, 10 deletions
diff --git a/tests/auto/controls/data/tst_abstractbutton.qml b/tests/auto/controls/data/tst_abstractbutton.qml index 80155f69..ee26a6d6 100644 --- a/tests/auto/controls/data/tst_abstractbutton.qml +++ b/tests/auto/controls/data/tst_abstractbutton.qml @@ -599,7 +599,7 @@ TestCase { AbstractButton { action: Action { text: "Default" - icon.name: "default" + icon.name: checked ? "checked" : "unchecked" icon.source: "qrc:/icons/default.png" checkable: true checked: true @@ -617,6 +617,7 @@ TestCase { compare(control.checkable, true) compare(control.checked, true) compare(control.enabled, false) + compare(control.icon.name, "checked") var textSpy = signalSpy.createObject(control, { target: control, signalName: "textChanged" }) verify(textSpy.valid) @@ -630,6 +631,7 @@ TestCase { compare(control.checkable, false) // propagates compare(control.checked, false) // propagates compare(control.enabled, true) // propagates + compare(control.icon.name, "unchecked") // propagates compare(textSpy.count, 1) // changes via button @@ -637,19 +639,23 @@ TestCase { control.checkable = true control.checked = true control.enabled = false + control.icon.name = "default" compare(control.text, "Button") compare(control.checkable, true) compare(control.checked, true) compare(control.enabled, false) + compare(control.icon.name, "default") compare(control.action.text, "Action") // does NOT propagate compare(control.action.checkable, true) // propagates compare(control.action.checked, true) // propagates compare(control.action.enabled, true) // does NOT propagate + compare(control.action.icon.name, control.action.checked ? "checked" : "unchecked") // does NOT propagate compare(textSpy.count, 2) // remove the action so that only the button's properties are left control.action = null compare(control.text, "Button") + compare(control.icon.name, "default") compare(textSpy.count, 2) // setting an action while button has a particular property set diff --git a/tests/auto/controls/data/tst_dial.qml b/tests/auto/controls/data/tst_dial.qml index cd2f6112..86999594 100644 --- a/tests/auto/controls/data/tst_dial.qml +++ b/tests/auto/controls/data/tst_dial.qml @@ -470,15 +470,15 @@ TestCase { function test_snapMode_data(immediate) { return [ - { tag: "NoSnap", snapMode: Slider.NoSnap, from: 0, to: 2, values: [0, 0, 1], positions: [0, 0.5, 0.5] }, - { tag: "SnapAlways (0..2)", snapMode: Slider.SnapAlways, from: 0, to: 2, values: [0.0, 0.0, 1.0], positions: [0.0, 0.5, 0.5] }, - { tag: "SnapAlways (1..3)", snapMode: Slider.SnapAlways, from: 1, to: 3, values: [1.0, 1.0, 2.0], positions: [0.0, 0.5, 0.5] }, - { tag: "SnapAlways (-1..1)", snapMode: Slider.SnapAlways, from: -1, to: 1, values: [0.0, 0.0, 0.0], positions: [0.5, 0.5, 0.5] }, - { tag: "SnapAlways (1..-1)", snapMode: Slider.SnapAlways, from: 1, to: -1, values: [1.0, 1.0, 0.0], positions: [0.0, 0.5, 0.5] }, - { tag: "SnapOnRelease (0..2)", snapMode: Slider.SnapOnRelease, from: 0, to: 2, values: [0.0, 0.0, 1.0], positions: [0.0, 0.5, 0.5] }, - { tag: "SnapOnRelease (1..3)", snapMode: Slider.SnapOnRelease, from: 1, to: 3, values: [1.0, 1.0, 2.0], positions: [0.0, 0.5, 0.5] }, - { tag: "SnapOnRelease (-1..1)", snapMode: Slider.SnapOnRelease, from: -1, to: 1, values: [0.0, 0.0, 0.0], positions: [immediate ? 0.0 : 0.5, 0.5, 0.5] }, - { tag: "SnapOnRelease (1..-1)", snapMode: Slider.SnapOnRelease, from: 1, to: -1, values: [1.0, 1.0, 0.0], positions: [0.0, 0.5, 0.5] } + { tag: "NoSnap", snapMode: Dial.NoSnap, from: 0, to: 2, values: [0, 0, 1], positions: [0, 0.5, 0.5] }, + { tag: "SnapAlways (0..2)", snapMode: Dial.SnapAlways, from: 0, to: 2, values: [0.0, 0.0, 1.0], positions: [0.0, 0.5, 0.5] }, + { tag: "SnapAlways (1..3)", snapMode: Dial.SnapAlways, from: 1, to: 3, values: [1.0, 1.0, 2.0], positions: [0.0, 0.5, 0.5] }, + { tag: "SnapAlways (-1..1)", snapMode: Dial.SnapAlways, from: -1, to: 1, values: [0.0, 0.0, 0.0], positions: [0.5, 0.5, 0.5] }, + { tag: "SnapAlways (1..-1)", snapMode: Dial.SnapAlways, from: 1, to: -1, values: [1.0, 1.0, 0.0], positions: [0.0, 0.5, 0.5] }, + { tag: "SnapOnRelease (0..2)", snapMode: Dial.SnapOnRelease, from: 0, to: 2, values: [0.0, 0.0, 1.0], positions: [0.0, 0.5, 0.5] }, + { tag: "SnapOnRelease (1..3)", snapMode: Dial.SnapOnRelease, from: 1, to: 3, values: [1.0, 1.0, 2.0], positions: [0.0, 0.5, 0.5] }, + { tag: "SnapOnRelease (-1..1)", snapMode: Dial.SnapOnRelease, from: -1, to: 1, values: [0.0, 0.0, 0.0], positions: [immediate ? 0.0 : 0.5, 0.5, 0.5] }, + { tag: "SnapOnRelease (1..-1)", snapMode: Dial.SnapOnRelease, from: 1, to: -1, values: [1.0, 1.0, 0.0], positions: [0.0, 0.5, 0.5] } ] } diff --git a/tests/auto/translation/data/dialogButtonBox.qml b/tests/auto/translation/data/dialogButtonBox.qml new file mode 100644 index 00000000..03a3ae0e --- /dev/null +++ b/tests/auto/translation/data/dialogButtonBox.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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. +** +** BSD License Usage +** Alternatively, 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.13 +import QtQuick.Controls 2.13 + +Item { + property Dialog dialog: Dialog { + width: 300 + height: 300 + visible: true + standardButtons: DialogButtonBox.Save | DialogButtonBox.Discard + } +} diff --git a/tests/auto/translation/qtbase_fr.ts b/tests/auto/translation/qtbase_fr.ts new file mode 100644 index 00000000..a2a05a07 --- /dev/null +++ b/tests/auto/translation/qtbase_fr.ts @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="fr_FR"> +<context> + <name>QPlatformTheme</name> + <message> + <source>Save</source> + <translation>Enregistrer</translation> + </message> + <message> + <source>Discard</source> + <translation>Ne pas tenir compte</translation> + </message> +</context> +<context> + <name>QGnomeTheme</name> + <message> + <source>&Save</source> + <translation>&Enregistrer</translation> + </message> +</context> +</TS> diff --git a/tests/auto/translation/translation.pro b/tests/auto/translation/translation.pro new file mode 100644 index 00000000..d2d9d6ee --- /dev/null +++ b/tests/auto/translation/translation.pro @@ -0,0 +1,19 @@ +CONFIG += testcase +TARGET = tst_translation +SOURCES += tst_translation.cpp + +macos:CONFIG -= app_bundle + +QT += testlib gui-private quicktemplates2-private + +include (../shared/util.pri) + +TESTDATA = data/* + +OTHER_FILES += \ + data/*.qml + +# We only want to run lrelease, which is why we use EXTRA_TRANSLATIONS. +EXTRA_TRANSLATIONS = qtbase_fr.ts +# Embed the translations in a qrc file. +CONFIG += lrelease embed_translations diff --git a/tests/auto/translation/tst_translation.cpp b/tests/auto/translation/tst_translation.cpp new file mode 100644 index 00000000..9cbca915 --- /dev/null +++ b/tests/auto/translation/tst_translation.cpp @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2019 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 "../shared/visualtestutil.h" + +#include <QtCore/qtranslator.h> +#include <QtGui/private/qguiapplication_p.h> +#include <QtGui/qpa/qplatformtheme.h> +#include <QtQuick/qquickview.h> +#include <QtQuickTemplates2/private/qquickabstractbutton_p.h> +#include <QtQuickTemplates2/private/qquickdialog_p.h> +#include <QtQuickTemplates2/private/qquickdialogbuttonbox_p.h> + +using namespace QQuickVisualTestUtil; + +class tst_translation : public QQmlDataTest +{ + Q_OBJECT + +private slots: + void dialogButtonBox(); +}; + +void tst_translation::dialogButtonBox() +{ + QQuickView view(testFileUrl("dialogButtonBox.qml")); + if (view.status() != QQuickView::Ready) + QFAIL("Failed to load QML file"); + view.show(); + QVERIFY(QTest::qWaitForWindowActive(&view)); + + QQuickDialog *dialog = view.rootObject()->property("dialog").value<QQuickDialog*>(); + QVERIFY(dialog); + + QQuickDialogButtonBox *dialogButtonBox = qobject_cast<QQuickDialogButtonBox*>(dialog->footer()); + QVERIFY(dialogButtonBox); + + QQuickAbstractButton *saveButton = dialogButtonBox->standardButton(QPlatformDialogHelper::Save); + QVERIFY(saveButton); + QString defaultSaveText = QGuiApplicationPrivate::platformTheme()->standardButtonText(QPlatformDialogHelper::Save); + defaultSaveText = QPlatformTheme::removeMnemonics(defaultSaveText); + QCOMPARE(saveButton->text(), defaultSaveText); + + QQuickAbstractButton *discardButton = dialogButtonBox->standardButton(QPlatformDialogHelper::Discard); + QVERIFY(discardButton); + QString defaultDiscardText = QGuiApplicationPrivate::platformTheme()->standardButtonText(QPlatformDialogHelper::Discard); + defaultDiscardText = QPlatformTheme::removeMnemonics(defaultDiscardText); + QCOMPARE(discardButton->text(), defaultDiscardText); + + QTranslator translator; + QVERIFY(translator.load(":/i18n/qtbase_fr.qm")); + QVERIFY(qApp->installTranslator(&translator)); + view.engine()->retranslate(); + + QString translatedSaveText = QGuiApplicationPrivate::platformTheme()->standardButtonText(QPlatformDialogHelper::Save); + translatedSaveText = QPlatformTheme::removeMnemonics(translatedSaveText); + QCOMPARE(saveButton->text(), translatedSaveText); + + QString translatedDiscardText = QGuiApplicationPrivate::platformTheme()->standardButtonText(QPlatformDialogHelper::Discard); + translatedDiscardText = QPlatformTheme::removeMnemonics(translatedDiscardText); + QCOMPARE(discardButton->text(), translatedDiscardText); +} + +QTEST_MAIN(tst_translation) + +#include "tst_translation.moc" |