summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
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/auto/widgets
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/auto/widgets')
-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
4 files changed, 30 insertions, 18 deletions
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);
}