diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-05-16 01:00:46 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-05-16 01:00:46 +0200 |
commit | 039071ea5e93d93deb0103e7c9488198dcce55d6 (patch) | |
tree | c4cfcf20ed1f836e9c958b2835c84a2b28915e3b /tests/auto | |
parent | 9b36512b9453f429644b0c388d381f7a2fc0f825 (diff) | |
parent | 56fbc277a1acc49d9ead4c89edd250a021ef2a01 (diff) |
Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: Ia93dc734ce25b3134b0f905f473a0c30777ceaf1
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qml/qqmlengine/data/CachedGetterLookup.qml | 20 | ||||
-rw-r--r-- | tests/auto/qml/qqmlengine/tst_qqmlengine.cpp | 11 | ||||
-rw-r--r-- | tests/auto/quick/qquickaccessible/data/text.qml | 11 | ||||
-rw-r--r-- | tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp | 26 | ||||
-rw-r--r-- | tests/auto/quick/qquicktextedit/qquicktextedit.pro | 1 | ||||
-rw-r--r-- | tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp | 56 | ||||
-rw-r--r-- | tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 56 |
7 files changed, 180 insertions, 1 deletions
diff --git a/tests/auto/qml/qqmlengine/data/CachedGetterLookup.qml b/tests/auto/qml/qqmlengine/data/CachedGetterLookup.qml new file mode 100644 index 0000000000..1a2a7ff341 --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/CachedGetterLookup.qml @@ -0,0 +1,20 @@ +import QtQuick 2.12 + +QtObject { + Component.onCompleted: { + // create getter + var getFoo = function(o) { return o.foo; } + + // create two diffrent shapes for x,y + var x = { foo:1 , bar:2 } + var y = { bar:2 , foo:1 } + + // initialize inline cache with getFoo + getFoo(x); + getFoo(y); + + // hit getter lookup with string "crash" + getFoo('crash'); + } +} + diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp index b9cb6b70d2..0cb6753020 100644 --- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp +++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp @@ -81,6 +81,7 @@ private slots: void cppSignalAndEval(); void singletonInstance(); void aggressiveGc(); + void cachedGetterLookup_qtbug_75335(); public slots: QObject *createAQObjectForOwnershipTest () @@ -1056,6 +1057,16 @@ void tst_qqmlengine::aggressiveGc() qputenv("QV4_MM_AGGRESSIVE_GC", origAggressiveGc); } +void tst_qqmlengine::cachedGetterLookup_qtbug_75335() +{ + QQmlEngine engine; + const QUrl testUrl = testFileUrl("CachedGetterLookup.qml"); + QQmlComponent component(&engine, testUrl); + QVERIFY(component.isReady()); + QScopedPointer<QObject> object(component.create()); + QVERIFY(object != nullptr); +} + QTEST_MAIN(tst_qqmlengine) #include "tst_qqmlengine.moc" diff --git a/tests/auto/quick/qquickaccessible/data/text.qml b/tests/auto/quick/qquickaccessible/data/text.qml index 88f292a61f..6daeacfd81 100644 --- a/tests/auto/quick/qquickaccessible/data/text.qml +++ b/tests/auto/quick/qquickaccessible/data/text.qml @@ -46,4 +46,15 @@ Item { text: "A multi-line text edit\nTesting Accessibility." Accessible.role: Accessible.EditableText } + + Text { + x: 100 + y: 160 + width: 100 + height: 40 + text : "Hello 3" + Accessible.name: text + Accessible.description: "description" + } + } diff --git a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp index 243d87f212..c5fdb6c1b9 100644 --- a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp +++ b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp @@ -312,7 +312,7 @@ void tst_QQuickAccessible::basicPropertiesTest() QAccessibleInterface *item = iface->child(0); QVERIFY(item); - QCOMPARE(item->childCount(), 4); + QCOMPARE(item->childCount(), 5); QCOMPARE(item->rect().size(), QSize(400, 400)); QCOMPARE(item->role(), QAccessible::Client); QCOMPARE(iface->indexOfChild(item), 0); @@ -382,6 +382,30 @@ void tst_QQuickAccessible::basicPropertiesTest() QEXPECT_FAIL("", "multi line is not implemented", Continue); QCOMPARE(textInput->state().multiLine, 1); + // Text "Hello 3" + QAccessibleInterface *text3 = item->child(4); + QVERIFY(text3); + QCOMPARE(text3->childCount(), 0); + QCOMPARE(text3->text(QAccessible::Name), QLatin1String("Hello 3")); + QCOMPARE(text3->role(), QAccessible::StaticText); + QCOMPARE(item->indexOfChild(text3), 4); + QCOMPARE(text3->state().editable, 0); + QCOMPARE(text3->state().readOnly, 0); + // test implicit state values due to role change + QQuickAccessibleAttached *attached = QQuickAccessibleAttached::attachedProperties(text3->object()); + attached->setRole(QAccessible::StaticText); + QCOMPARE(text3->role(), QAccessible::StaticText); + QCOMPARE(text3->state().readOnly, 1); + + // see if implicit changes back + attached->setRole(QAccessible::EditableText); + QEXPECT_FAIL("", "EditableText does not implicitly set readOnly to false", Continue); + QCOMPARE(text3->state().readOnly, 0); + // explicitly set state + attached->set_readOnly(false); + attached->setRole(QAccessible::StaticText); + QCOMPARE(text3->state().readOnly, 0); + delete window; QTestAccessibility::clearEvents(); } diff --git a/tests/auto/quick/qquicktextedit/qquicktextedit.pro b/tests/auto/quick/qquicktextedit/qquicktextedit.pro index ea6e8bc60d..576e25d092 100644 --- a/tests/auto/quick/qquicktextedit/qquicktextedit.pro +++ b/tests/auto/quick/qquicktextedit/qquicktextedit.pro @@ -8,6 +8,7 @@ SOURCES += tst_qquicktextedit.cpp \ HEADERS += ../../shared/testhttpserver.h include (../../shared/util.pri) +include (../shared/util.pri) TESTDATA = data/* diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index ce2a8eb257..33a6b829bc 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -49,6 +49,7 @@ #include <QMimeData> #include <private/qquicktextcontrol_p.h> #include "../../shared/util.h" +#include "../shared/viewtestutil.h" #include "../../shared/platformquirks.h" #include "../../shared/platforminputcontext.h" #include <private/qinputmethod_p.h> @@ -63,6 +64,11 @@ Q_DECLARE_METATYPE(QQuickTextEdit::SelectionMode) Q_DECLARE_METATYPE(Qt::Key) DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD) +static bool isPlatformWayland() +{ + return !QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive); +} + QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual) { // XXX This will be replaced by some clever persistent platform image store. @@ -133,6 +139,7 @@ private slots: void positionAt_data(); void positionAt(); + void linkHover(); void linkInteraction(); void cursorDelegate_data(); @@ -2536,10 +2543,59 @@ void tst_qquicktextedit::positionAt() QVERIFY(texteditObject->positionAt(x0 / 2, y1) > 0); } +#if QT_CONFIG(cursor) +void tst_qquicktextedit::linkHover() +{ + if (isPlatformWayland()) + QSKIP("Wayland: QCursor::setPos() doesn't work."); + + QQuickView window(testFileUrl("linkInteraction.qml")); + window.setFlag(Qt::FramelessWindowHint); + QVERIFY(window.rootObject() != nullptr); + QQuickViewTestUtil::centerOnScreen(&window); + QQuickViewTestUtil::moveMouseAway(&window); + window.show(); + window.requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(&window)); + QQuickTextEdit *texteditObject = qobject_cast<QQuickTextEdit *>(window.rootObject()); + QVERIFY(texteditObject != nullptr); + + QSignalSpy hover(texteditObject, SIGNAL(linkHovered(QString))); + + const QString link("http://example.com/"); + const QPoint linkPos = window.mapToGlobal(texteditObject->positionToRectangle(7).center().toPoint()); + const QPoint textPos = window.mapToGlobal(texteditObject->positionToRectangle(2).center().toPoint()); + + QCursor::setPos(linkPos); + QTRY_COMPARE(hover.count(), 1); + QCOMPARE(window.cursor().shape(), Qt::PointingHandCursor); + QCOMPARE(hover.last()[0].toString(), link); + + QCursor::setPos(textPos); + QTRY_COMPARE(hover.count(), 2); + QCOMPARE(window.cursor().shape(), Qt::IBeamCursor); + QCOMPARE(hover.last()[0].toString(), QString()); + + texteditObject->setCursor(Qt::OpenHandCursor); + + QCursor::setPos(linkPos); + QTRY_COMPARE(hover.count(), 3); + QCOMPARE(window.cursor().shape(), Qt::PointingHandCursor); + QCOMPARE(hover.last()[0].toString(), link); + + QCursor::setPos(textPos); + QTRY_COMPARE(hover.count(), 4); + QCOMPARE(window.cursor().shape(), Qt::OpenHandCursor); + QCOMPARE(hover.last()[0].toString(), QString()); +} +#endif + void tst_qquicktextedit::linkInteraction() { QQuickView window(testFileUrl("linkInteraction.qml")); QVERIFY(window.rootObject() != nullptr); + QQuickViewTestUtil::centerOnScreen(&window); + QQuickViewTestUtil::moveMouseAway(&window); window.show(); window.requestActivate(); QVERIFY(QTest::qWaitForWindowActive(&window)); diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index 4cf7fa7119..f08b9207d1 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -353,6 +353,11 @@ protected: m_mouseEvents << *event; } + void mouseDoubleClickEvent(QMouseEvent *event) override { + qCDebug(lcTests) << event; + m_mouseEvents << *event; + } + public: QList<QMouseEvent> m_mouseEvents; QList<QTouchEvent> m_touchEvents; @@ -401,6 +406,8 @@ private slots: void mouseFromTouch_basic(); void synthMouseFromTouch_data(); void synthMouseFromTouch(); + void synthMouseDoubleClickFromTouch_data(); + void synthMouseDoubleClickFromTouch(); void clearWindow(); @@ -1241,6 +1248,55 @@ void tst_qquickwindow::synthMouseFromTouch() QCOMPARE(ev.source(), Qt::MouseEventSynthesizedByQt); } +void tst_qquickwindow::synthMouseDoubleClickFromTouch_data() +{ + QTest::addColumn<QPoint>("movement"); + QTest::addColumn<QPoint>("distanceBetweenPresses"); + QTest::addColumn<bool>("expectedSynthesizedDoubleClickEvent"); + + QTest::newRow("normal") << QPoint(0, 0) << QPoint(0, 0) << true; + QTest::newRow("with 1 pixel wiggle") << QPoint(1, 1) << QPoint(1, 1) << true; + QTest::newRow("too much distance to second tap") << QPoint(0, 0) << QPoint(50, 0) << false; + QTest::newRow("too much drag") << QPoint(50, 0) << QPoint(0, 0) << false; + QTest::newRow("too much drag and too much distance to second tap") << QPoint(50, 0) << QPoint(50, 0) << false; +} + +void tst_qquickwindow::synthMouseDoubleClickFromTouch() +{ + QFETCH(QPoint, movement); + QFETCH(QPoint, distanceBetweenPresses); + QFETCH(bool, expectedSynthesizedDoubleClickEvent); + + QCoreApplication::setAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents, true); + QScopedPointer<MouseRecordingWindow> window(new MouseRecordingWindow); + QScopedPointer<MouseRecordingItem> item(new MouseRecordingItem(false, nullptr)); + item->setParentItem(window->contentItem()); + window->resize(250, 250); + window->setPosition(100, 100); + window->setTitle(QTest::currentTestFunction()); + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window.data())); + QTest::qWait(100); + + QPoint p1 = item->mapToScene(item->clipRect().center()).toPoint(); + QTest::touchEvent(window.data(), touchDevice).press(0, p1, window.data()); + QTest::touchEvent(window.data(), touchDevice).move(0, p1 + movement, window.data()); + QTest::touchEvent(window.data(), touchDevice).release(0, p1 + movement, window.data()); + + QPoint p2 = p1 + distanceBetweenPresses; + QTest::touchEvent(window.data(), touchDevice).press(1, p2, window.data()); + QTest::touchEvent(window.data(), touchDevice).move(1, p2 + movement, window.data()); + QTest::touchEvent(window.data(), touchDevice).release(1, p2 + movement, window.data()); + + const int eventCount = item->m_mouseEvents.count(); + QVERIFY(eventCount >= 2); + + const int nDoubleClicks = std::count_if(item->m_mouseEvents.constBegin(), item->m_mouseEvents.constEnd(), [](const QMouseEvent &ev) { return (ev.type() == QEvent::MouseButtonDblClick); } ); + const bool foundDoubleClick = (nDoubleClicks == 1); + QCOMPARE(foundDoubleClick, expectedSynthesizedDoubleClickEvent); + +} + void tst_qquickwindow::clearWindow() { QQuickWindow *window = new QQuickWindow; |