diff options
Diffstat (limited to 'tests/auto/quickcontrols2/translation')
-rw-r--r-- | tests/auto/quickcontrols2/translation/CMakeLists.txt | 63 | ||||
-rw-r--r-- | tests/auto/quickcontrols2/translation/data/comboBox.qml | 65 | ||||
-rw-r--r-- | tests/auto/quickcontrols2/translation/data/dialogButtonBox.qml | 61 | ||||
-rw-r--r-- | tests/auto/quickcontrols2/translation/data/dialogButtonBoxWithCustomButtons.qml | 75 | ||||
-rw-r--r-- | tests/auto/quickcontrols2/translation/qml_jp.qm | bin | 135 -> 0 bytes | |||
-rw-r--r-- | tests/auto/quickcontrols2/translation/qml_jp.ts | 28 | ||||
-rw-r--r-- | tests/auto/quickcontrols2/translation/qtbase_fr.qm | bin | 259 -> 0 bytes | |||
-rw-r--r-- | tests/auto/quickcontrols2/translation/qtbase_fr.ts | 23 | ||||
-rw-r--r-- | tests/auto/quickcontrols2/translation/tst_translation.cpp | 173 |
9 files changed, 0 insertions, 488 deletions
diff --git a/tests/auto/quickcontrols2/translation/CMakeLists.txt b/tests/auto/quickcontrols2/translation/CMakeLists.txt deleted file mode 100644 index e21dc999..00000000 --- a/tests/auto/quickcontrols2/translation/CMakeLists.txt +++ /dev/null @@ -1,63 +0,0 @@ -# Generated from translation.pro. - -##################################################################### -## tst_translation Test: -##################################################################### - -# Collect test data -file(GLOB_RECURSE test_data_glob - RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} - data/*) -list(APPEND test_data ${test_data_glob}) - -qt_internal_add_test(tst_translation - SOURCES - ../shared/qtest_quickcontrols.h - ../shared/util.cpp ../shared/util.h - ../shared/visualtestutil.cpp ../shared/visualtestutil.h - tst_translation.cpp - DEFINES - QQC2_IMPORT_PATH=\\\"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/quickcontrols2\\\" - PUBLIC_LIBRARIES - Qt::CorePrivate - Qt::Gui - Qt::GuiPrivate - Qt::QmlPrivate - Qt::QuickControls2 - Qt::QuickControls2Private - Qt::QuickPrivate - Qt::QuickTemplates2Private - Qt::QuickTest - Qt::TestPrivate - TESTDATA ${test_data} -) - -# Resources: -set(qmake_immediate_resource_files - "qml_jp.qm" - "qtbase_fr.qm" -) - -qt_internal_add_resource(tst_translation "qmake_immediate" - PREFIX - "/" - FILES - ${qmake_immediate_resource_files} -) - - -#### Keys ignored in scope 1:.:.:translation.pro:<TRUE>: -# OTHER_FILES = "data/*.qml" - -## Scopes: -##################################################################### - -qt_internal_extend_target(tst_translation CONDITION ANDROID OR IOS - DEFINES - QT_QMLTEST_DATADIR=\\\":/data\\\" -) - -qt_internal_extend_target(tst_translation CONDITION NOT ANDROID AND NOT IOS - DEFINES - QT_QMLTEST_DATADIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}/data\\\" -) diff --git a/tests/auto/quickcontrols2/translation/data/comboBox.qml b/tests/auto/quickcontrols2/translation/data/comboBox.qml deleted file mode 100644 index cba1cf0c..00000000 --- a/tests/auto/quickcontrols2/translation/data/comboBox.qml +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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 -import QtQuick.Controls - -ComboBox { - objectName: "comboBox" - textRole: "label" - model: ListModel { - ListElement { - label: qsTr("Hello") - } - ListElement { - label: qsTr("ListView") - } - } -} diff --git a/tests/auto/quickcontrols2/translation/data/dialogButtonBox.qml b/tests/auto/quickcontrols2/translation/data/dialogButtonBox.qml deleted file mode 100644 index fd8f9548..00000000 --- a/tests/auto/quickcontrols2/translation/data/dialogButtonBox.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** 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 -import QtQuick.Controls - -Item { - property Dialog dialog: Dialog { - width: 300 - height: 300 - visible: true - standardButtons: DialogButtonBox.Save | DialogButtonBox.Discard - } -} diff --git a/tests/auto/quickcontrols2/translation/data/dialogButtonBoxWithCustomButtons.qml b/tests/auto/quickcontrols2/translation/data/dialogButtonBoxWithCustomButtons.qml deleted file mode 100644 index bf0fb512..00000000 --- a/tests/auto/quickcontrols2/translation/data/dialogButtonBoxWithCustomButtons.qml +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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 -import QtQuick.Controls - -Item { - property Dialog dialog: Dialog { - width: 300 - height: 300 - visible: true - - footer: DialogButtonBox { - Button { - objectName: "okButton" - text: qsTr("OK") - - DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole - } - Button { - objectName: "cancelButton" - text: qsTr("Cancel") - - DialogButtonBox.buttonRole: DialogButtonBox.RejectRole - } - } - } -} diff --git a/tests/auto/quickcontrols2/translation/qml_jp.qm b/tests/auto/quickcontrols2/translation/qml_jp.qm Binary files differdeleted file mode 100644 index a3712e99..00000000 --- a/tests/auto/quickcontrols2/translation/qml_jp.qm +++ /dev/null diff --git a/tests/auto/quickcontrols2/translation/qml_jp.ts b/tests/auto/quickcontrols2/translation/qml_jp.ts deleted file mode 100644 index 303c142f..00000000 --- a/tests/auto/quickcontrols2/translation/qml_jp.ts +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE TS> -<TS version="2.1" language="ja_JP"> -<context> - <name>main</name> - <message> - <location filename="../main.qml" line="8"/> - <source>Hello World</source> - <translation>こんにちは世界</translation> - </message> - <message> - <location filename="../main.qml" line="12"/> - <source>Hello Text</source> - <translation>ハローテキスト</translation> - </message> - <message> - <location filename="../main.qml" line="35"/> - <source>Hello</source> - <translation>こんにちは</translation> - </message> - <message> - <location filename="../main.qml" line="38"/> - <source>ListView</source> - <translation>リストビュー</translation> - </message> -</context> -</TS> - diff --git a/tests/auto/quickcontrols2/translation/qtbase_fr.qm b/tests/auto/quickcontrols2/translation/qtbase_fr.qm Binary files differdeleted file mode 100644 index 176675a8..00000000 --- a/tests/auto/quickcontrols2/translation/qtbase_fr.qm +++ /dev/null diff --git a/tests/auto/quickcontrols2/translation/qtbase_fr.ts b/tests/auto/quickcontrols2/translation/qtbase_fr.ts deleted file mode 100644 index 7aff8bd7..00000000 --- a/tests/auto/quickcontrols2/translation/qtbase_fr.ts +++ /dev/null @@ -1,23 +0,0 @@ -<?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/quickcontrols2/translation/tst_translation.cpp b/tests/auto/quickcontrols2/translation/tst_translation.cpp deleted file mode 100644 index 58ce86cc..00000000 --- a/tests/auto/quickcontrols2/translation/tst_translation.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/**************************************************************************** -** -** 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/qquickcombobox_p.h> -#include <QtQuickTemplates2/private/qquickdialog_p.h> -#include <QtQuickTemplates2/private/qquickdialogbuttonbox_p.h> -#include <QtQuickTemplates2/private/qquicktextfield_p.h> -#include <QtQuickControls2/qquickstyle.h> - -using namespace QQuickVisualTestUtil; - -class tst_translation : public QQmlDataTest -{ - Q_OBJECT - -public: - tst_translation(); - -private slots: - void dialogButtonBox(); - void dialogButtonBoxWithCustomButtons(); - void comboBox(); -}; - -tst_translation::tst_translation() -{ - QQuickStyle::setStyle("Basic"); -} - -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("qtbase_fr.qm", ":/")); - QVERIFY(qApp->installTranslator(&translator)); - qApp->sendPostedEvents(); - 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); -} - -// Test that custom buttons with explicitly specified text -// do not have that text overwritten on language changes. -void tst_translation::dialogButtonBoxWithCustomButtons() -{ - // This is just a way of simulating the translator going out of scope - // after the QML has been loaded. - QScopedPointer<QTranslator> translator(new QTranslator); - // Doesn't matter which language it is, as we won't be using it anyway. - QVERIFY(translator->load("qtbase_fr.qm", ":/")); - QVERIFY(qApp->installTranslator(translator.data())); - - QQuickView view(testFileUrl("dialogButtonBoxWithCustomButtons.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); - - auto okButton = dialogButtonBox->findChild<QQuickAbstractButton*>("okButton"); - QVERIFY(okButton); - QCOMPARE(okButton->text(), QLatin1String("OK")); - - QQuickAbstractButton *cancelButton = dialogButtonBox->findChild<QQuickAbstractButton*>("cancelButton"); - QVERIFY(cancelButton); - QCOMPARE(cancelButton->text(), QLatin1String("Cancel")); - - // Delete the translator and hence cause a LanguageChange event, - // but _without_ calling QQmlEngine::retranslate(), which would - // restore the original bindings and hence not reproduce the issue. - translator.reset(); - QCOMPARE(okButton->text(), QLatin1String("OK")); - QCOMPARE(cancelButton->text(), QLatin1String("Cancel")); -} - -void tst_translation::comboBox() -{ - QQuickView view(testFileUrl("comboBox.qml")); - - QQuickComboBox *comboBox = qobject_cast<QQuickComboBox*>(view.rootObject()); - QVERIFY(comboBox); - QCOMPARE(comboBox->displayText(), QLatin1String("Hello")); - - QQuickTextField *contentItem = qobject_cast<QQuickTextField*>(comboBox->contentItem()); - QVERIFY(contentItem); - QCOMPARE(contentItem->text(), QLatin1String("Hello")); - - QTranslator translator; - QVERIFY(translator.load("qml_jp.qm", ":/")); - QVERIFY(qApp->installTranslator(&translator)); - view.engine()->retranslate(); - QTRY_COMPARE(comboBox->displayText(), QString::fromUtf8("こんにちは")); - QCOMPARE(contentItem->text(), QString::fromUtf8("こんにちは")); -} - -QTEST_MAIN(tst_translation) - -#include "tst_translation.moc" |