diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2012-04-11 14:56:22 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@nokia.com> | 2012-04-11 16:05:03 +0200 |
commit | a896d4b39ec3d45ba708d9b36ea9c864b1df2136 (patch) | |
tree | 45cfe153cce6114c2c76c48dc0bdabde2a8cf3e3 /tests/auto/quick | |
parent | 24fb8dc27eddfdd62bd2c3a6e863cbf433762cd6 (diff) | |
parent | 65bfc35429e845cf6b76d58107360a1360a654fc (diff) |
Merge remote-tracking branch 'origin/master' into api_changes
Conflicts:
src/qml/debugger/qqmlprofilerservice_p.h
src/qml/qml/qqmlboundsignal.cpp
src/qml/qml/v4/qv4bindings.cpp
src/quick/items/qquickshadereffect.cpp
src/quick/particles/qquickcustomparticle.cpp
src/quick/qtquick2.cpp
Change-Id: Ia9c6517035ae912fa75e77473a452bd3383def56
Diffstat (limited to 'tests/auto/quick')
32 files changed, 903 insertions, 209 deletions
diff --git a/tests/auto/quick/examples/examples.pro b/tests/auto/quick/examples/examples.pro index c320fdad9e..d24fe80498 100644 --- a/tests/auto/quick/examples/examples.pro +++ b/tests/auto/quick/examples/examples.pro @@ -8,5 +8,3 @@ DEFINES += SRCDIR=\\\"$$PWD\\\" CONFIG += parallel_test #temporary QT += core-private gui-private qml-private quick-private v8-private testlib - -cross_compile: DEFINES += QTEST_CROSS_COMPILED diff --git a/tests/auto/quick/examples/tst_examples.cpp b/tests/auto/quick/examples/tst_examples.cpp index 9a2a800cfd..b019c716b0 100644 --- a/tests/auto/quick/examples/tst_examples.cpp +++ b/tests/auto/quick/examples/tst_examples.cpp @@ -249,10 +249,6 @@ void tst_examples::sgexamples() { QFETCH(QString, file); -#if defined(QTEST_CROSS_COMPILED) - QSKIP("sources not available when cross compiled"); -#endif - QQmlComponent component(&engine, QUrl::fromLocalFile(file)); if (component.status() == QQmlComponent::Error) qWarning() << component.errors(); @@ -293,10 +289,6 @@ void tst_examples::sgsnippets() { QFETCH(QString, file); -#if defined(QTEST_CROSS_COMPILED) - QSKIP("sources not available when cross compiled"); -#endif - QQmlComponent component(&engine, QUrl::fromLocalFile(file)); if (component.status() == QQmlComponent::Error) qWarning() << component.errors(); diff --git a/tests/auto/quick/qquickaccessible/data/statictext.qml b/tests/auto/quick/qquickaccessible/data/statictext.qml index a0821cfc4d..7cf1b707a0 100644 --- a/tests/auto/quick/qquickaccessible/data/statictext.qml +++ b/tests/auto/quick/qquickaccessible/data/statictext.qml @@ -10,6 +10,10 @@ Item { width: 200 height: 50 text : "Hello Accessibility" + + // Setting any value of the attached property + // makes an item accessible. + Accessible.name: text } Text { diff --git a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp index 48c07c6e2c..45a9d11c69 100644 --- a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp +++ b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp @@ -340,23 +340,25 @@ void tst_QQuickAccessible::hitTest() canvas->setSource(testFileUrl("hittest.qml")); canvas->show(); - QAI iface = QAI(QAccessible::queryAccessibleInterface(canvas)); - QVERIFY(iface.data()); - QAI rootItem = QAI(iface->child(0)); + QAI canvasIface = QAI(QAccessible::queryAccessibleInterface(canvas)); + QVERIFY(canvasIface.data()); + QAI rootItem = QAI(canvasIface->child(0)); QRect rootRect = rootItem->rect(); - // hit the root item - QAI itemHit(iface->childAt(rootRect.x() + 200, rootRect.y() + 50)); + // check the root item from app + QAI appIface = QAI(QAccessible::queryAccessibleInterface(qApp)); + QVERIFY(appIface); + QAI itemHit(appIface->childAt(rootRect.x() + 200, rootRect.y() + 50)); QVERIFY(itemHit); QCOMPARE(rootRect, itemHit->rect()); // hit rect1 - QAI rect1(rootItem->child(1)); + QAI rect1(rootItem->child(0)); QRect rect1Rect = rect1->rect(); - itemHit = QAI(rootItem->childAt(rect1Rect.x() + 10, rect1Rect.y() + 10)); - QVERIFY(itemHit); - QCOMPARE(rect1Rect, itemHit->rect()); - QCOMPARE(itemHit->text(QAccessible::Name), QLatin1String("rect1")); + QAI rootItemIface = QAI(rootItem->childAt(rect1Rect.x() + 10, rect1Rect.y() + 10)); + QVERIFY(rootItemIface); + QCOMPARE(rect1Rect, rootItemIface->rect()); + QCOMPARE(rootItemIface->text(QAccessible::Name), QLatin1String("rect1")); // should also work from top level (app) QAI app(QAccessible::queryAccessibleInterface(qApp)); @@ -366,16 +368,20 @@ void tst_QQuickAccessible::hitTest() QCOMPARE(itemHit2->text(QAccessible::Name), QLatin1String("rect1")); // hit rect201 - QAI rect2(rootItem->child(2)); - QAI rect20(rect2->child(1)); - QAI rect201(rect20->child(2)); + QAI rect2(rootItem->child(1)); + QVERIFY(rect2); + // FIXME: This is seems broken on mac + // QCOMPARE(rect2->rect().translated(rootItem->rect().x(), rootItem->rect().y()), QRect(0, 50, 100, 100)); + QAI rect20(rect2->child(0)); + QVERIFY(rect20); + QAI rect201(rect20->child(1)); QVERIFY(rect201); QRect rect201Rect = rect201->rect(); - itemHit = QAI(iface->childAt(rect201Rect.x() + 20, rect201Rect.y() + 20)); - QVERIFY(itemHit); - QCOMPARE(itemHit->rect(), rect201Rect); - QCOMPARE(itemHit->text(QAccessible::Name), QLatin1String("rect201")); + rootItemIface = QAI(canvasIface->childAt(rect201Rect.x() + 20, rect201Rect.y() + 20)); + QVERIFY(rootItemIface); + QCOMPARE(rootItemIface->rect(), rect201Rect); + QCOMPARE(rootItemIface->text(QAccessible::Name), QLatin1String("rect201")); delete canvas; } diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_arc.qml b/tests/auto/quick/qquickcanvasitem/data/tst_arc.qml index c33901d294..10bc37e82d 100644 --- a/tests/auto/quick/qquickcanvasitem/data/tst_arc.qml +++ b/tests/auto/quick/qquickcanvasitem/data/tst_arc.qml @@ -43,7 +43,10 @@ Canvas { ctx.moveTo(100, 0); ctx.arc(100, 0, 150, (512+1/2)*Math.PI, (1024-1)*Math.PI, true); ctx.fill(); + /*FIXME: from: http://www.w3.org/TR/2dcontext/#dom-context-2d-arc + If the anticlockwise argument is omitted or false and endAngle-startAngle is equal to or greater than 2π, or, if the anticlockwise argument is true and startAngle-endAngle is equal to or greater than 2π, then the arc is the whole circumference of this circle. //verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); + */ } function test_angle_4() { var ctx = canvas.getContext('2d'); @@ -72,11 +75,10 @@ Canvas { ctx.moveTo(100, 0); ctx.arc(100, 0, 150, (1024-1)*Math.PI, (512+1/2)*Math.PI, false); ctx.fill(); - /*FIXME: - actual :[255,0,0,255] - expected:[0,255,0,255] +/- 0 - */ + /*FIXME: from: http://www.w3.org/TR/2dcontext/#dom-context-2d-arc + If the anticlockwise argument is omitted or false and endAngle-startAngle is equal to or greater than 2π, or, if the anticlockwise argument is true and startAngle-endAngle is equal to or greater than 2π, then the arc is the whole circumference of this circle. //verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); + */ } function test_angle_6() { @@ -108,11 +110,7 @@ Canvas { ctx.beginPath(); ctx.arc(200, 25, 5, 0, 2*Math.PI, true); ctx.stroke(); - /*FIXME: - actual :[255,0,0,255] - expected:[0,255,0,255] +/- 0 - */ - //verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); } function test_nonempty() { var ctx = canvas.getContext('2d'); @@ -129,7 +127,6 @@ Canvas { verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); } function test_nonfinite() { - skip("FIXME"); var ctx = canvas.getContext('2d'); ctx.reset(); @@ -241,13 +238,13 @@ Canvas { verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); } function test_scale_2() { @@ -271,7 +268,7 @@ Canvas { verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); } function test_selfintersect_1() { @@ -288,8 +285,8 @@ Canvas { ctx.beginPath(); ctx.arc(0, 0, 25, 0, -Math.PI/2, true); ctx.stroke(); - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); } function test_selfintersect_2() { @@ -307,10 +304,10 @@ Canvas { ctx.arc(100, 0, 25, 0, -Math.PI/2, true); ctx.stroke(); verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 90,10, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 97,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 97,2, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 97,3, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 90,10, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 97,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 97,2, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 97,3, 0,255,0,255)); verify(Helper.comparePixel(ctx, 2,48, 0,255,0,255)); } @@ -325,12 +322,12 @@ Canvas { ctx.beginPath(); ctx.arc(50, 50, 50, 0, Math.PI, false); ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); verify(Helper.comparePixel(ctx, 20,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); } function test_shape_2() { @@ -362,11 +359,11 @@ Canvas { ctx.beginPath(); ctx.arc(0, 50, 50, 0, -Math.PI/2, false); ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); } function test_shape_4() { @@ -398,11 +395,11 @@ Canvas { ctx.beginPath(); ctx.arc(300, 0, 100, 0, 5*Math.PI, false); ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); } function test_twopie() { @@ -416,7 +413,7 @@ Canvas { ctx.beginPath(); ctx.arc(50, 25, 50, 0, 2*Math.PI - 1e-4, true); ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#f00'; @@ -436,7 +433,8 @@ Canvas { ctx.beginPath(); ctx.arc(50, 25, 50, 0, 2*Math.PI + 1e-4, true); ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); + //FIXME:still different behavior from browsers, > 2pi span issue + //verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#f00'; @@ -460,7 +458,7 @@ Canvas { ctx.beginPath(); ctx.arc(50, 25, 50, 0, 0, true); ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#0f0'; @@ -470,7 +468,7 @@ Canvas { ctx.beginPath(); ctx.arc(50, 25, 50, 0, 0, false); ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#f00' diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_arcto.qml b/tests/auto/quick/qquickcanvasitem/data/tst_arcto.qml index 84bfc1a8db..188d538d29 100644 --- a/tests/auto/quick/qquickcanvasitem/data/tst_arcto.qml +++ b/tests/auto/quick/qquickcanvasitem/data/tst_arcto.qml @@ -118,7 +118,7 @@ Canvas { ctx.beginPath(); ctx.arcTo(100, 50, 200, 50, 0.1); ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#f00'; @@ -152,8 +152,6 @@ Canvas { var ctx = canvas.getContext('2d'); ctx.reset(); - skip("FIXME"); - ctx.moveTo(0, 0); ctx.lineTo(100, 0); ctx.arcTo(Infinity, 50, 0, 50, 0); @@ -221,7 +219,7 @@ Canvas { ctx.lineTo(-1000, 0); ctx.fill(); - skip("FIXME"); + //FIXME //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); //verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); @@ -332,7 +330,8 @@ Canvas { ctx.arcTo(200, 25, 200, 50, 10); ctx.stroke(); - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //FIXME + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); @@ -354,16 +353,15 @@ Canvas { ctx.lineTo(-100, 0); ctx.fill(); - skip("FIXME"); - //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); } function test_zero() { var ctx = canvas.getContext('2d'); diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml b/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml index 23d7b719ff..a70c798594 100644 --- a/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml +++ b/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml @@ -271,6 +271,7 @@ Rectangle { ctx = c.getContext('2D'); verify(ctx); compare(ctx.canvas, c); + ignoreWarning(Qt.resolvedUrl("tst_canvas.qml") + ":10:9: QML Canvas: Canvas already initialized with a different context type"); ctx = c.getContext('invalid'); verify(!ctx); c.destroy(); diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_composite.qml b/tests/auto/quick/qquickcanvasitem/data/tst_composite.qml index bdc9d37663..60c63ae04b 100644 --- a/tests/auto/quick/qquickcanvasitem/data/tst_composite.qml +++ b/tests/auto/quick/qquickcanvasitem/data/tst_composite.qml @@ -133,7 +133,6 @@ Canvas { } function test_solid() { - skip("FIXME"); var ctx = canvas.getContext('2d'); ctx.reset(); ctx.fillStyle = Qt.rgba(0, 1, 1, 1.0); @@ -230,7 +229,6 @@ Canvas { } function test_transparent() { - skip("FIXME"); var ctx = canvas.getContext('2d'); ctx.reset(); ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; @@ -279,7 +277,8 @@ Canvas { ctx.globalCompositeOperation = 'lighter'; ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; ctx.fillRect(0, 0, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,127,191,255, 5)); + //FIXME + //verify(Helper.comparePixel(ctx, 50,25, 0,127,191,255, 5)); ctx.reset(); ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; @@ -325,7 +324,6 @@ Canvas { } function test_uncovered() { - skip("FIXME"); var ctx = canvas.getContext('2d'); ctx.reset(); ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; @@ -334,7 +332,8 @@ Canvas { ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; ctx.translate(0, 25); ctx.fillRect(0, 50, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); + //FIXME + //verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); ctx.reset(); ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; @@ -343,7 +342,8 @@ Canvas { ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; ctx.translate(0, 25); ctx.fillRect(0, 50, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); + //FIXME + //verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); @@ -354,7 +354,8 @@ Canvas { ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; ctx.translate(0, 25); ctx.fillRect(0, 50, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); + //FIXME + //verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); ctx.reset(); ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; @@ -363,7 +364,8 @@ Canvas { ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; ctx.translate(0, 25); ctx.fillRect(0, 50, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); + //FIXME + //verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); ctx.reset(); ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; @@ -372,7 +374,8 @@ Canvas { ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; ctx.translate(0, 25); ctx.fillRect(0, 50, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); + //FIXME + //verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); } diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_path.qml b/tests/auto/quick/qquickcanvasitem/data/tst_path.qml index f72e5b9eaa..7c88106e5f 100644 --- a/tests/auto/quick/qquickcanvasitem/data/tst_path.qml +++ b/tests/auto/quick/qquickcanvasitem/data/tst_path.qml @@ -4,7 +4,6 @@ import "testhelper.js" as Helper Canvas { id:canvas; width:100;height:50; renderTarget: Canvas.Image; renderStrategy:Canvas.Threaded - smooth: false TestCase { name: "path"; when: windowShown @@ -102,7 +101,7 @@ Canvas { ctx.reset(); ctx.rect(20, 0, 20, 20); - //verify(ctx.isPointInPath(10, 10)); + verify(!ctx.isPointInPath(10, 10)); verify(ctx.isPointInPath(30, 10)); ctx.reset(); @@ -111,19 +110,19 @@ Canvas { verify(!ctx.isPointInPath(25, 30)); //verify(ctx.isPointInPath(30, 20)); verify(!ctx.isPointInPath(30, 30)); - //verify(!ctx.isPointInPath(40, 2)); + verify(!ctx.isPointInPath(40, 2)); //verify(ctx.isPointInPath(40, 20)); verify(!ctx.isPointInPath(40, 30)); verify(!ctx.isPointInPath(40, 47)); //verify(ctx.isPointInPath(45, 20)); - //verify(!ctx.isPointInPath(45, 30)); + verify(!ctx.isPointInPath(45, 30)); //verify(!ctx.isPointInPath(55, 20)); //verify(ctx.isPointInPath(55, 30)); - verify(!ctx.isPointInPath(60, 2)); + //verify(!ctx.isPointInPath(60, 2)); //verify(!ctx.isPointInPath(60, 20)); verify(ctx.isPointInPath(60, 30)); verify(!ctx.isPointInPath(60, 47)); - verify(!ctx.isPointInPath(70, 20)); + //verify(!ctx.isPointInPath(70, 20)); verify(ctx.isPointInPath(70, 30)); verify(!ctx.isPointInPath(75, 20)); verify(!ctx.isPointInPath(75, 30)); @@ -131,8 +130,8 @@ Canvas { ctx.reset(); ctx.arc(50, 25, 10, 0, 7, false); verify(!ctx.isPointInPath(50, 10)); - //verify(ctx.isPointInPath(50, 20)); - //verify(ctx.isPointInPath(50, 30)); + verify(ctx.isPointInPath(50, 20)); + verify(ctx.isPointInPath(50, 30)); verify(!ctx.isPointInPath(50, 40)); verify(!ctx.isPointInPath(30, 20)); verify(!ctx.isPointInPath(70, 20)); @@ -143,16 +142,16 @@ Canvas { ctx.rect(0, 0, 20, 20); verify(ctx.isPointInPath(0, 0)); verify(ctx.isPointInPath(10, 0)); - //verify(ctx.isPointInPath(20, 0)); - //verify(ctx.isPointInPath(20, 10)); - //verify(ctx.isPointInPath(20, 20)); - //verify(ctx.isPointInPath(10, 20)); - //verify(ctx.isPointInPath(0, 20)); + verify(ctx.isPointInPath(20, 0)); + verify(ctx.isPointInPath(20, 10)); + verify(ctx.isPointInPath(20, 20)); + verify(ctx.isPointInPath(10, 20)); + verify(ctx.isPointInPath(0, 20)); verify(ctx.isPointInPath(0, 10)); verify(!ctx.isPointInPath(10, -0.01)); verify(!ctx.isPointInPath(10, 20.01)); verify(!ctx.isPointInPath(-0.01, 10)); - //verify(!ctx.isPointInPath(20.01, 10)); + verify(!ctx.isPointInPath(20.01, 10)); ctx.reset(); verify(!ctx.isPointInPath(0, 0)); @@ -160,13 +159,13 @@ Canvas { ctx.reset(); ctx.rect(-100, -50, 200, 100); - //verify(ctx.isPointInPath(Infinity, 0)); - //verify(ctx.isPointInPath(-Infinity, 0)); - //verify(ctx.isPointInPath(NaN, 0)); - //verify(ctx.isPointInPath(0, Infinity)); - //verify(ctx.isPointInPath(0, -Infinity)); - //verify(ctx.isPointInPath(0, NaN)); - //verify(ctx.isPointInPath(NaN, NaN)); + verify(!ctx.isPointInPath(Infinity, 0)); + verify(!ctx.isPointInPath(-Infinity, 0)); + verify(!ctx.isPointInPath(NaN, 0)); + verify(!ctx.isPointInPath(0, Infinity)); + verify(!ctx.isPointInPath(0, -Infinity)); + verify(!ctx.isPointInPath(0, NaN)); + verify(!ctx.isPointInPath(NaN, NaN)); ctx.reset(); ctx.rect(0, -100, 20, 20); @@ -174,9 +173,9 @@ Canvas { verify(!ctx.isPointInPath(10, -110)); verify(ctx.isPointInPath(10, -90)); verify(!ctx.isPointInPath(10, -70)); - //verify(!ctx.isPointInPath(30, -20)); - //verify(ctx.isPointInPath(30, 0)); - //verify(!ctx.isPointInPath(30, 20)); + verify(!ctx.isPointInPath(30, -20)); + verify(ctx.isPointInPath(30, 0)); + verify(!ctx.isPointInPath(30, 20)); ctx.reset(); ctx.rect(0, 0, 20, 20); @@ -193,7 +192,7 @@ Canvas { ctx.rect(0, 0, 20, 20); verify(!ctx.isPointInPath(-40, 10)); verify(!ctx.isPointInPath(10, 10)); - //verify(!ctx.isPointInPath(49, 10)); + verify(!ctx.isPointInPath(49, 10)); verify(ctx.isPointInPath(51, 10)); verify(ctx.isPointInPath(69, 10)); verify(!ctx.isPointInPath(71, 10)); @@ -203,7 +202,7 @@ Canvas { ctx.translate(50, 0); verify(!ctx.isPointInPath(-40, 10)); verify(!ctx.isPointInPath(10, 10)); - //verify(!ctx.isPointInPath(49, 10)); + verify(!ctx.isPointInPath(49, 10)); verify(ctx.isPointInPath(51, 10)); verify(ctx.isPointInPath(69, 10)); verify(!ctx.isPointInPath(71, 10)); @@ -213,7 +212,7 @@ Canvas { ctx.rect(-70, 0, 20, 20); verify(!ctx.isPointInPath(-40, 10)); verify(!ctx.isPointInPath(10, 10)); - //verify(!ctx.isPointInPath(49, 10)); + verify(!ctx.isPointInPath(49, 10)); verify(ctx.isPointInPath(51, 10)); verify(ctx.isPointInPath(69, 10)); verify(!ctx.isPointInPath(71, 10)); @@ -224,7 +223,7 @@ Canvas { ctx.lineTo(20, 20); ctx.lineTo(0, 20); verify(ctx.isPointInPath(10, 10)); - //verify(!ctx.isPointInPath(30, 10)); + verify(!ctx.isPointInPath(30, 10)); ctx.reset(); ctx.moveTo(0, 0); @@ -279,8 +278,8 @@ Canvas { ctx.fillStyle = '#0f0'; ctx.fill(); - //verify(Helper.comparePixel(ctx, 90,10, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 10,40, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 90,10, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 10,40, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#000'; @@ -292,7 +291,7 @@ Canvas { ctx.rect(10, 10, 80, 30); ctx.fill(); - //verify(Helper.comparePixel(ctx, 50,25, 0,127,0,255, 1)); + verify(Helper.comparePixel(ctx, 50,25, 0,127,0,255, 1)); ctx.reset(); ctx.fillStyle = '#f00'; @@ -310,7 +309,7 @@ Canvas { ctx.lineTo(0, 50); ctx.fill(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#0f0'; @@ -422,7 +421,7 @@ Canvas { ctx.arc(50, 25, 10, 0, 0, false); ctx.stroke(); - // verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#0f0'; ctx.fillRect(0, 0, 100, 50); @@ -457,7 +456,8 @@ Canvas { ctx.lineTo(-100, 1000); ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //FIXME:lineJoin with miterLimit test fail! + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#0f0'; @@ -564,15 +564,15 @@ Canvas { ctx.stroke(); ctx.restore(); - //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#f00'; @@ -611,14 +611,14 @@ Canvas { ctx.restore(); //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); //verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#f00'; @@ -847,7 +847,7 @@ Canvas { ctx.beginPath(); ctx.lineTo(100, 50); ctx.stroke(); - // verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#f00'; @@ -911,8 +911,8 @@ Canvas { ctx.beginPath(); ctx.bezierCurveTo(100, 50, 200, 50, 200, 50); ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 95,45, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 95,45, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#f00'; @@ -923,7 +923,7 @@ Canvas { ctx.bezierCurveTo(0, 25, 100, 25, 100, 25); ctx.stroke(); verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 5,45, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 5,45, 0,255,0,255)); ctx.reset(); ctx.moveTo(0, 0); @@ -1035,11 +1035,11 @@ Canvas { ctx.moveTo(-2, 3.1); ctx.bezierCurveTo(-2, -1, 2.1, -1, 2.1, 3.1); ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#f00'; @@ -1078,8 +1078,8 @@ Canvas { ctx.beginPath(); ctx.quadraticCurveTo(100, 50, 200, 50); ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 95,45, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 95,45, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#f00'; @@ -1090,7 +1090,7 @@ Canvas { ctx.quadraticCurveTo(0, 25, 100, 25); ctx.stroke(); verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 5,45, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 5,45, 0,255,0,255)); ctx.reset(); ctx.moveTo(0, 0); @@ -1135,11 +1135,11 @@ Canvas { ctx.moveTo(-1, 1.05); ctx.quadraticCurveTo(0, -1, 1.2, 1.05); ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#f00'; @@ -1260,8 +1260,8 @@ Canvas { ctx.lineTo(0, 50); ctx.fillStyle = '#0f0'; ctx.fill(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 90,45, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 90,45, 0,255,0,255)); ctx.reset(); @@ -1399,7 +1399,7 @@ Canvas { ctx.fillStyle = '#0f0'; ctx.fill(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#f00'; @@ -1416,7 +1416,7 @@ Canvas { ctx.rotate(Math.PI/2); ctx.scale(0.1, 0.1); ctx.fill(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); ctx.reset(); ctx.fillStyle = '#0f0'; diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index 2ed42e7f0f..f926dbe8f0 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -443,11 +443,14 @@ void tst_qquickflickable::movingAndDragging() // Vertical with a quick press-move-release: should cause a flick in release. QSignalSpy vFlickSpy(flickable, SIGNAL(flickingVerticallyChanged())); - - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 90)); - QTest::qWait(10); - QTest::mouseMove(canvas, QPoint(50, 40)); - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 40)); + // Use something that generates a huge velocity just to make it testable. + // In practice this feature matters on touchscreen devices where the + // underlying drivers will hopefully provide a pre-calculated velocity + // (based on more data than what the UI gets), thus making this use case + // working even with small movements. + QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 10)); + QTest::mouseMove(canvas, QPoint(50, 300), 10); + QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 100), 10); QCOMPARE(vFlickSpy.count(), 1); diff --git a/tests/auto/quick/qquickflipable/data/flip-flipable.qml b/tests/auto/quick/qquickflipable/data/flip-flipable.qml new file mode 100644 index 0000000000..4f22a0df6d --- /dev/null +++ b/tests/auto/quick/qquickflipable/data/flip-flipable.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 + +Flipable { + id: flipable + width: 640; height: 480 + property bool flipped: false + + front: Rectangle { color: "red"; anchors.fill: flipable } + back: Rectangle { color: "blue"; anchors.fill: flipable } + + transform: Rotation { + id: rotation + origin.x: flipable.width/2 + origin.y: flipable.height/2 + axis.x: 0; axis.y: 1; axis.z: 0 // set axis.y to 1 to rotate around y-axis + angle: 0 // the default angle + } + + states: State { + name: "back" + PropertyChanges { target: rotation; angle: 540 } + when: flipable.flipped + } + + transitions: Transition { + NumberAnimation { target: rotation; property: "angle"; duration: 500 } + } +} diff --git a/tests/auto/quick/qquickflipable/tst_qquickflipable.cpp b/tests/auto/quick/qquickflipable/tst_qquickflipable.cpp index 4fe155168a..8c1c248925 100644 --- a/tests/auto/quick/qquickflipable/tst_qquickflipable.cpp +++ b/tests/auto/quick/qquickflipable/tst_qquickflipable.cpp @@ -58,6 +58,7 @@ private slots: void create(); void checkFrontAndBack(); void setFrontAndBack(); + void flipFlipable(); // below here task issues void QTBUG_9161_crash(); @@ -109,6 +110,20 @@ void tst_qquickflipable::setFrontAndBack() delete obj; } +void tst_qquickflipable::flipFlipable() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("flip-flipable.qml")); + QQuickFlipable *obj = qobject_cast<QQuickFlipable*>(c.create()); + QVERIFY(obj != 0); + QVERIFY(obj->side() == QQuickFlipable::Front); + obj->setProperty("flipped", QVariant(true)); + QTRY_VERIFY(obj->side() == QQuickFlipable::Back); + QTRY_VERIFY(obj->side() == QQuickFlipable::Front); + QTRY_VERIFY(obj->side() == QQuickFlipable::Back); + delete obj; +} + void tst_qquickflipable::QTBUG_9161_crash() { QQuickView *canvas = new QQuickView; diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp index c7b5ca6b40..22c9004ccc 100644 --- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp @@ -2094,15 +2094,17 @@ void tst_QQuickGridView::componentChanges() QTRY_VERIFY(gridView); QQmlComponent component(canvas->engine()); - component.setData("import QtQuick 1.0; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile("")); + component.setData("import QtQuick 2.0; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile("")); QQmlComponent delegateComponent(canvas->engine()); - delegateComponent.setData("import QtQuick 1.0; Text { text: '<b>Name:</b> ' + name }", QUrl::fromLocalFile("")); + delegateComponent.setData("import QtQuick 2.0; Text { text: '<b>Name:</b> ' + name }", QUrl::fromLocalFile("")); QSignalSpy highlightSpy(gridView, SIGNAL(highlightChanged())); QSignalSpy delegateSpy(gridView, SIGNAL(delegateChanged())); QSignalSpy headerSpy(gridView, SIGNAL(headerChanged())); QSignalSpy footerSpy(gridView, SIGNAL(footerChanged())); + QSignalSpy headerItemSpy(gridView, SIGNAL(headerItemChanged())); + QSignalSpy footerItemSpy(gridView, SIGNAL(footerItemChanged())); gridView->setHighlight(&component); gridView->setDelegate(&delegateComponent); @@ -2114,10 +2116,15 @@ void tst_QQuickGridView::componentChanges() QTRY_COMPARE(gridView->header(), &component); QTRY_COMPARE(gridView->footer(), &component); + QVERIFY(gridView->headerItem()); + QVERIFY(gridView->footerItem()); + QTRY_COMPARE(highlightSpy.count(),1); QTRY_COMPARE(delegateSpy.count(),1); QTRY_COMPARE(headerSpy.count(),1); QTRY_COMPARE(footerSpy.count(),1); + QTRY_COMPARE(headerItemSpy.count(),1); + QTRY_COMPARE(footerItemSpy.count(),1); gridView->setHighlight(&component); gridView->setDelegate(&delegateComponent); @@ -2128,6 +2135,8 @@ void tst_QQuickGridView::componentChanges() QTRY_COMPARE(delegateSpy.count(),1); QTRY_COMPARE(headerSpy.count(),1); QTRY_COMPARE(footerSpy.count(),1); + QTRY_COMPARE(headerItemSpy.count(),1); + QTRY_COMPARE(footerItemSpy.count(),1); delete canvas; } diff --git a/tests/auto/quick/qquickitem/data/focusSubItemInNonFocusScope.qml b/tests/auto/quick/qquickitem/data/focusSubItemInNonFocusScope.qml new file mode 100644 index 0000000000..0e50710717 --- /dev/null +++ b/tests/auto/quick/qquickitem/data/focusSubItemInNonFocusScope.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 + +Rectangle { + width: 400; height: 400 + + FocusScope { + width: 400; height: 400 + focus: true + Item { + width: 400; height: 400 + Item { + id: dummy + objectName: "dummyItem" + focus: true + } + TextInput { + id: ti + objectName: "textInput" + focus: true + } + } + } +} diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp index abd0da8ac1..a1377694e4 100644 --- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp @@ -139,6 +139,9 @@ private slots: void addedToCanvas(); void changeParent(); void multipleFocusClears(); + void focusSubItemInNonFocusScope(); + void parentItemWithFocus(); + void reparentFocusedItem(); void constructor(); void setParentItem(); @@ -707,6 +710,7 @@ void tst_qquickitem::changeParent() focusState[item].set(true, true); focusState.active(item); FVERIFY(); + delete child2; } } @@ -720,6 +724,133 @@ void tst_qquickitem::multipleFocusClears() QTRY_VERIFY(QGuiApplication::focusWindow() == view); } +void tst_qquickitem::focusSubItemInNonFocusScope() +{ + QQuickView *view = new QQuickView; + view->setSource(testFileUrl("focusSubItemInNonFocusScope.qml")); + view->show(); + qApp->processEvents(); + + QQuickItem *dummyItem = view->rootObject()->findChild<QQuickItem *>("dummyItem"); + QVERIFY(dummyItem); + + QQuickItem *textInput = view->rootObject()->findChild<QQuickItem *>("textInput"); + QVERIFY(textInput); + + QVERIFY(dummyItem->hasFocus()); + QVERIFY(!textInput->hasFocus()); + QVERIFY(dummyItem->hasActiveFocus()); + + QVERIFY(QMetaObject::invokeMethod(textInput, "forceActiveFocus")); + + QVERIFY(!dummyItem->hasFocus()); + QVERIFY(textInput->hasFocus()); + QVERIFY(textInput->hasActiveFocus()); + + delete view; +} + +void tst_qquickitem::parentItemWithFocus() +{ + QQuickCanvas canvas; + ensureFocus(&canvas); + QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); + { + QQuickItem parent; + QQuickItem child; + + FocusState focusState; + focusState << &parent << &child; + FVERIFY(); + + parent.setFocus(true); + child.setFocus(true); + focusState[&parent].set(true, false); + focusState[&child].set(true, false); + FVERIFY(); + + child.setParentItem(&parent); + focusState[&parent].set(true, false); + focusState[&child].set(false, false); + FVERIFY(); + + parent.setParentItem(canvas.rootItem()); + focusState[&parent].set(true, true); + focusState[&child].set(false, false); + focusState.active(&parent); + FVERIFY(); + + child.forceActiveFocus(); + focusState[&parent].set(false, false); + focusState[&child].set(true, true); + focusState.active(&child); + FVERIFY(); + } { + QQuickItem parent; + QQuickItem child; + QQuickItem grandchild(&child); + + FocusState focusState; + focusState << &parent << &child << &grandchild; + FVERIFY(); + + parent.setFocus(true); + grandchild.setFocus(true); + focusState[&parent].set(true, false); + focusState[&child].set(false, false); + focusState[&grandchild].set(true, false); + FVERIFY(); + + child.setParentItem(&parent); + focusState[&parent].set(true, false); + focusState[&child].set(false, false); + focusState[&grandchild].set(false, false); + FVERIFY(); + + parent.setParentItem(canvas.rootItem()); + focusState[&parent].set(true, true); + focusState[&child].set(false, false); + focusState[&grandchild].set(false, false); + focusState.active(&parent); + FVERIFY(); + + grandchild.forceActiveFocus(); + focusState[&parent].set(false, false); + focusState[&child].set(false, false); + focusState[&grandchild].set(true, true); + focusState.active(&grandchild); + FVERIFY(); + } +} + +void tst_qquickitem::reparentFocusedItem() +{ + QQuickCanvas canvas; + ensureFocus(&canvas); + QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); + + QQuickItem parent(canvas.rootItem()); + QQuickItem child(&parent); + QQuickItem sibling(&parent); + QQuickItem grandchild(&child); + + FocusState focusState; + focusState << &parent << &child << &sibling << &grandchild; + FVERIFY(); + + grandchild.setFocus(true); + focusState[&parent].set(false, false); + focusState[&child].set(false, false); + focusState[&sibling].set(false, false); + focusState[&grandchild].set(true, true); + focusState.active(&grandchild); + FVERIFY(); + + // Parenting the item to another item within the same focus scope shouldn't change it's focus. + child.setParentItem(&sibling); + FVERIFY(); +} + void tst_qquickitem::constructor() { QQuickItem *root = new QQuickItem; diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index 1218d3cfcb..1ef895d111 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -2120,13 +2120,13 @@ void tst_QQuickListView::sectionsPositioning() QVERIFY(bottomItem); QCOMPARE(bottomItem->y(), 380.); - // Change current section + // Change current section, and verify case insensitive comparison listview->setContentY(10); model.modifyItem(0, "One", "aaa"); - model.modifyItem(1, "Two", "aaa"); - model.modifyItem(2, "Three", "aaa"); - model.modifyItem(3, "Four", "aaa"); - model.modifyItem(4, "Five", "aaa"); + model.modifyItem(1, "Two", "AAA"); + model.modifyItem(2, "Three", "aAa"); + model.modifyItem(3, "Four", "aaA"); + model.modifyItem(4, "Five", "Aaa"); QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); QTRY_COMPARE(listview->currentSection(), QString("aaa")); diff --git a/tests/auto/quick/qquickloader/data/RedRect.qml b/tests/auto/quick/qquickloader/data/RedRect.qml new file mode 100644 index 0000000000..0eec9b56b7 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/RedRect.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +Rectangle { + objectName: "red" + width: 100 + height: 100 + color: "red" +} diff --git a/tests/auto/quick/qquickloader/data/implicitSize.qml b/tests/auto/quick/qquickloader/data/implicitSize.qml index 5c8c8348ed..ae8c0b8b30 100644 --- a/tests/auto/quick/qquickloader/data/implicitSize.qml +++ b/tests/auto/quick/qquickloader/data/implicitSize.qml @@ -3,12 +3,17 @@ import QtQuick 2.0 Rectangle { property real implWidth: 0 property real implHeight: 0 + function changeImplicitSize () { + loader.item.implicitWidth = 200 + loader.item.implicitHeight = 300 + } color: "green" width: loader.implicitWidth+50 height: loader.implicitHeight+50 Loader { id: loader + objectName: "loader" sourceComponent: Item { anchors.centerIn: parent diff --git a/tests/auto/quick/qquickloader/data/loadedSignal.2.qml b/tests/auto/quick/qquickloader/data/loadedSignal.2.qml new file mode 100644 index 0000000000..a4a663c71f --- /dev/null +++ b/tests/auto/quick/qquickloader/data/loadedSignal.2.qml @@ -0,0 +1,31 @@ +import QtQuick 2.0 + +Item { + id: root + + width: 200 + height: 200 + + property bool success: true + property int loadCount: 0 + + Loader { + id: loader + anchors.fill: parent + asynchronous: true + active: false + source: "TestComponent.qml" + onLoaded: { + if (status !== Loader.Ready) { + root.success = false; + } + root.loadCount++; + } + } + + function triggerLoading() { + // we set source to a valid path (but which is an invalid / erroneous component) + // we should not get onLoaded, since the status should not be Ready. + loader.source = "GreenRect.qml" // causes reference error. + } +} diff --git a/tests/auto/quick/qquickloader/data/loadedSignal.qml b/tests/auto/quick/qquickloader/data/loadedSignal.qml new file mode 100644 index 0000000000..7cc0fed001 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/loadedSignal.qml @@ -0,0 +1,48 @@ +import QtQuick 2.0 + +Item { + id: root + + width: 200 + height: 200 + + property bool success: true + property int loadCount: 0 + + Loader { + id: loader + anchors.fill: parent + asynchronous: true + active: false + source: "TestComponent.qml" + onLoaded: { + if (status !== Loader.Ready) { + root.success = false; + } + root.loadCount++; + } + } + + function triggerLoading() { + // we set active to true, which triggers loading. + // we then immediately set active to false. + // this should clear the incubator and stop loading. + loader.active = true; + loader.active = false; + } + + function activate() { + loader.active = true; + } + + function deactivate() { + loader.active = false; + } + + function triggerMultipleLoad() { + loader.active = false; // deactivate as a precondition. + loader.source = "BlueRect.qml" + loader.active = true; // should trigger loading to begin + loader.source = "RedRect.qml"; // should clear the incubator and restart loading + } +} diff --git a/tests/auto/quick/qquickloader/tst_qquickloader.cpp b/tests/auto/quick/qquickloader/tst_qquickloader.cpp index 01781f7b54..3bb06f737b 100644 --- a/tests/auto/quick/qquickloader/tst_qquickloader.cpp +++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp @@ -92,7 +92,7 @@ private slots: void noResize(); void networkRequestUrl(); void failNetworkRequest(); -// void networkComponent(); + void networkComponent(); void active(); void initialPropertyValues_data(); void initialPropertyValues(); @@ -111,6 +111,7 @@ private slots: void asynchronous(); void asynchronous_clear(); void simultaneousSyncAsync(); + void loadedSignal(); void parented(); void sizeBound(); @@ -442,21 +443,21 @@ void tst_QQuickLoader::networkRequestUrl() delete loader; } -/* XXX Component waits until all dependencies are loaded. Is this actually possible? +/* XXX Component waits until all dependencies are loaded. Is this actually possible? */ void tst_QQuickLoader::networkComponent() { TestHTTPServer server(SERVER_PORT); QVERIFY(server.isValid()); - server.serveDirectory("slowdata", TestHTTPServer::Delay); + server.serveDirectory(dataDirectory(), TestHTTPServer::Delay); QQmlComponent component(&engine); component.setData(QByteArray( "import QtQuick 2.0\n" "import \"http://127.0.0.1:14450/\" as NW\n" "Item {\n" - " Component { id: comp; NW.SlowRect {} }\n" + " Component { id: comp; NW.Rect120x60 {} }\n" " Loader { sourceComponent: comp } }") - , dataDirectoryUrl()); + , dataDirectory()); QQuickItem *item = qobject_cast<QQuickItem*>(component.create()); QVERIFY(item); @@ -472,7 +473,6 @@ void tst_QQuickLoader::networkComponent() delete loader; } -*/ void tst_QQuickLoader::failNetworkRequest() { @@ -842,6 +842,18 @@ void tst_QQuickLoader::implicitSize() QCOMPARE(item->property("implHeight").toReal(), 100.); QCOMPARE(item->property("implWidth").toReal(), 100.); + QQuickLoader *loader = item->findChild<QQuickLoader*>("loader"); + QSignalSpy implWidthSpy(loader, SIGNAL(implicitWidthChanged())); + QSignalSpy implHeightSpy(loader, SIGNAL(implicitHeightChanged())); + + QMetaObject::invokeMethod(item, "changeImplicitSize"); + + QCOMPARE(loader->property("implicitWidth").toReal(), 200.); + QCOMPARE(loader->property("implicitHeight").toReal(), 300.); + + QCOMPARE(implWidthSpy.count(), 1); + QCOMPARE(implHeightSpy.count(), 1); + delete item; } @@ -988,6 +1000,47 @@ void tst_QQuickLoader::simultaneousSyncAsync() delete root; } +void tst_QQuickLoader::loadedSignal() +{ + { + // ensure that triggering loading (by setting active = true) + // and then immediately setting active to false, causes the + // loader to be deactivated, including disabling the incubator. + QQmlComponent component(&engine, testFileUrl("loadedSignal.qml")); + QObject *obj = component.create(); + + QMetaObject::invokeMethod(obj, "triggerLoading"); + QTest::qWait(100); // ensure that loading would have finished if it wasn't deactivated + QCOMPARE(obj->property("loadCount").toInt(), 0); + QVERIFY(obj->property("success").toBool()); + + QMetaObject::invokeMethod(obj, "triggerLoading"); + QTest::qWait(100); + QCOMPARE(obj->property("loadCount").toInt(), 0); + QVERIFY(obj->property("success").toBool()); + + QMetaObject::invokeMethod(obj, "triggerMultipleLoad"); + QTest::qWait(100); + QCOMPARE(obj->property("loadCount").toInt(), 1); // only one loaded signal should be emitted. + QVERIFY(obj->property("success").toBool()); + + delete obj; + } + + { + // ensure that an error doesn't result in the onLoaded signal being emitted. + QQmlComponent component(&engine, testFileUrl("loadedSignal.2.qml")); + QObject *obj = component.create(); + + QMetaObject::invokeMethod(obj, "triggerLoading"); + QTest::qWait(100); + QCOMPARE(obj->property("loadCount").toInt(), 0); + QVERIFY(obj->property("success").toBool()); + + delete obj; + } +} + void tst_QQuickLoader::parented() { QQmlComponent component(&engine, testFileUrl("parented.qml")); diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp index a4b04bb88a..f072b005bc 100644 --- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp +++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp @@ -796,13 +796,11 @@ void tst_QQuickMouseArea::hoverVisible() mouseTracker->setVisible(true); - QTest::mouseMove(canvas,QPoint(10,31)); - QCOMPARE(mouseTracker->hovered(), true); QCOMPARE(enteredSpy.count(), 1); QEXPECT_FAIL("", "QTBUG-24282", Continue); - QCOMPARE(QPointF(mouseTracker->mouseX(), mouseTracker->mouseY()), QPointF(10,32)); + QCOMPARE(QPointF(mouseTracker->mouseX(), mouseTracker->mouseY()), QPointF(11,33)); delete canvas; } diff --git a/tests/auto/quick/qquickpathview/data/panels.qml b/tests/auto/quick/qquickpathview/data/panels.qml new file mode 100644 index 0000000000..a111e45736 --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/panels.qml @@ -0,0 +1,44 @@ +import QtQuick 2.0 + +Item { + id: root + property bool snapOne: false + property bool enforceRange: false + width: 320; height: 480 + + VisualItemModel { + id: itemModel + + Rectangle { + width: root.width + height: root.height + color: "blue" + } + Rectangle { + width: root.width + height: root.height + color: "yellow" + } + Rectangle { + width: root.width + height: root.height + color: "green" + } + } + + PathView { + id: view + objectName: "view" + anchors.fill: parent + model: itemModel + preferredHighlightBegin: 0.5 + preferredHighlightEnd: 0.5 + flickDeceleration: 30 + highlightRangeMode: enforceRange ? PathView.StrictlyEnforceRange : PathView.NoHighlightRange + snapMode: root.snapOne ? PathView.SnapOneItem : PathView.SnapToItem + path: Path { + startX: -root.width; startY: root.height/2 + PathLine { x: root.width*2; y: root.height/2 } + } + } +} diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp index 85d2c3b6ea..fbe96bf672 100644 --- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp +++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp @@ -125,6 +125,10 @@ private slots: void asynchronous(); void cancelDrag(); void maximumFlickVelocity(); + void snapToItem(); + void snapToItem_data(); + void snapOneItem(); + void snapOneItem_data(); }; class TestObject : public QObject @@ -1541,6 +1545,89 @@ void tst_QQuickPathView::maximumFlickVelocity() delete canvas; } +void tst_QQuickPathView::snapToItem() +{ + QFETCH(bool, enforceRange); + + QQuickView *canvas = createView(); + canvas->setSource(testFileUrl("panels.qml")); + QQuickPathView *pathview = canvas->rootObject()->findChild<QQuickPathView*>("view"); + QVERIFY(pathview != 0); + + canvas->rootObject()->setProperty("enforceRange", enforceRange); + QTRY_VERIFY(!pathview->isMoving()); // ensure stable + + int currentIndex = pathview->currentIndex(); + + QSignalSpy snapModeSpy(pathview, SIGNAL(snapModeChanged())); + + flick(canvas, QPoint(200,10), QPoint(10,10), 180); + + QVERIFY(pathview->isMoving()); + QTRY_VERIFY(!pathview->isMoving()); + + QVERIFY(pathview->offset() == qFloor(pathview->offset())); + + if (enforceRange) + QVERIFY(pathview->currentIndex() != currentIndex); + else + QVERIFY(pathview->currentIndex() == currentIndex); +} + +void tst_QQuickPathView::snapToItem_data() +{ + QTest::addColumn<bool>("enforceRange"); + + QTest::newRow("no enforce range") << false; + QTest::newRow("enforce range") << true; +} + +void tst_QQuickPathView::snapOneItem() +{ + QFETCH(bool, enforceRange); + + QQuickView *canvas = createView(); + canvas->setSource(testFileUrl("panels.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QTest::qWaitForWindowShown(canvas); + QTRY_COMPARE(canvas, qGuiApp->focusWindow()); + + QQuickPathView *pathview = canvas->rootObject()->findChild<QQuickPathView*>("view"); + QVERIFY(pathview != 0); + + canvas->rootObject()->setProperty("enforceRange", enforceRange); + + QSignalSpy snapModeSpy(pathview, SIGNAL(snapModeChanged())); + + canvas->rootObject()->setProperty("snapOne", true); + QVERIFY(snapModeSpy.count() == 1); + QTRY_VERIFY(!pathview->isMoving()); // ensure stable + + int currentIndex = pathview->currentIndex(); + + double startOffset = pathview->offset(); + flick(canvas, QPoint(200,10), QPoint(10,10), 180); + + QVERIFY(pathview->isMoving()); + QTRY_VERIFY(!pathview->isMoving()); + + // must have moved only one item + QCOMPARE(pathview->offset(), fmodf(3.0 + startOffset - 1.0, 3.0)); + + if (enforceRange) + QVERIFY(pathview->currentIndex() == currentIndex+1); + else + QVERIFY(pathview->currentIndex() == currentIndex); +} + +void tst_QQuickPathView::snapOneItem_data() +{ + QTest::addColumn<bool>("enforceRange"); + + QTest::newRow("no enforce range") << false; + QTest::newRow("enforce range") << true; +} QTEST_MAIN(tst_QQuickPathView) diff --git a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp index ab24fbe995..ae2bdc7fae 100644 --- a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp +++ b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp @@ -636,7 +636,7 @@ void tst_qquickpositioners::moveTransitions(const QString &positionerObjectName) QQuickView *canvas = QQuickViewTestUtil::createView(); QQmlContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("enableAddTransition", false); + ctxt->setContextProperty("enableAddTransition", QVariant(false)); ctxt->setContextProperty("model_targetItems_transitionFrom", &model_targetItems_transitionFrom); ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia); ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom); diff --git a/tests/auto/quick/qquickshadereffect/tst_qquickshadereffect.cpp b/tests/auto/quick/qquickshadereffect/tst_qquickshadereffect.cpp index 00ae8fc76d..1edf511ebf 100644 --- a/tests/auto/quick/qquickshadereffect/tst_qquickshadereffect.cpp +++ b/tests/auto/quick/qquickshadereffect/tst_qquickshadereffect.cpp @@ -257,13 +257,12 @@ void tst_qquickshadereffect::lookThroughShaderCode() if ((presenceFlags & TexCoordPresent) == 0) expected += "Warning: Missing reference to \'qt_MultiTexCoord0\'.\n"; if ((presenceFlags & MatrixPresent) == 0) - expected += "Warning: Missing reference to \'qt_Matrix\'.\n"; + expected += "Warning: Vertex shader is missing reference to \'qt_Matrix\'.\n"; if ((presenceFlags & OpacityPresent) == 0) - expected += "Warning: Missing reference to \'qt_Opacity\'.\n"; + expected += "Warning: Shaders are missing reference to \'qt_Opacity\'.\n"; item.setVertexShader(vertexShader); item.setFragmentShader(fragmentShader); - item.ensureCompleted(); QCOMPARE(item.parseLog(), expected); // If the uniform was successfully parsed, the notify signal has been connected to an update slot. diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index f4ba0864e5..724b24280a 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -1654,7 +1654,7 @@ void tst_qquicktext::implicitSizeBinding() QFETCH(QString, format); QString componentStr = "import QtQuick 2.0\nText { text: \"" + text + "\"; width: implicitWidth; height: implicitHeight; wrapMode: " + wrap + "; textFormat: " + format + " }"; - QDeclarativeComponent textComponent(&engine); + QQmlComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QScopedPointer<QObject> object(textComponent.create()); QQuickText *textObject = qobject_cast<QQuickText *>(object.data()); diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index ab21f3bc54..dd9aa0acad 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -1999,15 +1999,16 @@ void tst_qquicktextedit::cursorDelegate() void tst_qquicktextedit::cursorVisible() { + QQuickTextEdit edit; + edit.componentComplete(); + QSignalSpy spy(&edit, SIGNAL(cursorVisibleChanged(bool))); + QQuickView view(testFileUrl("cursorVisible.qml")); view.show(); view.requestActivateWindow(); QTest::qWaitForWindowShown(&view); QTRY_COMPARE(&view, qGuiApp->focusWindow()); - QQuickTextEdit edit; - QSignalSpy spy(&edit, SIGNAL(cursorVisibleChanged(bool))); - QCOMPARE(edit.isCursorVisible(), false); edit.setCursorVisible(true); @@ -2034,7 +2035,7 @@ void tst_qquicktextedit::cursorVisible() QCOMPARE(edit.isCursorVisible(), true); QCOMPARE(spy.count(), 5); - QQuickView alternateView; + QWindow alternateView; alternateView.show(); alternateView.requestActivateWindow(); QTest::qWaitForWindowShown(&alternateView); @@ -2046,6 +2047,47 @@ void tst_qquicktextedit::cursorVisible() QTest::qWaitForWindowShown(&view); QCOMPARE(edit.isCursorVisible(), true); QCOMPARE(spy.count(), 7); + + { // Cursor attribute with 0 length hides cursor. + QInputMethodEvent ev(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant())); + QCoreApplication::sendEvent(&edit, &ev); + } + QCOMPARE(edit.isCursorVisible(), false); + QCOMPARE(spy.count(), 8); + + { // Cursor attribute with non zero length shows cursor. + QInputMethodEvent ev(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 1, QVariant())); + QCoreApplication::sendEvent(&edit, &ev); + } + QCOMPARE(edit.isCursorVisible(), true); + QCOMPARE(spy.count(), 9); + + + { // If the cursor is hidden by the input method and the text is changed it should be visible again. + QInputMethodEvent ev(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant())); + QCoreApplication::sendEvent(&edit, &ev); + } + QCOMPARE(edit.isCursorVisible(), false); + QCOMPARE(spy.count(), 10); + + edit.setText("something"); + QCOMPARE(edit.isCursorVisible(), true); + QCOMPARE(spy.count(), 11); + + { // If the cursor is hidden by the input method and the cursor position is changed it should be visible again. + QInputMethodEvent ev(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant())); + QCoreApplication::sendEvent(&edit, &ev); + } + QCOMPARE(edit.isCursorVisible(), false); + QCOMPARE(spy.count(), 12); + + edit.setCursorPosition(5); + QCOMPARE(edit.isCursorVisible(), true); + QCOMPARE(spy.count(), 13); } void tst_qquicktextedit::delegateLoading_data() @@ -2568,7 +2610,7 @@ void tst_qquicktextedit::implicitSizeBinding() QFETCH(QString, wrap); QFETCH(QString, format); QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + text + "\"; width: implicitWidth; height: implicitHeight; wrapMode: " + wrap + "; textFormat: " + format + " }"; - QDeclarativeComponent textComponent(&engine); + QQmlComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QScopedPointer<QObject> object(textComponent.create()); QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit *>(object.data()); @@ -2682,6 +2724,74 @@ void tst_qquicktextedit::inputMethodComposing() } QCOMPARE(edit->isInputMethodComposing(), false); QCOMPARE(spy.count(), 2); + + // Changing the text while not composing doesn't alter the composing state. + edit->setText(text.mid(0, 16)); + QCOMPARE(edit->isInputMethodComposing(), false); + QCOMPARE(spy.count(), 2); + + { + QInputMethodEvent event(text.mid(16), QList<QInputMethodEvent::Attribute>()); + QGuiApplication::sendEvent(edit, &event); + } + QCOMPARE(edit->isInputMethodComposing(), true); + QCOMPARE(spy.count(), 3); + + // Changing the text while composing cancels composition. + edit->setText(text.mid(0, 12)); + QCOMPARE(edit->isInputMethodComposing(), false); + QCOMPARE(spy.count(), 4); + + { // Preedit cursor positioned outside (empty) preedit; composing. + QInputMethodEvent event(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, -2, 1, QVariant())); + QGuiApplication::sendEvent(edit, &event); + } + QCOMPARE(edit->isInputMethodComposing(), true); + QCOMPARE(spy.count(), 5); + + { // Cursor hidden; composing + QInputMethodEvent event(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant())); + QGuiApplication::sendEvent(edit, &event); + } + QCOMPARE(edit->isInputMethodComposing(), true); + QCOMPARE(spy.count(), 5); + + { // Default cursor attributes; composing. + QInputMethodEvent event(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 1, QVariant())); + QGuiApplication::sendEvent(edit, &event); + } + QCOMPARE(edit->isInputMethodComposing(), true); + QCOMPARE(spy.count(), 5); + + { // Selections are persisted: not composing + QInputMethodEvent event(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 2, 4, QVariant())); + QGuiApplication::sendEvent(edit, &event); + } + QCOMPARE(edit->isInputMethodComposing(), false); + QCOMPARE(spy.count(), 6); + + edit->setCursorPosition(0); + + { // Formatting applied; composing. + QTextCharFormat format; + format.setUnderlineStyle(QTextCharFormat::SingleUnderline); + QInputMethodEvent event(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, 2, 4, format)); + QGuiApplication::sendEvent(edit, &event); + } + QCOMPARE(edit->isInputMethodComposing(), true); + QCOMPARE(spy.count(), 7); + + { + QInputMethodEvent event; + QGuiApplication::sendEvent(edit, &event); + } + QCOMPARE(edit->isInputMethodComposing(), false); + QCOMPARE(spy.count(), 8); } void tst_qquicktextedit::cursorRectangleSize() diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp index 1c8bff9d69..4f2f3cbb62 100644 --- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp @@ -158,9 +158,7 @@ private slots: void focusOutClearSelection(); void echoMode(); -#ifdef QT_GUI_PASSWORD_ECHO_DELAY void passwordEchoDelay(); -#endif void geometrySignals(); void contentSize(); @@ -2368,16 +2366,16 @@ void tst_qquicktextinput::cursorDelegate() void tst_qquicktextinput::cursorVisible() { + QQuickTextInput input; + input.componentComplete(); + QSignalSpy spy(&input, SIGNAL(cursorVisibleChanged(bool))); + QQuickView view(testFileUrl("cursorVisible.qml")); view.show(); view.requestActivateWindow(); QTest::qWaitForWindowShown(&view); QTRY_COMPARE(&view, qGuiApp->focusWindow()); - QQuickTextInput input; - input.componentComplete(); - QSignalSpy spy(&input, SIGNAL(cursorVisibleChanged(bool))); - QCOMPARE(input.isCursorVisible(), false); input.setCursorVisible(true); @@ -2404,7 +2402,7 @@ void tst_qquicktextinput::cursorVisible() QCOMPARE(input.isCursorVisible(), true); QCOMPARE(spy.count(), 5); - QQuickView alternateView; + QWindow alternateView; alternateView.show(); alternateView.requestActivateWindow(); QTest::qWaitForWindowShown(&alternateView); @@ -2416,6 +2414,46 @@ void tst_qquicktextinput::cursorVisible() QTest::qWaitForWindowShown(&view); QCOMPARE(input.isCursorVisible(), true); QCOMPARE(spy.count(), 7); + + { // Cursor attribute with 0 length hides cursor. + QInputMethodEvent ev(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant())); + QCoreApplication::sendEvent(&input, &ev); + } + QCOMPARE(input.isCursorVisible(), false); + QCOMPARE(spy.count(), 8); + + { // Cursor attribute with non zero length shows cursor. + QInputMethodEvent ev(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 1, QVariant())); + QCoreApplication::sendEvent(&input, &ev); + } + QCOMPARE(input.isCursorVisible(), true); + QCOMPARE(spy.count(), 9); + + { // If the cursor is hidden by the input method and the text is changed it should be visible again. + QInputMethodEvent ev(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant())); + QCoreApplication::sendEvent(&input, &ev); + } + QCOMPARE(input.isCursorVisible(), false); + QCOMPARE(spy.count(), 10); + + input.setText("something"); + QCOMPARE(input.isCursorVisible(), true); + QCOMPARE(spy.count(), 11); + + { // If the cursor is hidden by the input method and the cursor position is changed it should be visible again. + QInputMethodEvent ev(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant())); + QCoreApplication::sendEvent(&input, &ev); + } + QCOMPARE(input.isCursorVisible(), false); + QCOMPARE(spy.count(), 12); + + input.setCursorPosition(5); + QCOMPARE(input.isCursorVisible(), true); + QCOMPARE(spy.count(), 13); } void tst_qquicktextinput::cursorRectangle_data() @@ -2716,9 +2754,11 @@ void tst_qquicktextinput::echoMode() QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), initial); } -#ifdef QT_GUI_PASSWORD_ECHO_DELAY void tst_qquicktextinput::passwordEchoDelay() { + int maskDelay = qGuiApp->styleHints()->passwordMaskDelay(); + if (maskDelay <= 0) + QSKIP("No mask delay in use"); QQuickView canvas(testFileUrl("echoMode.qml")); canvas.show(); canvas.requestActivateWindow(); @@ -2747,7 +2787,7 @@ void tst_qquicktextinput::passwordEchoDelay() QCOMPARE(input->displayText(), QString(4, fillChar)); QTest::keyPress(&canvas, '4'); QCOMPARE(input->displayText(), QString(4, fillChar) + QLatin1Char('4')); - QTest::qWait(QT_GUI_PASSWORD_ECHO_DELAY); + QTest::qWait(maskDelay); QTRY_COMPARE(input->displayText(), QString(5, fillChar)); QTest::keyPress(&canvas, '5'); QCOMPARE(input->displayText(), QString(5, fillChar) + QLatin1Char('5')); @@ -2772,7 +2812,6 @@ void tst_qquicktextinput::passwordEchoDelay() QTest::keyPress(&canvas, Qt::Key_Backspace); QCOMPARE(input->displayText(), QString(8, fillChar)); } -#endif void tst_qquicktextinput::simulateKey(QWindow *view, int key) @@ -3281,6 +3320,75 @@ void tst_qquicktextinput::inputMethodComposing() } QCOMPARE(input->isInputMethodComposing(), false); QCOMPARE(spy.count(), 2); + + // Changing the text while not composing doesn't alter the composing state. + input->setText(text.mid(0, 16)); + QCOMPARE(input->isInputMethodComposing(), false); + QCOMPARE(spy.count(), 2); + + { + QInputMethodEvent event(text.mid(16), QList<QInputMethodEvent::Attribute>()); + QGuiApplication::sendEvent(input, &event); + } + QCOMPARE(input->isInputMethodComposing(), true); + QCOMPARE(spy.count(), 3); + + // Changing the text while composing cancels composition. + input->setText(text.mid(0, 12)); + QCOMPARE(input->isInputMethodComposing(), false); + QCOMPARE(spy.count(), 4); + + { // Preedit cursor positioned outside (empty) preedit; composing. + QInputMethodEvent event(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, -2, 1, QVariant())); + QGuiApplication::sendEvent(input, &event); + } + QCOMPARE(input->isInputMethodComposing(), true); + QCOMPARE(spy.count(), 5); + + + { // Cursor hidden; composing + QInputMethodEvent event(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant())); + QGuiApplication::sendEvent(input, &event); + } + QCOMPARE(input->isInputMethodComposing(), true); + QCOMPARE(spy.count(), 5); + + { // Default cursor attributes; composing. + QInputMethodEvent event(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 1, QVariant())); + QGuiApplication::sendEvent(input, &event); + } + QCOMPARE(input->isInputMethodComposing(), true); + QCOMPARE(spy.count(), 5); + + { // Selections are persisted: not composing + QInputMethodEvent event(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, -5, 4, QVariant())); + QGuiApplication::sendEvent(input, &event); + } + QCOMPARE(input->isInputMethodComposing(), false); + QCOMPARE(spy.count(), 6); + + input->setCursorPosition(12); + + { // Formatting applied; composing. + QTextCharFormat format; + format.setUnderlineStyle(QTextCharFormat::SingleUnderline); + QInputMethodEvent event(QString(), QList<QInputMethodEvent::Attribute>() + << QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, -5, 4, format)); + QGuiApplication::sendEvent(input, &event); + } + QCOMPARE(input->isInputMethodComposing(), true); + QCOMPARE(spy.count(), 7); + + { + QInputMethodEvent event; + QGuiApplication::sendEvent(input, &event); + } + QCOMPARE(input->isInputMethodComposing(), false); + QCOMPARE(spy.count(), 8); } void tst_qquicktextinput::inputMethodUpdate() @@ -4949,7 +5057,7 @@ void tst_qquicktextinput::implicitSize() QFETCH(QString, text); QFETCH(QString, wrap); QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + text + "\"; width: 50; wrapMode: " + wrap + " }"; - QDeclarativeComponent textComponent(&engine); + QQmlComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QQuickTextInput *textObject = qobject_cast<QQuickTextInput*>(textComponent.create()); @@ -4971,7 +5079,7 @@ void tst_qquicktextinput::implicitSizeBinding() QFETCH(QString, text); QFETCH(QString, wrap); QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + text + "\"; width: implicitWidth; height: implicitHeight; wrapMode: " + wrap + " }"; - QDeclarativeComponent textComponent(&engine); + QQmlComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QScopedPointer<QObject> object(textComponent.create()); QQuickTextInput *textObject = qobject_cast<QQuickTextInput *>(object.data()); diff --git a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp index 73a35c1c78..78e9060acb 100644 --- a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp +++ b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp @@ -2707,9 +2707,6 @@ void tst_qquickvisualdatamodel::resolve_data() const QUrl stringListSource[] = { testFileUrl("stringlistproperties.qml"), testFileUrl("stringlistproperties-package.qml") }; - const QUrl objectListSource[] = { - testFileUrl("objectlistproperties.qml"), - testFileUrl("objectlistproperties-package.qml") }; for (int i = 0; i < 2; ++i) { // List Model. diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro index 654b1c86f0..b018fbf14a 100644 --- a/tests/auto/quick/quick.pro +++ b/tests/auto/quick/quick.pro @@ -1,12 +1,13 @@ TEMPLATE = subdirs PUBLICTESTS += \ - examples \ geometry \ nodes \ rendernode \ qquickpixmapcache +!cross_compile: PUBLICTESTS += examples + # This test requires the qtconcurrent module !contains(QT_CONFIG, concurrent):PUBLICTESTS -= qquickpixmapcache diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp index d00a0e2a96..1c4319f82f 100644 --- a/tests/auto/quick/shared/viewtestutil.cpp +++ b/tests/auto/quick/shared/viewtestutil.cpp @@ -88,12 +88,8 @@ void QQuickViewTestUtil::flick(QQuickView *canvas, const QPoint &from, const QPo // send press, five equally spaced moves, and release. QTest::mousePress(canvas, Qt::LeftButton, 0, from); - for (int i = 0; i < pointCount; ++i) { - QMouseEvent mv(QEvent::MouseMove, from + (i+1)*diff/pointCount, Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QGuiApplication::sendEvent(canvas, &mv); - QTest::qWait(duration/pointCount); - QCoreApplication::processEvents(); - } + for (int i = 0; i < pointCount; ++i) + QTest::mouseMove(canvas, from + (i+1)*diff/pointCount, duration / pointCount); QTest::mouseRelease(canvas, Qt::LeftButton, 0, to); QTest::qWait(50); |