summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2012-02-21 15:36:01 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-22 17:28:51 +0100
commit541949aed23ea14a71a7d4391bac244b623add0a (patch)
treef123b0cfb7d4c42f7b83a378ae670c8b51003057 /tests
parent53bb87d1d274a80b94595f6cd31bfa7a8ae81dc3 (diff)
Add further theme hints to QPlatformTheme.
- Add hints for QDialog/QDialogButtonBox. - Add hint for available popup-menu area. - Add keyboard scheme hint replacing QGuiApplicationPrivate::currentKeyPlatform() Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com> Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com> Task-number: QTBUG-24204 Task-number: QTBUG-24315 Change-Id: I6653786b0dcb49a6fc264d3b9891dbfee502bd3e Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/kernel/qkeysequence/qkeysequence.pro2
-rw-r--r--tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp59
-rw-r--r--tests/auto/other/languagechange/languagechange.pro2
-rw-r--r--tests/auto/other/languagechange/tst_languagechange.cpp14
-rw-r--r--tests/auto/widgets/dialogs/qmessagebox/qmessagebox.pro2
-rw-r--r--tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp15
-rw-r--r--tests/auto/widgets/kernel/qaction/qaction.pro2
-rw-r--r--tests/auto/widgets/kernel/qaction/tst_qaction.cpp29
8 files changed, 80 insertions, 45 deletions
diff --git a/tests/auto/gui/kernel/qkeysequence/qkeysequence.pro b/tests/auto/gui/kernel/qkeysequence/qkeysequence.pro
index 1e0baafd09..cf4337b156 100644
--- a/tests/auto/gui/kernel/qkeysequence/qkeysequence.pro
+++ b/tests/auto/gui/kernel/qkeysequence/qkeysequence.pro
@@ -1,7 +1,7 @@
CONFIG += testcase
TARGET = tst_qkeysequence
-QT += widgets widgets-private testlib
+QT += widgets testlib
QT += core-private gui-private
SOURCES += tst_qkeysequence.cpp
diff --git a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
index 29588e2ee9..861ad3835d 100644
--- a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+++ b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
@@ -41,9 +41,10 @@
#include <QtTest/QtTest>
-#include <private/qapplication_p.h>
#include <qkeysequence.h>
+#include <qplatformtheme_qpa.h>
#include <private/qkeysequence_p.h>
+#include <private/qguiapplication_p.h>
#include <QTranslator>
#include <QLibraryInfo>
@@ -142,6 +143,7 @@ private slots:
void initTestCase();
private:
+ int m_keyboardScheme;
QTranslator *ourTranslator;
QTranslator *qtTranslator;
#ifdef Q_OS_MAC
@@ -161,8 +163,10 @@ const QString tst_QKeySequence::MacAlt = QString(QChar(0x2325));
const QString tst_QKeySequence::MacShift = QString(QChar(0x21E7));
#endif
-tst_QKeySequence::tst_QKeySequence()
+tst_QKeySequence::tst_QKeySequence() : m_keyboardScheme(QPlatformTheme::WindowsKeyboardScheme)
{
+ if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
+ m_keyboardScheme = theme->themeHint(QPlatformTheme::KeyboardScheme).toInt();
}
tst_QKeySequence::~tst_QKeySequence()
@@ -297,8 +301,7 @@ void tst_QKeySequence::checkMultipleCodes()
*/
void tst_QKeySequence::ensureSorted()
{
-//### accessing static members from private classes does not work on msvc at the moment
-#if defined(QT_BUILD_INTERNAL) && !defined(Q_WS_WIN)
+#if defined(QT_BUILD_INTERNAL)
uint N = QKeySequencePrivate::numberOfKeyBindings;
uint val = QKeySequencePrivate::keyBindings[0].shortcut;
for ( uint i = 1 ; i < N ; ++i) {
@@ -322,13 +325,13 @@ void tst_QKeySequence::standardKeys_data()
QTest::newRow("delete") << (int)QKeySequence::Delete<< QString("DEL");
QTest::newRow("open") << (int)QKeySequence::Open << QString("CTRL+O");
QTest::newRow("find") << (int)QKeySequence::Find<< QString("CTRL+F");
-#ifdef Q_WS_WIN
- QTest::newRow("addTab") << (int)QKeySequence::AddTab<< QString("CTRL+T");
- QTest::newRow("findNext") << (int)QKeySequence::FindNext<< QString("F3");
- QTest::newRow("findPrevious") << (int)QKeySequence::FindPrevious << QString("SHIFT+F3");
- QTest::newRow("close") << (int)QKeySequence::Close<< QString("CTRL+F4");
- QTest::newRow("replace") << (int)QKeySequence::Replace<< QString("CTRL+H");
-#endif
+ if (m_keyboardScheme == QPlatformTheme::WindowsKeyboardScheme) {
+ QTest::newRow("addTab") << (int)QKeySequence::AddTab<< QString("CTRL+T");
+ QTest::newRow("findNext") << (int)QKeySequence::FindNext<< QString("F3");
+ QTest::newRow("findPrevious") << (int)QKeySequence::FindPrevious << QString("SHIFT+F3");
+ QTest::newRow("close") << (int)QKeySequence::Close<< QString("CTRL+F4");
+ QTest::newRow("replace") << (int)QKeySequence::Replace<< QString("CTRL+H");
+ }
QTest::newRow("bold") << (int)QKeySequence::Bold << QString("CTRL+B");
QTest::newRow("italic") << (int)QKeySequence::Italic << QString("CTRL+I");
QTest::newRow("underline") << (int)QKeySequence::Underline << QString("CTRL+U");
@@ -362,23 +365,33 @@ void tst_QKeySequence::standardKeys()
{
QFETCH(int, standardKey);
QFETCH(QString, expected);
- QKeySequence ks((QKeySequence::StandardKey)standardKey);
- QKeySequence ks2(expected);
- QVERIFY(ks == ks2);
+ QKeySequence actualKeySequence((QKeySequence::StandardKey)standardKey);
+ QKeySequence expectedKeySequence(expected);
+ QVERIFY2(actualKeySequence == expectedKeySequence,
+ qPrintable(QString::fromLatin1("Key mismatch, expected '%1', got '%2' for standard key %3").
+ arg(expected, actualKeySequence.toString()).arg(standardKey)));
}
void tst_QKeySequence::keyBindings()
{
- QList<QKeySequence> bindings = QKeySequence::keyBindings(QKeySequence::Copy);
+ const QList<QKeySequence> bindings =
+ QKeySequence::keyBindings(QKeySequence::Copy);
+
QList<QKeySequence> expected;
-#if defined(Q_OS_MAC)
- expected << QKeySequence("CTRL+C");
-#elif defined Q_WS_X11
- expected << QKeySequence("CTRL+C") << QKeySequence("F16") << QKeySequence("CTRL+INSERT");
-#else
- expected << QKeySequence("CTRL+C") << QKeySequence("CTRL+INSERT");
-#endif
- QVERIFY(bindings == expected);
+ const QKeySequence ctrlC = QKeySequence(QStringLiteral("CTRL+C"));
+ const QKeySequence ctrlInsert = QKeySequence(QStringLiteral("CTRL+INSERT"));
+ switch (m_keyboardScheme) {
+ case QPlatformTheme::MacKeyboardScheme:
+ expected << ctrlC;
+ break;
+ case QPlatformTheme::WindowsKeyboardScheme:
+ expected << ctrlC << ctrlInsert;
+ break;
+ default: // X11
+ expected << ctrlC << QKeySequence(QStringLiteral("F16")) << ctrlInsert;
+ break;
+ }
+ QCOMPARE(bindings, expected);
}
void tst_QKeySequence::mnemonic_data()
diff --git a/tests/auto/other/languagechange/languagechange.pro b/tests/auto/other/languagechange/languagechange.pro
index efbc524556..b115c01641 100644
--- a/tests/auto/other/languagechange/languagechange.pro
+++ b/tests/auto/other/languagechange/languagechange.pro
@@ -1,4 +1,4 @@
CONFIG += testcase
TARGET = tst_languagechange
-QT += widgets core-private testlib
+QT += widgets core-private gui-private testlib
SOURCES += tst_languagechange.cpp
diff --git a/tests/auto/other/languagechange/tst_languagechange.cpp b/tests/auto/other/languagechange/tst_languagechange.cpp
index b4bd766df7..663f2ef798 100644
--- a/tests/auto/other/languagechange/tst_languagechange.cpp
+++ b/tests/auto/other/languagechange/tst_languagechange.cpp
@@ -43,13 +43,16 @@
#include <QtTest/QtTest>
#include <qapplication.h>
+#include <private/qguiapplication_p.h>
#include <QtCore/QSet>
#include <QtCore/QFile>
#include <QtCore/QTranslator>
#include <QtCore/QTemporaryDir>
#include <private/qthread_p.h>
+#include <QtGui/QPlatformTheme>
#include <QtWidgets/QInputDialog>
#include <QtWidgets/QColorDialog>
+#include <QtWidgets/QDialogButtonBox>
#include <QtWidgets/QFileDialog>
#include <QtWidgets/QDesktopWidget>
@@ -66,12 +69,16 @@ private slots:
void retranslatability_data();
void retranslatability();
+private:
+ QDialogButtonBox::ButtonLayout m_layout;
};
-tst_languageChange::tst_languageChange()
-
+tst_languageChange::tst_languageChange() :
+ m_layout(QDialogButtonBox::WinLayout)
{
+ if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
+ m_layout = static_cast<QDialogButtonBox::ButtonLayout>(theme->themeHint(QPlatformTheme::DialogButtonBoxLayout).toInt());
}
void tst_languageChange::initTestCase()
@@ -240,6 +247,9 @@ void tst_languageChange::retranslatability()
QFETCH( int, dialogType);
QFETCH( TranslationSet, expected);
+ if (m_layout == QDialogButtonBox::GnomeLayout)
+ QSKIP("The input data are not suitable for this layout (QDialogButtonBox::GnomeLayout)");
+
// This will always be queried for when a language changes
expected.insert("QCoreApplication::QT_LAYOUT_DIRECTION::Translate this string to the string 'LTR' in left-to-right "
"languages or to 'RTL' in right-to-left languages (such as Hebrew and Arabic) to "
diff --git a/tests/auto/widgets/dialogs/qmessagebox/qmessagebox.pro b/tests/auto/widgets/dialogs/qmessagebox/qmessagebox.pro
index f25ed650c3..5b8f796485 100644
--- a/tests/auto/widgets/dialogs/qmessagebox/qmessagebox.pro
+++ b/tests/auto/widgets/dialogs/qmessagebox/qmessagebox.pro
@@ -1,7 +1,7 @@
CONFIG += testcase
TEMPLATE = app
TARGET = tst_qmessagebox
-QT += widgets testlib
+QT += gui-private core-private widgets testlib
DEPENDPATH += .
INCLUDEPATH += .
diff --git a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
index 7fc752488d..1d391a1c09 100644
--- a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
+++ b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
@@ -48,6 +48,8 @@
#include <QApplication>
#include <QPushButton>
#include <QDialogButtonBox>
+#include <QPlatformTheme>
+#include <private/qguiapplication_p.h>
#if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC)
#include <QMacStyle>
#endif
@@ -407,15 +409,12 @@ void tst_QMessageBox::staticSourceCompat()
sendKeySoon();
ret = QMessageBox::information(0, "title", "text", QMessageBox::Yes, QMessageBox::No);
int expectedButton = int(QMessageBox::Yes);
-#if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC)
- if (qobject_cast<QMacStyle *>(qApp->style()))
- expectedButton = int(QMessageBox::No);
-#elif !defined(QT_NO_STYLE_CLEANLOOKS)
- if (qobject_cast<QCleanlooksStyle *>(qApp->style())) {
- QEXPECT_FAIL("", "Special handling of QMessageBox::information buttons for Cleanlooks not implemented yet, QTBUG-24315", Continue);
- expectedButton = int(QMessageBox::No);
+ if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
+ const int dialogButtonBoxLayout = theme->themeHint(QPlatformTheme::DialogButtonBoxLayout).toInt();
+ if (dialogButtonBoxLayout == QDialogButtonBox::MacLayout
+ || dialogButtonBoxLayout == QDialogButtonBox::GnomeLayout)
+ expectedButton = int(QMessageBox::No);
}
-#endif
QCOMPARE(ret, expectedButton);
QCOMPARE(keyToSend, -1);
diff --git a/tests/auto/widgets/kernel/qaction/qaction.pro b/tests/auto/widgets/kernel/qaction/qaction.pro
index e6f0735394..c57107b1b0 100644
--- a/tests/auto/widgets/kernel/qaction/qaction.pro
+++ b/tests/auto/widgets/kernel/qaction/qaction.pro
@@ -1,6 +1,6 @@
CONFIG += testcase
TARGET = tst_qaction
-QT += widgets testlib
+QT += gui-private core-private widgets testlib
SOURCES += tst_qaction.cpp
diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
index 47aad21074..51123af953 100644
--- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
+++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
@@ -46,6 +46,8 @@
#include <qevent.h>
#include <qaction.h>
#include <qmenu.h>
+#include <qplatformtheme_qpa.h>
+#include <private/qguiapplication_p.h>
class tst_QAction : public QObject
{
@@ -77,6 +79,7 @@ private slots:
private:
int m_lastEventType;
+ int m_keyboardScheme;
QAction *m_lastAction;
QWidget *m_tstWidget;
};
@@ -121,8 +124,10 @@ private:
tst_QAction *tst;
};
-tst_QAction::tst_QAction()
+tst_QAction::tst_QAction() : m_keyboardScheme(QPlatformTheme::WindowsKeyboardScheme)
{
+ if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
+ m_keyboardScheme = theme->themeHint(QPlatformTheme::KeyboardScheme).toInt();
}
tst_QAction::~tst_QAction()
@@ -237,13 +242,21 @@ void tst_QAction::setStandardKeys()
QVERIFY(act.shortcut() == act.shortcuts().first());
QList<QKeySequence> expected;
-#if defined(Q_OS_MAC)
- expected << QKeySequence("CTRL+C");
-#else
- expected << QKeySequence("CTRL+C") << QKeySequence("CTRL+INSERT");
-#endif
-// Qt/Embedded on Windows: expected << QKeySequence("CTRL+C") << QKeySequence("F16") << QKeySequence("CTRL+INSERT");
- QVERIFY(act.shortcuts() == expected);
+ const QKeySequence ctrlC = QKeySequence(QStringLiteral("CTRL+C"));
+ const QKeySequence ctrlInsert = QKeySequence(QStringLiteral("CTRL+INSERT"));
+ switch (m_keyboardScheme) {
+ case QPlatformTheme::MacKeyboardScheme:
+ expected << ctrlC;
+ break;
+ case QPlatformTheme::WindowsKeyboardScheme:
+ expected << ctrlC << ctrlInsert;
+ break;
+ default: // X11
+ expected << ctrlC << QKeySequence(QStringLiteral("F16")) << ctrlInsert;
+ break;
+ }
+
+ QCOMPARE(act.shortcuts(), expected);
}