summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/gui/kernel')
-rw-r--r--tests/auto/gui/kernel/qclipboard/copier/copier.pro7
-rw-r--r--tests/auto/gui/kernel/qclipboard/paster/paster.pro8
-rw-r--r--tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp44
-rw-r--r--tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp116
-rw-r--r--tests/auto/gui/kernel/qkeysequence/qkeysequence.pro2
-rw-r--r--tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp59
6 files changed, 100 insertions, 136 deletions
diff --git a/tests/auto/gui/kernel/qclipboard/copier/copier.pro b/tests/auto/gui/kernel/qclipboard/copier/copier.pro
index 1c188ca7de..def50b6476 100644
--- a/tests/auto/gui/kernel/qclipboard/copier/copier.pro
+++ b/tests/auto/gui/kernel/qclipboard/copier/copier.pro
@@ -1,9 +1,4 @@
-TEMPLATE = app
-TARGET =
-DEPENDPATH += .
-INCLUDEPATH += .
CONFIG -= app_bundle
win32: DESTDIR = ../copier
-# Input
-SOURCES += main.cpp
+SOURCES += main.cpp
diff --git a/tests/auto/gui/kernel/qclipboard/paster/paster.pro b/tests/auto/gui/kernel/qclipboard/paster/paster.pro
index 2f50eefb1e..ef91e77b6e 100644
--- a/tests/auto/gui/kernel/qclipboard/paster/paster.pro
+++ b/tests/auto/gui/kernel/qclipboard/paster/paster.pro
@@ -1,10 +1,4 @@
-TEMPLATE = app
-TARGET =
-DEPENDPATH += .
-INCLUDEPATH += .
win32: DESTDIR = ../paster
CONFIG -= app_bundle
-# Input
-SOURCES += main.cpp
-
+SOURCES += main.cpp
diff --git a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp
index e1b0535e2f..7f41f0651e 100644
--- a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp
+++ b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp
@@ -291,19 +291,17 @@ void tst_QClipboard::setMimeData()
QGuiApplication::clipboard()->clear(QClipboard::Selection); // used to crash on X11
QGuiApplication::clipboard()->clear(QClipboard::FindBuffer);
-#if defined(Q_WS_X11)
- QCOMPARE(spySelection.count(), 1);
- QCOMPARE(spyData.count(), 1);
- QCOMPARE(spyFindBuffer.count(), 0);
-#elif defined(Q_OS_MAC)
- QCOMPARE(spySelection.count(), 0);
- QCOMPARE(spyData.count(), 1);
- QCOMPARE(spyFindBuffer.count(), 1);
-#elif defined(Q_WS_WIN)
- QCOMPARE(spySelection.count(), 0);
+ if (QGuiApplication::clipboard()->supportsSelection())
+ QCOMPARE(spySelection.count(), 1);
+ else
+ QCOMPARE(spySelection.count(), 0);
+
+ if (QGuiApplication::clipboard()->supportsFindBuffer())
+ QCOMPARE(spyFindBuffer.count(), 1);
+ else
+ QCOMPARE(spyFindBuffer.count(), 0);
+
QCOMPARE(spyData.count(), 1);
- QCOMPARE(spyFindBuffer.count(), 0);
-#endif
// an other crash test
data = new QMimeData;
@@ -324,19 +322,17 @@ void tst_QClipboard::setMimeData()
QGuiApplication::clipboard()->setMimeData(newData, QClipboard::Selection); // used to crash on X11
QGuiApplication::clipboard()->setMimeData(newData, QClipboard::FindBuffer);
-#if defined(Q_WS_X11)
- QCOMPARE(spySelection.count(), 1);
- QCOMPARE(spyData.count(), 1);
- QCOMPARE(spyFindBuffer.count(), 0);
-#elif defined(Q_OS_MAC)
- QCOMPARE(spySelection.count(), 0);
- QCOMPARE(spyData.count(), 1);
- QCOMPARE(spyFindBuffer.count(), 1);
-#elif defined(Q_WS_WIN)
- QCOMPARE(spySelection.count(), 0);
+ if (QGuiApplication::clipboard()->supportsSelection())
+ QCOMPARE(spySelection.count(), 1);
+ else
+ QCOMPARE(spySelection.count(), 0);
+
+ if (QGuiApplication::clipboard()->supportsFindBuffer())
+ QCOMPARE(spyFindBuffer.count(), 1);
+ else
+ QCOMPARE(spyFindBuffer.count(), 0);
+
QCOMPARE(spyData.count(), 1);
- QCOMPARE(spyFindBuffer.count(), 0);
-#endif
}
void tst_QClipboard::clearBeforeSetText()
diff --git a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp
index c10d954489..bc364e37f1 100644
--- a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp
+++ b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp
@@ -44,90 +44,22 @@
#include <private/qguiapplication_p.h>
#include <private/qinputmethod_p.h>
#include <qplatforminputcontext_qpa.h>
-
-class PlatformInputContext : public QPlatformInputContext
-{
-public:
- PlatformInputContext() :
- m_animating(false),
- m_visible(false),
- m_updateCallCount(0),
- m_resetCallCount(0),
- m_commitCallCount(0),
- m_localeCallCount(0),
- m_inputDirectionCallCount(0),
- m_lastQueries(Qt::ImhNone),
- m_action(QInputMethod::Click),
- m_cursorPosition(0),
- m_lastEventType(QEvent::None)
- {}
-
- virtual QRectF keyboardRect() const { return m_keyboardRect; }
- virtual bool isAnimating() const { return m_animating; }
- virtual void reset() { m_resetCallCount++; }
- virtual void commit() { m_commitCallCount++; }
-
- virtual void update(Qt::InputMethodQueries queries)
- {
- m_updateCallCount++;
- m_lastQueries = queries;
- }
- virtual void invokeAction(QInputMethod::Action action, int cursorPosition)
- {
- m_action = action;
- m_cursorPosition = cursorPosition;
- }
- virtual bool filterEvent(const QEvent *event)
- {
- m_lastEventType = event->type(); return false;
- }
- virtual void showInputPanel()
- {
- m_visible = true;
- }
- virtual void hideInputPanel()
- {
- m_visible = false;
- }
- virtual bool isInputPanelVisible() const
- {
- return m_visible;
- }
- virtual QLocale locale() const
- {
- m_localeCallCount++;
- return QLocale::c();
- }
- virtual Qt::LayoutDirection inputDirection() const
- {
- m_inputDirectionCallCount++;
- return Qt::LeftToRight;
- }
-
- bool m_animating;
- bool m_visible;
- int m_updateCallCount;
- int m_resetCallCount;
- int m_commitCallCount;
- mutable int m_localeCallCount;
- mutable int m_inputDirectionCallCount;
- Qt::InputMethodQueries m_lastQueries;
- QInputMethod::Action m_action;
- int m_cursorPosition;
- int m_lastEventType;
- QRectF m_keyboardRect;
-};
+#include "../../../shared/platforminputcontext.h"
class InputItem : public QObject
{
Q_OBJECT
public:
+ InputItem() : cursorRectangle(1, 2, 3, 4), m_enabled(true) {}
+
bool event(QEvent *event)
{
if (event->type() == QEvent::InputMethodQuery) {
QInputMethodQueryEvent *query = static_cast<QInputMethodQueryEvent *>(event);
+ if (query->queries() & Qt::ImEnabled)
+ query->setValue(Qt::ImEnabled, m_enabled);
if (query->queries() & Qt::ImCursorRectangle)
- query->setValue(Qt::ImCursorRectangle, QRectF(1, 2, 3, 4));
+ query->setValue(Qt::ImCursorRectangle, cursorRectangle);
if (query->queries() & Qt::ImPreferredLanguage)
query->setValue(Qt::ImPreferredLanguage, QString("English"));
m_lastQueries = query->queries();
@@ -136,9 +68,40 @@ public:
}
return false;
}
+
+ void setEnabled(bool enabled) {
+ if (enabled != m_enabled) {
+ m_enabled = enabled;
+ qApp->inputMethod()->update(Qt::ImEnabled);
+ }
+ }
+
+ QRectF cursorRectangle;
Qt::InputMethodQueries m_lastQueries;
+ bool m_enabled;
};
+
+class DummyWindow : public QWindow
+{
+public:
+ DummyWindow() : m_focusObject(0) {}
+
+ virtual QObject *focusObject() const
+ {
+ return m_focusObject;
+ }
+
+ void setFocusObject(QObject *object)
+ {
+ m_focusObject = object;
+ emit focusObjectChanged(object);
+ }
+
+ QObject *m_focusObject;
+};
+
+
class tst_qinputmethod : public QObject
{
Q_OBJECT
@@ -258,7 +221,11 @@ void tst_qinputmethod::cursorRectangle()
QCOMPARE(qApp->inputMethod()->cursorRectangle(), transform.mapRect(QRectF(1, 2, 3, 4)));
+ m_inputItem.cursorRectangle = QRectF(1.5, 2, 1, 8);
+ QCOMPARE(qApp->inputMethod()->cursorRectangle(), transform.mapRect(QRectF(1.5, 2, 1, 8)));
+
// reset
+ m_inputItem.cursorRectangle = QRectF(1, 2, 3, 4);
qApp->inputMethod()->setInputItem(0);
qApp->inputMethod()->setInputItemTransform(QTransform());
}
@@ -297,7 +264,6 @@ void tst_qinputmethod::commit()
void tst_qinputmethod::update()
{
- qApp->inputMethod()->setInputItem(&m_inputItem);
QCOMPARE(m_platformInputContext.m_updateCallCount, 0);
QCOMPARE(int(m_platformInputContext.m_lastQueries), int(Qt::ImhNone));
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()