From c5fb0a9d8a7eedaed0c4ecfe354219a9d252062f Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 23 Jan 2013 22:02:53 -0600 Subject: Disconnect from previous loading image when loading a new image. Change-Id: If2fa95d9715a55d3f07ecf5f232e4f4b9a44a6fb Reviewed-by: Gunnar Sletta --- .../auto/quick/qquickimage/data/correctStatus.qml | 26 +++++++++++ tests/auto/quick/qquickimage/tst_qquickimage.cpp | 51 ++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 tests/auto/quick/qquickimage/data/correctStatus.qml (limited to 'tests/auto/quick') diff --git a/tests/auto/quick/qquickimage/data/correctStatus.qml b/tests/auto/quick/qquickimage/data/correctStatus.qml new file mode 100644 index 0000000000..2326078657 --- /dev/null +++ b/tests/auto/quick/qquickimage/data/correctStatus.qml @@ -0,0 +1,26 @@ +import QtQuick 2.0 + +Item { + property alias status: image1.status + + Image { + id: image1 + asynchronous: true + source: "image://test/first-image.png" + } + + Image { + id: image2 + asynchronous: true + source: "image://test/first-image.png" + } + + Timer { + interval: 50 + running: true + repeat: false + onTriggered: { + image1.source = "image://test/second-image.png" + } + } +} diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp index 7f3f0d5cbc..51ac5c640a 100644 --- a/tests/auto/quick/qquickimage/tst_qquickimage.cpp +++ b/tests/auto/quick/qquickimage/tst_qquickimage.cpp @@ -56,6 +56,7 @@ #include #include #include +#include #include "../../shared/util.h" #include "../../shared/testhttpserver.h" @@ -102,6 +103,7 @@ private slots: void sourceSize(); void progressAndStatusChanges(); void sourceSizeChanges(); + void correctStatus(); private: QQmlEngine engine; @@ -868,6 +870,55 @@ void tst_qquickimage::progressAndStatusChanges() delete obj; } +class TestQImageProvider : public QQuickImageProvider +{ +public: + TestQImageProvider() : QQuickImageProvider(Image) {} + + QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize) + { + if (id == QLatin1String("first-image.png")) { + QTest::qWait(50); + int width = 100; + int height = 100; + QImage image(width, height, QImage::Format_RGB32); + image.fill(QColor("yellow").rgb()); + if (size) + *size = QSize(width, height); + return image; + } + + QTest::qWait(400); + int width = 100; + int height = 100; + QImage image(width, height, QImage::Format_RGB32); + image.fill(QColor("green").rgb()); + if (size) + *size = QSize(width, height); + return image; + } +}; + +void tst_qquickimage::correctStatus() +{ + QQmlEngine engine; + engine.addImageProvider(QLatin1String("test"), new TestQImageProvider()); + + QQmlComponent component(&engine, testFileUrl("correctStatus.qml")); + QObject *obj = component.create(); + QVERIFY(obj); + + QTest::qWait(200); + + // at this point image1 should be attempting to load second-image.png, + // and should be in the loading state. Without a clear prior to that load, + // the status can mistakenly be in the ready state. + QCOMPARE(obj->property("status").toInt(), int(QQuickImage::Loading)); + + QTest::qWait(400); + delete obj; +} + QTEST_MAIN(tst_qquickimage) #include "tst_qquickimage.moc" -- cgit v1.2.3 From 6933b7e8e6dc279a8eb34e1f4c60bc109dfb7d26 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Fri, 11 Jan 2013 14:48:32 +0100 Subject: Ungrab mouse when FocusAboutToChange instead of Leave Commit 7b2e2117162594a2d0234bb02408f5b5a446488b introduced a regression in mouse handling: When moving the mouse out of the window it would cancel all further mouse events. That is actually not wanted (eg scroll bars). Instead ungrab the mouse when the focus changes, that means the mouse handling with popups works and the scrollbar use case is also fixed. All the tests related to this seem quite timing sensitive, so try some more QTRY_VERIFY. Remove the parallel_test so that more cpu time will actually let the tests pass more reliably. Change-Id: I90586b05f461d3762728a466d71bcb967e03d14b Reviewed-by: Gabriel de Dietrich --- .../auto/quick/qquickflickable/qquickflickable.pro | 1 - .../quick/qquickflickable/tst_qquickflickable.cpp | 10 ++++----- .../auto/quick/qquickmousearea/qquickmousearea.pro | 2 -- .../quick/qquickmousearea/tst_qquickmousearea.cpp | 26 +++++++++++++--------- 4 files changed, 21 insertions(+), 18 deletions(-) (limited to 'tests/auto/quick') diff --git a/tests/auto/quick/qquickflickable/qquickflickable.pro b/tests/auto/quick/qquickflickable/qquickflickable.pro index 3ba752bf7d..95c703befe 100644 --- a/tests/auto/quick/qquickflickable/qquickflickable.pro +++ b/tests/auto/quick/qquickflickable/qquickflickable.pro @@ -9,6 +9,5 @@ include (../shared/util.pri) TESTDATA = data/* -CONFIG += parallel_test QT += core-private gui-private v8-private qml-private quick-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index 662e86018c..784988b913 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -618,7 +618,7 @@ void tst_qquickflickable::movingAndFlicking() window->setSource(testFileUrl("flickable03.qml")); window->show(); window->requestActivate(); - QTest::qWaitForWindowActive(window); + QVERIFY(QTest::qWaitForWindowActive(window)); QVERIFY(window->rootObject() != 0); QQuickFlickable *flickable = qobject_cast(window->rootObject()); @@ -639,7 +639,7 @@ void tst_qquickflickable::movingAndFlicking() // do a flick that keeps the view within the bounds flick(window, flickFrom, flickToWithoutSnapBack, 200); - QVERIFY(flickable->isMoving()); + QTRY_VERIFY(flickable->isMoving()); QCOMPARE(flickable->isMovingHorizontally(), horizontalEnabled); QCOMPARE(flickable->isMovingVertically(), verticalEnabled); QVERIFY(flickable->isFlicking()); @@ -695,7 +695,7 @@ void tst_qquickflickable::movingAndFlicking() QTRY_VERIFY(!flickable->isMoving()); flick(window, flickFrom, flickToWithSnapBack, 200); - QVERIFY(flickable->isMoving()); + QTRY_VERIFY(flickable->isMoving()); QCOMPARE(flickable->isMovingHorizontally(), horizontalEnabled); QCOMPARE(flickable->isMovingVertically(), verticalEnabled); QVERIFY(flickable->isFlicking()); @@ -999,7 +999,7 @@ void tst_qquickflickable::pressWhileFlicking() // flicking == false, moving == true; flick(window, QPoint(20,190), QPoint(20, 50), 200); QVERIFY(flickable->verticalVelocity() > 0.0); - QVERIFY(flickable->isFlicking()); + QTRY_VERIFY(flickable->isFlicking()); QVERIFY(flickable->isFlickingVertically()); QVERIFY(!flickable->isFlickingHorizontally()); QVERIFY(flickable->isMoving()); @@ -1257,7 +1257,7 @@ void tst_qquickflickable::flickTwiceUsingTouches() window->setSource(testFileUrl("longList.qml")); window->show(); window->requestActivate(); - QTest::qWaitForWindowActive(window); + QVERIFY(QTest::qWaitForWindowActive(window)); QVERIFY(window->rootObject() != 0); QQuickFlickable *flickable = qobject_cast(window->rootObject()); diff --git a/tests/auto/quick/qquickmousearea/qquickmousearea.pro b/tests/auto/quick/qquickmousearea/qquickmousearea.pro index 957b04a558..dd7b434898 100644 --- a/tests/auto/quick/qquickmousearea/qquickmousearea.pro +++ b/tests/auto/quick/qquickmousearea/qquickmousearea.pro @@ -10,7 +10,5 @@ include (../../shared/util.pri) TESTDATA = data/* -CONFIG += parallel_test - QT += core-private gui-private qml-private quick-private network testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp index 9fd42373e2..ffe7b51537 100644 --- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp +++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp @@ -248,7 +248,7 @@ void tst_QQuickMouseArea::dragging() window->setSource(testFileUrl("dragging.qml")); window->show(); window->requestActivate(); - QTest::qWait(20); + QVERIFY(QTest::qWaitForWindowExposed(window)); QVERIFY(window->rootObject() != 0); QQuickMouseArea *mouseRegion = window->rootObject()->findChild("mouseregion"); @@ -274,19 +274,17 @@ void tst_QQuickMouseArea::dragging() // First move event triggers drag, second is acted upon. // This is due to possibility of higher stacked area taking precedence. - QTest::mouseMove(window, QPoint(111,111)); - QTest::qWait(50); - QTest::mouseMove(window, QPoint(122,122)); - QTest::qWait(50); + QTest::mouseMove(window, QPoint(111,111), 50); + QTest::mouseMove(window, QPoint(116,116), 50); + QTest::mouseMove(window, QPoint(122,122), 50); - QVERIFY(drag->active()); - QCOMPARE(blackRect->x(), 72.0); + QTRY_VERIFY(drag->active()); + QTRY_COMPARE(blackRect->x(), 72.0); QCOMPARE(blackRect->y(), 72.0); QTest::mouseRelease(window, button, 0, QPoint(122,122)); - QTest::qWait(50); - QVERIFY(!drag->active()); + QTRY_VERIFY(!drag->active()); QCOMPARE(blackRect->x(), 72.0); QCOMPARE(blackRect->y(), 72.0); @@ -477,20 +475,28 @@ void tst_QQuickMouseArea::noOnClickedWithPressAndHold() window->show(); window->requestActivate(); QVERIFY(window->rootObject() != 0); + QQuickMouseArea *mouseArea = qobject_cast(window->rootObject()->children().first()); + QVERIFY(mouseArea); QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); QGuiApplication::sendEvent(window, &pressEvent); + QVERIFY(mouseArea->pressedButtons() == Qt::LeftButton); QVERIFY(!window->rootObject()->property("clicked").toBool()); QVERIFY(!window->rootObject()->property("held").toBool()); + // timeout is 800 (in qquickmousearea.cpp) QTest::qWait(1000); + QCoreApplication::processEvents(); + + QVERIFY(!window->rootObject()->property("clicked").toBool()); + QVERIFY(window->rootObject()->property("held").toBool()); QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); QGuiApplication::sendEvent(window, &releaseEvent); + QTRY_VERIFY(window->rootObject()->property("held").toBool()); QVERIFY(!window->rootObject()->property("clicked").toBool()); - QVERIFY(window->rootObject()->property("held").toBool()); delete window; } -- cgit v1.2.3 From 561ab99ad65711b61c47df9bd78ea928de525a53 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Wed, 19 Dec 2012 17:12:58 +1000 Subject: Ensure the cursorRectangle is updated as the width of the text changes. Outside of when of a monospace font is used, if the text changes the visual position of the cursor will have most likely changed as well even when the cursor index hasn't. Task-number: QTBUG-28677 Change-Id: If8077772d8541a677d5875976e6cd9fc453731df Reviewed-by: Alan Alpert --- tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/auto/quick') diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp index 3b1c5eb31c..86a05c3d3b 100644 --- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp @@ -3087,6 +3087,14 @@ void tst_qquicktextinput::cursorRectangle() input.setHAlign(leftToRight ? QQuickTextInput::AlignRight : QQuickTextInput::AlignLeft); r = input.cursorRectangle(); QCOMPARE(r.left(), leftToRight ? input.width() : 0); + + QSignalSpy cursorRectangleSpy(&input, SIGNAL(cursorRectangleChanged())); + + QString widerText = shortText; + widerText[1] = 'W'; // Assumes shortText is at least two characters long. + input.setText(widerText); + + QCOMPARE(cursorRectangleSpy.count(), 1); } void tst_qquicktextinput::readOnly() -- cgit v1.2.3 From fc454c16c84d159767273a21019fbd65572f3bad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 6 Feb 2013 09:18:19 +0100 Subject: Fixed Canvas ImageData pixel values not being settable to 0. Someone probably figured "since the data is all initialized to 0 to begin with, we can skip 0 values". However, it's possible to temporarily set a value to other than 0 and then back to 0, a fully valid use case that we need to support. Task-number: QTBUG-29065 Change-Id: Ia9f0803743d696ca8b9cca89c666ccba80a3abd0 Reviewed-by: Paul Olav Tvete Reviewed-by: Gunnar Sletta --- tests/auto/quick/qquickcanvasitem/data/tst_pixel.qml | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/auto/quick') diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_pixel.qml b/tests/auto/quick/qquickcanvasitem/data/tst_pixel.qml index 469ff2398d..487f7dc903 100644 --- a/tests/auto/quick/qquickcanvasitem/data/tst_pixel.qml +++ b/tests/auto/quick/qquickcanvasitem/data/tst_pixel.qml @@ -1,4 +1,5 @@ import QtQuick 2.0 +import QtTest 1.0 CanvasTestCase { id:testCase @@ -7,6 +8,13 @@ CanvasTestCase { function test_createImageData(row) { var canvas = createCanvasObject(row); var ctx = canvas.getContext('2d'); + var imageData = ctx.createImageData(1, 1); + var imageDataValues = imageData.data; + imageDataValues[0] = 255; + imageDataValues[0] = 0; + if (imageDataValues[0] != 0) + qtest_fail('ImageData value access fail, expecting 0, got ' + imageDataValues[0]); + ctx.reset(); canvas.destroy() } -- cgit v1.2.3 From 1d29d8edf8e4e709ca2f27791cdf8672c15488f3 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Thu, 7 Feb 2013 14:30:48 +0100 Subject: Stabilize resizemodeitem test. Resizing can take time. Instead of qWait(50) use QTRY_COMPARE to make sure we give enough time. Change-Id: I484eca1f4d49381913dc82f405c73de653608493 Reviewed-by: Shawn Rutledge Reviewed-by: David Faure (KDE) Reviewed-by: Friedemann Kleint --- tests/auto/quick/qquickview/tst_qquickview.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'tests/auto/quick') diff --git a/tests/auto/quick/qquickview/tst_qquickview.cpp b/tests/auto/quick/qquickview/tst_qquickview.cpp index 64b108cbec..e2e20a6516 100644 --- a/tests/auto/quick/qquickview/tst_qquickview.cpp +++ b/tests/auto/quick/qquickview/tst_qquickview.cpp @@ -153,8 +153,7 @@ void tst_QQuickView::resizemodeitem() // size update from view view->resize(QSize(200,300)); - QTest::qWait(50); - QCOMPARE(item->width(), 200.0); + QTRY_COMPARE(item->width(), 200.0); QCOMPARE(item->height(), 300.0); QCOMPARE(view->size(), QSize(200, 300)); QCOMPARE(view->size(), view->sizeHint()); -- cgit v1.2.3