aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quickcontrols2/translation
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2021-07-20 13:30:11 +0200
committerMitch Curtis <mitch.curtis@qt.io>2021-08-02 13:05:48 +0200
commit357f8490606f32c43b36494fc4c68220e94fbd89 (patch)
tree0bcf82dfb35facd37a7c398607269ac6ff7df3ca /tests/auto/quickcontrols2/translation
parent4c841bda4877c39e49a52e34877f991af7a2dbc1 (diff)
Restructure tests in preparation for merging into qtdeclarative
Task-number: QTBUG-95173 Change-Id: I541dc26cf2cdd6f2640824f693f7d059445367d9 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit f865f4b76d9385077c9ba4ca91a91246554dd36e) Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/quickcontrols2/translation')
-rw-r--r--tests/auto/quickcontrols2/translation/CMakeLists.txt63
-rw-r--r--tests/auto/quickcontrols2/translation/data/comboBox.qml65
-rw-r--r--tests/auto/quickcontrols2/translation/data/dialogButtonBox.qml61
-rw-r--r--tests/auto/quickcontrols2/translation/data/dialogButtonBoxWithCustomButtons.qml75
-rw-r--r--tests/auto/quickcontrols2/translation/qml_jp.qmbin0 -> 135 bytes
-rw-r--r--tests/auto/quickcontrols2/translation/qml_jp.ts28
-rw-r--r--tests/auto/quickcontrols2/translation/qtbase_fr.qmbin0 -> 259 bytes
-rw-r--r--tests/auto/quickcontrols2/translation/qtbase_fr.ts23
-rw-r--r--tests/auto/quickcontrols2/translation/tst_translation.cpp173
9 files changed, 488 insertions, 0 deletions
diff --git a/tests/auto/quickcontrols2/translation/CMakeLists.txt b/tests/auto/quickcontrols2/translation/CMakeLists.txt
new file mode 100644
index 0000000000..efb0ab6e41
--- /dev/null
+++ b/tests/auto/quickcontrols2/translation/CMakeLists.txt
@@ -0,0 +1,63 @@
+# 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\\\"
+ 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
new file mode 100644
index 0000000000..cba1cf0c23
--- /dev/null
+++ b/tests/auto/quickcontrols2/translation/data/comboBox.qml
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** 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
new file mode 100644
index 0000000000..fd8f9548a2
--- /dev/null
+++ b/tests/auto/quickcontrols2/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
+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
new file mode 100644
index 0000000000..bf0fb512a7
--- /dev/null
+++ b/tests/auto/quickcontrols2/translation/data/dialogButtonBoxWithCustomButtons.qml
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** 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
new file mode 100644
index 0000000000..a3712e9964
--- /dev/null
+++ b/tests/auto/quickcontrols2/translation/qml_jp.qm
Binary files differ
diff --git a/tests/auto/quickcontrols2/translation/qml_jp.ts b/tests/auto/quickcontrols2/translation/qml_jp.ts
new file mode 100644
index 0000000000..303c142fd8
--- /dev/null
+++ b/tests/auto/quickcontrols2/translation/qml_jp.ts
@@ -0,0 +1,28 @@
+<?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
new file mode 100644
index 0000000000..176675a820
--- /dev/null
+++ b/tests/auto/quickcontrols2/translation/qtbase_fr.qm
Binary files differ
diff --git a/tests/auto/quickcontrols2/translation/qtbase_fr.ts b/tests/auto/quickcontrols2/translation/qtbase_fr.ts
new file mode 100644
index 0000000000..7aff8bd760
--- /dev/null
+++ b/tests/auto/quickcontrols2/translation/qtbase_fr.ts
@@ -0,0 +1,23 @@
+<?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>&amp;Save</source>
+ <translation>&amp;Enregistrer</translation>
+ </message>
+</context>
+</TS>
+
diff --git a/tests/auto/quickcontrols2/translation/tst_translation.cpp b/tests/auto/quickcontrols2/translation/tst_translation.cpp
new file mode 100644
index 0000000000..58ce86ccd8
--- /dev/null
+++ b/tests/auto/quickcontrols2/translation/tst_translation.cpp
@@ -0,0 +1,173 @@
+/****************************************************************************
+**
+** 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"