summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/gui')
-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
-rw-r--r--tests/auto/gui/painting/qpainter/utils/createImages/createImages.pro8
-rw-r--r--tests/auto/gui/text/qtextscriptengine/generate/generate.pro9
-rw-r--r--tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp42
9 files changed, 142 insertions, 153 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()
diff --git a/tests/auto/gui/painting/qpainter/utils/createImages/createImages.pro b/tests/auto/gui/painting/qpainter/utils/createImages/createImages.pro
index ce2d341e92..36661c7d63 100644
--- a/tests/auto/gui/painting/qpainter/utils/createImages/createImages.pro
+++ b/tests/auto/gui/painting/qpainter/utils/createImages/createImages.pro
@@ -1,11 +1,3 @@
-######################################################################
-# Automatically generated by qmake (1.02a) Thu Apr 18 18:56:53 2002
-######################################################################
-
-TEMPLATE = app
CONFIG -= moc
-# Input
SOURCES += main.cpp
-
-
diff --git a/tests/auto/gui/text/qtextscriptengine/generate/generate.pro b/tests/auto/gui/text/qtextscriptengine/generate/generate.pro
index 354e0e5cdf..101b7451de 100644
--- a/tests/auto/gui/text/qtextscriptengine/generate/generate.pro
+++ b/tests/auto/gui/text/qtextscriptengine/generate/generate.pro
@@ -1,14 +1,5 @@
-######################################################################
-# Automatically generated by qmake (1.07a) Fri Sep 30 15:20:45 2005
-######################################################################
-
-TEMPLATE = app
CONFIG -= moc
INCLUDEPATH += . /usr/include/freetype2
INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/harfbuzz/src
-# Input
SOURCES += main.cpp
-CONFIG += qt warn_on debug thread create_prl link_prl
-
-
diff --git a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp
index cf02d1af50..7c9a83eaa4 100644
--- a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp
+++ b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp
@@ -104,6 +104,7 @@ private slots:
void mirroredChars();
void thaiIsolatedSaraAm();
+ void thaiWithZWJ();
private:
bool haveTestFonts;
@@ -1280,5 +1281,46 @@ void tst_QTextScriptEngine::thaiIsolatedSaraAm()
QSKIP("Cannot find Waree.");
}
+void tst_QTextScriptEngine::thaiWithZWJ()
+{
+ QString s(QString::fromUtf8("ร‍ร‌.ร.“ร…ร”ร\xA0ร本ร") + QChar(0x0363)/*superscript 'a', for testing Inherited class*/);
+ QTextLayout layout(s);
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
+
+ QTextEngine *e = layout.engine();
+ e->width(0, s.length()); //force itemize and shape
+
+ // A thai implementation could either remove the ZWJ and ZWNJ characters, or hide them.
+ // The current implementation hides them, so we test for that.
+ // But make sure that we don't hide anything else
+ QCOMPARE(e->layoutData->items.size(), 11);
+ QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(7)); // Thai: The ZWJ and ZWNJ characters are inherited, so should be part of the thai script
+ QCOMPARE(e->layoutData->items[1].num_glyphs, ushort(1)); // Common: The smart quotes cannot be handled by thai, so should be a seperate item
+ QCOMPARE(e->layoutData->items[2].num_glyphs, ushort(1)); // Thai: Thai character
+ QCOMPARE(e->layoutData->items[3].num_glyphs, ushort(1)); // Common: Ellipsis
+ QCOMPARE(e->layoutData->items[4].num_glyphs, ushort(1)); // Thai: Thai character
+ QCOMPARE(e->layoutData->items[5].num_glyphs, ushort(1)); // Common: Smart quote
+ QCOMPARE(e->layoutData->items[6].num_glyphs, ushort(1)); // Thai: Thai character
+ QCOMPARE(e->layoutData->items[7].num_glyphs, ushort(1)); // Common: \xA0 = non-breaking space. Could be useful to have in thai, but not currently implemented
+ QCOMPARE(e->layoutData->items[8].num_glyphs, ushort(1)); // Thai: Thai character
+ QCOMPARE(e->layoutData->items[9].num_glyphs, ushort(1)); // Japanese: Kanji for tree
+ QCOMPARE(e->layoutData->items[10].num_glyphs, ushort(2)); // Thai: Thai character followed by superscript "a" which is of inherited type
+
+ //A quick sanity check - check all the characters are individual clusters
+ unsigned short *logClusters = e->layoutData->logClustersPtr;
+ for (int i = 0; i < 7; i++)
+ QCOMPARE(logClusters[i], ushort(i));
+ for (int i = 0; i < 10; i++)
+ QCOMPARE(logClusters[i+7], ushort(0));
+ QCOMPARE(logClusters[17], ushort(1));
+
+ // The only characters that we should be hiding are the ZWJ and ZWNJ characters in position 1
+ // and 3.
+ for (int i = 0; i < 18; i++)
+ QCOMPARE((bool)e->layoutData->glyphLayout.attributes[i].dontPrint, (i == 1 || i == 3));
+}
+
QTEST_MAIN(tst_QTextScriptEngine)
#include "tst_qtextscriptengine.moc"