aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qtquick1
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qtquick1')
-rw-r--r--tests/auto/qtquick1/examples/data/dummytest.qml6
-rw-r--r--tests/auto/qtquick1/examples/data/webbrowser/webbrowser.qml6
-rw-r--r--tests/auto/qtquick1/examples/examples.pro14
-rw-r--r--tests/auto/qtquick1/examples/tst_examples.cpp212
-rw-r--r--tests/auto/qtquick1/moduleqt47/data/importqt47.qml80
-rw-r--r--tests/auto/qtquick1/moduleqt47/moduleqt47.pro11
-rw-r--r--tests/auto/qtquick1/moduleqt47/tst_moduleqt47.cpp137
-rw-r--r--tests/auto/qtquick1/qdeclarativeanchors/data/anchors.qml162
-rw-r--r--tests/auto/qtquick1/qdeclarativeanchors/data/anchorsqgraphicswidget.qml162
-rw-r--r--tests/auto/qtquick1/qdeclarativeanchors/data/centerin.qml12
-rw-r--r--tests/auto/qtquick1/qdeclarativeanchors/data/crash1.qml11
-rw-r--r--tests/auto/qtquick1/qdeclarativeanchors/data/fill.qml14
-rw-r--r--tests/auto/qtquick1/qdeclarativeanchors/data/hvCenter.qml11
-rw-r--r--tests/auto/qtquick1/qdeclarativeanchors/data/loop1.qml8
-rw-r--r--tests/auto/qtquick1/qdeclarativeanchors/data/loop2.qml20
-rw-r--r--tests/auto/qtquick1/qdeclarativeanchors/data/margins.qml13
-rw-r--r--tests/auto/qtquick1/qdeclarativeanchors/qdeclarativeanchors.pro10
-rw-r--r--tests/auto/qtquick1/qdeclarativeanchors/tst_qdeclarativeanchors.cpp767
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimatedimage/data/colors.gifbin505 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimatedimage/data/colors.qml5
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimatedimage/data/hearts.gifbin6524 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimatedimage/data/hearts.qml6
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimatedimage/data/qmldir1
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimatedimage/data/qtbug-16520.qml17
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickman.gifbin164923 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickman.qml5
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanerror1.qml6
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanpause.qml7
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanscaled.qml7
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanstopped.qml6
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro11
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp381
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/Double.qml14
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/attached.qml34
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/badproperty1.qml21
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/badproperty2.qml21
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/badtype1.qml12
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/badtype2.qml12
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/badtype3.qml12
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/badtype4.qml27
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/dontAutoStart.qml18
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/dontStart.qml19
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/dontStart2.qml19
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/dotproperty.qml24
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/doubleRegistrationBug.qml8
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/mixedtype1.qml25
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/mixedtype2.qml25
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/nonTransitionBug.qml30
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/pauseBug.qml7
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/properties.qml14
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/properties2.qml14
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/properties3.qml14
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/properties4.qml14
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/properties5.qml14
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition.qml29
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition2.qml29
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition3.qml29
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition4.qml29
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition5.qml29
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition6.qml29
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition7.qml29
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/registrationBug.qml18
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/rotation.qml48
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/runningTrueBug.qml30
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/transitionAssignmentBug.qml12
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/valuesource.qml14
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/data/valuesource2.qml14
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/qdeclarativeanimations.pro8
-rw-r--r--tests/auto/qtquick1/qdeclarativeanimations/tst_qdeclarativeanimations.cpp877
-rw-r--r--tests/auto/qtquick1/qdeclarativeapplication/qdeclarativeapplication.pro6
-rw-r--r--tests/auto/qtquick1/qdeclarativeapplication/tst_qdeclarativeapplication.cpp122
-rw-r--r--tests/auto/qtquick1/qdeclarativebehaviors/data/binding.qml26
-rw-r--r--tests/auto/qtquick1/qdeclarativebehaviors/data/color.qml24
-rw-r--r--tests/auto/qtquick1/qdeclarativebehaviors/data/cpptrigger.qml11
-rw-r--r--tests/auto/qtquick1/qdeclarativebehaviors/data/delayedRegistration.qml25
-rw-r--r--tests/auto/qtquick1/qdeclarativebehaviors/data/disabled.qml27
-rw-r--r--tests/auto/qtquick1/qdeclarativebehaviors/data/dontStart.qml18
-rw-r--r--tests/auto/qtquick1/qdeclarativebehaviors/data/empty.qml23
-rw-r--r--tests/auto/qtquick1/qdeclarativebehaviors/data/explicit.qml26
-rw-r--r--tests/auto/qtquick1/qdeclarativebehaviors/data/groupProperty.qml23
-rw-r--r--tests/auto/qtquick1/qdeclarativebehaviors/data/groupProperty2.qml23
-rw-r--r--tests/auto/qtquick1/qdeclarativebehaviors/data/groupedPropertyCrash.qml10
-rw-r--r--tests/auto/qtquick1/qdeclarativebehaviors/data/loop.qml19
-rw-r--r--tests/auto/qtquick1/qdeclarativebehaviors/data/nonSelecting2.qml26
-rw-r--r--tests/auto/qtquick1/qdeclarativebehaviors/data/parent.qml28
-rw-r--r--tests/auto/qtquick1/qdeclarativebehaviors/data/qtbug12295.qml17
-rw-r--r--tests/auto/qtquick1/qdeclarativebehaviors/data/reassignedAnimation.qml32
-rw-r--r--tests/auto/qtquick1/qdeclarativebehaviors/data/runningTrue.qml20
-rw-r--r--tests/auto/qtquick1/qdeclarativebehaviors/data/scripttrigger.qml16
-rw-r--r--tests/auto/qtquick1/qdeclarativebehaviors/data/simple.qml26
-rw-r--r--tests/auto/qtquick1/qdeclarativebehaviors/data/startup.qml17
-rw-r--r--tests/auto/qtquick1/qdeclarativebehaviors/data/startup2.qml16
-rw-r--r--tests/auto/qtquick1/qdeclarativebehaviors/qdeclarativebehaviors.pro10
-rw-r--r--tests/auto/qtquick1/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp429
-rw-r--r--tests/auto/qtquick1/qdeclarativebinding/data/deletedObject.qml24
-rw-r--r--tests/auto/qtquick1/qdeclarativebinding/data/test-binding.qml16
-rw-r--r--tests/auto/qtquick1/qdeclarativebinding/data/test-binding2.qml16
-rw-r--r--tests/auto/qtquick1/qdeclarativebinding/qdeclarativebinding.pro11
-rw-r--r--tests/auto/qtquick1/qdeclarativebinding/tst_qdeclarativebinding.cpp128
-rw-r--r--tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round-quotes.sci7
-rw-r--r--tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round-remote.sci7
-rw-r--r--tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round.sci7
-rw-r--r--tests/auto/qtquick1/qdeclarativeborderimage/data/colors.pngbin1655 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativeborderimage/data/heart200.pngbin7943 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativeborderimage/data/invalid.sci7
-rw-r--r--tests/auto/qtquick1/qdeclarativeborderimage/qdeclarativeborderimage.pro12
-rw-r--r--tests/auto/qtquick1/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp423
-rw-r--r--tests/auto/qtquick1/qdeclarativeconnection/data/connection-targetchange.qml25
-rw-r--r--tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-ignored.qml8
-rw-r--r--tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-notarget.qml7
-rw-r--r--tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-parent.qml7
-rw-r--r--tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals.qml7
-rw-r--r--tests/auto/qtquick1/qdeclarativeconnection/data/error-object.qml7
-rw-r--r--tests/auto/qtquick1/qdeclarativeconnection/data/error-property.qml5
-rw-r--r--tests/auto/qtquick1/qdeclarativeconnection/data/error-property2.qml5
-rw-r--r--tests/auto/qtquick1/qdeclarativeconnection/data/error-syntax.qml9
-rw-r--r--tests/auto/qtquick1/qdeclarativeconnection/data/test-connection.qml10
-rw-r--r--tests/auto/qtquick1/qdeclarativeconnection/data/test-connection2.qml3
-rw-r--r--tests/auto/qtquick1/qdeclarativeconnection/data/test-connection3.qml3
-rw-r--r--tests/auto/qtquick1/qdeclarativeconnection/data/trimming.qml10
-rw-r--r--tests/auto/qtquick1/qdeclarativeconnection/qdeclarativeconnection.pro11
-rw-r--r--tests/auto/qtquick1/qdeclarativeconnection/tst_qdeclarativeconnection.cpp227
-rw-r--r--tests/auto/qtquick1/qdeclarativeflickable/data/disabled.qml30
-rw-r--r--tests/auto/qtquick1/qdeclarativeflickable/data/disabledcontent.qml8
-rw-r--r--tests/auto/qtquick1/qdeclarativeflickable/data/flickable01.qml4
-rw-r--r--tests/auto/qtquick1/qdeclarativeflickable/data/flickable02.qml14
-rw-r--r--tests/auto/qtquick1/qdeclarativeflickable/data/flickable03.qml14
-rw-r--r--tests/auto/qtquick1/qdeclarativeflickable/data/flickable04.qml22
-rw-r--r--tests/auto/qtquick1/qdeclarativeflickable/data/flickableqgraphicswidget.qml7
-rw-r--r--tests/auto/qtquick1/qdeclarativeflickable/data/nestedPressDelay.qml33
-rw-r--r--tests/auto/qtquick1/qdeclarativeflickable/data/resize.qml27
-rw-r--r--tests/auto/qtquick1/qdeclarativeflickable/data/wheel.qml21
-rw-r--r--tests/auto/qtquick1/qdeclarativeflickable/qdeclarativeflickable.pro11
-rw-r--r--tests/auto/qtquick1/qdeclarativeflickable/tst_qdeclarativeflickable.cpp583
-rw-r--r--tests/auto/qtquick1/qdeclarativeflipable/data/crash.qml9
-rw-r--r--tests/auto/qtquick1/qdeclarativeflipable/data/flipable-abort.qml10
-rw-r--r--tests/auto/qtquick1/qdeclarativeflipable/data/test-flipable.qml9
-rw-r--r--tests/auto/qtquick1/qdeclarativeflipable/qdeclarativeflipable.pro12
-rw-r--r--tests/auto/qtquick1/qdeclarativeflipable/tst_qdeclarativeflipable.cpp138
-rw-r--r--tests/auto/qtquick1/qdeclarativefocusscope/data/chain.qml28
-rw-r--r--tests/auto/qtquick1/qdeclarativefocusscope/data/forceActiveFocus.qml26
-rw-r--r--tests/auto/qtquick1/qdeclarativefocusscope/data/forcefocus.qml81
-rw-r--r--tests/auto/qtquick1/qdeclarativefocusscope/data/qtBug13380.qml24
-rw-r--r--tests/auto/qtquick1/qdeclarativefocusscope/data/signalEmission.qml33
-rw-r--r--tests/auto/qtquick1/qdeclarativefocusscope/data/test.qml77
-rw-r--r--tests/auto/qtquick1/qdeclarativefocusscope/data/test2.qml39
-rw-r--r--tests/auto/qtquick1/qdeclarativefocusscope/data/test3.qml52
-rw-r--r--tests/auto/qtquick1/qdeclarativefocusscope/data/test4.qml76
-rw-r--r--tests/auto/qtquick1/qdeclarativefocusscope/data/test5.qml84
-rw-r--r--tests/auto/qtquick1/qdeclarativefocusscope/qdeclarativefocusscope.pro9
-rw-r--r--tests/auto/qtquick1/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp513
-rw-r--r--tests/auto/qtquick1/qdeclarativefontloader/data/daniel.ttfbin51984 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativefontloader/data/dummy.ttf0
-rw-r--r--tests/auto/qtquick1/qdeclarativefontloader/data/tarzeau_ocr_a.ttfbin24544 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativefontloader/qdeclarativefontloader.pro12
-rw-r--r--tests/auto/qtquick1/qdeclarativefontloader/tst_qdeclarativefontloader.cpp224
-rw-r--r--tests/auto/qtquick1/qdeclarativegridview/data/attachedSignals.qml27
-rw-r--r--tests/auto/qtquick1/qdeclarativegridview/data/displaygrid.qml39
-rw-r--r--tests/auto/qtquick1/qdeclarativegridview/data/footer.qml40
-rw-r--r--tests/auto/qtquick1/qdeclarativegridview/data/gridview-enforcerange.qml58
-rw-r--r--tests/auto/qtquick1/qdeclarativegridview/data/gridview-initCurrent.qml52
-rw-r--r--tests/auto/qtquick1/qdeclarativegridview/data/gridview-noCurrent.qml52
-rw-r--r--tests/auto/qtquick1/qdeclarativegridview/data/gridview1.qml66
-rw-r--r--tests/auto/qtquick1/qdeclarativegridview/data/gridview2.qml26
-rw-r--r--tests/auto/qtquick1/qdeclarativegridview/data/gridview3.qml6
-rw-r--r--tests/auto/qtquick1/qdeclarativegridview/data/header.qml40
-rw-r--r--tests/auto/qtquick1/qdeclarativegridview/data/manual-highlight.qml48
-rw-r--r--tests/auto/qtquick1/qdeclarativegridview/data/mirroring.qml43
-rw-r--r--tests/auto/qtquick1/qdeclarativegridview/data/propertychangestest.qml69
-rw-r--r--tests/auto/qtquick1/qdeclarativegridview/data/setindex.qml29
-rw-r--r--tests/auto/qtquick1/qdeclarativegridview/qdeclarativegridview.pro11
-rw-r--r--tests/auto/qtquick1/qdeclarativegridview/tst_qdeclarativegridview.cpp2217
-rw-r--r--tests/auto/qtquick1/qdeclarativeimage/data/aspectratio.qml10
-rw-r--r--tests/auto/qtquick1/qdeclarativeimage/data/big.jpegbin1700081 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativeimage/data/big256.pngbin3566 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativeimage/data/colors.pngbin1655 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativeimage/data/colors1.pngbin1655 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativeimage/data/green.pngbin314 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativeimage/data/heart-win32.pngbin12621 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativeimage/data/heart.pngbin12577 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativeimage/data/heart.svg55
-rw-r--r--tests/auto/qtquick1/qdeclarativeimage/data/heart200-win32.pngbin8062 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativeimage/data/heart200.pngbin8063 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativeimage/data/qtbug_16389.qml30
-rw-r--r--tests/auto/qtquick1/qdeclarativeimage/data/rect.pngbin171 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativeimage/data/tiling.qml16
-rw-r--r--tests/auto/qtquick1/qdeclarativeimage/qdeclarativeimage.pro12
-rw-r--r--tests/auto/qtquick1/qdeclarativeimage/tst_qdeclarativeimage.cpp801
-rw-r--r--tests/auto/qtquick1/qdeclarativeimageprovider/qdeclarativeimageprovider.pro14
-rw-r--r--tests/auto/qtquick1/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp426
-rw-r--r--tests/auto/qtquick1/qdeclarativeitem/data/childrenProperty.qml14
-rw-r--r--tests/auto/qtquick1/qdeclarativeitem/data/childrenRect.qml27
-rw-r--r--tests/auto/qtquick1/qdeclarativeitem/data/childrenRectBug.qml23
-rw-r--r--tests/auto/qtquick1/qdeclarativeitem/data/childrenRectBug2.qml53
-rw-r--r--tests/auto/qtquick1/qdeclarativeitem/data/childrenRectBug3.qml15
-rw-r--r--tests/auto/qtquick1/qdeclarativeitem/data/implicitsize.qml19
-rw-r--r--tests/auto/qtquick1/qdeclarativeitem/data/keynavigationtest.qml87
-rw-r--r--tests/auto/qtquick1/qdeclarativeitem/data/keynavigationtest_implicit.qml68
-rw-r--r--tests/auto/qtquick1/qdeclarativeitem/data/keyspriority.qml9
-rw-r--r--tests/auto/qtquick1/qdeclarativeitem/data/keystest.qml24
-rw-r--r--tests/auto/qtquick1/qdeclarativeitem/data/layoutmirroring.qml54
-rw-r--r--tests/auto/qtquick1/qdeclarativeitem/data/mapCoordinates.qml43
-rw-r--r--tests/auto/qtquick1/qdeclarativeitem/data/mouseFocus.qml20
-rw-r--r--tests/auto/qtquick1/qdeclarativeitem/data/propertychanges.qml10
-rw-r--r--tests/auto/qtquick1/qdeclarativeitem/data/qtbug_16871.qml5
-rw-r--r--tests/auto/qtquick1/qdeclarativeitem/data/resourcesProperty.qml21
-rw-r--r--tests/auto/qtquick1/qdeclarativeitem/data/transformCrash.qml13
-rw-r--r--tests/auto/qtquick1/qdeclarativeitem/qdeclarativeitem.pro12
-rw-r--r--tests/auto/qtquick1/qdeclarativeitem/tst_qdeclarativeitem.cpp1376
-rw-r--r--tests/auto/qtquick1/qdeclarativelayoutitem/data/layoutItem.qml9
-rw-r--r--tests/auto/qtquick1/qdeclarativelayoutitem/qdeclarativelayoutitem.pro9
-rw-r--r--tests/auto/qtquick1/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp119
-rw-r--r--tests/auto/qtquick1/qdeclarativelistmodel/data/enumerate.qml24
-rw-r--r--tests/auto/qtquick1/qdeclarativelistmodel/data/model.qml22
-rw-r--r--tests/auto/qtquick1/qdeclarativelistmodel/data/multipleroles.qml25
-rw-r--r--tests/auto/qtquick1/qdeclarativelistmodel/data/script.js13
-rw-r--r--tests/auto/qtquick1/qdeclarativelistmodel/data/setmodelcachelist.qml20
-rw-r--r--tests/auto/qtquick1/qdeclarativelistmodel/qdeclarativelistmodel.pro11
-rw-r--r--tests/auto/qtquick1/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp1118
-rw-r--r--tests/auto/qtquick1/qdeclarativelistview/data/attachedSignals.qml24
-rw-r--r--tests/auto/qtquick1/qdeclarativelistview/data/displaylist.qml50
-rw-r--r--tests/auto/qtquick1/qdeclarativelistview/data/footer.qml38
-rw-r--r--tests/auto/qtquick1/qdeclarativelistview/data/header.qml38
-rw-r--r--tests/auto/qtquick1/qdeclarativelistview/data/header1.qml33
-rw-r--r--tests/auto/qtquick1/qdeclarativelistview/data/headerfooter.qml26
-rw-r--r--tests/auto/qtquick1/qdeclarativelistview/data/itemlist.qml43
-rw-r--r--tests/auto/qtquick1/qdeclarativelistview/data/listview-enforcerange.qml55
-rw-r--r--tests/auto/qtquick1/qdeclarativelistview/data/listview-initCurrent.qml51
-rw-r--r--tests/auto/qtquick1/qdeclarativelistview/data/listview-noCurrent.qml50
-rw-r--r--tests/auto/qtquick1/qdeclarativelistview/data/listview-sections.qml64
-rw-r--r--tests/auto/qtquick1/qdeclarativelistview/data/listview-sections_delegate.qml69
-rw-r--r--tests/auto/qtquick1/qdeclarativelistview/data/listviewtest.qml133
-rw-r--r--tests/auto/qtquick1/qdeclarativelistview/data/manual-highlight.qml47
-rw-r--r--tests/auto/qtquick1/qdeclarativelistview/data/orientchange.qml7
-rw-r--r--tests/auto/qtquick1/qdeclarativelistview/data/propertychangestest.qml71
-rw-r--r--tests/auto/qtquick1/qdeclarativelistview/data/qtbug14821.qml31
-rw-r--r--tests/auto/qtquick1/qdeclarativelistview/data/qtbug16037.qml37
-rw-r--r--tests/auto/qtquick1/qdeclarativelistview/data/rightToLeft.qml42
-rw-r--r--tests/auto/qtquick1/qdeclarativelistview/data/sizelessthan1.qml26
-rw-r--r--tests/auto/qtquick1/qdeclarativelistview/data/strictlyenforcerange.qml29
-rw-r--r--tests/auto/qtquick1/qdeclarativelistview/incrementalmodel.cpp89
-rw-r--r--tests/auto/qtquick1/qdeclarativelistview/incrementalmodel.h68
-rw-r--r--tests/auto/qtquick1/qdeclarativelistview/qdeclarativelistview.pro11
-rw-r--r--tests/auto/qtquick1/qdeclarativelistview/tst_qdeclarativelistview.cpp2892
-rw-r--r--tests/auto/qtquick1/qdeclarativeloader/data/AnchoredLoader.qml14
-rw-r--r--tests/auto/qtquick1/qdeclarativeloader/data/BlueRect.qml8
-rw-r--r--tests/auto/qtquick1/qdeclarativeloader/data/CreationContextLoader.qml15
-rw-r--r--tests/auto/qtquick1/qdeclarativeloader/data/GraphicsWidget250x250.qml5
-rw-r--r--tests/auto/qtquick1/qdeclarativeloader/data/GreenRect.qml7
-rw-r--r--tests/auto/qtquick1/qdeclarativeloader/data/NoResize.qml8
-rw-r--r--tests/auto/qtquick1/qdeclarativeloader/data/NoResizeGraphicsWidget.qml9
-rw-r--r--tests/auto/qtquick1/qdeclarativeloader/data/QTBUG_16928.qml23
-rw-r--r--tests/auto/qtquick1/qdeclarativeloader/data/QTBUG_17114.qml18
-rw-r--r--tests/auto/qtquick1/qdeclarativeloader/data/Rect120x60.qml6
-rw-r--r--tests/auto/qtquick1/qdeclarativeloader/data/SetSourceComponent.qml9
-rw-r--r--tests/auto/qtquick1/qdeclarativeloader/data/SizeGraphicsWidgetToLoader.qml7
-rw-r--r--tests/auto/qtquick1/qdeclarativeloader/data/SizeLoaderToGraphicsWidget.qml5
-rw-r--r--tests/auto/qtquick1/qdeclarativeloader/data/SizeToItem.qml5
-rw-r--r--tests/auto/qtquick1/qdeclarativeloader/data/SizeToLoader.qml6
-rw-r--r--tests/auto/qtquick1/qdeclarativeloader/data/VmeError.qml7
-rw-r--r--tests/auto/qtquick1/qdeclarativeloader/data/crash.qml14
-rw-r--r--tests/auto/qtquick1/qdeclarativeloader/data/creationContext.qml8
-rw-r--r--tests/auto/qtquick1/qdeclarativeloader/data/differentorigin.qml3
-rw-r--r--tests/auto/qtquick1/qdeclarativeloader/data/implicitSize.qml28
-rw-r--r--tests/auto/qtquick1/qdeclarativeloader/data/nonItem.qml5
-rw-r--r--tests/auto/qtquick1/qdeclarativeloader/data/qmldir1
-rw-r--r--tests/auto/qtquick1/qdeclarativeloader/data/sameorigin-load.qml3
-rw-r--r--tests/auto/qtquick1/qdeclarativeloader/data/sameorigin.qml3
-rw-r--r--tests/auto/qtquick1/qdeclarativeloader/data/vmeErrors.qml6
-rw-r--r--tests/auto/qtquick1/qdeclarativeloader/qdeclarativeloader.pro14
-rw-r--r--tests/auto/qtquick1/qdeclarativeloader/tst_qdeclarativeloader.cpp631
-rw-r--r--tests/auto/qtquick1/qdeclarativemousearea/data/clickandhold.qml13
-rw-r--r--tests/auto/qtquick1/qdeclarativemousearea/data/clicktwice.qml16
-rw-r--r--tests/auto/qtquick1/qdeclarativemousearea/data/doubleclick.qml16
-rw-r--r--tests/auto/qtquick1/qdeclarativemousearea/data/dragging.qml28
-rw-r--r--tests/auto/qtquick1/qdeclarativemousearea/data/dragproperties.qml28
-rw-r--r--tests/auto/qtquick1/qdeclarativemousearea/data/dragreset.qml28
-rw-r--r--tests/auto/qtquick1/qdeclarativemousearea/data/pressedOrdering.qml28
-rw-r--r--tests/auto/qtquick1/qdeclarativemousearea/data/preventContextMenu.qml22
-rw-r--r--tests/auto/qtquick1/qdeclarativemousearea/data/preventstealing.qml24
-rw-r--r--tests/auto/qtquick1/qdeclarativemousearea/data/rejectEvent.qml28
-rw-r--r--tests/auto/qtquick1/qdeclarativemousearea/data/updateMousePosOnClick.qml20
-rw-r--r--tests/auto/qtquick1/qdeclarativemousearea/data/updateMousePosOnResize.qml38
-rw-r--r--tests/auto/qtquick1/qdeclarativemousearea/qdeclarativemousearea.pro12
-rw-r--r--tests/auto/qtquick1/qdeclarativemousearea/tst_qdeclarativemousearea.cpp700
-rw-r--r--tests/auto/qtquick1/qdeclarativeparticles/data/particle.pngbin262 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativeparticles/data/particlemotiontest.qml35
-rw-r--r--tests/auto/qtquick1/qdeclarativeparticles/data/particlestest.qml17
-rw-r--r--tests/auto/qtquick1/qdeclarativeparticles/qdeclarativeparticles.pro11
-rw-r--r--tests/auto/qtquick1/qdeclarativeparticles/tst_qdeclarativeparticles.cpp222
-rw-r--r--tests/auto/qtquick1/qdeclarativepathview/data/closedPath.qml24
-rw-r--r--tests/auto/qtquick1/qdeclarativepathview/data/datamodel.qml38
-rw-r--r--tests/auto/qtquick1/qdeclarativepathview/data/displaypath.qml59
-rw-r--r--tests/auto/qtquick1/qdeclarativepathview/data/dragpath.qml19
-rw-r--r--tests/auto/qtquick1/qdeclarativepathview/data/emptymodel.qml5
-rw-r--r--tests/auto/qtquick1/qdeclarativepathview/data/openPath.qml10
-rw-r--r--tests/auto/qtquick1/qdeclarativepathview/data/pathUpdate.qml18
-rw-r--r--tests/auto/qtquick1/qdeclarativepathview/data/pathUpdateOnStartChanged.qml38
-rw-r--r--tests/auto/qtquick1/qdeclarativepathview/data/pathtest.qml14
-rw-r--r--tests/auto/qtquick1/qdeclarativepathview/data/pathview0.qml84
-rw-r--r--tests/auto/qtquick1/qdeclarativepathview/data/pathview1.qml4
-rw-r--r--tests/auto/qtquick1/qdeclarativepathview/data/pathview2.qml57
-rw-r--r--tests/auto/qtquick1/qdeclarativepathview/data/pathview3.qml59
-rw-r--r--tests/auto/qtquick1/qdeclarativepathview/data/pathview_package.qml88
-rw-r--r--tests/auto/qtquick1/qdeclarativepathview/data/propertychanges.qml116
-rw-r--r--tests/auto/qtquick1/qdeclarativepathview/data/treemodel.qml19
-rw-r--r--tests/auto/qtquick1/qdeclarativepathview/data/undefinedpath.qml17
-rw-r--r--tests/auto/qtquick1/qdeclarativepathview/data/vdm.qml28
-rw-r--r--tests/auto/qtquick1/qdeclarativepathview/qdeclarativepathview.pro11
-rw-r--r--tests/auto/qtquick1/qdeclarativepathview/tst_qdeclarativepathview.cpp1061
-rw-r--r--tests/auto/qtquick1/qdeclarativepincharea/data/flickresize.qml50
-rw-r--r--tests/auto/qtquick1/qdeclarativepincharea/data/pinchproperties.qml46
-rw-r--r--tests/auto/qtquick1/qdeclarativepincharea/qdeclarativepincharea.pro11
-rw-r--r--tests/auto/qtquick1/qdeclarativepincharea/tst_qdeclarativepincharea.cpp393
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/flow-testimplicitsize.qml19
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/flowtest-toptobottom.qml44
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/flowtest.qml43
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/grid-animated.qml64
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/grid-spacing.qml41
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/grid-toptobottom.qml41
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/gridtest.qml42
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/gridzerocolumns.qml40
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/horizontal-animated.qml44
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/horizontal-spacing.qml31
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/horizontal.qml29
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/propertychangestest.qml39
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/repeatertest.qml38
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/vertical-animated.qml41
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/vertical-spacing.qml28
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/vertical.qml27
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/data/verticalqgraphicswidget.qml24
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/qdeclarativepositioners.pro10
-rw-r--r--tests/auto/qtquick1/qdeclarativepositioners/tst_qdeclarativepositioners.cpp1349
-rw-r--r--tests/auto/qtquick1/qdeclarativerepeater/data/intmodel.qml29
-rw-r--r--tests/auto/qtquick1/qdeclarativerepeater/data/itemlist.qml68
-rw-r--r--tests/auto/qtquick1/qdeclarativerepeater/data/modelChanged.qml26
-rw-r--r--tests/auto/qtquick1/qdeclarativerepeater/data/objlist.qml21
-rw-r--r--tests/auto/qtquick1/qdeclarativerepeater/data/properties.qml11
-rw-r--r--tests/auto/qtquick1/qdeclarativerepeater/data/repeater1.qml28
-rw-r--r--tests/auto/qtquick1/qdeclarativerepeater/data/repeater2.qml36
-rw-r--r--tests/auto/qtquick1/qdeclarativerepeater/qdeclarativerepeater.pro10
-rw-r--r--tests/auto/qtquick1/qdeclarativerepeater/tst_qdeclarativerepeater.cpp730
-rw-r--r--tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation1.qml3
-rw-r--r--tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation2.qml5
-rw-r--r--tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation3.qml6
-rw-r--r--tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimationBehavior.qml24
-rw-r--r--tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimationValueSource.qml13
-rw-r--r--tests/auto/qtquick1/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro11
-rw-r--r--tests/auto/qtquick1/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp210
-rw-r--r--tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation1.qml4
-rw-r--r--tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation2.qml9
-rw-r--r--tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation3.qml8
-rw-r--r--tests/auto/qtquick1/qdeclarativespringanimation/qdeclarativespringanimation.pro11
-rw-r--r--tests/auto/qtquick1/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp130
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/ExtendedRectangle.qml19
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/Implementation/MyType.qml32
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/Implementation/images/qt-logo.pngbin5149 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/QTBUG-14830.qml29
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/anchorChanges1.qml23
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/anchorChanges2.qml21
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/anchorChanges3.qml29
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/anchorChanges4.qml22
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/anchorChanges5.qml22
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/anchorChangesCrash.qml14
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/anchorRewindBug.qml37
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/anchorRewindBug2.qml25
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/attachedPropertyChanges.qml20
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml18
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/basicBinding.qml12
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/basicBinding2.qml12
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/basicBinding3.qml13
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/basicBinding4.qml17
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/basicChanges.qml10
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/basicChanges2.qml15
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/basicChanges3.qml15
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/basicChanges4.qml19
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/basicExtension.qml16
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/deleting.qml11
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/deletingState.qml13
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/editProperties.qml34
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/explicit.qml15
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/extendsBug.qml26
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/fakeExtension.qml16
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/illegalObj.qml12
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/illegalTempState.qml21
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/image.pngbin173 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/legalTempState.qml23
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/nonExistantProp.qml11
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/parentChange1.qml37
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/parentChange2.qml31
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/parentChange3.qml42
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/parentChange4.qml30
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/parentChange5.qml30
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/parentChange6.qml30
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/propertyErrors.qml10
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/reset.qml19
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/restoreEntryValues.qml14
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/returnToBase.qml21
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/script.qml10
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/signalOverride.qml18
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/signalOverride2.qml9
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/signalOverrideCrash.qml15
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/signalOverrideCrash2.qml24
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/signalOverrideCrash3.qml27
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/unnamedWhen.qml14
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/urlResolution.qml12
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/data/whenOrdering.qml11
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/qdeclarativestates.pro10
-rw-r--r--tests/auto/qtquick1/qdeclarativestates/tst_qdeclarativestates.cpp1526
-rw-r--r--tests/auto/qtquick1/qdeclarativesystempalette/qdeclarativesystempalette.pro11
-rw-r--r--tests/auto/qtquick1/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp185
-rw-r--r--tests/auto/qtquick1/qdeclarativetext/data/alignments.qml41
-rw-r--r--tests/auto/qtquick1/qdeclarativetext/data/alignments_cb.pngbin496 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativetext/data/alignments_cc.pngbin556 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativetext/data/alignments_ct.pngbin533 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativetext/data/alignments_lb.pngbin496 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativetext/data/alignments_lc.pngbin535 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativetext/data/alignments_lt.pngbin514 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativetext/data/alignments_rb.pngbin505 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativetext/data/alignments_rc.pngbin559 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativetext/data/alignments_rt.pngbin539 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativetext/data/elideimplicitwidth.qml7
-rw-r--r--tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesLocal.qml5
-rw-r--r--tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesLocalError.qml5
-rw-r--r--tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesRemote.qml5
-rw-r--r--tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesRemoteError.qml5
-rw-r--r--tests/auto/qtquick1/qdeclarativetext/data/horizontalAlignment_RightToLeft.qml23
-rw-r--r--tests/auto/qtquick1/qdeclarativetext/data/http/exists.pngbin2738 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativetext/data/lineCount.qml15
-rw-r--r--tests/auto/qtquick1/qdeclarativetext/data/lineHeight.qml15
-rw-r--r--tests/auto/qtquick1/qdeclarativetext/data/qtbug_14734.qml10
-rw-r--r--tests/auto/qtquick1/qdeclarativetext/data/rotated.qml18
-rw-r--r--tests/auto/qtquick1/qdeclarativetext/qdeclarativetext.pro15
-rw-r--r--tests/auto/qtquick1/qdeclarativetext/tst_qdeclarativetext.cpp1444
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/CursorRect.qml8
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/alignments.qml41
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/alignments_cb.pngbin496 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/alignments_cc.pngbin556 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/alignments_ct.pngbin533 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/alignments_lb.pngbin496 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/alignments_lc.pngbin535 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/alignments_lt.pngbin514 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/alignments_rb.pngbin505 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/alignments_rc.pngbin559 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/alignments_rt.pngbin539 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/cursorTest.qml9
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/geometrySignals.qml12
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/horizontalAlignment_RightToLeft.qml24
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/http/ErrItem.qml7
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/http/NormItem.qml6
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTest.qml22
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTestFail1.qml18
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTestFail2.qml18
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTestPass.qml18
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/http/qmldir4
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/httpfail/FailItem.qml5
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/httpslow/WaitItem.qml5
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/inputmethodhints.qml6
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_default.qml7
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_false.qml7
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_false_readonly.qml8
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_false_words.qml8
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_multiline.qml8
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_true.qml7
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_true_readonly.qml8
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_true_words.qml8
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/mouseselectionmode_characters.qml8
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/mouseselectionmode_default.qml7
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/mouseselectionmode_words.qml8
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/navigation.qml24
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/positionAt.qml9
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/data/readOnly.qml12
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/qdeclarativetextedit.pro10
-rw-r--r--tests/auto/qtquick1/qdeclarativetextedit/tst_qdeclarativetextedit.cpp2549
-rw-r--r--tests/auto/qtquick1/qdeclarativetextinput/data/cursorTest.qml8
-rw-r--r--tests/auto/qtquick1/qdeclarativetextinput/data/echoMode.qml11
-rw-r--r--tests/auto/qtquick1/qdeclarativetextinput/data/geometrySignals.qml12
-rw-r--r--tests/auto/qtquick1/qdeclarativetextinput/data/halign_center.pngbin293 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativetextinput/data/halign_left.pngbin291 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativetextinput/data/halign_right.pngbin292 -> 0 bytes
-rw-r--r--tests/auto/qtquick1/qdeclarativetextinput/data/horizontalAlignment.qml22
-rw-r--r--tests/auto/qtquick1/qdeclarativetextinput/data/horizontalAlignment_RightToLeft.qml24
-rw-r--r--tests/auto/qtquick1/qdeclarativetextinput/data/inputmethods.qml7
-rw-r--r--tests/auto/qtquick1/qdeclarativetextinput/data/masks.qml7
-rw-r--r--tests/auto/qtquick1/qdeclarativetextinput/data/maxLength.qml7
-rw-r--r--tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_default.qml7
-rw-r--r--tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_false.qml7
-rw-r--r--tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_false_readonly.qml8
-rw-r--r--tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_false_words.qml7
-rw-r--r--tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_true.qml7
-rw-r--r--tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_true_readonly.qml8
-rw-r--r--tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_true_words.qml7
-rw-r--r--tests/auto/qtquick1/qdeclarativetextinput/data/mouseselectionmode_characters.qml8
-rw-r--r--tests/auto/qtquick1/qdeclarativetextinput/data/mouseselectionmode_default.qml7
-rw-r--r--tests/auto/qtquick1/qdeclarativetextinput/data/mouseselectionmode_words.qml8
-rw-r--r--tests/auto/qtquick1/qdeclarativetextinput/data/navigation.qml24
-rw-r--r--tests/auto/qtquick1/qdeclarativetextinput/data/positionAt.qml8
-rw-r--r--tests/auto/qtquick1/qdeclarativetextinput/data/readOnly.qml12
-rw-r--r--tests/auto/qtquick1/qdeclarativetextinput/data/validators.qml22
-rw-r--r--tests/auto/qtquick1/qdeclarativetextinput/qdeclarativetextinput.pro9
-rw-r--r--tests/auto/qtquick1/qdeclarativetextinput/tst_qdeclarativetextinput.cpp2752
-rw-r--r--tests/auto/qtquick1/qdeclarativetimer/qdeclarativetimer.pro10
-rw-r--r--tests/auto/qtquick1/qdeclarativetimer/tst_qdeclarativetimer.cpp334
-rw-r--r--tests/auto/qtquick1/qdeclarativeview/data/error1.qml5
-rw-r--r--tests/auto/qtquick1/qdeclarativeview/data/resizemodedeclarativeitem.qml5
-rw-r--r--tests/auto/qtquick1/qdeclarativeview/data/resizemodegraphicswidget.qml5
-rw-r--r--tests/auto/qtquick1/qdeclarativeview/qdeclarativeview.pro9
-rw-r--r--tests/auto/qtquick1/qdeclarativeview/tst_qdeclarativeview.cpp333
-rw-r--r--tests/auto/qtquick1/qdeclarativeviewer/data/orientation.qml19
-rw-r--r--tests/auto/qtquick1/qdeclarativeviewer/qdeclarativeviewer.pro12
-rw-r--r--tests/auto/qtquick1/qdeclarativeviewer/tst_qdeclarativeviewer.cpp388
-rw-r--r--tests/auto/qtquick1/qdeclarativevisualdatamodel/data/datalist.qml19
-rw-r--r--tests/auto/qtquick1/qdeclarativevisualdatamodel/data/modelproperties.qml17
-rw-r--r--tests/auto/qtquick1/qdeclarativevisualdatamodel/data/modelproperties2.qml17
-rw-r--r--tests/auto/qtquick1/qdeclarativevisualdatamodel/data/objectlist.qml19
-rw-r--r--tests/auto/qtquick1/qdeclarativevisualdatamodel/data/singlerole1.qml11
-rw-r--r--tests/auto/qtquick1/qdeclarativevisualdatamodel/data/singlerole2.qml11
-rw-r--r--tests/auto/qtquick1/qdeclarativevisualdatamodel/data/visualdatamodel.qml11
-rw-r--r--tests/auto/qtquick1/qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro11
-rw-r--r--tests/auto/qtquick1/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp528
-rw-r--r--tests/auto/qtquick1/qdeclarativexmllistmodel/data/get.qml61
-rw-r--r--tests/auto/qtquick1/qdeclarativexmllistmodel/data/model.qml10
-rw-r--r--tests/auto/qtquick1/qdeclarativexmllistmodel/data/model.xml54
-rw-r--r--tests/auto/qtquick1/qdeclarativexmllistmodel/data/model2.xml14
-rw-r--r--tests/auto/qtquick1/qdeclarativexmllistmodel/data/propertychanges.qml10
-rw-r--r--tests/auto/qtquick1/qdeclarativexmllistmodel/data/recipes.qml10
-rw-r--r--tests/auto/qtquick1/qdeclarativexmllistmodel/data/recipes.xml90
-rw-r--r--tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleCrash.qml7
-rw-r--r--tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleErrors.qml10
-rw-r--r--tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleKeys.qml13
-rw-r--r--tests/auto/qtquick1/qdeclarativexmllistmodel/data/testtypes.qml8
-rw-r--r--tests/auto/qtquick1/qdeclarativexmllistmodel/data/unique.qml8
-rw-r--r--tests/auto/qtquick1/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro11
-rw-r--r--tests/auto/qtquick1/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp954
-rw-r--r--tests/auto/qtquick1/qtquick1.pro50
535 files changed, 0 insertions, 40596 deletions
diff --git a/tests/auto/qtquick1/examples/data/dummytest.qml b/tests/auto/qtquick1/examples/data/dummytest.qml
deleted file mode 100644
index b20e907f27..0000000000
--- a/tests/auto/qtquick1/examples/data/dummytest.qml
+++ /dev/null
@@ -1,6 +0,0 @@
-import Qt.VisualTest 4.6
-
-VisualTest {
- Frame { msec: 0 }
- Frame { msec: 10 }
-}
diff --git a/tests/auto/qtquick1/examples/data/webbrowser/webbrowser.qml b/tests/auto/qtquick1/examples/data/webbrowser/webbrowser.qml
deleted file mode 100644
index d31787b939..0000000000
--- a/tests/auto/qtquick1/examples/data/webbrowser/webbrowser.qml
+++ /dev/null
@@ -1,6 +0,0 @@
-import Qt.VisualTest 4.6
-
-VisualTest {
- Frame { msec: 0 }
- Frame { msec: 2000 }
-}
diff --git a/tests/auto/qtquick1/examples/examples.pro b/tests/auto/qtquick1/examples/examples.pro
deleted file mode 100644
index 3086ea1413..0000000000
--- a/tests/auto/qtquick1/examples/examples.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-CONFIG += testcase
-TARGET = tst_examples
-macx:CONFIG -= app_bundle
-
-include(../../../../tools/qmlviewer/qml.pri)
-
-SOURCES += tst_examples.cpp
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
-QT += core-private gui-private widgets-private declarative-private qtquick1-private testlib
-
-CONFIG+=insignificant_test # QTBUG-20990, aborts
diff --git a/tests/auto/qtquick1/examples/tst_examples.cpp b/tests/auto/qtquick1/examples/tst_examples.cpp
deleted file mode 100644
index 4e8e146e40..0000000000
--- a/tests/auto/qtquick1/examples/tst_examples.cpp
+++ /dev/null
@@ -1,212 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QLibraryInfo>
-#include <QDir>
-#include <QProcess>
-#include <QDebug>
-#include "qmlruntime.h"
-#include <QDeclarativeView>
-#include <QDeclarativeError>
-
-class tst_examples : public QObject
-{
- Q_OBJECT
-public:
- tst_examples();
-
-private slots:
- void examples_data();
- void examples();
-
- void namingConvention();
-private:
- QStringList excludedDirs;
-
- void namingConvention(const QDir &);
- QStringList findQmlFiles(const QDir &);
-};
-
-tst_examples::tst_examples()
-{
- // Add directories you want excluded here
-
-#ifdef QT_NO_WEBKIT
- excludedDirs << "examples/declarative/qtquick1/modelviews/webview";
- excludedDirs << "examples/declarative/qtquick1/webbrowser";
- excludedDirs << "doc/src/snippets/declarative/qtquick1/webview";
- excludedDirs << "doc/src/snippets/qtquick1/qtquick1/webview";
-#endif
-
-#ifdef QT_NO_XMLPATTERNS
- excludedDirs << "examples/declarative/qtquick1/xml/xmldata";
- excludedDirs << "examples/declarative/qtquick1/twitter";
- excludedDirs << "examples/declarative/qtquick1/flickr";
- excludedDirs << "examples/declarative/qtquick1/photoviewer";
-#endif
-}
-
-/*
-This tests that the examples follow the naming convention required
-to have them tested by the examples() test.
-*/
-void tst_examples::namingConvention(const QDir &d)
-{
- for (int ii = 0; ii < excludedDirs.count(); ++ii) {
- QString s = excludedDirs.at(ii);
- if (d.absolutePath().endsWith(s))
- return;
- }
-
- QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"),
- QDir::Files);
-
- bool seenQml = !files.isEmpty();
- bool seenLowercase = false;
-
- foreach (const QString &file, files) {
- if (file.at(0).isLower())
- seenLowercase = true;
- }
-
- if (!seenQml) {
- QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
- QDir::NoSymLinks);
- foreach (const QString &dir, dirs) {
- QDir sub = d;
- sub.cd(dir);
- namingConvention(sub);
- }
- } else if (!seenLowercase) {
- QFAIL(qPrintable(QString(
- "Directory %1 violates naming convention; expected at least one qml file "
- "starting with lower case, got: %2"
- ).arg(d.absolutePath()).arg(files.join(","))));
- }
-}
-
-void tst_examples::namingConvention()
-{
- QString examples = QLibraryInfo::location(QLibraryInfo::ExamplesPath);
-
- namingConvention(QDir(examples));
-}
-
-QStringList tst_examples::findQmlFiles(const QDir &d)
-{
- for (int ii = 0; ii < excludedDirs.count(); ++ii) {
- QString s = excludedDirs.at(ii);
- if (d.absolutePath().endsWith(s))
- return QStringList();
- }
-
- QStringList rv;
-
- QStringList cppfiles = d.entryList(QStringList() << QLatin1String("*.cpp"), QDir::Files);
- if (cppfiles.isEmpty()) {
- QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"),
- QDir::Files);
- foreach (const QString &file, files) {
- if (file.at(0).isLower()) {
- rv << d.absoluteFilePath(file);
- }
- }
- }
-
- QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
- QDir::NoSymLinks);
- foreach (const QString &dir, dirs) {
- QDir sub = d;
- sub.cd(dir);
- rv << findQmlFiles(sub);
- }
-
- return rv;
-}
-
-/*
-This test runs all the examples in the declarative UI source tree and ensures
-that they start and exit cleanly.
-
-Examples are any .qml files under the examples/ directory that start
-with a lower case letter.
-*/
-static void silentErrorsMsgHandler(QtMsgType, const char *)
-{
-}
-
-
-void tst_examples::examples_data()
-{
- QTest::addColumn<QString>("file");
-
- QString examples = QLatin1String(SRCDIR) + "/../../../../examples/declarative/qtquick1";
-
- QStringList files;
- files << findQmlFiles(QDir(examples));
-
- foreach (const QString &file, files)
- QTest::newRow(qPrintable(file)) << file;
-}
-
-void tst_examples::examples()
-{
- QFETCH(QString, file);
-
- QDeclarativeViewer viewer;
-
- QtMsgHandler old = qInstallMsgHandler(silentErrorsMsgHandler);
- QVERIFY(viewer.open(file));
- qInstallMsgHandler(old);
-
- if (viewer.view()->status() == QDeclarativeView::Error)
- qWarning() << viewer.view()->errors();
-
- QCOMPARE(viewer.view()->status(), QDeclarativeView::Ready);
- viewer.show();
-
- QTest::qWaitForWindowShown(&viewer);
-}
-
-QTEST_MAIN(tst_examples)
-
-#include "tst_examples.moc"
diff --git a/tests/auto/qtquick1/moduleqt47/data/importqt47.qml b/tests/auto/qtquick1/moduleqt47/data/importqt47.qml
deleted file mode 100644
index 0a1b533cba..0000000000
--- a/tests/auto/qtquick1/moduleqt47/data/importqt47.qml
+++ /dev/null
@@ -1,80 +0,0 @@
-import Qt 4.7
-
-Item {
- QtObject {}
-
- Component { Item {} }
-
- // Util
- states: [
- State {
- name: "bob"
- AnchorChanges {}
- ParentChange {}
- StateChangeScript {}
- PropertyChanges {}
- }
- ]
- transitions: [
- Transition {
- AnchorAnimation {}
- ColorAnimation {}
- SmoothedAnimation {}
- NumberAnimation {}
- ParallelAnimation {}
- ParentAnimation {}
- PauseAnimation {}
- PropertyAnimation {}
- RotationAnimation {}
- ScriptAction {}
- SequentialAnimation {}
- SpringAnimation {}
- Vector3dAnimation {}
- }
- ]
-
- Behavior on x {}
- Binding {}
- Connections {}
- FontLoader {}
- ListModel { ListElement {} }
- SystemPalette {}
- Timer {}
-
- // graphic items
- BorderImage {}
- Column {}
- MouseArea {}
- Flickable {}
- Flipable {}
- Flow {}
- FocusPanel {}
- FocusScope {}
- Rectangle { gradient: Gradient { GradientStop {} } }
- Grid {}
- GridView {}
- Image {}
- ListView {}
- Loader {}
- PathView {
- path: Path {
- PathLine {}
- PathCubic {}
- PathPercent {}
- PathQuad {}
- PathAttribute {}
- }
- }
- Repeater {}
- Rotation {}
- Row {}
- Translate {}
- Scale {}
- Text {}
- TextEdit {}
- TextInput {}
- VisualItemModel {}
- VisualDataModel {}
-
- Keys.onPressed: console.log("Press")
-}
diff --git a/tests/auto/qtquick1/moduleqt47/moduleqt47.pro b/tests/auto/qtquick1/moduleqt47/moduleqt47.pro
deleted file mode 100644
index d751ea0b86..0000000000
--- a/tests/auto/qtquick1/moduleqt47/moduleqt47.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-TARGET = tst_moduleqt47
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_moduleqt47.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
-QT += core-private gui-private widgets-private declarative-private qtquick1-private testlib
diff --git a/tests/auto/qtquick1/moduleqt47/tst_moduleqt47.cpp b/tests/auto/qtquick1/moduleqt47/tst_moduleqt47.cpp
deleted file mode 100644
index 6c04ad262c..0000000000
--- a/tests/auto/qtquick1/moduleqt47/tst_moduleqt47.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QDir>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QDebug>
-
-class tst_moduleqt47 : public QObject
-{
- Q_OBJECT
-public:
- tst_moduleqt47();
-
-private slots:
- void create();
-
- void accidentalImport_data();
- void accidentalImport();
-
-private:
- QStringList findFiles(const QDir &d);
-
- QDeclarativeEngine engine;
- QStringList excludedFiles;
-};
-
-tst_moduleqt47::tst_moduleqt47()
-{
- excludedFiles << "tests/auto/qtquick1/moduleqt47/data/importqt47.qml"
- << "doc/src/declarative/whatsnew.qdoc"
- << "doc/src/qtquick1/whatsnew.qdoc";
-}
-
-void tst_moduleqt47::create()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/importqt47.qml"));
- QObject *obj = qobject_cast<QObject*>(c.create());
- if (!obj)
- qWarning() << c.errorString();
-
- QVERIFY(obj != 0);
- delete obj;
-}
-
-QStringList tst_moduleqt47::findFiles(const QDir &d)
-{
- QStringList rv;
-
- QStringList files = d.entryList(QStringList() << QLatin1String("*.qml") << QLatin1String("*.qdoc"), QDir::Files);
- foreach (const QString &file, files) {
-
- QString absFile = d.absoluteFilePath(file);
-
- bool skip = false;
- for (int ii = 0; !skip && ii < excludedFiles.count(); ++ii)
- skip = (absFile.endsWith(excludedFiles.at(ii)));
-
- if (!skip)
- rv << absFile;
- }
-
- QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
- foreach (const QString &dir, dirs) {
- QDir sub = d;
- sub.cd(dir);
- rv << findFiles(sub);
- }
-
- return rv;
-}
-
-void tst_moduleqt47::accidentalImport_data()
-{
- QTest::addColumn<QString>("file");
- QStringList files = findFiles(QDir(SRCDIR "/../../../../"));
-
- foreach(const QString &file, files)
- QTest::newRow(qPrintable(file)) << file;
-}
-
-void tst_moduleqt47::accidentalImport()
-{
- QFETCH(QString, file);
-
- QFile f(file);
- if (!f.open(QIODevice::ReadOnly))
- return;
- QByteArray data = f.readAll();
-
- if (data.contains("import Qt 4"))
- qDebug() << file;
- QVERIFY(!data.contains("import Qt 4"));
-}
-
-QTEST_MAIN(tst_moduleqt47)
-
-#include "tst_moduleqt47.moc"
diff --git a/tests/auto/qtquick1/qdeclarativeanchors/data/anchors.qml b/tests/auto/qtquick1/qdeclarativeanchors/data/anchors.qml
deleted file mode 100644
index 9b7c805336..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanchors/data/anchors.qml
+++ /dev/null
@@ -1,162 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- color: "white"
- width: 240
- height: 320
- Rectangle { id: masterRect; objectName: "masterRect"; x: 26; width: 96; height: 20; color: "red" }
- Rectangle {
- id: rect1; objectName: "rect1"
- y: 20; width: 10; height: 10
- anchors.left: masterRect.left
- }
- Rectangle {
- id: rect2; objectName: "rect2"
- y: 20; width: 10; height: 10
- anchors.left: masterRect.right
- }
- Rectangle {
- id: rect3; objectName: "rect3"
- y: 20; width: 10; height: 10
- anchors.left: masterRect.horizontalCenter
- }
- Rectangle {
- id: rect4; objectName: "rect4"
- y: 30; width: 10; height: 10
- anchors.right: masterRect.left
- }
- Rectangle {
- id: rect5; objectName: "rect5"
- y: 30; width: 10; height: 10
- anchors.right: masterRect.right
- }
- Rectangle {
- id: rect6; objectName: "rect6"
- y: 30; width: 10; height: 10
- anchors.right: masterRect.horizontalCenter
- }
- Rectangle {
- id: rect7; objectName: "rect7"
- y: 50; width: 10; height: 10
- anchors.left: parent.left
- }
- Rectangle {
- id: rect8; objectName: "rect8"
- y: 50; width: 10; height: 10
- anchors.left: parent.right
- }
- Rectangle {
- id: rect9; objectName: "rect9"
- y: 50; width: 10; height: 10
- anchors.left: parent.horizontalCenter
- }
- Rectangle {
- id: rect10; objectName: "rect10"
- y: 60; width: 10; height: 10
- anchors.right: parent.left
- }
- Rectangle {
- id: rect11; objectName: "rect11"
- y: 60; width: 10; height: 10
- anchors.right: parent.right
- }
- Rectangle {
- id: rect12; objectName: "rect12"
- y: 60; width: 10; height: 10
- anchors.right: parent.horizontalCenter
- }
- Rectangle {
- id: rect13; objectName: "rect13"
- x: 200; width: 10; height: 10
- anchors.top: masterRect.bottom
- }
- Rectangle {
- id: rect14; objectName: "rect14"
- width: 10; height: 10; color: "steelblue"
- anchors.verticalCenter: parent.verticalCenter
- }
- Rectangle {
- id: rect15; objectName: "rect15"
- y: 200; height: 10
- anchors.left: masterRect.left
- anchors.right: masterRect.right
- }
- Rectangle {
- id: rect16; objectName: "rect16"
- y: 220; height: 10
- anchors.left: masterRect.left
- anchors.horizontalCenter: masterRect.right
- }
- Rectangle {
- id: rect17; objectName: "rect17"
- y: 240; height: 10
- anchors.right: masterRect.right
- anchors.horizontalCenter: masterRect.left
- }
- Rectangle {
- id: rect18; objectName: "rect18"
- x: 180; width: 10
- anchors.top: masterRect.bottom
- anchors.bottom: rect12.top
- }
- Rectangle {
- id: rect19; objectName: "rect19"
- y: 70; width: 10; height: 10
- anchors.horizontalCenter: parent.horizontalCenter
- }
- Rectangle {
- id: rect20; objectName: "rect20"
- y: 70; width: 10; height: 10
- anchors.horizontalCenter: parent.right
- }
- Rectangle {
- id: rect21; objectName: "rect21"
- y: 70; width: 10; height: 10
- anchors.horizontalCenter: parent.left
- }
- Rectangle {
- id: rect22; objectName: "rect22"
- width: 10; height: 10
- anchors.centerIn: masterRect
- }
- Rectangle {
- id: rect23; objectName: "rect23"
- anchors.left: masterRect.left
- anchors.leftMargin: 5
- anchors.right: masterRect.right
- anchors.rightMargin: 5
- anchors.top: masterRect.top
- anchors.topMargin: 5
- anchors.bottom: masterRect.bottom
- anchors.bottomMargin: 5
- }
- Rectangle {
- id: rect24; objectName: "rect24"
- width: 10; height: 10
- anchors.horizontalCenter: masterRect.left
- anchors.horizontalCenterOffset: width/2
- }
- Rectangle {
- id: rect25; objectName: "rect25"
- width: 10; height: 10
- anchors.verticalCenter: rect12.top
- anchors.verticalCenterOffset: height/2
- }
- Rectangle {
- id: rect26; objectName: "rect26"
- width: 10; height: 10
- anchors.baseline: masterRect.top
- anchors.baselineOffset: height/2
- }
- Text {
- id: text1; objectName: "text1"
- y: 200;
- text: "Hello"
- }
- Text {
- id: text2; objectName: "text2"
- anchors.baseline: text1.baseline
- anchors.left: text1.right
- text: "World"
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanchors/data/anchorsqgraphicswidget.qml b/tests/auto/qtquick1/qdeclarativeanchors/data/anchorsqgraphicswidget.qml
deleted file mode 100644
index 82d0315aad..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanchors/data/anchorsqgraphicswidget.qml
+++ /dev/null
@@ -1,162 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- color: "white"
- width: 240
- height: 320
- Rectangle { id: masterRect; objectName: "masterRect"; x: 26; width: 96; height: 20; color: "red" }
- QGraphicsWidget {
- id: rect1; objectName: "rect1"
- y: 20; width: 10; height: 10
- anchors.left: masterRect.left
- }
- QGraphicsWidget {
- id: rect2; objectName: "rect2"
- y: 20; width: 10; height: 10
- anchors.left: masterRect.right
- }
- QGraphicsWidget {
- id: rect3; objectName: "rect3"
- y: 20; width: 10; height: 10
- anchors.left: masterRect.horizontalCenter
- }
- QGraphicsWidget {
- id: rect4; objectName: "rect4"
- y: 30; width: 10; height: 10
- anchors.right: masterRect.left
- }
- QGraphicsWidget {
- id: rect5; objectName: "rect5"
- y: 30; width: 10; height: 10
- anchors.right: masterRect.right
- }
- QGraphicsWidget {
- id: rect6; objectName: "rect6"
- y: 30; width: 10; height: 10
- anchors.right: masterRect.horizontalCenter
- }
- QGraphicsWidget {
- id: rect7; objectName: "rect7"
- y: 50; width: 10; height: 10
- anchors.left: parent.left
- }
- QGraphicsWidget {
- id: rect8; objectName: "rect8"
- y: 50; width: 10; height: 10
- anchors.left: parent.right
- }
- QGraphicsWidget {
- id: rect9; objectName: "rect9"
- y: 50; width: 10; height: 10
- anchors.left: parent.horizontalCenter
- }
- QGraphicsWidget {
- id: rect10; objectName: "rect10"
- y: 60; width: 10; height: 10
- anchors.right: parent.left
- }
- QGraphicsWidget {
- id: rect11; objectName: "rect11"
- y: 60; width: 10; height: 10
- anchors.right: parent.right
- }
- QGraphicsWidget {
- id: rect12; objectName: "rect12"
- y: 60; width: 10; height: 10
- anchors.right: parent.horizontalCenter
- }
- QGraphicsWidget {
- id: rect13; objectName: "rect13"
- x: 200; width: 10; height: 10
- anchors.top: masterRect.bottom
- }
- QGraphicsWidget {
- id: rect14; objectName: "rect14"
- width: 10; height: 10;
- anchors.verticalCenter: parent.verticalCenter
- }
- QGraphicsWidget {
- id: rect15; objectName: "rect15"
- y: 200; height: 10
- anchors.left: masterRect.left
- anchors.right: masterRect.right
- }
- QGraphicsWidget {
- id: rect16; objectName: "rect16"
- y: 220; height: 10
- anchors.left: masterRect.left
- anchors.horizontalCenter: masterRect.right
- }
- QGraphicsWidget {
- id: rect17; objectName: "rect17"
- y: 240; height: 10
- anchors.right: masterRect.right
- anchors.horizontalCenter: masterRect.left
- }
- QGraphicsWidget {
- id: rect18; objectName: "rect18"
- x: 180; width: 10
- anchors.top: masterRect.bottom
- anchors.bottom: rect12.top
- }
- QGraphicsWidget {
- id: rect19; objectName: "rect19"
- y: 70; width: 10; height: 10
- anchors.horizontalCenter: parent.horizontalCenter
- }
- QGraphicsWidget {
- id: rect20; objectName: "rect20"
- y: 70; width: 10; height: 10
- anchors.horizontalCenter: parent.right
- }
- QGraphicsWidget {
- id: rect21; objectName: "rect21"
- y: 70; width: 10; height: 10
- anchors.horizontalCenter: parent.left
- }
- QGraphicsWidget {
- id: rect22; objectName: "rect22"
- width: 10; height: 10
- anchors.centerIn: masterRect
- }
- QGraphicsWidget {
- id: rect23; objectName: "rect23"
- anchors.left: masterRect.left
- anchors.leftMargin: 5
- anchors.right: masterRect.right
- anchors.rightMargin: 5
- anchors.top: masterRect.top
- anchors.topMargin: 5
- anchors.bottom: masterRect.bottom
- anchors.bottomMargin: 5
- }
- QGraphicsWidget {
- id: rect24; objectName: "rect24"
- width: 10; height: 10
- anchors.horizontalCenter: masterRect.left
- anchors.horizontalCenterOffset: width/2
- }
- QGraphicsWidget {
- id: rect25; objectName: "rect25"
- width: 10; height: 10
- anchors.verticalCenter: rect12.top
- anchors.verticalCenterOffset: height/2
- }
- Rectangle {
- id: rect26; objectName: "rect26"
- width: 10; height: 10
- anchors.baseline: masterRect.top
- anchors.baselineOffset: height/2
- }
- Text {
- id: text1; objectName: "text1"
- y: 200;
- text: "Hello"
- }
- Text {
- id: text2; objectName: "text2"
- anchors.baseline: text1.baseline
- anchors.left: text1.right
- text: "World"
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanchors/data/centerin.qml b/tests/auto/qtquick1/qdeclarativeanchors/data/centerin.qml
deleted file mode 100644
index d3bc8cb2bc..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanchors/data/centerin.qml
+++ /dev/null
@@ -1,12 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 200; height: 200
- Rectangle {
- objectName: "centered"
- width: 50; height: 50; color: "blue"
- anchors.centerIn: parent;
- anchors.verticalCenterOffset: 30
- anchors.horizontalCenterOffset: 10
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanchors/data/crash1.qml b/tests/auto/qtquick1/qdeclarativeanchors/data/crash1.qml
deleted file mode 100644
index de66067ce6..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanchors/data/crash1.qml
+++ /dev/null
@@ -1,11 +0,0 @@
-import QtQuick 1.0
-
-Column {
- Text {
- text: "foo"
- anchors.fill: parent
- }
- Text {
- text: "bar"
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanchors/data/fill.qml b/tests/auto/qtquick1/qdeclarativeanchors/data/fill.qml
deleted file mode 100644
index ff19675ef1..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanchors/data/fill.qml
+++ /dev/null
@@ -1,14 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 200; height: 200
- Rectangle {
- objectName: "filler"
- width: 50; height: 50; color: "blue"
- anchors.fill: parent;
- anchors.leftMargin: 10;
- anchors.rightMargin: 20;
- anchors.topMargin: 30;
- anchors.bottomMargin: 40;
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanchors/data/hvCenter.qml b/tests/auto/qtquick1/qdeclarativeanchors/data/hvCenter.qml
deleted file mode 100644
index 11b31ffdc0..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanchors/data/hvCenter.qml
+++ /dev/null
@@ -1,11 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 77; height: 95
- Rectangle {
- objectName: "centered"
- width: 57; height: 57; color: "blue"
- anchors.verticalCenter: parent.verticalCenter
- anchors.horizontalCenter: parent.horizontalCenter
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanchors/data/loop1.qml b/tests/auto/qtquick1/qdeclarativeanchors/data/loop1.qml
deleted file mode 100644
index def48fae52..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanchors/data/loop1.qml
+++ /dev/null
@@ -1,8 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: rect
- width: 120; height: 200; color: "white"
- Text { id: text1; anchors.right: text2.right; text: "Hello" }
- Text { id: text2; anchors.right: text1.right; anchors.rightMargin: 10; text: "World" }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanchors/data/loop2.qml b/tests/auto/qtquick1/qdeclarativeanchors/data/loop2.qml
deleted file mode 100644
index 93430efb15..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanchors/data/loop2.qml
+++ /dev/null
@@ -1,20 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: container;
- width: 600;
- height: 600;
-
- Image {
- id: image1
- source: "http://labs.qt.nokia.com/blogs/wp-content/uploads/2009/03/3311388091_ac2a257feb.jpg"
- anchors.right: image2.left
- }
-
- Image {
- id: image2
- source: "http://labs.qt.nokia.com/blogs/wp-content/uploads/2009/03/oslo_groupphoto.jpg"
- anchors.left: image1.right
- anchors.leftMargin: 20
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanchors/data/margins.qml b/tests/auto/qtquick1/qdeclarativeanchors/data/margins.qml
deleted file mode 100644
index 685346a879..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanchors/data/margins.qml
+++ /dev/null
@@ -1,13 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 200; height: 200
- Rectangle {
- objectName: "filler"
- width: 50; height: 50; color: "blue"
- anchors.fill: parent;
- anchors.margins: 10
- anchors.leftMargin: 5
- anchors.topMargin: 6
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanchors/qdeclarativeanchors.pro b/tests/auto/qtquick1/qdeclarativeanchors/qdeclarativeanchors.pro
deleted file mode 100644
index 57a285b4f9..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanchors/qdeclarativeanchors.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeanchors
-SOURCES += tst_qdeclarativeanchors.cpp
-macx:CONFIG -= app_bundle
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
-QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib
diff --git a/tests/auto/qtquick1/qdeclarativeanchors/tst_qdeclarativeanchors.cpp b/tests/auto/qtquick1/qdeclarativeanchors/tst_qdeclarativeanchors.cpp
deleted file mode 100644
index 1130cd7a14..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanchors/tst_qdeclarativeanchors.cpp
+++ /dev/null
@@ -1,767 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QSignalSpy>
-#include <QtWidgets/QGraphicsWidget>
-#include <private/qgraphicsitem_p.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick1/qdeclarativeview.h>
-#include <QtQuick1/private/qdeclarativerectangle_p.h>
-#include <QtQuick1/private/qdeclarativetext_p.h>
-#include <QtQuick1/private/qdeclarativeanchors_p_p.h>
-#include <QtQuick1/private/qdeclarativeitem_p.h>
-
-Q_DECLARE_METATYPE(QDeclarative1Anchors::Anchor)
-Q_DECLARE_METATYPE(QDeclarative1AnchorLine::AnchorLine)
-
-class tst_QDeclarative1Anchors : public QObject
-{
- Q_OBJECT
-public:
- tst_QDeclarative1Anchors() {}
-
-private slots:
- void basicAnchors();
- void basicAnchorsQGraphicsWidget();
- void basicAnchorsRTL();
- void loops();
- void illegalSets();
- void illegalSets_data();
- void reset();
- void reset_data();
- void resetConvenience();
- void nullItem();
- void nullItem_data();
- void crash1();
- void centerIn();
- void centerInRTL();
- void hvCenter();
- void hvCenterRTL();
- void fill();
- void fillRTL();
- void margins();
- void marginsRTL();
-};
-
-/*
- Find an item with the specified id.
-*/
-template<typename T>
-T *findItem(QGraphicsObject *parent, const QString &objectName)
-{
- const QMetaObject &mo = T::staticMetaObject;
- QList<QGraphicsItem *> children = parent->childItems();
- for (int i = 0; i < children.count(); ++i) {
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(children.at(i)->toGraphicsObject());
- if (item) {
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
- return static_cast<T*>(item);
- }
- item = findItem<T>(item, objectName);
- if (item)
- return static_cast<T*>(item);
- }
- }
-
- return 0;
-}
-
-QGraphicsObject *findObject(QGraphicsObject *parent, const QString &objectName)
-{
- QList<QGraphicsItem *> children = parent->childItems();
- for (int i = 0; i < children.count(); ++i) {
- QGraphicsObject *item = children.at(i)->toGraphicsObject();
- if (item) {
- if (objectName.isEmpty() || item->objectName() == objectName) {
- return item;
- }
- item = findObject(item, objectName);
- if (item)
- return item;
- }
- }
-
- return 0;
-}
-
-
-void tst_QDeclarative1Anchors::basicAnchors()
-{
- QDeclarativeView *view = new QDeclarativeView;
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/anchors.qml"));
-
- qApp->processEvents();
-
- //sibling horizontal
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect1"))->x(), 26.0);
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect2"))->x(), 122.0);
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect3"))->x(), 74.0);
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect4"))->x(), 16.0);
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect5"))->x(), 112.0);
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect6"))->x(), 64.0);
-
- //parent horizontal
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect7"))->x(), 0.0);
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect8"))->x(), 240.0);
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect9"))->x(), 120.0);
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect10"))->x(), -10.0);
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect11"))->x(), 230.0);
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect12"))->x(), 110.0);
-
- //vertical
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect13"))->y(), 20.0);
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect14"))->y(), 155.0);
-
- //stretch
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect15"))->x(), 26.0);
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect15"))->width(), 96.0);
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect16"))->x(), 26.0);
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect16"))->width(), 192.0);
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect17"))->x(), -70.0);
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect17"))->width(), 192.0);
-
- //vertical stretch
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect18"))->y(), 20.0);
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect18"))->height(), 40.0);
-
- //more parent horizontal
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect19"))->x(), 115.0);
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect20"))->x(), 235.0);
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect21"))->x(), -5.0);
-
- //centerIn
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect22"))->x(), 69.0);
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect22"))->y(), 5.0);
-
- //margins
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect23"))->x(), 31.0);
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect23"))->y(), 5.0);
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect23"))->width(), 86.0);
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect23"))->height(), 10.0);
-
- // offsets
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect24"))->x(), 26.0);
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect25"))->y(), 60.0);
- QCOMPARE(findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("rect26"))->y(), 5.0);
-
- //baseline
- QDeclarative1Text *text1 = findItem<QDeclarative1Text>(view->rootObject(), QLatin1String("text1"));
- QDeclarative1Text *text2 = findItem<QDeclarative1Text>(view->rootObject(), QLatin1String("text2"));
- QCOMPARE(text1->y(), text2->y());
-
- delete view;
-}
-
-void tst_QDeclarative1Anchors::basicAnchorsQGraphicsWidget()
-{
- QDeclarativeView *view = new QDeclarativeView;
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/anchorsqgraphicswidget.qml"));
-
- qApp->processEvents();
-
- //sibling horizontal
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect1"))->x(), 26.0);
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect2"))->x(), 122.0);
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect3"))->x(), 74.0);
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect4"))->x(), 16.0);
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect5"))->x(), 112.0);
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect6"))->x(), 64.0);
-
- //parent horizontal
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect7"))->x(), 0.0);
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect8"))->x(), 240.0);
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect9"))->x(), 120.0);
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect10"))->x(), -10.0);
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect11"))->x(), 230.0);
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect12"))->x(), 110.0);
-
- //vertical
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect13"))->y(), 20.0);
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect14"))->y(), 155.0);
-
- //stretch
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect15"))->x(), 26.0);
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect15"))->property("width").toReal(), 96.0);
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect16"))->x(), 26.0);
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect16"))->property("width").toReal(), 192.0);
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect17"))->x(), -70.0);
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect17"))->property("width").toReal(), 192.0);
-
- //vertical stretch
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect18"))->y(), 20.0);
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect18"))->property("height").toReal(), 40.0);
-
- //more parent horizontal
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect19"))->x(), 115.0);
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect20"))->x(), 235.0);
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect21"))->x(), -5.0);
-
- //centerIn
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect22"))->x(), 69.0);
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect22"))->y(), 5.0);
-
- //margins
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect23"))->x(), 31.0);
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect23"))->y(), 5.0);
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect23"))->property("width").toReal(), 86.0);
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect23"))->property("height").toReal(), 10.0);
-
- // offsets
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect24"))->x(), 26.0);
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect25"))->y(), 60.0);
- QCOMPARE(findObject(view->rootObject(), QLatin1String("rect26"))->y(), 5.0);
-
- //baseline
- QDeclarative1Text *text1 = findItem<QDeclarative1Text>(view->rootObject(), QLatin1String("text1"));
- QDeclarative1Text *text2 = findItem<QDeclarative1Text>(view->rootObject(), QLatin1String("text2"));
- QCOMPARE(text1->y(), text2->y());
-
- delete view;
-}
-
-QDeclarativeItem* childItem(QDeclarativeItem *parentItem, const char * itemString) {
- return findItem<QDeclarativeItem>(parentItem, QLatin1String(itemString));
-}
-
-qreal offsetMasterRTL(QDeclarativeItem *rootItem, const char * itemString) {
- QDeclarativeItem* masterItem = findItem<QDeclarativeItem>(rootItem, QLatin1String("masterRect"));
- return masterItem->width()+2*masterItem->x()-findItem<QDeclarativeItem>(rootItem, QLatin1String(itemString))->width();
-}
-
-qreal offsetParentRTL(QDeclarativeItem *rootItem, const char * itemString) {
- return rootItem->width()+2*rootItem->x()-findItem<QDeclarativeItem>(rootItem, QLatin1String(itemString))->width();
-}
-
-void mirrorAnchors(QDeclarativeItem *item) {
- QDeclarativeItemPrivate *itemPrivate = QDeclarativeItemPrivate::get(item);
- itemPrivate->setLayoutMirror(true);
-}
-
-void tst_QDeclarative1Anchors::basicAnchorsRTL()
-{
- QDeclarativeView *view = new QDeclarativeView;
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/anchors.qml"));
-
- qApp->processEvents();
-
- QDeclarativeItem* rootItem = qobject_cast<QDeclarativeItem*>(view->rootObject());
- foreach(QObject *child, rootItem->children()) {
- bool mirrored = QDeclarativeItemPrivate::get(qobject_cast<QDeclarativeItem*>(child))->anchors()->property("mirrored").toBool();
- QCOMPARE(mirrored, false);
- }
-
- foreach(QObject *child, rootItem->children())
- mirrorAnchors(qobject_cast<QDeclarativeItem*>(child));
-
- foreach(QObject *child, rootItem->children()) {
- bool mirrored = QDeclarativeItemPrivate::get(qobject_cast<QDeclarativeItem*>(child))->anchors()->property("mirrored").toBool();
- QCOMPARE(mirrored, true);
- }
-
- //sibling horizontal
- QCOMPARE(childItem(rootItem, "rect1")->x(), offsetMasterRTL(rootItem, "rect1")-26.0);
- QCOMPARE(childItem(rootItem, "rect2")->x(), offsetMasterRTL(rootItem, "rect2")-122.0);
- QCOMPARE(childItem(rootItem, "rect3")->x(), offsetMasterRTL(rootItem, "rect3")-74.0);
- QCOMPARE(childItem(rootItem, "rect4")->x(), offsetMasterRTL(rootItem, "rect4")-16.0);
- QCOMPARE(childItem(rootItem, "rect5")->x(), offsetMasterRTL(rootItem, "rect5")-112.0);
- QCOMPARE(childItem(rootItem, "rect6")->x(), offsetMasterRTL(rootItem, "rect6")-64.0);
-
- //parent horizontal
- QCOMPARE(childItem(rootItem, "rect7")->x(), offsetParentRTL(rootItem, "rect7")-0.0);
- QCOMPARE(childItem(rootItem, "rect8")->x(), offsetParentRTL(rootItem, "rect8")-240.0);
- QCOMPARE(childItem(rootItem, "rect9")->x(), offsetParentRTL(rootItem, "rect9")-120.0);
- QCOMPARE(childItem(rootItem, "rect10")->x(), offsetParentRTL(rootItem, "rect10")+10.0);
- QCOMPARE(childItem(rootItem, "rect11")->x(), offsetParentRTL(rootItem, "rect11")-230.0);
- QCOMPARE(childItem(rootItem, "rect12")->x(), offsetParentRTL(rootItem, "rect12")-110.0);
-
- //vertical
- QCOMPARE(childItem(rootItem, "rect13")->y(), 20.0);
- QCOMPARE(childItem(rootItem, "rect14")->y(), 155.0);
-
- //stretch
- QCOMPARE(childItem(rootItem, "rect15")->x(), offsetMasterRTL(rootItem, "rect15")-26.0);
- QCOMPARE(childItem(rootItem, "rect15")->width(), 96.0);
- QCOMPARE(childItem(rootItem, "rect16")->x(), offsetMasterRTL(rootItem, "rect16")-26.0);
- QCOMPARE(childItem(rootItem, "rect16")->width(), 192.0);
- QCOMPARE(childItem(rootItem, "rect17")->x(), offsetMasterRTL(rootItem, "rect17")+70.0);
- QCOMPARE(childItem(rootItem, "rect17")->width(), 192.0);
-
- //vertical stretch
- QCOMPARE(childItem(rootItem, "rect18")->y(), 20.0);
- QCOMPARE(childItem(rootItem, "rect18")->height(), 40.0);
-
- //more parent horizontal
- QCOMPARE(childItem(rootItem, "rect19")->x(), offsetParentRTL(rootItem, "rect19")-115.0);
- QCOMPARE(childItem(rootItem, "rect20")->x(), offsetParentRTL(rootItem, "rect20")-235.0);
- QCOMPARE(childItem(rootItem, "rect21")->x(), offsetParentRTL(rootItem, "rect21")+5.0);
-
- //centerIn
- QCOMPARE(childItem(rootItem, "rect22")->x(), offsetMasterRTL(rootItem, "rect22")-69.0);
- QCOMPARE(childItem(rootItem, "rect22")->y(), 5.0);
-
- //margins
- QCOMPARE(childItem(rootItem, "rect23")->x(), offsetMasterRTL(rootItem, "rect23")-31.0);
- QCOMPARE(childItem(rootItem, "rect23")->y(), 5.0);
- QCOMPARE(childItem(rootItem, "rect23")->width(), 86.0);
- QCOMPARE(childItem(rootItem, "rect23")->height(), 10.0);
-
- // offsets
- QCOMPARE(childItem(rootItem, "rect24")->x(), offsetMasterRTL(rootItem, "rect24")-26.0);
- QCOMPARE(childItem(rootItem, "rect25")->y(), 60.0);
- QCOMPARE(childItem(rootItem, "rect26")->y(), 5.0);
-
- //baseline
- QDeclarative1Text *text1 = findItem<QDeclarative1Text>(rootItem, QLatin1String("text1"));
- QDeclarative1Text *text2 = findItem<QDeclarative1Text>(rootItem, QLatin1String("text2"));
- QCOMPARE(text1->y(), text2->y());
-
- delete view;
-}
-
-// mostly testing that we don't crash
-void tst_QDeclarative1Anchors::loops()
-{
- {
- QUrl source(QUrl::fromLocalFile(SRCDIR "/data/loop1.qml"));
-
- QString expect = source.toString() + ":6:5: QML Text: Possible anchor loop detected on horizontal anchor.";
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
-
- QDeclarativeView *view = new QDeclarativeView;
- view->setSource(source);
- qApp->processEvents();
-
- delete view;
- }
-
- {
- QSKIP("This causes a lockup due to Bearer management stuff");
- QUrl source(QUrl::fromLocalFile(SRCDIR "/data/loop2.qml"));
-
- QString expect = source.toString() + ":8:3: QML Image: Possible anchor loop detected on horizontal anchor.";
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
-
- QDeclarativeView *view = new QDeclarativeView;
- view->setSource(source);
- qApp->processEvents();
-
- delete view;
- }
-}
-
-void tst_QDeclarative1Anchors::illegalSets()
-{
- QFETCH(QString, qml);
- QFETCH(QString, warning);
-
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 1.0\n" + qml.toUtf8()), QUrl::fromLocalFile(""));
- if (!component.isReady())
- qWarning() << "Test errors:" << component.errors();
- QVERIFY(component.isReady());
- QObject *o = component.create();
- delete o;
-}
-
-void tst_QDeclarative1Anchors::illegalSets_data()
-{
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QString>("warning");
-
- QTest::newRow("H - too many anchors")
- << "Rectangle { id: rect; Rectangle { anchors.left: rect.left; anchors.right: rect.right; anchors.horizontalCenter: rect.horizontalCenter } }"
- << "file::2:23: QML Rectangle: Cannot specify left, right, and hcenter anchors.";
-
- foreach (const QString &side, QStringList() << "left" << "right") {
- QTest::newRow("H - anchor to V")
- << QString("Rectangle { Rectangle { anchors.%1: parent.top } }").arg(side)
- << "file::2:13: QML Rectangle: Cannot anchor a horizontal edge to a vertical edge.";
-
- QTest::newRow("H - anchor to non parent/sibling")
- << QString("Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.%1: rect.%1 } }").arg(side)
- << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling.";
-
- QTest::newRow("H - anchor to self")
- << QString("Rectangle { id: rect; anchors.%1: rect.%1 }").arg(side)
- << "file::2:1: QML Rectangle: Cannot anchor item to self.";
- }
-
-
- QTest::newRow("V - too many anchors")
- << "Rectangle { id: rect; Rectangle { anchors.top: rect.top; anchors.bottom: rect.bottom; anchors.verticalCenter: rect.verticalCenter } }"
- << "file::2:23: QML Rectangle: Cannot specify top, bottom, and vcenter anchors.";
-
- QTest::newRow("V - too many anchors with baseline")
- << "Rectangle { Text { id: text1; text: \"Hello\" } Text { anchors.baseline: text1.baseline; anchors.top: text1.top; } }"
- << "file::2:47: QML Text: Baseline anchor cannot be used in conjunction with top, bottom, or vcenter anchors.";
-
- foreach (const QString &side, QStringList() << "top" << "bottom" << "baseline") {
-
- QTest::newRow("V - anchor to H")
- << QString("Rectangle { Rectangle { anchors.%1: parent.left } }").arg(side)
- << "file::2:13: QML Rectangle: Cannot anchor a vertical edge to a horizontal edge.";
-
- QTest::newRow("V - anchor to non parent/sibling")
- << QString("Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.%1: rect.%1 } }").arg(side)
- << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling.";
-
- QTest::newRow("V - anchor to self")
- << QString("Rectangle { id: rect; anchors.%1: rect.%1 }").arg(side)
- << "file::2:1: QML Rectangle: Cannot anchor item to self.";
- }
-
-
- QTest::newRow("centerIn - anchor to non parent/sibling")
- << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.centerIn: rect} }"
- << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling.";
-
-
- QTest::newRow("fill - anchor to non parent/sibling")
- << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.fill: rect} }"
- << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling.";
-}
-
-void tst_QDeclarative1Anchors::reset()
-{
- QFETCH(QString, side);
- QFETCH(QDeclarative1AnchorLine::AnchorLine, anchorLine);
- QFETCH(QDeclarative1Anchors::Anchor, usedAnchor);
-
- QDeclarativeItem *baseItem = new QDeclarativeItem;
-
- QDeclarative1AnchorLine anchor;
- anchor.item = baseItem;
- anchor.anchorLine = anchorLine;
-
- QDeclarativeItem *item = new QDeclarativeItem;
- QDeclarativeItemPrivate *itemPrivate = QDeclarativeItemPrivate::get(item);
-
- const QMetaObject *meta = itemPrivate->anchors()->metaObject();
- QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData()));
-
- QVERIFY(p.write(itemPrivate->anchors(), qVariantFromValue(anchor)));
- QCOMPARE(itemPrivate->anchors()->usedAnchors().testFlag(usedAnchor), true);
-
- QVERIFY(p.reset(itemPrivate->anchors()));
- QCOMPARE(itemPrivate->anchors()->usedAnchors().testFlag(usedAnchor), false);
-
- delete item;
- delete baseItem;
-}
-
-void tst_QDeclarative1Anchors::reset_data()
-{
- QTest::addColumn<QString>("side");
- QTest::addColumn<QDeclarative1AnchorLine::AnchorLine>("anchorLine");
- QTest::addColumn<QDeclarative1Anchors::Anchor>("usedAnchor");
-
- QTest::newRow("left") << "left" << QDeclarative1AnchorLine::Left << QDeclarative1Anchors::LeftAnchor;
- QTest::newRow("top") << "top" << QDeclarative1AnchorLine::Top << QDeclarative1Anchors::TopAnchor;
- QTest::newRow("right") << "right" << QDeclarative1AnchorLine::Right << QDeclarative1Anchors::RightAnchor;
- QTest::newRow("bottom") << "bottom" << QDeclarative1AnchorLine::Bottom << QDeclarative1Anchors::BottomAnchor;
-
- QTest::newRow("hcenter") << "horizontalCenter" << QDeclarative1AnchorLine::HCenter << QDeclarative1Anchors::HCenterAnchor;
- QTest::newRow("vcenter") << "verticalCenter" << QDeclarative1AnchorLine::VCenter << QDeclarative1Anchors::VCenterAnchor;
- QTest::newRow("baseline") << "baseline" << QDeclarative1AnchorLine::Baseline << QDeclarative1Anchors::BaselineAnchor;
-}
-
-void tst_QDeclarative1Anchors::resetConvenience()
-{
- QDeclarativeItem *baseItem = new QDeclarativeItem;
- QDeclarativeItem *item = new QDeclarativeItem;
- QDeclarativeItemPrivate *itemPrivate = QDeclarativeItemPrivate::get(item);
-
- //fill
- itemPrivate->anchors()->setFill(baseItem);
- QVERIFY(itemPrivate->anchors()->fill() == baseItem);
- itemPrivate->anchors()->resetFill();
- QVERIFY(itemPrivate->anchors()->fill() == 0);
-
- //centerIn
- itemPrivate->anchors()->setCenterIn(baseItem);
- QVERIFY(itemPrivate->anchors()->centerIn() == baseItem);
- itemPrivate->anchors()->resetCenterIn();
- QVERIFY(itemPrivate->anchors()->centerIn() == 0);
-
- delete item;
- delete baseItem;
-}
-
-void tst_QDeclarative1Anchors::nullItem()
-{
- QFETCH(QString, side);
-
- QDeclarative1AnchorLine anchor;
- QDeclarativeItem *item = new QDeclarativeItem;
- QDeclarativeItemPrivate *itemPrivate = QDeclarativeItemPrivate::get(item);
-
- const QMetaObject *meta = itemPrivate->anchors()->metaObject();
- QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData()));
-
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML Item: Cannot anchor to a null item.");
- QVERIFY(p.write(itemPrivate->anchors(), qVariantFromValue(anchor)));
-
- delete item;
-}
-
-void tst_QDeclarative1Anchors::nullItem_data()
-{
- QTest::addColumn<QString>("side");
-
- QTest::newRow("left") << "left";
- QTest::newRow("top") << "top";
- QTest::newRow("right") << "right";
- QTest::newRow("bottom") << "bottom";
-
- QTest::newRow("hcenter") << "horizontalCenter";
- QTest::newRow("vcenter") << "verticalCenter";
- QTest::newRow("baseline") << "baseline";
-}
-
-void tst_QDeclarative1Anchors::crash1()
-{
- QUrl source(QUrl::fromLocalFile(SRCDIR "/data/crash1.qml"));
-
- QString expect = source.toString() + ":4:5: QML Text: Possible anchor loop detected on fill.";
-
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
-
- // QT-3245 ... anchor loop detection needs improving.
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
-
- QDeclarativeView *view = new QDeclarativeView(source);
- qApp->processEvents();
-
- delete view;
-}
-
-void tst_QDeclarative1Anchors::fill()
-{
- QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/fill.qml"));
-
- qApp->processEvents();
- QDeclarative1Rectangle* rect = findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("filler"));
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
- QCOMPARE(rect->x(), 0.0 + 10.0);
- QCOMPARE(rect->y(), 0.0 + 30.0);
- QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0);
- QCOMPARE(rect->height(), 200.0 - 30.0 - 40.0);
- //Alter Offsets (tests QTBUG-6631)
- rectPrivate->anchors()->setLeftMargin(20.0);
- rectPrivate->anchors()->setRightMargin(0.0);
- rectPrivate->anchors()->setBottomMargin(0.0);
- rectPrivate->anchors()->setTopMargin(10.0);
- QCOMPARE(rect->x(), 0.0 + 20.0);
- QCOMPARE(rect->y(), 0.0 + 10.0);
- QCOMPARE(rect->width(), 200.0 - 20.0);
- QCOMPARE(rect->height(), 200.0 - 10.0);
-
- delete view;
-}
-
-void tst_QDeclarative1Anchors::fillRTL()
-{
- QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/fill.qml"));
-
- qApp->processEvents();
- QDeclarative1Rectangle* rect = findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("filler"));
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
- mirrorAnchors(rect);
-
- QCOMPARE(rect->x(), 0.0 + 20.0);
- QCOMPARE(rect->y(), 0.0 + 30.0);
- QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0);
- QCOMPARE(rect->height(), 200.0 - 30.0 - 40.0);
- //Alter Offsets (tests QTBUG-6631)
- rectPrivate->anchors()->setLeftMargin(20.0);
- rectPrivate->anchors()->setRightMargin(0.0);
- rectPrivate->anchors()->setBottomMargin(0.0);
- rectPrivate->anchors()->setTopMargin(10.0);
- QCOMPARE(rect->x(), 0.0 + 0.0);
- QCOMPARE(rect->y(), 0.0 + 10.0);
- QCOMPARE(rect->width(), 200.0 - 20.0);
- QCOMPARE(rect->height(), 200.0 - 10.0);
-
- delete view;
-}
-void tst_QDeclarative1Anchors::centerIn()
-{
- QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/centerin.qml"));
-
- qApp->processEvents();
- QDeclarative1Rectangle* rect = findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("centered"));
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
-
- QCOMPARE(rect->x(), 75.0 + 10);
- QCOMPARE(rect->y(), 75.0 + 30);
- //Alter Offsets (tests QTBUG-6631)
- rectPrivate->anchors()->setHorizontalCenterOffset(-20.0);
- rectPrivate->anchors()->setVerticalCenterOffset(-10.0);
- QCOMPARE(rect->x(), 75.0 - 20.0);
- QCOMPARE(rect->y(), 75.0 - 10.0);
-
- delete view;
-}
-
-
-void tst_QDeclarative1Anchors::centerInRTL()
-{
- QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/centerin.qml"));
-
- qApp->processEvents();
- QDeclarative1Rectangle* rect = findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("centered"));
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
- mirrorAnchors(rect);
-
- QCOMPARE(rect->x(), 75.0 - 10);
- QCOMPARE(rect->y(), 75.0 + 30);
- //Alter Offsets (tests QTBUG-6631)
- rectPrivate->anchors()->setHorizontalCenterOffset(-20.0);
- rectPrivate->anchors()->setVerticalCenterOffset(-10.0);
- QCOMPARE(rect->x(), 75.0 + 20.0);
- QCOMPARE(rect->y(), 75.0 - 10.0);
-
- delete view;
-}
-
-void tst_QDeclarative1Anchors::hvCenter()
-{
- QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/hvCenter.qml"));
-
- qApp->processEvents();
- QDeclarative1Rectangle* rect = findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("centered"));
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
-
- // test QTBUG-10999
- QCOMPARE(rect->x(), 10.0);
- QCOMPARE(rect->y(), 19.0);
-
- rectPrivate->anchors()->setHorizontalCenterOffset(-5.0);
- rectPrivate->anchors()->setVerticalCenterOffset(5.0);
- QCOMPARE(rect->x(), 10.0 - 5.0);
- QCOMPARE(rect->y(), 19.0 + 5.0);
-
- delete view;
-}
-
-void tst_QDeclarative1Anchors::hvCenterRTL()
-{
- QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/hvCenter.qml"));
-
- qApp->processEvents();
- QDeclarative1Rectangle* rect = findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("centered"));
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
- mirrorAnchors(rect);
-
- // test QTBUG-10999
- QCOMPARE(rect->x(), 10.0);
- QCOMPARE(rect->y(), 19.0);
-
- rectPrivate->anchors()->setHorizontalCenterOffset(-5.0);
- rectPrivate->anchors()->setVerticalCenterOffset(5.0);
- QCOMPARE(rect->x(), 10.0 + 5.0);
- QCOMPARE(rect->y(), 19.0 + 5.0);
-
- delete view;
-}
-void tst_QDeclarative1Anchors::margins()
-{
- QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/margins.qml"));
-
- qApp->processEvents();
- QDeclarative1Rectangle* rect = findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("filler"));
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
- QCOMPARE(rect->x(), 5.0);
- QCOMPARE(rect->y(), 6.0);
- QCOMPARE(rect->width(), 200.0 - 5.0 - 10.0);
- QCOMPARE(rect->height(), 200.0 - 6.0 - 10.0);
-
- rectPrivate->anchors()->setTopMargin(0.0);
- rectPrivate->anchors()->setMargins(20.0);
-
- QCOMPARE(rect->x(), 5.0);
- QCOMPARE(rect->y(), 20.0);
- QCOMPARE(rect->width(), 200.0 - 5.0 - 20.0);
- QCOMPARE(rect->height(), 200.0 - 20.0 - 20.0);
-
- delete view;
-}
-
-void tst_QDeclarative1Anchors::marginsRTL()
-{
- QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/margins.qml"));
-
- QDeclarative1Rectangle* rect = findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("filler"));
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
- mirrorAnchors(rect);
-
- QCOMPARE(rect->x(), 10.0);
- QCOMPARE(rect->y(), 6.0);
- QCOMPARE(rect->width(), 200.0 - 5.0 - 10.0);
- QCOMPARE(rect->height(), 200.0 - 6.0 - 10.0);
-
- rectPrivate->anchors()->setTopMargin(0.0);
- rectPrivate->anchors()->setMargins(20.0);
-
- QCOMPARE(rect->x(), 20.0);
- QCOMPARE(rect->y(), 20.0);
- QCOMPARE(rect->width(), 200.0 - 5.0 - 20.0);
- QCOMPARE(rect->height(), 200.0 - 20.0 - 20.0);
-
- delete view;
-}
-
-
-QTEST_MAIN(tst_QDeclarative1Anchors)
-
-#include "tst_qdeclarativeanchors.moc"
diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/colors.gif b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/colors.gif
deleted file mode 100644
index 1270bfaa79..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/colors.gif
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/colors.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/colors.qml
deleted file mode 100644
index 51deb56b18..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/colors.qml
+++ /dev/null
@@ -1,5 +0,0 @@
-import QtQuick 1.0
-
-AnimatedImage {
- source: "colors.gif"
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/hearts.gif b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/hearts.gif
deleted file mode 100644
index cfb55f27f5..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/hearts.gif
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/hearts.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/hearts.qml
deleted file mode 100644
index 8729dd2ef2..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/hearts.qml
+++ /dev/null
@@ -1,6 +0,0 @@
-import QtQuick 1.0
-
-AnimatedImage {
- source: "hearts.gif"
- playing: false
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/qmldir b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/qmldir
deleted file mode 100644
index ef7c1f44f3..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/qmldir
+++ /dev/null
@@ -1 +0,0 @@
-# No local types
diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/qtbug-16520.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/qtbug-16520.qml
deleted file mode 100644
index cf5b60110b..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/qtbug-16520.qml
+++ /dev/null
@@ -1,17 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 500
- height: 500
-
- AnimatedImage {
- objectName: "anim"
- anchors.centerIn: parent
- asynchronous: true
- opacity: status == AnimatedImage.Ready ? 1 : 0
-
- Behavior on opacity {
- NumberAnimation { duration: 1000 }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickman.gif b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickman.gif
deleted file mode 100644
index 7c4cd18687..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickman.gif
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickman.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickman.qml
deleted file mode 100644
index d44937f913..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickman.qml
+++ /dev/null
@@ -1,5 +0,0 @@
-import QtQuick 1.0
-
-AnimatedImage {
- source: "stickman.gif"
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanerror1.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanerror1.qml
deleted file mode 100644
index f08f74da56..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanerror1.qml
+++ /dev/null
@@ -1,6 +0,0 @@
-import QtQuick 1.0
-
-AnimatedImage {
- sourceSize: "240x180"
- source: "stickman.gif"
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanpause.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanpause.qml
deleted file mode 100644
index 1d7e25909f..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanpause.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import QtQuick 1.0
-
-AnimatedImage {
- source: "stickman.gif"
- paused: true
- currentFrame: 2
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanscaled.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanscaled.qml
deleted file mode 100644
index 8b24d73715..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanscaled.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import QtQuick 1.0
-
-AnimatedImage {
- width: 240
- height: 180
- source: "stickman.gif"
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanstopped.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanstopped.qml
deleted file mode 100644
index c5b14137e3..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanstopped.qml
+++ /dev/null
@@ -1,6 +0,0 @@
-import QtQuick 1.0
-
-AnimatedImage {
- source: "stickman.gif"
- playing: false
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro b/tests/auto/qtquick1/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro
deleted file mode 100644
index 21c846b4eb..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeanimatedimage
-HEADERS += ../../shared/testhttpserver.h
-SOURCES += tst_qdeclarativeanimatedimage.cpp ../../shared/testhttpserver.cpp
-macx:CONFIG -= app_bundle
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
-QT += core-private gui-private widgets-private declarative-private qtquick1-private network testlib
diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp b/tests/auto/qtquick1/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp
deleted file mode 100644
index 5545705341..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp
+++ /dev/null
@@ -1,381 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick1/qdeclarativeview.h>
-#include <private/qdeclarativerectangle_p.h>
-#include <private/qdeclarativeimage_p.h>
-#include <private/qdeclarativeanimatedimage_p.h>
-#include <QSignalSpy>
-#include <QtDeclarative/qdeclarativecontext.h>
-
-#include "../../shared/testhttpserver.h"
-
-class tst_qdeclarativeanimatedimage : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativeanimatedimage() {}
-
-private slots:
- void play();
- void pause();
- void stopped();
- void setFrame();
- void frameCount();
- void mirror_running();
- void mirror_notRunning();
- void mirror_notRunning_data();
- void remote();
- void remote_data();
- void sourceSize();
- void sourceSizeReadOnly();
- void invalidSource();
- void qtbug_16520();
- void progressAndStatusChanges();
-
-private:
- QPixmap grabScene(QGraphicsScene *scene, int width, int height);
-};
-
-QPixmap tst_qdeclarativeanimatedimage::grabScene(QGraphicsScene *scene, int width, int height)
-{
- QPixmap screenshot(width, height);
- screenshot.fill();
- QPainter p_screenshot(&screenshot);
- scene->render(&p_screenshot, QRect(0, 0, width, height), QRect(0, 0, width, height));
- return screenshot;
-}
-
-void tst_qdeclarativeanimatedimage::play()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickman.qml"));
- QDeclarative1AnimatedImage *anim = qobject_cast<QDeclarative1AnimatedImage *>(component.create());
- QVERIFY(anim);
- QVERIFY(anim->isPlaying());
-
- delete anim;
-}
-
-void tst_qdeclarativeanimatedimage::pause()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml"));
- QDeclarative1AnimatedImage *anim = qobject_cast<QDeclarative1AnimatedImage *>(component.create());
- QVERIFY(anim);
- QVERIFY(anim->isPlaying());
- QVERIFY(anim->isPaused());
-
- delete anim;
-}
-
-void tst_qdeclarativeanimatedimage::stopped()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanstopped.qml"));
- QDeclarative1AnimatedImage *anim = qobject_cast<QDeclarative1AnimatedImage *>(component.create());
- QVERIFY(anim);
- QVERIFY(!anim->isPlaying());
- QCOMPARE(anim->currentFrame(), 0);
-
- delete anim;
-}
-
-void tst_qdeclarativeanimatedimage::setFrame()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml"));
- QDeclarative1AnimatedImage *anim = qobject_cast<QDeclarative1AnimatedImage *>(component.create());
- QVERIFY(anim);
- QVERIFY(anim->isPlaying());
- QCOMPARE(anim->currentFrame(), 2);
-
- delete anim;
-}
-
-void tst_qdeclarativeanimatedimage::frameCount()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/colors.qml"));
- QDeclarative1AnimatedImage *anim = qobject_cast<QDeclarative1AnimatedImage *>(component.create());
- QVERIFY(anim);
- QVERIFY(anim->isPlaying());
- QCOMPARE(anim->frameCount(), 3);
-
- delete anim;
-}
-
-void tst_qdeclarativeanimatedimage::mirror_running()
-{
- // test where mirror is set to true after animation has started
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/hearts.qml"));
- QDeclarative1AnimatedImage *anim = qobject_cast<QDeclarative1AnimatedImage *>(component.create());
- QVERIFY(anim);
-
- QGraphicsScene scene;
- int width = anim->property("width").toInt();
- int height = anim->property("height").toInt();
- scene.addItem(qobject_cast<QGraphicsObject *>(anim));
-
- QCOMPARE(anim->currentFrame(), 0);
- QPixmap frame0 = grabScene(&scene, width, height);
- anim->setCurrentFrame(1);
- QPixmap frame1 = grabScene(&scene, width, height);
-
- anim->setCurrentFrame(0);
-
- QSignalSpy spy(anim, SIGNAL(frameChanged()));
- anim->setPlaying(true);
-
- QTRY_VERIFY(spy.count() == 1); spy.clear();
- anim->setProperty("mirror", true);
-
- QCOMPARE(anim->currentFrame(), 1);
- QPixmap frame1_flipped = grabScene(&scene, width, height);
-
- QTRY_VERIFY(spy.count() == 1); spy.clear();
- QCOMPARE(anim->currentFrame(), 0); // animation only has 2 frames, should cycle back to first
- QPixmap frame0_flipped = grabScene(&scene, width, height);
-
- QTransform transform;
- transform.translate(width, 0).scale(-1, 1.0);
- QPixmap frame0_expected = frame0.transformed(transform);
- QPixmap frame1_expected = frame1.transformed(transform);
-
- QCOMPARE(frame0_flipped, frame0_expected);
- QCOMPARE(frame1_flipped, frame1_expected);
-}
-
-void tst_qdeclarativeanimatedimage::mirror_notRunning()
-{
- QFETCH(QUrl, fileUrl);
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, fileUrl);
- QDeclarative1AnimatedImage *anim = qobject_cast<QDeclarative1AnimatedImage *>(component.create());
- QVERIFY(anim);
-
- QGraphicsScene scene;
- int width = anim->property("width").toInt();
- int height = anim->property("height").toInt();
- scene.addItem(qobject_cast<QGraphicsObject *>(anim));
- QPixmap screenshot = grabScene(&scene, width, height);
-
- QTransform transform;
- transform.translate(width, 0).scale(-1, 1.0);
- QPixmap expected = screenshot.transformed(transform);
-
- int frame = anim->currentFrame();
- bool playing = anim->isPlaying();
- bool paused = anim->isPlaying();
-
- anim->setProperty("mirror", true);
- screenshot = grabScene(&scene, width, height);
-
- QCOMPARE(screenshot, expected);
-
- // mirroring should not change the current frame or playing status
- QCOMPARE(anim->currentFrame(), frame);
- QCOMPARE(anim->isPlaying(), playing);
- QCOMPARE(anim->isPaused(), paused);
-
- delete anim;
-}
-
-void tst_qdeclarativeanimatedimage::mirror_notRunning_data()
-{
- QTest::addColumn<QUrl>("fileUrl");
-
- QTest::newRow("paused") << QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml");
- QTest::newRow("stopped") << QUrl::fromLocalFile(SRCDIR "/data/stickmanstopped.qml");
-}
-
-void tst_qdeclarativeanimatedimage::remote()
-{
- QFETCH(QString, fileName);
- QFETCH(bool, paused);
-
- TestHTTPServer server(14449);
- QVERIFY(server.isValid());
- server.serveDirectory(SRCDIR "/data");
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl("http://127.0.0.1:14449/" + fileName));
- QTRY_VERIFY(component.isReady());
-
- QDeclarative1AnimatedImage *anim = qobject_cast<QDeclarative1AnimatedImage *>(component.create());
- QVERIFY(anim);
-
- QTRY_VERIFY(anim->isPlaying());
- if (paused) {
- QTRY_VERIFY(anim->isPaused());
- QCOMPARE(anim->currentFrame(), 2);
- }
- QVERIFY(anim->status() != QDeclarative1AnimatedImage::Error);
-
- delete anim;
-}
-
-void tst_qdeclarativeanimatedimage::sourceSize()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanscaled.qml"));
- QDeclarative1AnimatedImage *anim = qobject_cast<QDeclarative1AnimatedImage *>(component.create());
- QVERIFY(anim);
- QCOMPARE(anim->width(),240.0);
- QCOMPARE(anim->height(),180.0);
- QCOMPARE(anim->sourceSize(),QSize(160,120));
-
- delete anim;
-}
-
-void tst_qdeclarativeanimatedimage::sourceSizeReadOnly()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanerror1.qml"));
- QVERIFY(component.isError());
- QCOMPARE(component.errors().at(0).description(), QString("Invalid property assignment: \"sourceSize\" is a read-only property"));
-}
-
-void tst_qdeclarativeanimatedimage::remote_data()
-{
- QTest::addColumn<QString>("fileName");
- QTest::addColumn<bool>("paused");
-
- QTest::newRow("playing") << "stickman.qml" << false;
- QTest::newRow("paused") << "stickmanpause.qml" << true;
-}
-
-void tst_qdeclarativeanimatedimage::invalidSource()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 1.0\n AnimatedImage { source: \"no-such-file.gif\" }", QUrl::fromLocalFile(""));
- QVERIFY(component.isReady());
-
- QTest::ignoreMessage(QtWarningMsg, "file::2:2: QML AnimatedImage: Error Reading Animated Image File file:no-such-file.gif");
-
- QDeclarative1AnimatedImage *anim = qobject_cast<QDeclarative1AnimatedImage *>(component.create());
- QVERIFY(anim);
-
- QVERIFY(!anim->isPlaying());
- QVERIFY(!anim->isPaused());
- QCOMPARE(anim->currentFrame(), 0);
- QCOMPARE(anim->frameCount(), 0);
- QTRY_VERIFY(anim->status() == 3);
-}
-
-void tst_qdeclarativeanimatedimage::qtbug_16520()
-{
- TestHTTPServer server(14449);
- QVERIFY(server.isValid());
- server.serveDirectory(SRCDIR "/data");
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/qtbug-16520.qml"));
- QTRY_VERIFY(component.isReady());
-
- QDeclarative1Rectangle *root = qobject_cast<QDeclarative1Rectangle *>(component.create());
- QVERIFY(root);
- QDeclarative1AnimatedImage *anim = root->findChild<QDeclarative1AnimatedImage*>("anim");
-
- anim->setProperty("source", "http://127.0.0.1:14449/stickman.gif");
-
- QTRY_VERIFY(anim->opacity() == 0);
- QTRY_VERIFY(anim->opacity() == 1);
-
- delete anim;
-}
-
-void tst_qdeclarativeanimatedimage::progressAndStatusChanges()
-{
- TestHTTPServer server(14449);
- QVERIFY(server.isValid());
- server.serveDirectory(SRCDIR "/data");
-
- QDeclarativeEngine engine;
- QString componentStr = "import QtQuick 1.0\nAnimatedImage { source: srcImage }";
- QDeclarativeContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/stickman.gif"));
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Image *obj = qobject_cast<QDeclarative1Image*>(component.create());
- QVERIFY(obj != 0);
- QVERIFY(obj->status() == QDeclarative1Image::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
-
- QSignalSpy sourceSpy(obj, SIGNAL(sourceChanged(const QUrl &)));
- QSignalSpy progressSpy(obj, SIGNAL(progressChanged(qreal)));
- QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QDeclarative1ImageBase::Status)));
-
- // Loading local file
- ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.gif"));
- QTRY_VERIFY(obj->status() == QDeclarative1Image::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
- QTRY_COMPARE(sourceSpy.count(), 1);
- QTRY_COMPARE(progressSpy.count(), 0);
- QTRY_COMPARE(statusSpy.count(), 0);
-
- // Loading remote file
- ctxt->setContextProperty("srcImage", "http://127.0.0.1:14449/stickman.gif");
- QTRY_VERIFY(obj->status() == QDeclarative1Image::Loading);
- QTRY_VERIFY(obj->progress() == 0.0);
- QTRY_VERIFY(obj->status() == QDeclarative1Image::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
- QTRY_COMPARE(sourceSpy.count(), 2);
- QTRY_VERIFY(progressSpy.count() > 1);
- QTRY_COMPARE(statusSpy.count(), 2);
-
- ctxt->setContextProperty("srcImage", "");
- QTRY_VERIFY(obj->status() == QDeclarative1Image::Null);
- QTRY_VERIFY(obj->progress() == 0.0);
- QTRY_COMPARE(sourceSpy.count(), 3);
- QTRY_VERIFY(progressSpy.count() > 2);
- QTRY_COMPARE(statusSpy.count(), 3);
-}
-
-QTEST_MAIN(tst_qdeclarativeanimatedimage)
-
-#include "tst_qdeclarativeanimatedimage.moc"
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/Double.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/Double.qml
deleted file mode 100644
index b247fcee5f..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/Double.qml
+++ /dev/null
@@ -1,14 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: container
- property bool on: false
- border.color: "#ffffff"
- color: "green"
- width: 50
- height: 50
- NumberAnimation on x {
- objectName: "animation"
- running: container.on; from: 0; to: 600; loops: Animation.Infinite; duration: 2000
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/attached.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/attached.qml
deleted file mode 100644
index c5d5535bb7..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/attached.qml
+++ /dev/null
@@ -1,34 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 180; height: 200;
-
- Component {
- id: delegate
- Rectangle {
- id: wrapper
- width: 180; height: 200
- color: "blue"
-
- states: State {
- name: "otherState"
- PropertyChanges { target: wrapper; color: "green" }
- }
-
- transitions: Transition {
- PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true }
- ScriptAction { script: console.log(wrapper.ListView.delayRemove ? "on" : "off") }
- }
-
- Component.onCompleted: {
- console.log(ListView.delayRemove ? "on" : "off");
- wrapper.state = "otherState"
- }
- }
- }
-
- ListView {
- model: 1
- delegate: delegate
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/badproperty1.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/badproperty1.qml
deleted file mode 100644
index 3e7ebe7440..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/badproperty1.qml
+++ /dev/null
@@ -1,21 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: wrapper
- width: 240
- height: 320
- Rectangle {
- id: myRect
- color: "red"
- width: 50; height: 50
- x: 100; y: 100
- }
- states: State {
- name: "state1"
- PropertyChanges { target: myRect; border.color: "blue" }
- }
- transitions: Transition {
- ColorAnimation { target: myRect; to: "red"; property: "border.colr"; duration: 1000 }
- }
- Component.onCompleted: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1";
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/badproperty2.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/badproperty2.qml
deleted file mode 100644
index 40235eee15..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/badproperty2.qml
+++ /dev/null
@@ -1,21 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: wrapper
- width: 240
- height: 320
- Rectangle {
- id: myRect
- color: "red"
- width: 50; height: 50
- x: 100; y: 100
- }
- states: State {
- name: "state1"
- PropertyChanges { target: myRect; border.color: "blue" }
- }
- transitions: Transition {
- ColorAnimation { target: myRect; to: "red"; property: "border"; duration: 1000 }
- }
- Component.onCompleted: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1";
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/badtype1.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/badtype1.qml
deleted file mode 100644
index 0a8a7ea7f9..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/badtype1.qml
+++ /dev/null
@@ -1,12 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 240
- height: 320
- Rectangle {
- color: "red"
- width: 50; height: 50
- x: 100; y: 100
- PropertyAnimation on x { from: "blue"; to: "green"; }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/badtype2.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/badtype2.qml
deleted file mode 100644
index 118bbbc889..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/badtype2.qml
+++ /dev/null
@@ -1,12 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 240
- height: 320
- Rectangle {
- color: "red"
- width: 50; height: 50
- x: 100; y: 100
- NumberAnimation on x { from: "blue"; to: "green"; }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/badtype3.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/badtype3.qml
deleted file mode 100644
index 2599e70cc9..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/badtype3.qml
+++ /dev/null
@@ -1,12 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 240
- height: 320
- Rectangle {
- color: "red"
- ColorAnimation on color { from: 10; to: 15; }
- width: 50; height: 50
- x: 100; y: 100
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/badtype4.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/badtype4.qml
deleted file mode 100644
index 5dafb0e344..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/badtype4.qml
+++ /dev/null
@@ -1,27 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: wrapper
- width: 240
- height: 320
- Rectangle {
- id: myRect
- objectName: "MyRect"
- color: "red"
- width: 50; height: 50
- x: 100; y: 100
- MouseArea {
- anchors.fill: parent
- onClicked: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1";
- }
- }
- states: State {
- name: "state1"
- PropertyChanges { target: myRect; x: 200; color: "blue" }
- }
- transitions: Transition {
- //comment out each in turn to make sure each only animates the relevant property
- ColorAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color
- NumberAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/dontAutoStart.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/dontAutoStart.qml
deleted file mode 100644
index e2ce07fbfc..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/dontAutoStart.qml
+++ /dev/null
@@ -1,18 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: wrapper
- width: 600
- height: 400
-
- Rectangle {
- id: redRect
- width: 100; height: 100
- color: Qt.rgba(1,0,0)
- Behavior on x {
- NumberAnimation { id: myAnim; objectName: "MyAnim"; target: redRect; property: "y"; to: 300; loops: Animation.Infinite}
- }
-
- }
-
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/dontStart.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/dontStart.qml
deleted file mode 100644
index 6b8031769f..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/dontStart.qml
+++ /dev/null
@@ -1,19 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: wrapper
- width: 600
- height: 400
-
- Rectangle {
- id: redRect
- width: 100; height: 100
- color: Qt.rgba(1,0,0)
- SequentialAnimation on x {
- running: false
- NumberAnimation { objectName: "MyAnim"; running: true }
- }
-
- }
-
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/dontStart2.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/dontStart2.qml
deleted file mode 100644
index 2563c01d4f..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/dontStart2.qml
+++ /dev/null
@@ -1,19 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: wrapper
- width: 600
- height: 400
-
- Rectangle {
- id: redRect
- width: 100; height: 100
- color: Qt.rgba(1,0,0)
-
- transitions: Transition {
- SequentialAnimation {
- NumberAnimation { id: myAnim; objectName: "MyAnim"; running: true }
- }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/dotproperty.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/dotproperty.qml
deleted file mode 100644
index aff69e5c12..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/dotproperty.qml
+++ /dev/null
@@ -1,24 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: wrapper
- width: 240
- height: 320
- Rectangle {
- id: myRect
- color: "red"
- width: 50; height: 50
- x: 100; y: 100
- MouseArea {
- anchors.fill: parent
- onClicked: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1";
- }
- }
- states: State {
- name: "state1"
- PropertyChanges { target: myRect; border.color: "blue" }
- }
- transitions: Transition {
- ColorAnimation { properties: "border.color"; duration: 1000 }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/doubleRegistrationBug.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/doubleRegistrationBug.qml
deleted file mode 100644
index f0fdf9cfb5..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/doubleRegistrationBug.qml
+++ /dev/null
@@ -1,8 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 400; height: 400
-
- Double { id: dub; on: parent.width < 800 }
- Component.onCompleted: dub.on = false
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/mixedtype1.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/mixedtype1.qml
deleted file mode 100644
index a97b3fd5bf..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/mixedtype1.qml
+++ /dev/null
@@ -1,25 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: wrapper
- width: 240
- height: 320
- Rectangle {
- id: myRect
- objectName: "MyRect"
- color: "red"
- width: 50; height: 50
- x: 100; y: 100
- MouseArea {
- anchors.fill: parent
- onClicked: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1";
- }
- }
- states: State {
- name: "state1"
- PropertyChanges { target: myRect; x: 200; border.width: 10 }
- }
- transitions: Transition {
- PropertyAnimation { properties: "x,border.width"; duration: 1000 } //x is real, border.width is int
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/mixedtype2.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/mixedtype2.qml
deleted file mode 100644
index 9a77467820..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/mixedtype2.qml
+++ /dev/null
@@ -1,25 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: wrapper
- width: 240
- height: 320
- Rectangle {
- id: myRect
- objectName: "MyRect"
- color: "red"
- width: 50; height: 50
- x: 100; y: 100
- MouseArea {
- anchors.fill: parent
- onClicked: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1";
- }
- }
- states: State {
- name: "state1"
- PropertyChanges { target: myRect; x: 200; color: "blue" }
- }
- transitions: Transition {
- PropertyAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/nonTransitionBug.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/nonTransitionBug.qml
deleted file mode 100644
index 04741ff348..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/nonTransitionBug.qml
+++ /dev/null
@@ -1,30 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: root
- width: 200
- height: 200
-
- Rectangle {
- id: mover
- objectName: "mover"
- }
-
- states: [
- State {
- name: "free"
- },
- State {
- name: "left"
- PropertyChanges {
- restoreEntryValues: false
- target: mover
- x: 0
- }
- }
- ]
-
- transitions: Transition {
- PropertyAnimation { properties: "x"; duration: 50 }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/pauseBug.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/pauseBug.qml
deleted file mode 100644
index d514cf7c43..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/pauseBug.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import QtQuick 1.1
-
-SequentialAnimation {
- id: animation
- running: true
- ScriptAction { script: animation.paused = true }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/properties.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/properties.qml
deleted file mode 100644
index e6af9acc93..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/properties.qml
+++ /dev/null
@@ -1,14 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 400
- height: 400
- Rectangle {
- id: theRect
- objectName: "TheRect"
- color: "red"
- width: 50; height: 50
- x: 100; y: 100
- NumberAnimation on x { to: 200 }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/properties2.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/properties2.qml
deleted file mode 100644
index 60ec456c71..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/properties2.qml
+++ /dev/null
@@ -1,14 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 400
- height: 400
- Rectangle {
- id: theRect
- objectName: "TheRect"
- color: "red"
- width: 50; height: 50
- x: 100; y: 100
- NumberAnimation on x { targets: theRect; properties: "x"; to: 200; }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/properties3.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/properties3.qml
deleted file mode 100644
index e86eca1316..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/properties3.qml
+++ /dev/null
@@ -1,14 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 400
- height: 400
- Rectangle {
- id: theRect
- objectName: "TheRect"
- color: "red"
- width: 50; height: 50
- x: 100; y: 100
- NumberAnimation on x { target: theRect; property: "x"; to: 300; }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/properties4.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/properties4.qml
deleted file mode 100644
index 04d41c64c1..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/properties4.qml
+++ /dev/null
@@ -1,14 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 400
- height: 400
- Rectangle {
- id: theRect
- objectName: "TheRect"
- color: "red"
- width: 50; height: 50
- x: 100; y: 100
- NumberAnimation on x { target: theRect; property: "y"; to: 200; }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/properties5.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/properties5.qml
deleted file mode 100644
index e139f8c6c0..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/properties5.qml
+++ /dev/null
@@ -1,14 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 400
- height: 400
- Rectangle {
- id: theRect
- objectName: "TheRect"
- color: "red"
- width: 50; height: 50
- x: 100; y: 100
- NumberAnimation on x { targets: theRect; properties: "y"; to: 200; }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition.qml
deleted file mode 100644
index 8e2b41db6c..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition.qml
+++ /dev/null
@@ -1,29 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 400
- height: 400
- Rectangle {
- id: theRect
- objectName: "TheRect"
- color: "red"
- width: 50; height: 50
- x: 100; y: 100
- }
-
- states: State {
- name: "moved"
- PropertyChanges {
- target: theRect
- x: 200
- }
- }
- transitions: Transition {
- NumberAnimation { targets: theRect; properties: "x" }
- }
-
- MouseArea {
- anchors.fill: parent
- onClicked: parent.state = "moved"
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition2.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition2.qml
deleted file mode 100644
index 6b846852ff..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition2.qml
+++ /dev/null
@@ -1,29 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 400
- height: 400
- Rectangle {
- id: theRect
- objectName: "TheRect"
- color: "red"
- width: 50; height: 50
- x: 100; y: 100
- }
-
- states: State {
- name: "moved"
- PropertyChanges {
- target: theRect
- x: 200
- }
- }
- transitions: Transition {
- NumberAnimation { target: theRect; property: "y"; to: 200 }
- }
-
- MouseArea {
- anchors.fill: parent
- onClicked: parent.state = "moved"
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition3.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition3.qml
deleted file mode 100644
index c9d8e95bd3..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition3.qml
+++ /dev/null
@@ -1,29 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 400
- height: 400
- Rectangle {
- id: theRect
- objectName: "TheRect"
- color: "red"
- width: 50; height: 50
- x: 100; y: 100
- }
-
- states: State {
- name: "moved"
- PropertyChanges {
- target: theRect
- x: 200
- }
- }
- transitions: Transition {
- NumberAnimation { targets: theRect; properties: "y" }
- }
-
- MouseArea {
- anchors.fill: parent
- onClicked: parent.state = "moved"
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition4.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition4.qml
deleted file mode 100644
index 61e8a96788..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition4.qml
+++ /dev/null
@@ -1,29 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 400
- height: 400
- Rectangle {
- id: theRect
- objectName: "TheRect"
- color: "red"
- width: 50; height: 50
- x: 100; y: 100
- }
-
- states: State {
- name: "moved"
- PropertyChanges {
- target: theRect
- x: 200
- }
- }
- transitions: Transition {
- NumberAnimation { target: theRect; properties: "x" }
- }
-
- MouseArea {
- anchors.fill: parent
- onClicked: parent.state = "moved"
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition5.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition5.qml
deleted file mode 100644
index b023943007..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition5.qml
+++ /dev/null
@@ -1,29 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 400
- height: 400
- Rectangle {
- id: theRect
- objectName: "TheRect"
- color: "red"
- width: 50; height: 50
- x: 100; y: 100
- }
-
- states: State {
- name: "moved"
- PropertyChanges {
- target: theRect
- x: 200
- }
- }
- transitions: Transition {
- NumberAnimation { targets: theRect; property: "x" }
- }
-
- MouseArea {
- anchors.fill: parent
- onClicked: parent.state = "moved"
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition6.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition6.qml
deleted file mode 100644
index 7c88a7f038..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition6.qml
+++ /dev/null
@@ -1,29 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 400
- height: 400
- Rectangle {
- id: theRect
- objectName: "TheRect"
- color: "red"
- width: 50; height: 50
- x: 100; y: 100
- }
-
- states: State {
- name: "moved"
- PropertyChanges {
- target: theRect
- x: 200
- }
- }
- transitions: Transition {
- NumberAnimation { targets: theItem; properties: "x" }
- }
-
- MouseArea {
- anchors.fill: parent
- onClicked: parent.state = "moved"
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition7.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition7.qml
deleted file mode 100644
index fbef95e572..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition7.qml
+++ /dev/null
@@ -1,29 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 400
- height: 400
- Rectangle {
- id: theRect
- objectName: "TheRect"
- color: "red"
- width: 50; height: 50
- x: 100; y: 100
- }
-
- states: State {
- name: "moved"
- PropertyChanges {
- target: theRect
- x: 200
- }
- }
- transitions: Transition {
- SpringAnimation { targets: theRect; properties: "x"; velocity: 10000 }
- }
-
- MouseArea {
- anchors.fill: parent
- onClicked: parent.state = "moved"
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/registrationBug.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/registrationBug.qml
deleted file mode 100644
index 7dc29f9315..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/registrationBug.qml
+++ /dev/null
@@ -1,18 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: rect
- width: 200
- height: 200
-
- property bool animating: true
- property int value: 0
-
- NumberAnimation {
- target: rect
- property: "value"
- running: rect.animating
- to: 100
- duration: 50
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/rotation.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/rotation.qml
deleted file mode 100644
index ac158df719..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/rotation.qml
+++ /dev/null
@@ -1,48 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 600; height: 200
-
- Row {
- spacing: 5
- Rectangle {
- id: rr
- objectName: "rr"
- color: "red"
- width: 100; height: 100
- }
- Rectangle {
- id: rr2
- objectName: "rr2"
- color: "red"
- width: 100; height: 100
- }
- Rectangle {
- id: rr3
- objectName: "rr3"
- color: "red"
- width: 100; height: 100
- }
- Rectangle {
- id: rr4
- objectName: "rr4"
- color: "red"
- width: 100; height: 100
- }
- }
-
- states: State {
- name: "state1"
- PropertyChanges { target: rr; rotation: 370 }
- PropertyChanges { target: rr2; rotation: 370 }
- PropertyChanges { target: rr3; rotation: 370 }
- PropertyChanges { target: rr4; rotation: 370 }
- }
-
- transitions: Transition {
- RotationAnimation { target: rr; direction: RotationAnimation.Numerical; duration: 1000 }
- RotationAnimation { target: rr2; direction: RotationAnimation.Clockwise; duration: 1000 }
- RotationAnimation { target: rr3; direction: RotationAnimation.Counterclockwise; duration: 1000 }
- RotationAnimation { target: rr4; direction: RotationAnimation.Shortest; duration: 1000 }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/runningTrueBug.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/runningTrueBug.qml
deleted file mode 100644
index 7d33ed7175..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/runningTrueBug.qml
+++ /dev/null
@@ -1,30 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- color: "skyblue"
- width: 500
- height: 200
- Rectangle {
- objectName: "cloud"
- color: "white"
- y: 50
- width: 100
- height: 100
-
- SequentialAnimation on x {
- loops: Animation.Infinite
- running: true
- NumberAnimation {
- id: firstAnimation
- from: 0
- to: 500
- duration: 5000
- }
- NumberAnimation {
- id: secondAnimation
- from: -100
- to: 0
- duration: 1000
- }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/transitionAssignmentBug.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/transitionAssignmentBug.qml
deleted file mode 100644
index 99b9ac57d4..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/transitionAssignmentBug.qml
+++ /dev/null
@@ -1,12 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 400
- height: 400
-
- property bool nullObject
- Component.onCompleted: nullObject = transitions.length > 0 && transitions[0] === null
-
- property list<Transition> myTransitions: [Transition {}, Transition {}]
- transitions: myTransitions
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/valuesource.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/valuesource.qml
deleted file mode 100644
index fa9cd400ac..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/valuesource.qml
+++ /dev/null
@@ -1,14 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 400
- height: 400
- Rectangle {
- id: rect
- objectName: "MyRect"
- color: "red"
- width: 50; height: 50
- x: 100; y: 100
- NumberAnimation on x { id: anim; objectName: "MyAnim"; to: 200 }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/valuesource2.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/valuesource2.qml
deleted file mode 100644
index f6343a1bff..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/data/valuesource2.qml
+++ /dev/null
@@ -1,14 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 400
- height: 400
- Rectangle {
- id: rect
- objectName: "MyRect"
- color: "red"
- width: 50; height: 50
- x: 100; y: 100
- NumberAnimation on x { id: anim; objectName: "MyAnim"; running: false; to: 200 }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/qdeclarativeanimations.pro b/tests/auto/qtquick1/qdeclarativeanimations/qdeclarativeanimations.pro
deleted file mode 100644
index 7998a069b6..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/qdeclarativeanimations.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeanimations
-SOURCES += tst_qdeclarativeanimations.cpp
-macx:CONFIG -= app_bundle
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-CONFIG += parallel_test
-
-QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib
diff --git a/tests/auto/qtquick1/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/qtquick1/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
deleted file mode 100644
index 8e51361baa..0000000000
--- a/tests/auto/qtquick1/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
+++ /dev/null
@@ -1,877 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick1/qdeclarativeview.h>
-#include <QtQuick1/private/qdeclarativerectangle_p.h>
-#include <QtQuick1/private/qdeclarativeanimation_p.h>
-#include <QtQuick1/private/qdeclarativeitem_p.h>
-#include <QVariantAnimation>
-#include <QEasingCurve>
-
-class tst_qdeclarativeanimations : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativeanimations() {}
-
-private slots:
- void initTestCase() { QDeclarativeEngine engine; } // ensure types are registered
-
- void simpleProperty();
- void simpleNumber();
- void simpleColor();
- void simpleRotation();
- void alwaysRunToEnd();
- void complete();
- void resume();
- void dotProperty();
- void badTypes();
- void badProperties();
- void mixedTypes();
- void properties();
- void propertiesTransition();
- void invalidDuration();
- void attached();
- void propertyValueSourceDefaultStart();
- void dontStart();
- void easingProperties();
- void rotation();
- void runningTrueBug();
- void nonTransitionBug();
- void registrationBug();
- void doubleRegistrationBug();
- void alwaysRunToEndRestartBug();
- void transitionAssignmentBug();
- void pauseBug();
-};
-
-#define QTIMED_COMPARE(lhs, rhs) do { \
- for (int ii = 0; ii < 5; ++ii) { \
- if (lhs == rhs) \
- break; \
- QTest::qWait(50); \
- } \
- QCOMPARE(lhs, rhs); \
-} while (false)
-
-void tst_qdeclarativeanimations::simpleProperty()
-{
- QDeclarative1Rectangle rect;
- QDeclarative1PropertyAnimation animation;
- animation.setTarget(&rect);
- animation.setProperty("pos");
- animation.setTo(QPointF(200,200));
- QVERIFY(animation.target() == &rect);
- QVERIFY(animation.property() == "pos");
- QVERIFY(animation.to().toPointF() == QPointF(200,200));
- animation.start();
- QVERIFY(animation.isRunning());
- QTest::qWait(animation.duration());
- QTIMED_COMPARE(rect.pos(), QPointF(200,200));
-
- rect.setPos(0,0);
- animation.start();
- animation.pause();
- QVERIFY(animation.isRunning());
- QVERIFY(animation.isPaused());
- animation.setCurrentTime(125);
- QVERIFY(animation.currentTime() == 125);
- QCOMPARE(rect.pos(), QPointF(100,100));
-}
-
-void tst_qdeclarativeanimations::simpleNumber()
-{
- QDeclarative1Rectangle rect;
- QDeclarative1NumberAnimation animation;
- animation.setTarget(&rect);
- animation.setProperty("x");
- animation.setTo(200);
- QVERIFY(animation.target() == &rect);
- QVERIFY(animation.property() == "x");
- QVERIFY(animation.to() == 200);
- animation.start();
- QVERIFY(animation.isRunning());
- QTest::qWait(animation.duration());
- QTIMED_COMPARE(rect.x(), qreal(200));
-
- rect.setX(0);
- animation.start();
- animation.pause();
- QVERIFY(animation.isRunning());
- QVERIFY(animation.isPaused());
- animation.setCurrentTime(125);
- QVERIFY(animation.currentTime() == 125);
- QCOMPARE(rect.x(), qreal(100));
-}
-
-void tst_qdeclarativeanimations::simpleColor()
-{
- QDeclarative1Rectangle rect;
- QDeclarative1ColorAnimation animation;
- animation.setTarget(&rect);
- animation.setProperty("color");
- animation.setTo(QColor("red"));
- QVERIFY(animation.target() == &rect);
- QVERIFY(animation.property() == "color");
- QVERIFY(animation.to() == QColor("red"));
- animation.start();
- QVERIFY(animation.isRunning());
- QTest::qWait(animation.duration());
- QTIMED_COMPARE(rect.color(), QColor("red"));
-
- rect.setColor(QColor("blue"));
- animation.start();
- animation.pause();
- QVERIFY(animation.isRunning());
- QVERIFY(animation.isPaused());
- animation.setCurrentTime(125);
- QVERIFY(animation.currentTime() == 125);
- QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1));
-
- rect.setColor(QColor("green"));
- animation.setFrom(QColor("blue"));
- QVERIFY(animation.from() == QColor("blue"));
- animation.restart();
- QCOMPARE(rect.color(), QColor("blue"));
- QVERIFY(animation.isRunning());
- animation.setCurrentTime(125);
- QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1));
-}
-
-void tst_qdeclarativeanimations::simpleRotation()
-{
- QDeclarative1Rectangle rect;
- QDeclarative1RotationAnimation animation;
- animation.setTarget(&rect);
- animation.setProperty("rotation");
- animation.setTo(270);
- QVERIFY(animation.target() == &rect);
- QVERIFY(animation.property() == "rotation");
- QVERIFY(animation.to() == 270);
- QVERIFY(animation.direction() == QDeclarative1RotationAnimation::Numerical);
- animation.start();
- QVERIFY(animation.isRunning());
- QTest::qWait(animation.duration());
- QTIMED_COMPARE(rect.rotation(), qreal(270));
-
- rect.setRotation(0);
- animation.start();
- animation.pause();
- QVERIFY(animation.isRunning());
- QVERIFY(animation.isPaused());
- animation.setCurrentTime(125);
- QVERIFY(animation.currentTime() == 125);
- QCOMPARE(rect.rotation(), qreal(135));
-}
-
-void tst_qdeclarativeanimations::alwaysRunToEnd()
-{
- QDeclarative1Rectangle rect;
- QDeclarative1PropertyAnimation animation;
- animation.setTarget(&rect);
- animation.setProperty("x");
- animation.setTo(200);
- animation.setDuration(1000);
- animation.setLoops(-1);
- animation.setAlwaysRunToEnd(true);
- QVERIFY(animation.loops() == -1);
- QVERIFY(animation.alwaysRunToEnd() == true);
- animation.start();
- QTest::qWait(1500);
- animation.stop();
- QVERIFY(rect.x() != qreal(200));
- QTest::qWait(500);
- QTIMED_COMPARE(rect.x(), qreal(200));
-}
-
-void tst_qdeclarativeanimations::complete()
-{
- QDeclarative1Rectangle rect;
- QDeclarative1PropertyAnimation animation;
- animation.setTarget(&rect);
- animation.setProperty("x");
- animation.setFrom(1);
- animation.setTo(200);
- animation.setDuration(500);
- QVERIFY(animation.from() == 1);
- animation.start();
- QTest::qWait(50);
- animation.stop();
- QVERIFY(rect.x() != qreal(200));
- animation.start();
- QTest::qWait(50);
- QVERIFY(animation.isRunning());
- animation.complete();
- QCOMPARE(rect.x(), qreal(200));
-}
-
-void tst_qdeclarativeanimations::resume()
-{
- QDeclarative1Rectangle rect;
- QDeclarative1PropertyAnimation animation;
- animation.setTarget(&rect);
- animation.setProperty("x");
- animation.setFrom(10);
- animation.setTo(200);
- animation.setDuration(1000);
- QVERIFY(animation.from() == 10);
-
- animation.start();
- QTest::qWait(400);
- animation.pause();
- qreal x = rect.x();
- QVERIFY(x != qreal(200) && x != qreal(10));
- QVERIFY(animation.isRunning());
- QVERIFY(animation.isPaused());
-
- animation.resume();
- QVERIFY(animation.isRunning());
- QVERIFY(!animation.isPaused());
- QTest::qWait(400);
- animation.stop();
- QVERIFY(rect.x() > x);
-}
-
-void tst_qdeclarativeanimations::dotProperty()
-{
- QDeclarativeEngine engine;
- QString componentStr = "import QtQuick 1.0\nRectangle{ id: rect; NumberAnimation{ objectName: \"anim\"; target: rect; property: \"border.width\"; to: 10 }}";
- QDeclarativeComponent animationComponent(&engine);
- animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(animationComponent.create());
- QVERIFY(rect);
- QDeclarative1NumberAnimation *animation = rect->findChild<QDeclarative1NumberAnimation*>("anim");
- QVERIFY(animation);
-
- animation->start();
- QTest::qWait(animation->duration()+50);
- QTIMED_COMPARE(rect->border()->width(), 10);
-
- rect->border()->setWidth(0);
- animation->start();
- animation->pause();
- animation->setCurrentTime(125);
- QVERIFY(animation->currentTime() == 125);
- QCOMPARE(rect->border()->width(), 5);
-
- delete rect;
-}
-
-void tst_qdeclarativeanimations::badTypes()
-{
- //don't crash
- {
- QDeclarativeView *view = new QDeclarativeView;
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/badtype1.qml"));
-
- qApp->processEvents();
-
- delete view;
- }
-
- //make sure we get a compiler error
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/badtype2.qml"));
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
- c.create();
-
- QVERIFY(c.errors().count() == 1);
- QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: number expected"));
- }
-
- //make sure we get a compiler error
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/badtype3.qml"));
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
- c.create();
-
- QVERIFY(c.errors().count() == 1);
- QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: color expected"));
- }
-
- //don't crash
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/badtype4.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarativeItemPrivate::get(rect)->setState("state1");
- QTest::qWait(1000 + 50);
- QDeclarative1Rectangle *myRect = rect->findChild<QDeclarative1Rectangle*>("MyRect");
- QVERIFY(myRect);
- QCOMPARE(myRect->x(),qreal(200));
- }
-}
-
-void tst_qdeclarativeanimations::badProperties()
-{
- //make sure we get a runtime error
- {
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c1(&engine, QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml"));
- QByteArray message = QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate non-existent property \"border.colr\"";
- QTest::ignoreMessage(QtWarningMsg, message);
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c1.create());
- QVERIFY(rect);
-
- QDeclarativeComponent c2(&engine, QUrl::fromLocalFile(SRCDIR "/data/badproperty2.qml"));
- message = QUrl::fromLocalFile(SRCDIR "/data/badproperty2.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate read-only property \"border\"";
- QTest::ignoreMessage(QtWarningMsg, message);
- rect = qobject_cast<QDeclarative1Rectangle*>(c2.create());
- QVERIFY(rect);
-
- //### should we warn here are well?
- //rect->setState("state1");
- }
-}
-
-//test animating mixed types with property animation in a transition
-//for example, int + real; color + real; etc
-void tst_qdeclarativeanimations::mixedTypes()
-{
- //assumes border.width stays a real -- not real robust
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/mixedtype1.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarativeItemPrivate::get(rect)->setState("state1");
- QTest::qWait(500);
- QDeclarative1Rectangle *myRect = rect->findChild<QDeclarative1Rectangle*>("MyRect");
- QVERIFY(myRect);
-
- //rather inexact -- is there a better way?
- QVERIFY(myRect->x() > 100 && myRect->x() < 200);
- QVERIFY(myRect->border()->width() > 1 && myRect->border()->width() < 10);
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/mixedtype2.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarativeItemPrivate::get(rect)->setState("state1");
- QTest::qWait(500);
- QDeclarative1Rectangle *myRect = rect->findChild<QDeclarative1Rectangle*>("MyRect");
- QVERIFY(myRect);
-
- //rather inexact -- is there a better way?
- QVERIFY(myRect->x() > 100 && myRect->x() < 200);
- QVERIFY(myRect->color() != QColor("red") && myRect->color() != QColor("blue"));
- }
-}
-
-void tst_qdeclarativeanimations::properties()
-{
- const int waitDuration = 300;
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarative1Rectangle *myRect = rect->findChild<QDeclarative1Rectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(200));
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties2.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarative1Rectangle *myRect = rect->findChild<QDeclarative1Rectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(200));
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties3.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarative1Rectangle *myRect = rect->findChild<QDeclarative1Rectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(300));
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties4.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarative1Rectangle *myRect = rect->findChild<QDeclarative1Rectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->y(),qreal(200));
- QTIMED_COMPARE(myRect->x(),qreal(100));
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties5.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarative1Rectangle *myRect = rect->findChild<QDeclarative1Rectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(100));
- QTIMED_COMPARE(myRect->y(),qreal(200));
- }
-}
-
-void tst_qdeclarativeanimations::propertiesTransition()
-{
- const int waitDuration = 300;
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarativeItemPrivate::get(rect)->setState("moved");
- QDeclarative1Rectangle *myRect = rect->findChild<QDeclarative1Rectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(200));
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition2.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarative1Rectangle *myRect = rect->findChild<QDeclarative1Rectangle*>("TheRect");
- QVERIFY(myRect);
- QDeclarativeItemPrivate::get(rect)->setState("moved");
- QCOMPARE(myRect->x(),qreal(200));
- QCOMPARE(myRect->y(),qreal(100));
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->y(),qreal(200));
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition3.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarative1Rectangle *myRect = rect->findChild<QDeclarative1Rectangle*>("TheRect");
- QVERIFY(myRect);
- QDeclarativeItemPrivate::get(rect)->setState("moved");
- QCOMPARE(myRect->x(),qreal(200));
- QCOMPARE(myRect->y(),qreal(100));
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition4.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarative1Rectangle *myRect = rect->findChild<QDeclarative1Rectangle*>("TheRect");
- QVERIFY(myRect);
- QDeclarativeItemPrivate::get(rect)->setState("moved");
- QCOMPARE(myRect->x(),qreal(100));
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(200));
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition5.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarative1Rectangle *myRect = rect->findChild<QDeclarative1Rectangle*>("TheRect");
- QVERIFY(myRect);
- QDeclarativeItemPrivate::get(rect)->setState("moved");
- QCOMPARE(myRect->x(),qreal(100));
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(200));
- }
-
- /*{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition6.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarative1Rectangle *myRect = rect->findChild<QDeclarative1Rectangle*>("TheRect");
- QVERIFY(myRect);
- QDeclarativeItemPrivate::get(rect)->setState("moved");
- QCOMPARE(myRect->x(),qreal(100));
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(100));
- }*/
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition7.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarativeItemPrivate::get(rect)->setState("moved");
- QDeclarative1Rectangle *myRect = rect->findChild<QDeclarative1Rectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(200));
- }
-
-}
-
-void tst_qdeclarativeanimations::invalidDuration()
-{
- QDeclarative1PropertyAnimation *animation = new QDeclarative1PropertyAnimation;
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML PropertyAnimation: Cannot set a duration of < 0");
- animation->setDuration(-1);
- QCOMPARE(animation->duration(), 250);
-
- QDeclarative1PauseAnimation *pauseAnimation = new QDeclarative1PauseAnimation;
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML PauseAnimation: Cannot set a duration of < 0");
- pauseAnimation->setDuration(-1);
- QCOMPARE(pauseAnimation->duration(), 250);
-}
-
-void tst_qdeclarativeanimations::attached()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/attached.qml"));
- QTest::ignoreMessage(QtDebugMsg, "off");
- QTest::ignoreMessage(QtDebugMsg, "on");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-}
-
-void tst_qdeclarativeanimations::propertyValueSourceDefaultStart()
-{
- {
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/valuesource.qml"));
-
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarative1AbstractAnimation *myAnim = rect->findChild<QDeclarative1AbstractAnimation*>("MyAnim");
- QVERIFY(myAnim);
- QVERIFY(myAnim->isRunning());
- }
-
- {
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/valuesource2.qml"));
-
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarative1AbstractAnimation *myAnim = rect->findChild<QDeclarative1AbstractAnimation*>("MyAnim");
- QVERIFY(myAnim);
- QVERIFY(myAnim->isRunning() == false);
- }
-
- {
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontAutoStart.qml"));
-
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarative1AbstractAnimation *myAnim = rect->findChild<QDeclarative1AbstractAnimation*>("MyAnim");
- QVERIFY(myAnim && myAnim->qtAnimation());
- QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
- }
-}
-
-
-void tst_qdeclarativeanimations::dontStart()
-{
- {
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart.qml"));
-
- QString warning = c.url().toString() + ":14:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes.";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarative1AbstractAnimation *myAnim = rect->findChild<QDeclarative1AbstractAnimation*>("MyAnim");
- QVERIFY(myAnim && myAnim->qtAnimation());
- QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
- }
-
- {
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart2.qml"));
-
- QString warning = c.url().toString() + ":15:17: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes.";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarative1AbstractAnimation *myAnim = rect->findChild<QDeclarative1AbstractAnimation*>("MyAnim");
- QVERIFY(myAnim && myAnim->qtAnimation());
- QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
- }
-}
-
-void tst_qdeclarativeanimations::easingProperties()
-{
- {
- QDeclarativeEngine engine;
- QString componentStr = "import QtQuick 1.0\nNumberAnimation { easing.type: \"InOutQuad\" }";
- QDeclarativeComponent animationComponent(&engine);
- animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1PropertyAnimation *animObject = qobject_cast<QDeclarative1PropertyAnimation*>(animationComponent.create());
-
- QVERIFY(animObject != 0);
- QCOMPARE(animObject->easing().type(), QEasingCurve::InOutQuad);
- }
-
- {
- QDeclarativeEngine engine;
- QString componentStr = "import QtQuick 1.0\nPropertyAnimation { easing.type: \"OutBounce\"; easing.amplitude: 5.0 }";
- QDeclarativeComponent animationComponent(&engine);
- animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1PropertyAnimation *animObject = qobject_cast<QDeclarative1PropertyAnimation*>(animationComponent.create());
-
- QVERIFY(animObject != 0);
- QCOMPARE(animObject->easing().type(), QEasingCurve::OutBounce);
- QCOMPARE(animObject->easing().amplitude(), 5.0);
- }
-
- {
- QDeclarativeEngine engine;
- QString componentStr = "import QtQuick 1.0\nPropertyAnimation { easing.type: \"OutElastic\"; easing.amplitude: 5.0; easing.period: 3.0}";
- QDeclarativeComponent animationComponent(&engine);
- animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1PropertyAnimation *animObject = qobject_cast<QDeclarative1PropertyAnimation*>(animationComponent.create());
-
- QVERIFY(animObject != 0);
- QCOMPARE(animObject->easing().type(), QEasingCurve::OutElastic);
- QCOMPARE(animObject->easing().amplitude(), 5.0);
- QCOMPARE(animObject->easing().period(), 3.0);
- }
-
- {
- QDeclarativeEngine engine;
- QString componentStr = "import QtQuick 1.0\nPropertyAnimation { easing.type: \"InOutBack\"; easing.overshoot: 2 }";
- QDeclarativeComponent animationComponent(&engine);
- animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1PropertyAnimation *animObject = qobject_cast<QDeclarative1PropertyAnimation*>(animationComponent.create());
-
- QVERIFY(animObject != 0);
- QCOMPARE(animObject->easing().type(), QEasingCurve::InOutBack);
- QCOMPARE(animObject->easing().overshoot(), 2.0);
- }
-}
-
-void tst_qdeclarativeanimations::rotation()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/rotation.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarative1Rectangle *rr = rect->findChild<QDeclarative1Rectangle*>("rr");
- QDeclarative1Rectangle *rr2 = rect->findChild<QDeclarative1Rectangle*>("rr2");
- QDeclarative1Rectangle *rr3 = rect->findChild<QDeclarative1Rectangle*>("rr3");
- QDeclarative1Rectangle *rr4 = rect->findChild<QDeclarative1Rectangle*>("rr4");
-
- QDeclarativeItemPrivate::get(rect)->setState("state1");
- QTest::qWait(800);
- qreal r1 = rr->rotation();
- qreal r2 = rr2->rotation();
- qreal r3 = rr3->rotation();
- qreal r4 = rr4->rotation();
-
- QVERIFY(r1 > qreal(0) && r1 < qreal(370));
- QVERIFY(r2 > qreal(0) && r2 < qreal(370));
- QVERIFY(r3 < qreal(0) && r3 > qreal(-350));
- QVERIFY(r4 > qreal(0) && r4 < qreal(10));
- QCOMPARE(r1,r2);
- QVERIFY(r4 < r2);
-
- QTest::qWait(800);
- QTIMED_COMPARE(rr->rotation() + rr2->rotation() + rr3->rotation() + rr4->rotation(), qreal(370*4));
-}
-
-void tst_qdeclarativeanimations::runningTrueBug()
-{
- //ensure we start correctly when "running: true" is explicitly set
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/runningTrueBug.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarative1Rectangle *cloud = rect->findChild<QDeclarative1Rectangle*>("cloud");
- QVERIFY(cloud);
- QTest::qWait(1000);
- QVERIFY(cloud->x() > qreal(0));
-}
-
-//QTBUG-12805
-void tst_qdeclarativeanimations::nonTransitionBug()
-{
- //tests that the animation values from the previous transition are properly cleared
- //in the case where an animation in the transition doesn't match anything (but previously did)
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, SRCDIR "/data/nonTransitionBug.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect != 0);
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
- QDeclarative1Rectangle *mover = rect->findChild<QDeclarative1Rectangle*>("mover");
-
- mover->setX(100);
- QCOMPARE(mover->x(), qreal(100));
-
- rectPrivate->setState("left");
- QTRY_COMPARE(mover->x(), qreal(0));
-
- mover->setX(100);
- QCOMPARE(mover->x(), qreal(100));
-
- //make sure we don't try to animate back to 0
- rectPrivate->setState("free");
- QTest::qWait(300);
- QCOMPARE(mover->x(), qreal(100));
-}
-
-//QTBUG-14042
-void tst_qdeclarativeanimations::registrationBug()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, SRCDIR "/data/registrationBug.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect != 0);
- QTRY_COMPARE(rect->property("value"), QVariant(int(100)));
-}
-
-void tst_qdeclarativeanimations::doubleRegistrationBug()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, SRCDIR "/data/doubleRegistrationBug.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QDeclarative1AbstractAnimation *anim = rect->findChild<QDeclarative1AbstractAnimation*>("animation");
- QVERIFY(anim != 0);
- QTRY_COMPARE(anim->qtAnimation()->state(), QAbstractAnimation::Stopped);
-}
-
-//QTBUG-16736
-void tst_qdeclarativeanimations::alwaysRunToEndRestartBug()
-{
- QDeclarative1Rectangle rect;
- QDeclarative1PropertyAnimation animation;
- animation.setTarget(&rect);
- animation.setProperty("x");
- animation.setTo(200);
- animation.setDuration(1000);
- animation.setLoops(-1);
- animation.setAlwaysRunToEnd(true);
- QVERIFY(animation.loops() == -1);
- QVERIFY(animation.alwaysRunToEnd() == true);
- animation.start();
- animation.stop();
- animation.start();
- animation.stop();
- QTest::qWait(500);
- QVERIFY(rect.x() != qreal(200));
- QTest::qWait(800);
- QTIMED_COMPARE(rect.x(), qreal(200));
- QCOMPARE(static_cast<QDeclarative1AbstractAnimation*>(&animation)->qtAnimation()->state(), QAbstractAnimation::Stopped);
-}
-
-//QTBUG-20227
-void tst_qdeclarativeanimations::transitionAssignmentBug()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, SRCDIR "/data/transitionAssignmentBug.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->property("nullObject").toBool(), false);
-}
-
-//QTBUG-13598
-void tst_qdeclarativeanimations::pauseBug()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, SRCDIR "/data/pauseBug.qml");
- QDeclarative1AbstractAnimation *anim = qobject_cast<QDeclarative1AbstractAnimation*>(c.create());
- QVERIFY(anim != 0);
- QCOMPARE(anim->qtAnimation()->state(), QAbstractAnimation::Paused);
- QCOMPARE(anim->isPaused(), true);
- QCOMPARE(anim->isRunning(), true);
-
- delete anim;
-}
-
-QTEST_MAIN(tst_qdeclarativeanimations)
-
-#include "tst_qdeclarativeanimations.moc"
diff --git a/tests/auto/qtquick1/qdeclarativeapplication/qdeclarativeapplication.pro b/tests/auto/qtquick1/qdeclarativeapplication/qdeclarativeapplication.pro
deleted file mode 100644
index d74cbff668..0000000000
--- a/tests/auto/qtquick1/qdeclarativeapplication/qdeclarativeapplication.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeapplication
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeapplication.cpp
-QT += core-private gui-private widgets-private declarative-private qtquick1-private testlib
diff --git a/tests/auto/qtquick1/qdeclarativeapplication/tst_qdeclarativeapplication.cpp b/tests/auto/qtquick1/qdeclarativeapplication/tst_qdeclarativeapplication.cpp
deleted file mode 100644
index 297b40c5f4..0000000000
--- a/tests/auto/qtquick1/qdeclarativeapplication/tst_qdeclarativeapplication.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtQuick1/qdeclarativeitem.h>
-#include <QtWidgets/qgraphicsview.h>
-#include <QtWidgets/QGraphicsScene>
-
-class tst_qdeclarativeapplication : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativeapplication();
-
-private slots:
- void active();
- void layoutDirection();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_qdeclarativeapplication::tst_qdeclarativeapplication()
-{
-}
-
-void tst_qdeclarativeapplication::active()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 1.0; Item { property bool active: Qt.application.active }", QUrl::fromLocalFile(""));
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(component.create());
- QVERIFY(item);
- QGraphicsScene scene;
- QGraphicsView view(&scene);
- scene.addItem(item);
-
- // not active
- QVERIFY(!item->property("active").toBool());
- QCOMPARE(item->property("active").toBool(), QApplication::activeWindow() != 0);
-
- // active
- view.show();
- QApplication::setActiveWindow(&view);
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
- QCOMPARE(item->property("active").toBool(), QApplication::activeWindow() != 0);
-
- // not active again
- // on mac, setActiveWindow(0) on mac does not deactivate the current application
- // (you have to switch to a different app or hide the current app to trigger this)
-#if !defined(Q_WS_MAC)
- QApplication::setActiveWindow(0);
- QVERIFY(!item->property("active").toBool());
- QCOMPARE(item->property("active").toBool(), QApplication::activeWindow() != 0);
-#endif
-}
-
-void tst_qdeclarativeapplication::layoutDirection()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 1.0; Item { property bool layoutDirection: Qt.application.layoutDirection }", QUrl::fromLocalFile(""));
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(component.create());
- QVERIFY(item);
- QGraphicsScene scene;
- QGraphicsView view(&scene);
- scene.addItem(item);
-
- // not mirrored
- QCOMPARE(Qt::LayoutDirection(item->property("layoutDirection").toInt()), Qt::LeftToRight);
-
- // mirrored
- QApplication::setLayoutDirection(Qt::RightToLeft);
- QCOMPARE(Qt::LayoutDirection(item->property("layoutDirection").toInt()), Qt::RightToLeft);
-
- // not mirrored again
- QApplication::setLayoutDirection(Qt::LeftToRight);
- QCOMPARE(Qt::LayoutDirection(item->property("layoutDirection").toInt()), Qt::LeftToRight);
-}
-
-QTEST_MAIN(tst_qdeclarativeapplication)
-
-#include "tst_qdeclarativeapplication.moc"
diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/binding.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/binding.qml
deleted file mode 100644
index a452447f31..0000000000
--- a/tests/auto/qtquick1/qdeclarativebehaviors/data/binding.qml
+++ /dev/null
@@ -1,26 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- width: 400
- height: 400
- property real basex : 0
- property real movedx: 200
- Rectangle {
- id: rect
- objectName: "MyRect"
- width: 100; height: 100; color: "green"
- x: basex
- Behavior on x { NumberAnimation { duration: 800; } }
- }
- MouseArea {
- id: clicker
- anchors.fill: parent
- }
- states: State {
- name: "moved"
- when: clicker.pressed
- PropertyChanges {
- target: rect
- x: movedx
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/color.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/color.qml
deleted file mode 100644
index c4b783a0f0..0000000000
--- a/tests/auto/qtquick1/qdeclarativebehaviors/data/color.qml
+++ /dev/null
@@ -1,24 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- width: 400
- height: 400
- Rectangle {
- id: rect
- objectName: "MyRect"
- width: 100; height: 100;
- color: "green"
- Behavior on color { ColorAnimation { duration: 500; } }
- }
- MouseArea {
- id: clicker
- anchors.fill: parent
- }
- states: State {
- name: "red"
- when: clicker.pressed
- PropertyChanges {
- target: rect
- color: "red"
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/cpptrigger.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/cpptrigger.qml
deleted file mode 100644
index 88ddfaa1a7..0000000000
--- a/tests/auto/qtquick1/qdeclarativebehaviors/data/cpptrigger.qml
+++ /dev/null
@@ -1,11 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- width: 400
- height: 400
- Rectangle {
- id: rect
- objectName: "MyRect"
- width: 100; height: 100; color: "green"
- Behavior on x { NumberAnimation { duration: 500; } }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/delayedRegistration.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/delayedRegistration.qml
deleted file mode 100644
index aa384c335f..0000000000
--- a/tests/auto/qtquick1/qdeclarativebehaviors/data/delayedRegistration.qml
+++ /dev/null
@@ -1,25 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: container
-
- width: 400; height: 400;
- property Item myItem
-
- function doCreate() {
- myItem = myComponent.createObject(container)
- myItem.x = 100
- }
-
- Component {
- id: myComponent
- Rectangle {
- width: 100
- height: 100
- color: "green"
- Behavior on x { NumberAnimation { duration: 500 } }
- }
- }
-
- Component.onCompleted: doCreate()
-}
diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/disabled.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/disabled.qml
deleted file mode 100644
index f6cfa5e33d..0000000000
--- a/tests/auto/qtquick1/qdeclarativebehaviors/data/disabled.qml
+++ /dev/null
@@ -1,27 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- width: 400
- height: 400
- Rectangle {
- id: rect
- objectName: "MyRect"
- width: 100; height: 100; color: "green"
- Behavior on x {
- objectName: "MyBehavior";
- enabled: false
- NumberAnimation { duration: 200; }
- }
- }
- MouseArea {
- id: clicker
- anchors.fill: parent
- }
- states: State {
- name: "moved"
- when: clicker.pressed
- PropertyChanges {
- target: rect
- x: 200
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/dontStart.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/dontStart.qml
deleted file mode 100644
index e318dd2567..0000000000
--- a/tests/auto/qtquick1/qdeclarativebehaviors/data/dontStart.qml
+++ /dev/null
@@ -1,18 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: wrapper
- width: 600
- height: 400
-
- Rectangle {
- id: redRect
- width: 100; height: 100
- color: Qt.rgba(1,0,0)
- Behavior on x {
- NumberAnimation {id: myAnim; objectName: "MyAnim"; running: true }
- }
-
- }
-
-}
diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/empty.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/empty.qml
deleted file mode 100644
index 6c78a84540..0000000000
--- a/tests/auto/qtquick1/qdeclarativebehaviors/data/empty.qml
+++ /dev/null
@@ -1,23 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- width: 400
- height: 400
- Rectangle {
- id: rect
- objectName: "MyRect"
- width: 100; height: 100; color: "green"
- Behavior on x {}
- }
- MouseArea {
- id: clicker
- anchors.fill: parent
- }
- states: State {
- name: "moved"
- when: clicker.pressed
- PropertyChanges {
- target: rect
- x: 200
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/explicit.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/explicit.qml
deleted file mode 100644
index 3baa1ac23a..0000000000
--- a/tests/auto/qtquick1/qdeclarativebehaviors/data/explicit.qml
+++ /dev/null
@@ -1,26 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- width: 400
- height: 400
- Rectangle {
- id: rect
- objectName: "MyRect"
- width: 100; height: 100; color: "green"
- Behavior on x {
- objectName: "MyBehavior";
- NumberAnimation { target: rect; property: "x"; duration: 500; }
- }
- }
- MouseArea {
- id: clicker
- anchors.fill: parent
- }
- states: State {
- name: "moved"
- when: clicker.pressed
- PropertyChanges {
- target: rect
- x: 200
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/groupProperty.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/groupProperty.qml
deleted file mode 100644
index ddb5bbd40c..0000000000
--- a/tests/auto/qtquick1/qdeclarativebehaviors/data/groupProperty.qml
+++ /dev/null
@@ -1,23 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- width: 400
- height: 400
- Rectangle {
- id: rect
- objectName: "MyRect"
- width: 100; height: 100; color: "green"
- Behavior on pos { PropertyAnimation { duration: 500; } }
- }
- MouseArea {
- id: clicker
- anchors.fill: parent
- }
- states: State {
- name: "moved"
- when: clicker.pressed
- PropertyChanges {
- target: rect
- pos: Qt.point(200,0);
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/groupProperty2.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/groupProperty2.qml
deleted file mode 100644
index c0b71cdb04..0000000000
--- a/tests/auto/qtquick1/qdeclarativebehaviors/data/groupProperty2.qml
+++ /dev/null
@@ -1,23 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- width: 400
- height: 400
- Rectangle {
- id: rect
- objectName: "MyRect"
- width: 100; height: 100; color: "green"
- Behavior on pos.x { NumberAnimation { duration: 500; } }
- }
- MouseArea {
- id: clicker
- anchors.fill: parent
- }
- states: State {
- name: "moved"
- when: clicker.pressed
- PropertyChanges {
- target: rect
- pos.x: 200;
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/groupedPropertyCrash.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/groupedPropertyCrash.qml
deleted file mode 100644
index 8aa590bca1..0000000000
--- a/tests/auto/qtquick1/qdeclarativebehaviors/data/groupedPropertyCrash.qml
+++ /dev/null
@@ -1,10 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 200
- height: 200
- Text {
- Behavior on anchors.verticalCenterOffset { NumberAnimation { duration: 300; } }
- text: "Hello World"
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/loop.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/loop.qml
deleted file mode 100644
index 76379c00a2..0000000000
--- a/tests/auto/qtquick1/qdeclarativebehaviors/data/loop.qml
+++ /dev/null
@@ -1,19 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- width: 400
- height: 400
- Rectangle {
- id: rect
- objectName: "MyRect"
- width: 100; height: 100; color: "green"
- Behavior on x { NumberAnimation { duration: 200; } }
- onXChanged: x = 100;
- }
- states: State {
- name: "moved"
- PropertyChanges {
- target: rect
- x: 200
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/nonSelecting2.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/nonSelecting2.qml
deleted file mode 100644
index c5c78d1aa2..0000000000
--- a/tests/auto/qtquick1/qdeclarativebehaviors/data/nonSelecting2.qml
+++ /dev/null
@@ -1,26 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- width: 400
- height: 400
- Rectangle {
- id: rect
- objectName: "MyRect"
- width: 100; height: 100; color: "green"
- Behavior on x {
- objectName: "MyBehavior";
- NumberAnimation { targets: rect; properties: "y"; duration: 200; }
- }
- }
- MouseArea {
- id: clicker
- anchors.fill: parent
- }
- states: State {
- name: "moved"
- when: clicker.pressed
- PropertyChanges {
- target: rect
- x: 200
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/parent.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/parent.qml
deleted file mode 100644
index d19da298b2..0000000000
--- a/tests/auto/qtquick1/qdeclarativebehaviors/data/parent.qml
+++ /dev/null
@@ -1,28 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- width: 400
- height: 400
- Rectangle {
- id: rect
- objectName: "MyRect"
- width: 100; height: 100; color: "green"
- Behavior on parent {
- SequentialAnimation {
- PauseAnimation { duration: 500 }
- PropertyAction {}
- }
- }
- }
- Item {
- id: newParent
- objectName: "NewParent"
- x: 100
- }
- states: State {
- name: "reparented"
- PropertyChanges {
- target: rect
- parent: newParent
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/qtbug12295.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/qtbug12295.qml
deleted file mode 100644
index 03b542164b..0000000000
--- a/tests/auto/qtquick1/qdeclarativebehaviors/data/qtbug12295.qml
+++ /dev/null
@@ -1,17 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 200
- height: 200
- color: "blue"
-
- Rectangle {
- id: myRect
- objectName: "myRect"
- width: 100
- height: 100
- Behavior on x {
- NumberAnimation { duration: 500 }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/reassignedAnimation.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/reassignedAnimation.qml
deleted file mode 100644
index 56ac216c5a..0000000000
--- a/tests/auto/qtquick1/qdeclarativebehaviors/data/reassignedAnimation.qml
+++ /dev/null
@@ -1,32 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- width: 400
- height: 400
- Rectangle {
- id: rect
- objectName: "MyRect"
- width: 100; height: 100; color: "green"
- Behavior on x {
- id: myBehavior
- objectName: "MyBehavior"
- NumberAnimation {id: na1; duration: 200 }
- }
- }
- MouseArea {
- id: clicker
- anchors.fill: parent
- }
- states: State {
- name: "moved"
- when: clicker.pressed
- PropertyChanges {
- target: rect
- x: 200
- }
- }
-
- NumberAnimation {id: na2; duration: 1000 }
- Component.onCompleted: {
- myBehavior.animation = na2;
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/runningTrue.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/runningTrue.qml
deleted file mode 100644
index 25cdf10acf..0000000000
--- a/tests/auto/qtquick1/qdeclarativebehaviors/data/runningTrue.qml
+++ /dev/null
@@ -1,20 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: root
- width:200; height:200
-
- property real myValue: 0
-
- Rectangle {
- anchors.centerIn: parent
- width: 100
- height: 100
- color: "green"
- smooth: true
- rotation: myValue
- Behavior on rotation {
- RotationAnimation { id: rotAnim; objectName: "rotAnim"; direction: RotationAnimation.Shortest }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/scripttrigger.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/scripttrigger.qml
deleted file mode 100644
index c05cdaa940..0000000000
--- a/tests/auto/qtquick1/qdeclarativebehaviors/data/scripttrigger.qml
+++ /dev/null
@@ -1,16 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- width: 400
- height: 400
-
- onColorChanged: {
- rect.x = 200
- }
-
- Rectangle {
- id: rect
- objectName: "MyRect"
- width: 100; height: 100; color: "green"
- Behavior on x { NumberAnimation { duration: 800; } }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/simple.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/simple.qml
deleted file mode 100644
index 6ba0118660..0000000000
--- a/tests/auto/qtquick1/qdeclarativebehaviors/data/simple.qml
+++ /dev/null
@@ -1,26 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- width: 400
- height: 400
- Rectangle {
- id: rect
- objectName: "MyRect"
- width: 100; height: 100; color: "green"
- Behavior on x {
- objectName: "MyBehavior";
- NumberAnimation {id: na; duration: 500; }
- }
- }
- MouseArea {
- id: clicker
- anchors.fill: parent
- }
- states: State {
- name: "moved"
- when: clicker.pressed
- PropertyChanges {
- target: rect
- x: 200
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/startup.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/startup.qml
deleted file mode 100644
index fca416c08c..0000000000
--- a/tests/auto/qtquick1/qdeclarativebehaviors/data/startup.qml
+++ /dev/null
@@ -1,17 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 400
- height: 400
-
- Rectangle {
- objectName: "innerRect"
- height: 100; width: 100; color: "green"
- property real targetX: 100
-
- x: targetX
- Behavior on x {
- NumberAnimation {}
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/startup2.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/startup2.qml
deleted file mode 100644
index eb627613d4..0000000000
--- a/tests/auto/qtquick1/qdeclarativebehaviors/data/startup2.qml
+++ /dev/null
@@ -1,16 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 800;
- height: 480;
-
- Text { id:theText; text: "hello world" }
-
- Rectangle {
- objectName: "innerRect"
- color: "red"
- x: theText.width
- Behavior on x { NumberAnimation {} }
- width: 100; height: 100
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/qdeclarativebehaviors.pro b/tests/auto/qtquick1/qdeclarativebehaviors/qdeclarativebehaviors.pro
deleted file mode 100644
index 76a89eb0eb..0000000000
--- a/tests/auto/qtquick1/qdeclarativebehaviors/qdeclarativebehaviors.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativebehaviors
-SOURCES += tst_qdeclarativebehaviors.cpp
-macx:CONFIG -= app_bundle
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test insignificant_test
-
-QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib
diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/qtquick1/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
deleted file mode 100644
index fab364ac78..0000000000
--- a/tests/auto/qtquick1/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
+++ /dev/null
@@ -1,429 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <qsignalspy.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick1/qdeclarativeview.h>
-#include <QtQuick1/private/qdeclarativerectangle_p.h>
-#include <QtQuick1/private/qdeclarativetext_p.h>
-#include <QtQuick1/private/qdeclarativebehavior_p.h>
-#include <QtQuick1/private/qdeclarativeanimation_p.h>
-#include <QtQuick1/private/qdeclarativeitem_p.h>
-
-class tst_qdeclarativebehaviors : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativebehaviors() {}
-
-private slots:
- void simpleBehavior();
- void scriptTriggered();
- void cppTriggered();
- void loop();
- void colorBehavior();
- void parentBehavior();
- void replaceBinding();
- //void transitionOverrides();
- void group();
- void emptyBehavior();
- void explicitSelection();
- void nonSelectingBehavior();
- void reassignedAnimation();
- void disabled();
- void dontStart();
- void startup();
- void groupedPropertyCrash();
- void runningTrue();
- void sameValue();
- void delayedRegistration();
-};
-
-void tst_qdeclarativebehaviors::simpleBehavior()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/simple.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QTRY_VERIFY(rect);
- QTRY_VERIFY(qobject_cast<QDeclarative1Behavior*>(rect->findChild<QDeclarative1Behavior*>("MyBehavior"))->animation());
-
- QDeclarativeItemPrivate::get(rect)->setState("moved");
- QTRY_VERIFY(qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"))->x() > 0);
- QTRY_VERIFY(qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"))->x() < 200);
- //i.e. the behavior has been triggered
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::scriptTriggered()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/scripttrigger.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QTRY_VERIFY(rect);
-
- rect->setColor(QColor("red"));
- QTRY_VERIFY(qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"))->x() > 0);
- QTRY_VERIFY(qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"))->x() < 200);
- //i.e. the behavior has been triggered
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::cppTriggered()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/cpptrigger.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QTRY_VERIFY(rect);
-
- QDeclarative1Rectangle *innerRect = qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"));
- QTRY_VERIFY(innerRect);
-
- innerRect->setProperty("x", 200);
- QTRY_VERIFY(innerRect->x() > 0);
- QTRY_VERIFY(innerRect->x() < 200); //i.e. the behavior has been triggered
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::loop()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/loop.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QTRY_VERIFY(rect);
-
- //don't crash
- QDeclarativeItemPrivate::get(rect)->setState("moved");
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::colorBehavior()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/color.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QTRY_VERIFY(rect);
-
- QDeclarativeItemPrivate::get(rect)->setState("red");
- QTRY_VERIFY(qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"))->color() != QColor("red"));
- QTRY_VERIFY(qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"))->color() != QColor("green"));
- //i.e. the behavior has been triggered
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::parentBehavior()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/parent.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QTRY_VERIFY(rect);
-
- QDeclarativeItemPrivate::get(rect)->setState("reparented");
- QTRY_VERIFY(rect->findChild<QDeclarative1Rectangle*>("MyRect")->parentItem() != rect->findChild<QDeclarativeItem*>("NewParent"));
- QTRY_VERIFY(rect->findChild<QDeclarative1Rectangle*>("MyRect")->parentItem() == rect->findChild<QDeclarativeItem*>("NewParent"));
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::replaceBinding()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/binding.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QTRY_VERIFY(rect);
-
- QDeclarativeItemPrivate::get(rect)->setState("moved");
- QDeclarative1Rectangle *innerRect = qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"));
- QTRY_VERIFY(innerRect);
- QTRY_VERIFY(innerRect->x() > 0);
- QTRY_VERIFY(innerRect->x() < 200);
- //i.e. the behavior has been triggered
- QTRY_COMPARE(innerRect->x(), (qreal)200);
- rect->setProperty("basex", 10);
- QTRY_COMPARE(innerRect->x(), (qreal)200);
- rect->setProperty("movedx", 210);
- QTRY_COMPARE(innerRect->x(), (qreal)210);
-
- QDeclarativeItemPrivate::get(rect)->setState("");
- QTRY_VERIFY(innerRect->x() > 10);
- QTRY_VERIFY(innerRect->x() < 210); //i.e. the behavior has been triggered
- QTRY_COMPARE(innerRect->x(), (qreal)10);
- rect->setProperty("movedx", 200);
- QTRY_COMPARE(innerRect->x(), (qreal)10);
- rect->setProperty("basex", 20);
- QTRY_COMPARE(innerRect->x(), (qreal)20);
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::group()
-{
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/groupProperty.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QTRY_VERIFY(rect);
-
- QDeclarativeItemPrivate::get(rect)->setState("moved");
- //QTest::qWait(200);
- QTRY_VERIFY(qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"))->x() > 0);
- QTRY_VERIFY(qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"))->x() < 200);
- //i.e. the behavior has been triggered
-
- delete rect;
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/groupProperty2.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QTRY_VERIFY(rect);
-
- QDeclarativeItemPrivate::get(rect)->setState("moved");
- QTRY_VERIFY(qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"))->x() > 0);
- QTRY_VERIFY(qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"))->x() < 200);
- //i.e. the behavior has been triggered
-
- delete rect;
- }
-}
-
-void tst_qdeclarativebehaviors::emptyBehavior()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/empty.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarativeItemPrivate::get(rect)->setState("moved");
- qreal x = qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"))->x();
- QCOMPARE(x, qreal(200)); //should change immediately
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::explicitSelection()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/explicit.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarativeItemPrivate::get(rect)->setState("moved");
- QTRY_VERIFY(qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"))->x() > 0);
- QTRY_VERIFY(qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"))->x() < 200);
- //i.e. the behavior has been triggered
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::nonSelectingBehavior()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/nonSelecting2.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarativeItemPrivate::get(rect)->setState("moved");
- qreal x = qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"))->x();
- QCOMPARE(x, qreal(200)); //should change immediately
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::reassignedAnimation()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml"));
- QString warning = QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml").toString() + ":9:9: QML Behavior: Cannot change the animation assigned to a Behavior.";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
- QCOMPARE(qobject_cast<QDeclarative1NumberAnimation*>(
- rect->findChild<QDeclarative1Behavior*>("MyBehavior")->animation())->duration(), 200);
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::disabled()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/disabled.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
- QCOMPARE(rect->findChild<QDeclarative1Behavior*>("MyBehavior")->enabled(), false);
-
- QDeclarativeItemPrivate::get(rect)->setState("moved");
- qreal x = qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"))->x();
- QCOMPARE(x, qreal(200)); //should change immediately
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::dontStart()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart.qml"));
-
- QString warning = c.url().toString() + ":13:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes.";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarative1AbstractAnimation *myAnim = rect->findChild<QDeclarative1AbstractAnimation*>("MyAnim");
- QVERIFY(myAnim && myAnim->qtAnimation());
- QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::startup()
-{
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/startup.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarative1Rectangle *innerRect = rect->findChild<QDeclarative1Rectangle*>("innerRect");
- QVERIFY(innerRect);
-
- QCOMPARE(innerRect->x(), qreal(100)); //should be set immediately
-
- delete rect;
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/startup2.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarative1Rectangle *innerRect = rect->findChild<QDeclarative1Rectangle*>("innerRect");
- QVERIFY(innerRect);
-
- QDeclarative1Text *text = rect->findChild<QDeclarative1Text*>();
- QVERIFY(text);
-
- QCOMPARE(innerRect->x(), text->width()); //should be set immediately
-
- delete rect;
- }
-}
-
-//QTBUG-10799
-void tst_qdeclarativebehaviors::groupedPropertyCrash()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/groupedPropertyCrash.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect); //don't crash
-}
-
-//QTBUG-5491
-void tst_qdeclarativebehaviors::runningTrue()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/runningTrue.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarative1AbstractAnimation *animation = rect->findChild<QDeclarative1AbstractAnimation*>("rotAnim");
- QVERIFY(animation);
-
- QSignalSpy runningSpy(animation, SIGNAL(runningChanged(bool)));
- rect->setProperty("myValue", 180);
- QTRY_VERIFY(runningSpy.count() > 0);
-}
-
-//QTBUG-12295
-void tst_qdeclarativebehaviors::sameValue()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/qtbug12295.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarative1Rectangle *target = rect->findChild<QDeclarative1Rectangle*>("myRect");
- QVERIFY(target);
-
- target->setX(100);
- QCOMPARE(target->x(), qreal(100));
-
- target->setProperty("x", 0);
- QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100));
- QTRY_VERIFY(target->x() == qreal(0)); //make sure Behavior has finished.
-
- target->setX(100);
- QCOMPARE(target->x(), qreal(100));
-
- //this is the main point of the test -- the behavior needs to be triggered again
- //even though we set 0 twice in a row.
- target->setProperty("x", 0);
- QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100));
-}
-
-//QTBUG-18362
-void tst_qdeclarativebehaviors::delayedRegistration()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, SRCDIR "/data/delayedRegistration.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QDeclarativeItem *innerRect = rect->property("myItem").value<QDeclarativeItem*>();
- QVERIFY(innerRect != 0);
-
- QCOMPARE(innerRect->property("x").toInt(), int(0));
-
- QTRY_COMPARE(innerRect->property("x").toInt(), int(100));
-}
-
-QTEST_MAIN(tst_qdeclarativebehaviors)
-
-#include "tst_qdeclarativebehaviors.moc"
diff --git a/tests/auto/qtquick1/qdeclarativebinding/data/deletedObject.qml b/tests/auto/qtquick1/qdeclarativebinding/data/deletedObject.qml
deleted file mode 100644
index ba4c9f6f7c..0000000000
--- a/tests/auto/qtquick1/qdeclarativebinding/data/deletedObject.qml
+++ /dev/null
@@ -1,24 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: wrapper
- width: 400
- height: 400
-
- property bool activateBinding: false
-
- Binding {
- id: binding
- target: Qt.createQmlObject('import QtQuick 1.0; Item { property real value: 10 }', wrapper)
- property: "value"
- when: activateBinding
- value: x + y
- }
-
- Component.onCompleted: binding.target.destroy();
-
-// MouseArea {
-// anchors.fill: parent
-// onClicked: activateBinding = true;
-// }
-}
diff --git a/tests/auto/qtquick1/qdeclarativebinding/data/test-binding.qml b/tests/auto/qtquick1/qdeclarativebinding/data/test-binding.qml
deleted file mode 100644
index 94497368a7..0000000000
--- a/tests/auto/qtquick1/qdeclarativebinding/data/test-binding.qml
+++ /dev/null
@@ -1,16 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: screen
- width: 320; height: 240
- property string text
- property bool changeColor: false
-
- Text { id: s1; text: "Hello" }
- Rectangle { id: r1; width: 1; height: 1; color: "yellow" }
- Rectangle { id: r2; width: 1; height: 1; color: "red" }
-
- Binding { target: screen; property: "text"; value: s1.text; objectName: "binding1" }
- Binding { target: screen; property: "color"; value: r1.color }
- Binding { target: screen; property: "color"; when: screen.changeColor == true; value: r2.color; objectName: "binding3" }
-}
diff --git a/tests/auto/qtquick1/qdeclarativebinding/data/test-binding2.qml b/tests/auto/qtquick1/qdeclarativebinding/data/test-binding2.qml
deleted file mode 100644
index 3e99e2b5e6..0000000000
--- a/tests/auto/qtquick1/qdeclarativebinding/data/test-binding2.qml
+++ /dev/null
@@ -1,16 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: screen
- width: 320; height: 240
- property string text
- property bool changeColor: false
-
- Text { id: s1; text: "Hello" }
- Rectangle { id: r1; width: 1; height: 1; color: "yellow" }
- Rectangle { id: r2; width: 1; height: 1; color: "red" }
-
- Binding { target: screen; property: "text"; value: s1.text }
- Binding { target: screen; property: "color"; value: r1.color }
- Binding { target: screen; property: "color"; value: r2.color; when: screen.changeColor == true }
-}
diff --git a/tests/auto/qtquick1/qdeclarativebinding/qdeclarativebinding.pro b/tests/auto/qtquick1/qdeclarativebinding/qdeclarativebinding.pro
deleted file mode 100644
index 0c38a9c783..0000000000
--- a/tests/auto/qtquick1/qdeclarativebinding/qdeclarativebinding.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativebinding
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativebinding.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
-QT += core-private gui-private widgets-private declarative-private qtquick1-private testlib
diff --git a/tests/auto/qtquick1/qdeclarativebinding/tst_qdeclarativebinding.cpp b/tests/auto/qtquick1/qdeclarativebinding/tst_qdeclarativebinding.cpp
deleted file mode 100644
index 75ada59b24..0000000000
--- a/tests/auto/qtquick1/qdeclarativebinding/tst_qdeclarativebinding.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick1/private/qdeclarativebind_p.h>
-#include <QtQuick1/private/qdeclarativerectangle_p.h>
-
-class tst_qdeclarativebinding : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativebinding();
-
-private slots:
- void binding();
- void whenAfterValue();
- void deletedObject();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_qdeclarativebinding::tst_qdeclarativebinding()
-{
-}
-
-void tst_qdeclarativebinding::binding()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-binding.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QDeclarative1Bind *binding3 = qobject_cast<QDeclarative1Bind*>(rect->findChild<QDeclarative1Bind*>("binding3"));
- QVERIFY(binding3 != 0);
-
- QCOMPARE(rect->color(), QColor("yellow"));
- QCOMPARE(rect->property("text").toString(), QString("Hello"));
- QCOMPARE(binding3->when(), false);
-
- rect->setProperty("changeColor", true);
- QCOMPARE(rect->color(), QColor("red"));
-
- QCOMPARE(binding3->when(), true);
-
- QDeclarative1Bind *binding = qobject_cast<QDeclarative1Bind*>(rect->findChild<QDeclarative1Bind*>("binding1"));
- QVERIFY(binding != 0);
- QCOMPARE(binding->object(), qobject_cast<QObject*>(rect));
- QCOMPARE(binding->property(), QLatin1String("text"));
- QCOMPARE(binding->value().toString(), QLatin1String("Hello"));
-
- delete rect;
-}
-
-void tst_qdeclarativebinding::whenAfterValue()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-binding2.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
-
- QVERIFY(rect != 0);
- QCOMPARE(rect->color(), QColor("yellow"));
- QCOMPARE(rect->property("text").toString(), QString("Hello"));
-
- rect->setProperty("changeColor", true);
- QCOMPARE(rect->color(), QColor("red"));
-
- delete rect;
-}
-
-//QTBUG-20692
-void tst_qdeclarativebinding::deletedObject()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/deletedObject.qml"));
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QApplication::sendPostedEvents(0, QEvent::DeferredDelete);
-
- //don't crash
- rect->setProperty("activateBinding", true);
-
- delete rect;
-}
-
-QTEST_MAIN(tst_qdeclarativebinding)
-
-#include "tst_qdeclarativebinding.moc"
diff --git a/tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round-quotes.sci b/tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round-quotes.sci
deleted file mode 100644
index 294f3cfe48..0000000000
--- a/tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round-quotes.sci
+++ /dev/null
@@ -1,7 +0,0 @@
-border.left:10
-border.top:20
-border.right:30
-border.bottom:40
-horizontalTileRule:Round
-verticalTileRule:Repeat
-source:"colors.png"
diff --git a/tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round-remote.sci b/tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round-remote.sci
deleted file mode 100644
index c673bed598..0000000000
--- a/tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round-remote.sci
+++ /dev/null
@@ -1,7 +0,0 @@
-border.left:10
-border.top:20
-border.right:30
-border.bottom:40
-horizontalTileRule:Round
-verticalTileRule:Repeat
-source:http://127.0.0.1:14446/colors.png
diff --git a/tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round.sci b/tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round.sci
deleted file mode 100644
index 5d2f49f0e1..0000000000
--- a/tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round.sci
+++ /dev/null
@@ -1,7 +0,0 @@
-border.left:10
-border.top:20
-border.right:30
-border.bottom:40
-horizontalTileRule:Round
-verticalTileRule:Repeat
-source:colors.png
diff --git a/tests/auto/qtquick1/qdeclarativeborderimage/data/colors.png b/tests/auto/qtquick1/qdeclarativeborderimage/data/colors.png
deleted file mode 100644
index dfb62f3d64..0000000000
--- a/tests/auto/qtquick1/qdeclarativeborderimage/data/colors.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativeborderimage/data/heart200.png b/tests/auto/qtquick1/qdeclarativeborderimage/data/heart200.png
deleted file mode 100644
index 5a31ae8f4d..0000000000
--- a/tests/auto/qtquick1/qdeclarativeborderimage/data/heart200.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativeborderimage/data/invalid.sci b/tests/auto/qtquick1/qdeclarativeborderimage/data/invalid.sci
deleted file mode 100644
index 98c72c9bf1..0000000000
--- a/tests/auto/qtquick1/qdeclarativeborderimage/data/invalid.sci
+++ /dev/null
@@ -1,7 +0,0 @@
-border.left:10
-border.top:20
-border.down:30
-border.up:40
-horizontalTileRule:Roun
-verticalTileRule:Repea
-source:colors.png
diff --git a/tests/auto/qtquick1/qdeclarativeborderimage/qdeclarativeborderimage.pro b/tests/auto/qtquick1/qdeclarativeborderimage/qdeclarativeborderimage.pro
deleted file mode 100644
index a8c8b18a37..0000000000
--- a/tests/auto/qtquick1/qdeclarativeborderimage/qdeclarativeborderimage.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeborderimage
-macx:CONFIG -= app_bundle
-
-HEADERS += ../../shared/testhttpserver.h
-SOURCES += tst_qdeclarativeborderimage.cpp ../../shared/testhttpserver.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
-QT += core-private gui-private widgets-private declarative-private qtquick1-private network testlib
diff --git a/tests/auto/qtquick1/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp b/tests/auto/qtquick1/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp
deleted file mode 100644
index 8ac3bd3559..0000000000
--- a/tests/auto/qtquick1/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp
+++ /dev/null
@@ -1,423 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QTextDocument>
-#include <QTcpServer>
-#include <QTcpSocket>
-#include <QDir>
-#include <QGraphicsScene>
-#include <QPainter>
-
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <private/qdeclarativeborderimage_p.h>
-#include <private/qdeclarativeimagebase_p.h>
-#include <private/qdeclarativescalegrid_p_p.h>
-#include <private/qdeclarativeloader_p.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-
-#include "../../shared/testhttpserver.h"
-
-#define SERVER_PORT 14446
-#define SERVER_ADDR "http://127.0.0.1:14446"
-
-class tst_qdeclarativeborderimage : public QObject
-
-{
- Q_OBJECT
-public:
- tst_qdeclarativeborderimage();
-
-private slots:
- void noSource();
- void imageSource();
- void imageSource_data();
- void clearSource();
- void resized();
- void smooth();
- void mirror();
- void tileModes();
- void sciSource();
- void sciSource_data();
- void invalidSciFile();
- void pendingRemoteRequest();
- void pendingRemoteRequest_data();
- void testQtQuick11Attributes();
- void testQtQuick11Attributes_data();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_qdeclarativeborderimage::tst_qdeclarativeborderimage()
-{
-}
-
-void tst_qdeclarativeborderimage::noSource()
-{
- QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"\" }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1BorderImage *obj = qobject_cast<QDeclarative1BorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->source(), QUrl());
- QCOMPARE(obj->width(), 0.);
- QCOMPARE(obj->height(), 0.);
- QCOMPARE(obj->horizontalTileMode(), QDeclarative1BorderImage::Stretch);
- QCOMPARE(obj->verticalTileMode(), QDeclarative1BorderImage::Stretch);
-
- delete obj;
-}
-
-void tst_qdeclarativeborderimage::imageSource_data()
-{
- QTest::addColumn<QString>("source");
- QTest::addColumn<bool>("remote");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() << false << "";
- QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() << false
- << "file::2:1: QML BorderImage: Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString();
- QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << "";
- QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true
- << "file::2:1: QML BorderImage: Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found";
-}
-
-void tst_qdeclarativeborderimage::imageSource()
-{
- QFETCH(QString, source);
- QFETCH(bool, remote);
- QFETCH(QString, error);
-
- TestHTTPServer *server = 0;
- if (remote) {
- server = new TestHTTPServer(SERVER_PORT);
- QVERIFY(server->isValid());
- server->serveDirectory(SRCDIR "/data");
- }
-
- if (!error.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
-
- QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" + source + "\" }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1BorderImage *obj = qobject_cast<QDeclarative1BorderImage*>(component.create());
- QVERIFY(obj != 0);
-
- if (remote)
- QTRY_VERIFY(obj->status() == QDeclarative1BorderImage::Loading);
-
- QCOMPARE(obj->source(), remote ? source : QUrl(source));
-
- if (error.isEmpty()) {
- QTRY_VERIFY(obj->status() == QDeclarative1BorderImage::Ready);
- QCOMPARE(obj->width(), 120.);
- QCOMPARE(obj->height(), 120.);
- QCOMPARE(obj->sourceSize().width(), 120);
- QCOMPARE(obj->sourceSize().height(), 120);
- QCOMPARE(obj->horizontalTileMode(), QDeclarative1BorderImage::Stretch);
- QCOMPARE(obj->verticalTileMode(), QDeclarative1BorderImage::Stretch);
- } else {
- QTRY_VERIFY(obj->status() == QDeclarative1BorderImage::Error);
- }
-
- delete obj;
- delete server;
-}
-
-void tst_qdeclarativeborderimage::clearSource()
-{
- QString componentStr = "import QtQuick 1.0\nBorderImage { source: srcImage }";
- QDeclarativeContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.png"));
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1BorderImage *obj = qobject_cast<QDeclarative1BorderImage*>(component.create());
- QVERIFY(obj != 0);
- QVERIFY(obj->status() == QDeclarative1BorderImage::Ready);
- QCOMPARE(obj->width(), 120.);
- QCOMPARE(obj->height(), 120.);
-
- ctxt->setContextProperty("srcImage", "");
- QVERIFY(obj->source().isEmpty());
- QVERIFY(obj->status() == QDeclarative1BorderImage::Null);
- QCOMPARE(obj->width(), 0.);
- QCOMPARE(obj->height(), 0.);
-}
-
-void tst_qdeclarativeborderimage::resized()
-{
- QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" + QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() + "\"; width: 300; height: 300 }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1BorderImage *obj = qobject_cast<QDeclarative1BorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->sourceSize().width(), 120);
- QCOMPARE(obj->sourceSize().height(), 120);
- QCOMPARE(obj->horizontalTileMode(), QDeclarative1BorderImage::Stretch);
- QCOMPARE(obj->verticalTileMode(), QDeclarative1BorderImage::Stretch);
-
- delete obj;
-}
-
-void tst_qdeclarativeborderimage::smooth()
-{
- QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; smooth: true; width: 300; height: 300 }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1BorderImage *obj = qobject_cast<QDeclarative1BorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->smooth(), true);
- QCOMPARE(obj->horizontalTileMode(), QDeclarative1BorderImage::Stretch);
- QCOMPARE(obj->verticalTileMode(), QDeclarative1BorderImage::Stretch);
-
- delete obj;
-}
-
-void tst_qdeclarativeborderimage::mirror()
-{
- QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" SRCDIR "/data/heart200.png\"; smooth: true; width: 300; height: 300; border { top: 50; right: 50; bottom: 50; left: 50 } }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1BorderImage *obj = qobject_cast<QDeclarative1BorderImage*>(component.create());
- QVERIFY(obj != 0);
-
- int width = obj->property("width").toInt();
- int height = obj->property("height").toInt();
-
- QGraphicsScene scene;
- scene.addItem(qobject_cast<QGraphicsObject *>(obj));
- QPixmap screenshot(width, height);
- screenshot.fill();
- QPainter p_screenshot(&screenshot);
- scene.render(&p_screenshot, QRect(0, 0, width, height), QRect(0, 0, width, height));
-
- QTransform transform;
- transform.translate(width, 0).scale(-1, 1.0);
- QPixmap expected = screenshot.transformed(transform);
-
- obj->setProperty("mirror", true);
- p_screenshot.fillRect(QRect(0, 0, width, height), Qt::white);
- scene.render(&p_screenshot, QRect(0, 0, width, height), QRect(0, 0, width, height));
-
- QEXPECT_FAIL("", "QTBUG-19538", Continue);
- QCOMPARE(screenshot, expected);
-
- delete obj;
-}
-
-void tst_qdeclarativeborderimage::tileModes()
-{
- {
- QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; width: 100; height: 300; horizontalTileMode: BorderImage.Repeat; verticalTileMode: BorderImage.Repeat }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1BorderImage *obj = qobject_cast<QDeclarative1BorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 100.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->horizontalTileMode(), QDeclarative1BorderImage::Repeat);
- QCOMPARE(obj->verticalTileMode(), QDeclarative1BorderImage::Repeat);
-
- delete obj;
- }
- {
- QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 150; horizontalTileMode: BorderImage.Round; verticalTileMode: BorderImage.Round }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1BorderImage *obj = qobject_cast<QDeclarative1BorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 150.);
- QCOMPARE(obj->horizontalTileMode(), QDeclarative1BorderImage::Round);
- QCOMPARE(obj->verticalTileMode(), QDeclarative1BorderImage::Round);
-
- delete obj;
- }
-}
-
-void tst_qdeclarativeborderimage::sciSource()
-{
- QFETCH(QString, source);
- QFETCH(bool, valid);
-
- bool remote = source.startsWith("http");
- TestHTTPServer *server = 0;
- if (remote) {
- server = new TestHTTPServer(SERVER_PORT);
- QVERIFY(server->isValid());
- server->serveDirectory(SRCDIR "/data");
- }
-
- QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" + source + "\"; width: 300; height: 300 }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1BorderImage *obj = qobject_cast<QDeclarative1BorderImage*>(component.create());
- QVERIFY(obj != 0);
-
- if (remote)
- QTRY_VERIFY(obj->status() == QDeclarative1BorderImage::Loading);
-
- QCOMPARE(obj->source(), remote ? source : QUrl(source));
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
-
- if (valid) {
- QTRY_VERIFY(obj->status() == QDeclarative1BorderImage::Ready);
- QCOMPARE(obj->border()->left(), 10);
- QCOMPARE(obj->border()->top(), 20);
- QCOMPARE(obj->border()->right(), 30);
- QCOMPARE(obj->border()->bottom(), 40);
- QCOMPARE(obj->horizontalTileMode(), QDeclarative1BorderImage::Round);
- QCOMPARE(obj->verticalTileMode(), QDeclarative1BorderImage::Repeat);
- } else {
- QTRY_VERIFY(obj->status() == QDeclarative1BorderImage::Error);
- }
-
- delete obj;
- delete server;
-}
-
-void tst_qdeclarativeborderimage::sciSource_data()
-{
- QTest::addColumn<QString>("source");
- QTest::addColumn<bool>("valid");
-
- QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors-round.sci").toString() << true;
- QTest::newRow("local quoted filename") << QUrl::fromLocalFile(SRCDIR "/data/colors-round-quotes.sci").toString() << true;
- QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.sci").toString() << false;
- QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true;
- QTest::newRow("remote filename quoted") << SERVER_ADDR "/colors-round-quotes.sci" << true;
- QTest::newRow("remote image") << SERVER_ADDR "/colors-round-remote.sci" << true;
- QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.sci" << false;
-}
-
-void tst_qdeclarativeborderimage::invalidSciFile()
-{
- QTest::ignoreMessage(QtWarningMsg, "QDeclarative1GridScaledImage: Invalid tile rule specified. Using Stretch."); // for "Roun"
- QTest::ignoreMessage(QtWarningMsg, "QDeclarative1GridScaledImage: Invalid tile rule specified. Using Stretch."); // for "Repea"
-
- QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" + QUrl::fromLocalFile(SRCDIR "/data/invalid.sci").toString() +"\"; width: 300; height: 300 }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1BorderImage *obj = qobject_cast<QDeclarative1BorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->status(), QDeclarative1ImageBase::Error);
- QCOMPARE(obj->horizontalTileMode(), QDeclarative1BorderImage::Stretch);
- QCOMPARE(obj->verticalTileMode(), QDeclarative1BorderImage::Stretch);
-
- delete obj;
-}
-
-void tst_qdeclarativeborderimage::pendingRemoteRequest()
-{
- QFETCH(QString, source);
-
- QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" + source + "\" }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1BorderImage *obj = qobject_cast<QDeclarative1BorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->status(), QDeclarative1BorderImage::Loading);
-
- // verify no crash
- // This will cause a delayed "QThread: Destroyed while thread is still running" warning
- delete obj;
- QTest::qWait(50);
-}
-
-void tst_qdeclarativeborderimage::pendingRemoteRequest_data()
-{
- QTest::addColumn<QString>("source");
-
- QTest::newRow("png file") << "http://localhost/none.png";
- QTest::newRow("sci file") << "http://localhost/none.sci";
-}
-
-void tst_qdeclarativeborderimage::testQtQuick11Attributes()
-{
- QFETCH(QString, code);
- QFETCH(QString, warning);
- QFETCH(QString, error);
-
- QDeclarativeEngine engine;
- QObject *obj;
-
- QDeclarativeComponent valid(&engine);
- valid.setData("import QtQuick 1.1; BorderImage { " + code.toUtf8() + " }", QUrl(""));
- obj = valid.create();
- QVERIFY(obj);
- QVERIFY(valid.errorString().isEmpty());
- delete obj;
-
- QDeclarativeComponent invalid(&engine);
- invalid.setData("import QtQuick 1.0; BorderImage { " + code.toUtf8() + " }", QUrl(""));
- QTest::ignoreMessage(QtWarningMsg, warning.toUtf8());
- obj = invalid.create();
- QCOMPARE(invalid.errorString(), error);
- delete obj;
-}
-
-void tst_qdeclarativeborderimage::testQtQuick11Attributes_data()
-{
- QTest::addColumn<QString>("code");
- QTest::addColumn<QString>("warning");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("mirror") << "mirror: true"
- << "QDeclarativeComponent: Component is not ready"
- << ":1 \"BorderImage.mirror\" is not available in QtQuick 1.0.\n";
-
- QTest::newRow("cache") << "cache: true"
- << "QDeclarativeComponent: Component is not ready"
- << ":1 \"BorderImage.cache\" is not available in QtQuick 1.0.\n";
-}
-
-QTEST_MAIN(tst_qdeclarativeborderimage)
-
-#include "tst_qdeclarativeborderimage.moc"
diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/connection-targetchange.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/connection-targetchange.qml
deleted file mode 100644
index dd92cb9c67..0000000000
--- a/tests/auto/qtquick1/qdeclarativeconnection/data/connection-targetchange.qml
+++ /dev/null
@@ -1,25 +0,0 @@
-import QtQuick 1.0
-
-Item {
- Component {
- id: item1
- Item {
- objectName: "item1"
- }
- }
- Component {
- id: item2
- Item {
- objectName: "item2"
- }
- }
- Loader {
- id: loader
- sourceComponent: item1
- }
- Connections {
- objectName: "connections"
- target: loader.item
- onWidthChanged: loader.sourceComponent = item2
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-ignored.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-ignored.qml
deleted file mode 100644
index 459c34617b..0000000000
--- a/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-ignored.qml
+++ /dev/null
@@ -1,8 +0,0 @@
-import QtQuick 1.0
-
-Item {
- id: screen
-
- Connections { target: screen; onNotFooBar1: {} ignoreUnknownSignals: true }
- Connections { objectName: "connections"; onNotFooBar2: {} ignoreUnknownSignals: true }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-notarget.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-notarget.qml
deleted file mode 100644
index 8eddf43fe6..0000000000
--- a/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-notarget.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import QtQuick 1.0
-
-Item {
- id: screen
-
- Connections { objectName: "connections"; target: null; onNotFooBar: {} }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-parent.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-parent.qml
deleted file mode 100644
index 953347a3b2..0000000000
--- a/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-parent.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import QtQuick 1.0
-
-Item {
- id: screen
-
- Connections { objectName: "connections"; onFooBar: {} }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals.qml
deleted file mode 100644
index 3702bdbe73..0000000000
--- a/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import QtQuick 1.0
-
-Item {
- id: screen
-
- Connections { objectName: "connections"; target: screen; onFooBar: {} }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/error-object.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/error-object.qml
deleted file mode 100644
index 376a2182fe..0000000000
--- a/tests/auto/qtquick1/qdeclarativeconnection/data/error-object.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import QtQuick 1.0
-
-Item {
- Connections {
- onClicked: Item {}
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/error-property.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/error-property.qml
deleted file mode 100644
index 677af152ce..0000000000
--- a/tests/auto/qtquick1/qdeclarativeconnection/data/error-property.qml
+++ /dev/null
@@ -1,5 +0,0 @@
-import QtQuick 1.0
-
-Item {
- Connections { fakeProperty: {} }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/error-property2.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/error-property2.qml
deleted file mode 100644
index 127e58e657..0000000000
--- a/tests/auto/qtquick1/qdeclarativeconnection/data/error-property2.qml
+++ /dev/null
@@ -1,5 +0,0 @@
-import QtQuick 1.0
-
-Item {
- Connections { onfakeProperty: {} }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/error-syntax.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/error-syntax.qml
deleted file mode 100644
index 6a82528e1a..0000000000
--- a/tests/auto/qtquick1/qdeclarativeconnection/data/error-syntax.qml
+++ /dev/null
@@ -1,9 +0,0 @@
-import QtQuick 1.0
-
-Item {
- Connections {
- onClicked {
- onPressed: {}
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/test-connection.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/test-connection.qml
deleted file mode 100644
index c5990830cd..0000000000
--- a/tests/auto/qtquick1/qdeclarativeconnection/data/test-connection.qml
+++ /dev/null
@@ -1,10 +0,0 @@
-import QtQuick 1.0
-
-Item {
- id: screen; width: 50
-
- property bool tested: false
- signal testMe
-
- Connections { target: screen; onWidthChanged: screen.tested = true }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/test-connection2.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/test-connection2.qml
deleted file mode 100644
index f0dbaba5a6..0000000000
--- a/tests/auto/qtquick1/qdeclarativeconnection/data/test-connection2.qml
+++ /dev/null
@@ -1,3 +0,0 @@
-import QtQuick 1.0
-
-Connections { id: connection; target: connection; onTargetChanged: 1 == 1 }
diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/test-connection3.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/test-connection3.qml
deleted file mode 100644
index 94c9c7ca7f..0000000000
--- a/tests/auto/qtquick1/qdeclarativeconnection/data/test-connection3.qml
+++ /dev/null
@@ -1,3 +0,0 @@
-import QtQuick 1.0
-
-Connections {}
diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/trimming.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/trimming.qml
deleted file mode 100644
index 00507d919c..0000000000
--- a/tests/auto/qtquick1/qdeclarativeconnection/data/trimming.qml
+++ /dev/null
@@ -1,10 +0,0 @@
-import QtQuick 1.0
-
-Item {
- id: screen; width: 50
-
- property string tested
- signal testMe(int param1, string param2)
-
- Connections { target: screen; onTestMe: screen.tested = param2 + param1 }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeconnection/qdeclarativeconnection.pro b/tests/auto/qtquick1/qdeclarativeconnection/qdeclarativeconnection.pro
deleted file mode 100644
index 833c77db54..0000000000
--- a/tests/auto/qtquick1/qdeclarativeconnection/qdeclarativeconnection.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeconnection
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeconnection.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
-QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib
diff --git a/tests/auto/qtquick1/qdeclarativeconnection/tst_qdeclarativeconnection.cpp b/tests/auto/qtquick1/qdeclarativeconnection/tst_qdeclarativeconnection.cpp
deleted file mode 100644
index 6d5c17f8f2..0000000000
--- a/tests/auto/qtquick1/qdeclarativeconnection/tst_qdeclarativeconnection.cpp
+++ /dev/null
@@ -1,227 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick1/private/qdeclarativeconnections_p.h>
-#include <QtQuick1/private/qdeclarativeitem_p.h>
-#include <QtDeclarative/qdeclarativescriptstring.h>
-
-class tst_qdeclarativeconnection : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativeconnection();
-
-private slots:
- void defaultValues();
- void properties();
- void connection();
- void trimming();
- void targetChanged();
- void unknownSignals_data();
- void unknownSignals();
- void errors_data();
- void errors();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_qdeclarativeconnection::tst_qdeclarativeconnection()
-{
-}
-
-void tst_qdeclarativeconnection::defaultValues()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-connection3.qml"));
- QDeclarative1Connections *item = qobject_cast<QDeclarative1Connections*>(c.create());
-
- QVERIFY(item != 0);
- QVERIFY(item->target() == 0);
-
- delete item;
-}
-
-void tst_qdeclarativeconnection::properties()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-connection2.qml"));
- QDeclarative1Connections *item = qobject_cast<QDeclarative1Connections*>(c.create());
-
- QVERIFY(item != 0);
-
- QVERIFY(item != 0);
- QVERIFY(item->target() == item);
-
- delete item;
-}
-
-void tst_qdeclarativeconnection::connection()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-connection.qml"));
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(c.create());
-
- QVERIFY(item != 0);
-
- QCOMPARE(item->property("tested").toBool(), false);
- QCOMPARE(item->width(), 50.);
- emit item->setWidth(100.);
- QCOMPARE(item->width(), 100.);
- QCOMPARE(item->property("tested").toBool(), true);
-
- delete item;
-}
-
-void tst_qdeclarativeconnection::trimming()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/trimming.qml"));
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(c.create());
-
- QVERIFY(item != 0);
-
- QCOMPARE(item->property("tested").toString(), QString(""));
- int index = item->metaObject()->indexOfSignal("testMe(int,QString)");
- QMetaMethod method = item->metaObject()->method(index);
- method.invoke(item,
- Qt::DirectConnection,
- Q_ARG(int, 5),
- Q_ARG(QString, "worked"));
- QCOMPARE(item->property("tested").toString(), QString("worked5"));
-
- delete item;
-}
-
-// Confirm that target can be changed by one of our signal handlers
-void tst_qdeclarativeconnection::targetChanged()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/connection-targetchange.qml"));
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(c.create());
- QVERIFY(item != 0);
-
- QDeclarative1Connections *connections = item->findChild<QDeclarative1Connections*>("connections");
- QVERIFY(connections);
-
- QDeclarativeItem *item1 = item->findChild<QDeclarativeItem*>("item1");
- QVERIFY(item1);
-
- item1->setWidth(200);
-
- QDeclarativeItem *item2 = item->findChild<QDeclarativeItem*>("item2");
- QVERIFY(item2);
- QVERIFY(connections->target() == item2);
-
- // If we don't crash then we're OK
-
- delete item;
-}
-
-void tst_qdeclarativeconnection::unknownSignals_data()
-{
- QTest::addColumn<QString>("file");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("basic") << "connection-unknownsignals.qml" << ":6:5: QML Connections: Cannot assign to non-existent property \"onFooBar\"";
- QTest::newRow("parent") << "connection-unknownsignals-parent.qml" << ":6:5: QML Connections: Cannot assign to non-existent property \"onFooBar\"";
- QTest::newRow("ignored") << "connection-unknownsignals-ignored.qml" << ""; // should be NO error
- QTest::newRow("notarget") << "connection-unknownsignals-notarget.qml" << ""; // should be NO error
-}
-
-void tst_qdeclarativeconnection::unknownSignals()
-{
- QFETCH(QString, file);
- QFETCH(QString, error);
-
- QUrl url = QUrl::fromLocalFile(SRCDIR "/data/" + file);
- if (!error.isEmpty()) {
- QTest::ignoreMessage(QtWarningMsg, (url.toString() + error).toLatin1());
- } else {
- // QTest has no way to insist no message (i.e. fail)
- }
-
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, url);
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(c.create());
- QVERIFY(item != 0);
-
- // check that connection is created (they are all runtime errors)
- QDeclarative1Connections *connections = item->findChild<QDeclarative1Connections*>("connections");
- QVERIFY(connections);
-
- if (file == "connection-unknownsignals-ignored.qml")
- QVERIFY(connections->ignoreUnknownSignals());
-
- delete item;
-}
-
-void tst_qdeclarativeconnection::errors_data()
-{
- QTest::addColumn<QString>("file");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("no \"on\"") << "error-property.qml" << "Cannot assign to non-existent property \"fakeProperty\"";
- QTest::newRow("3rd letter lowercase") << "error-property2.qml" << "Cannot assign to non-existent property \"onfakeProperty\"";
- QTest::newRow("child object") << "error-object.qml" << "Connections: nested objects not allowed";
- QTest::newRow("grouped object") << "error-syntax.qml" << "Connections: syntax error";
-}
-
-void tst_qdeclarativeconnection::errors()
-{
- QFETCH(QString, file);
- QFETCH(QString, error);
-
- QUrl url = QUrl::fromLocalFile(SRCDIR "/data/" + file);
-
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, url);
- QVERIFY(c.isError() == true);
- QList<QDeclarativeError> errors = c.errors();
- QVERIFY(errors.count() == 1);
- QCOMPARE(errors.at(0).description(), error);
-}
-
-QTEST_MAIN(tst_qdeclarativeconnection)
-
-#include "tst_qdeclarativeconnection.moc"
diff --git a/tests/auto/qtquick1/qdeclarativeflickable/data/disabled.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/disabled.qml
deleted file mode 100644
index ac63cd461b..0000000000
--- a/tests/auto/qtquick1/qdeclarativeflickable/data/disabled.qml
+++ /dev/null
@@ -1,30 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: root
- width: 100; height: 100
- property bool clicked: false
-
- Flickable {
- objectName: "flickable"
- width: 100; height: 100
- contentWidth: column.width; contentHeight: column.height
- enabled: false
-
- Column {
- id: column
- Repeater {
- model: 4
- Rectangle {
- width: 200; height: 300; color: "blue"
- MouseArea { anchors.fill: parent; onClicked: { } }
- }
- }
- }
- }
-
- MouseArea {
- width: 100; height: 30
- onClicked: root.clicked = true
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeflickable/data/disabledcontent.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/disabledcontent.qml
deleted file mode 100644
index dcbb20bdd5..0000000000
--- a/tests/auto/qtquick1/qdeclarativeflickable/data/disabledcontent.qml
+++ /dev/null
@@ -1,8 +0,0 @@
-import QtQuick 1.0
-
-Flickable {
- width: 100; height: 100
- contentWidth: 200; contentHeight: 300
-
- QGraphicsWidget { width: 200; height: 300; enabled: false }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeflickable/data/flickable01.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/flickable01.qml
deleted file mode 100644
index c53ae3f98a..0000000000
--- a/tests/auto/qtquick1/qdeclarativeflickable/data/flickable01.qml
+++ /dev/null
@@ -1,4 +0,0 @@
-import QtQuick 1.0
-
-Flickable {
-}
diff --git a/tests/auto/qtquick1/qdeclarativeflickable/data/flickable02.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/flickable02.qml
deleted file mode 100644
index 98925ae3c6..0000000000
--- a/tests/auto/qtquick1/qdeclarativeflickable/data/flickable02.qml
+++ /dev/null
@@ -1,14 +0,0 @@
-import QtQuick 1.0
-
-Flickable {
- width: 100; height: 100
- contentWidth: row.width; contentHeight: row.height
-
- Row {
- id: row
- Repeater {
- model: 4
- Rectangle { width: 200; height: 300; color: "blue" }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeflickable/data/flickable03.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/flickable03.qml
deleted file mode 100644
index 8359ad1bb4..0000000000
--- a/tests/auto/qtquick1/qdeclarativeflickable/data/flickable03.qml
+++ /dev/null
@@ -1,14 +0,0 @@
-import QtQuick 1.0
-
-Flickable {
- width: 100; height: 200
- contentWidth: column.width; contentHeight: column.height
-
- Column {
- id: column
- Repeater {
- model: 4
- Rectangle { width: 200; height: 300; color: "blue" }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeflickable/data/flickable04.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/flickable04.qml
deleted file mode 100644
index fcc683ae4d..0000000000
--- a/tests/auto/qtquick1/qdeclarativeflickable/data/flickable04.qml
+++ /dev/null
@@ -1,22 +0,0 @@
-import QtQuick 1.0
-
-Flickable {
- property bool ok: false
- function check() {
- if (column.parent == contentItem)
- ok = true;
- }
-
- width: 100; height: 100
- contentWidth: column.width; contentHeight: column.height
- pressDelay: 200; boundsBehavior: Flickable.StopAtBounds; interactive: false
- maximumFlickVelocity: 2000
-
- Column {
- id: column
- Repeater {
- model: 4
- Rectangle { width: 200; height: 300; color: "blue" }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeflickable/data/flickableqgraphicswidget.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/flickableqgraphicswidget.qml
deleted file mode 100644
index 6cbf12c1ee..0000000000
--- a/tests/auto/qtquick1/qdeclarativeflickable/data/flickableqgraphicswidget.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import QtQuick 1.0
-
-Flickable {
- width: 100; height: 100
-
- QGraphicsWidget { objectName: "widget1"; width: 200; height: 300 }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeflickable/data/nestedPressDelay.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/nestedPressDelay.qml
deleted file mode 100644
index d0ee545f97..0000000000
--- a/tests/auto/qtquick1/qdeclarativeflickable/data/nestedPressDelay.qml
+++ /dev/null
@@ -1,33 +0,0 @@
-import QtQuick 1.0
-
-Flickable {
- property bool pressed: ma.pressed
- width: 240
- height: 320
- contentWidth: 480
- contentHeight: 320
- flickableDirection: Flickable.HorizontalFlick
- pressDelay: 50
- Flickable {
- objectName: "innerFlickable"
- flickableDirection: Flickable.VerticalFlick
- width: 480
- height: 320
- contentWidth: 480
- contentHeight: 400
- pressDelay: 10000
- Rectangle {
- y: 100
- anchors.horizontalCenter: parent.horizontalCenter
- width: 240
- height: 100
- color: ma.pressed ? 'blue' : 'green'
- MouseArea {
- id: ma
- objectName: "mouseArea"
- anchors.fill: parent
- }
- }
- }
-}
-
diff --git a/tests/auto/qtquick1/qdeclarativeflickable/data/resize.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/resize.qml
deleted file mode 100644
index e2abb99f2a..0000000000
--- a/tests/auto/qtquick1/qdeclarativeflickable/data/resize.qml
+++ /dev/null
@@ -1,27 +0,0 @@
-import QtQuick 1.1
-
-Rectangle {
- function resizeContent() {
- flick.resizeContent(600, 600, Qt.point(100, 100))
- }
- function returnToBounds() {
- flick.returnToBounds()
- }
- width: 400
- height: 360
- color: "gray"
-
- Flickable {
- id: flick
- objectName: "flick"
- anchors.fill: parent
- contentWidth: 300
- contentHeight: 300
-
- Rectangle {
- width: flick.contentWidth
- height: flick.contentHeight
- color: "red"
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeflickable/data/wheel.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/wheel.qml
deleted file mode 100644
index 6ea81b2d9e..0000000000
--- a/tests/auto/qtquick1/qdeclarativeflickable/data/wheel.qml
+++ /dev/null
@@ -1,21 +0,0 @@
-import QtQuick 1.1
-
-Rectangle {
- width: 400
- height: 400
- color: "gray"
-
- Flickable {
- id: flick
- objectName: "flick"
- anchors.fill: parent
- contentWidth: 800
- contentHeight: 800
-
- Rectangle {
- width: flick.contentWidth
- height: flick.contentHeight
- color: "red"
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeflickable/qdeclarativeflickable.pro b/tests/auto/qtquick1/qdeclarativeflickable/qdeclarativeflickable.pro
deleted file mode 100644
index 1c54ef413f..0000000000
--- a/tests/auto/qtquick1/qdeclarativeflickable/qdeclarativeflickable.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-TARGET = tst_qdeclarativeflickable
-CONFIG += testcase
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeflickable.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
-QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib
diff --git a/tests/auto/qtquick1/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/qtquick1/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
deleted file mode 100644
index 140ccf036c..0000000000
--- a/tests/auto/qtquick1/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
+++ /dev/null
@@ -1,583 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QSignalSpy>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick1/qdeclarativeview.h>
-#include <private/qdeclarativeflickable_p.h>
-#include <private/qdeclarativevaluetype_p.h>
-#include <QtWidgets/qgraphicswidget.h>
-#include <math.h>
-
-class tst_qdeclarativeflickable : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativeflickable();
-
-private slots:
- void create();
- void horizontalViewportSize();
- void verticalViewportSize();
- void properties();
- void boundsBehavior();
- void maximumFlickVelocity();
- void flickDeceleration();
- void pressDelay();
- void disabledContent();
- void nestedPressDelay();
- void flickableDirection();
- void qgraphicswidget();
- void resizeContent();
- void returnToBounds();
- void testQtQuick11Attributes();
- void testQtQuick11Attributes_data();
- void wheel();
- void disabled();
- void flickVelocity();
-
-private:
- QDeclarativeEngine engine;
-
- void flick(QGraphicsView *canvas, const QPoint &from, const QPoint &to, int duration);
- template<typename T>
- T *findItem(QGraphicsObject *parent, const QString &objectName);
-};
-
-tst_qdeclarativeflickable::tst_qdeclarativeflickable()
-{
-}
-
-void tst_qdeclarativeflickable::create()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable01.qml"));
- QDeclarative1Flickable *obj = qobject_cast<QDeclarative1Flickable*>(c.create());
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->isAtXBeginning(), true);
- QCOMPARE(obj->isAtXEnd(), false);
- QCOMPARE(obj->isAtYBeginning(), true);
- QCOMPARE(obj->isAtYEnd(), false);
- QCOMPARE(obj->contentX(), 0.);
- QCOMPARE(obj->contentY(), 0.);
-
- QCOMPARE(obj->horizontalVelocity(), 0.);
- QCOMPARE(obj->verticalVelocity(), 0.);
-
- QCOMPARE(obj->isInteractive(), true);
- QCOMPARE(obj->boundsBehavior(), QDeclarative1Flickable::DragAndOvershootBounds);
- QCOMPARE(obj->pressDelay(), 0);
- QCOMPARE(obj->maximumFlickVelocity(), 2500.);
-
- delete obj;
-}
-
-void tst_qdeclarativeflickable::horizontalViewportSize()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable02.qml"));
- QDeclarative1Flickable *obj = qobject_cast<QDeclarative1Flickable*>(c.create());
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->contentWidth(), 800.);
- QCOMPARE(obj->contentHeight(), 300.);
- QCOMPARE(obj->isAtXBeginning(), true);
- QCOMPARE(obj->isAtXEnd(), false);
- QCOMPARE(obj->isAtYBeginning(), true);
- QCOMPARE(obj->isAtYEnd(), false);
-
- delete obj;
-}
-
-void tst_qdeclarativeflickable::verticalViewportSize()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable03.qml"));
- QDeclarative1Flickable *obj = qobject_cast<QDeclarative1Flickable*>(c.create());
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->contentWidth(), 200.);
- QCOMPARE(obj->contentHeight(), 1200.);
- QCOMPARE(obj->isAtXBeginning(), true);
- QCOMPARE(obj->isAtXEnd(), false);
- QCOMPARE(obj->isAtYBeginning(), true);
- QCOMPARE(obj->isAtYEnd(), false);
-
- delete obj;
-}
-
-void tst_qdeclarativeflickable::properties()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable04.qml"));
- QDeclarative1Flickable *obj = qobject_cast<QDeclarative1Flickable*>(c.create());
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->isInteractive(), false);
- QCOMPARE(obj->boundsBehavior(), QDeclarative1Flickable::StopAtBounds);
- QCOMPARE(obj->pressDelay(), 200);
- QCOMPARE(obj->maximumFlickVelocity(), 2000.);
-
- QVERIFY(obj->property("ok").toBool() == false);
- QMetaObject::invokeMethod(obj, "check");
- QVERIFY(obj->property("ok").toBool() == true);
-
- delete obj;
-}
-
-void tst_qdeclarativeflickable::boundsBehavior()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 1.0; Flickable { boundsBehavior: Flickable.StopAtBounds }", QUrl::fromLocalFile(""));
- QDeclarative1Flickable *flickable = qobject_cast<QDeclarative1Flickable*>(component.create());
- QSignalSpy spy(flickable, SIGNAL(boundsBehaviorChanged()));
-
- QVERIFY(flickable);
- QVERIFY(flickable->boundsBehavior() == QDeclarative1Flickable::StopAtBounds);
-
- flickable->setBoundsBehavior(QDeclarative1Flickable::DragAndOvershootBounds);
- QVERIFY(flickable->boundsBehavior() == QDeclarative1Flickable::DragAndOvershootBounds);
- QCOMPARE(spy.count(),1);
- flickable->setBoundsBehavior(QDeclarative1Flickable::DragAndOvershootBounds);
- QCOMPARE(spy.count(),1);
-
- flickable->setBoundsBehavior(QDeclarative1Flickable::DragOverBounds);
- QVERIFY(flickable->boundsBehavior() == QDeclarative1Flickable::DragOverBounds);
- QCOMPARE(spy.count(),2);
- flickable->setBoundsBehavior(QDeclarative1Flickable::DragOverBounds);
- QCOMPARE(spy.count(),2);
-
- flickable->setBoundsBehavior(QDeclarative1Flickable::StopAtBounds);
- QVERIFY(flickable->boundsBehavior() == QDeclarative1Flickable::StopAtBounds);
- QCOMPARE(spy.count(),3);
- flickable->setBoundsBehavior(QDeclarative1Flickable::StopAtBounds);
- QCOMPARE(spy.count(),3);
-}
-
-void tst_qdeclarativeflickable::maximumFlickVelocity()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 1.0; Flickable { maximumFlickVelocity: 1.0; }", QUrl::fromLocalFile(""));
- QDeclarative1Flickable *flickable = qobject_cast<QDeclarative1Flickable*>(component.create());
- QSignalSpy spy(flickable, SIGNAL(maximumFlickVelocityChanged()));
-
- QVERIFY(flickable);
- QCOMPARE(flickable->maximumFlickVelocity(), 1.0);
-
- flickable->setMaximumFlickVelocity(2.0);
- QCOMPARE(flickable->maximumFlickVelocity(), 2.0);
- QCOMPARE(spy.count(),1);
- flickable->setMaximumFlickVelocity(2.0);
- QCOMPARE(spy.count(),1);
-}
-
-void tst_qdeclarativeflickable::flickDeceleration()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 1.0; Flickable { flickDeceleration: 1.0; }", QUrl::fromLocalFile(""));
- QDeclarative1Flickable *flickable = qobject_cast<QDeclarative1Flickable*>(component.create());
- QSignalSpy spy(flickable, SIGNAL(flickDecelerationChanged()));
-
- QVERIFY(flickable);
- QCOMPARE(flickable->flickDeceleration(), 1.0);
-
- flickable->setFlickDeceleration(2.0);
- QCOMPARE(flickable->flickDeceleration(), 2.0);
- QCOMPARE(spy.count(),1);
- flickable->setFlickDeceleration(2.0);
- QCOMPARE(spy.count(),1);
-}
-
-void tst_qdeclarativeflickable::pressDelay()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 1.0; Flickable { pressDelay: 100; }", QUrl::fromLocalFile(""));
- QDeclarative1Flickable *flickable = qobject_cast<QDeclarative1Flickable*>(component.create());
- QSignalSpy spy(flickable, SIGNAL(pressDelayChanged()));
-
- QVERIFY(flickable);
- QCOMPARE(flickable->pressDelay(), 100);
-
- flickable->setPressDelay(200);
- QCOMPARE(flickable->pressDelay(), 200);
- QCOMPARE(spy.count(),1);
- flickable->setPressDelay(200);
- QCOMPARE(spy.count(),1);
-}
-
-// QT-4677
-void tst_qdeclarativeflickable::disabledContent()
-{
- QDeclarativeView *canvas = new QDeclarativeView;
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/disabledcontent.qml"));
- canvas->show();
- canvas->setFocus();
- QVERIFY(canvas->rootObject() != 0);
-
- QDeclarative1Flickable *flickable = qobject_cast<QDeclarative1Flickable*>(canvas->rootObject());
- QVERIFY(flickable != 0);
-
- QVERIFY(flickable->contentX() == 0);
- QVERIFY(flickable->contentY() == 0);
-
- QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(50, 50)));
- {
- QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(70,70)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(canvas->viewport(), &mv);
- }
- {
- QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(90,90)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(canvas->viewport(), &mv);
- }
- {
- QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(100,100)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(canvas->viewport(), &mv);
- }
-
- QVERIFY(flickable->contentX() < 0);
- QVERIFY(flickable->contentY() < 0);
-
- QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(90, 90)));
-
- delete canvas;
-}
-
-
-// QTBUG-17361
-void tst_qdeclarativeflickable::nestedPressDelay()
-{
- QDeclarativeView *canvas = new QDeclarativeView;
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/nestedPressDelay.qml"));
- canvas->show();
- canvas->setFocus();
- QVERIFY(canvas->rootObject() != 0);
-
- QDeclarative1Flickable *outer = qobject_cast<QDeclarative1Flickable*>(canvas->rootObject());
- QVERIFY(outer != 0);
-
- QDeclarative1Flickable *inner = canvas->rootObject()->findChild<QDeclarative1Flickable*>("innerFlickable");
- QVERIFY(inner != 0);
-
- QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(150, 150)));
- // the MouseArea is not pressed immediately
- QVERIFY(outer->property("pressed").toBool() == false);
-
- // The outer pressDelay will prevail (50ms, vs. 10sec)
- // QTRY_VERIFY() has 5sec timeout, so will timeout well within 10sec.
- QTRY_VERIFY(outer->property("pressed").toBool() == true);
-
- QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(150, 150)));
-
- delete canvas;
-}
-
-void tst_qdeclarativeflickable::flickableDirection()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 1.0; Flickable { flickableDirection: Flickable.VerticalFlick; }", QUrl::fromLocalFile(""));
- QDeclarative1Flickable *flickable = qobject_cast<QDeclarative1Flickable*>(component.create());
- QSignalSpy spy(flickable, SIGNAL(flickableDirectionChanged()));
-
- QVERIFY(flickable);
- QCOMPARE(flickable->flickableDirection(), QDeclarative1Flickable::VerticalFlick);
-
- flickable->setFlickableDirection(QDeclarative1Flickable::HorizontalAndVerticalFlick);
- QCOMPARE(flickable->flickableDirection(), QDeclarative1Flickable::HorizontalAndVerticalFlick);
- QCOMPARE(spy.count(),1);
-
- flickable->setFlickableDirection(QDeclarative1Flickable::AutoFlickDirection);
- QCOMPARE(flickable->flickableDirection(), QDeclarative1Flickable::AutoFlickDirection);
- QCOMPARE(spy.count(),2);
-
- flickable->setFlickableDirection(QDeclarative1Flickable::HorizontalFlick);
- QCOMPARE(flickable->flickableDirection(), QDeclarative1Flickable::HorizontalFlick);
- QCOMPARE(spy.count(),3);
-
- flickable->setFlickableDirection(QDeclarative1Flickable::HorizontalFlick);
- QCOMPARE(flickable->flickableDirection(), QDeclarative1Flickable::HorizontalFlick);
- QCOMPARE(spy.count(),3);
-}
-
-void tst_qdeclarativeflickable::qgraphicswidget()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickableqgraphicswidget.qml"));
- QDeclarative1Flickable *flickable = qobject_cast<QDeclarative1Flickable*>(c.create());
-
- QVERIFY(flickable != 0);
- QGraphicsWidget *widget = findItem<QGraphicsWidget>(flickable->contentItem(), "widget1");
- QVERIFY(widget);
-}
-
-// QtQuick 1.1
-void tst_qdeclarativeflickable::resizeContent()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/resize.qml"));
- QDeclarativeItem *root = qobject_cast<QDeclarativeItem*>(c.create());
- QDeclarative1Flickable *obj = findItem<QDeclarative1Flickable>(root, "flick");
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->contentX(), 0.);
- QCOMPARE(obj->contentY(), 0.);
- QCOMPARE(obj->contentWidth(), 300.);
- QCOMPARE(obj->contentHeight(), 300.);
-
- QMetaObject::invokeMethod(root, "resizeContent");
-
- QCOMPARE(obj->contentX(), 100.);
- QCOMPARE(obj->contentY(), 100.);
- QCOMPARE(obj->contentWidth(), 600.);
- QCOMPARE(obj->contentHeight(), 600.);
-
- delete root;
-}
-
-// QtQuick 1.1
-void tst_qdeclarativeflickable::returnToBounds()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/resize.qml"));
- QDeclarativeItem *root = qobject_cast<QDeclarativeItem*>(c.create());
- QDeclarative1Flickable *obj = findItem<QDeclarative1Flickable>(root, "flick");
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->contentX(), 0.);
- QCOMPARE(obj->contentY(), 0.);
- QCOMPARE(obj->contentWidth(), 300.);
- QCOMPARE(obj->contentHeight(), 300.);
-
- obj->setContentX(100);
- obj->setContentY(400);
- QTRY_COMPARE(obj->contentX(), 100.);
- QTRY_COMPARE(obj->contentY(), 400.);
-
- QMetaObject::invokeMethod(root, "returnToBounds");
-
- QTRY_COMPARE(obj->contentX(), 0.);
- QTRY_COMPARE(obj->contentY(), 0.);
-
- delete root;
-}
-
-void tst_qdeclarativeflickable::testQtQuick11Attributes()
-{
- QFETCH(QString, code);
- QFETCH(QString, warning);
- QFETCH(QString, error);
-
- QDeclarativeEngine engine;
- QObject *obj;
-
- QDeclarativeComponent invalid(&engine);
- invalid.setData("import QtQuick 1.0; Flickable { " + code.toUtf8() + " }", QUrl(""));
- QTest::ignoreMessage(QtWarningMsg, warning.toUtf8());
- obj = invalid.create();
- QCOMPARE(invalid.errorString(), error);
- delete obj;
-
- QDeclarativeComponent valid(&engine);
- valid.setData("import QtQuick 1.1; Flickable { " + code.toUtf8() + " }", QUrl(""));
- obj = valid.create();
- QVERIFY(obj);
- QVERIFY(valid.errorString().isEmpty());
- delete obj;
-}
-
-void tst_qdeclarativeflickable::testQtQuick11Attributes_data()
-{
- QTest::addColumn<QString>("code");
- QTest::addColumn<QString>("warning");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("resizeContent") << "Component.onCompleted: resizeContent(100,100,Qt.point(50,50))"
- << "<Unknown File>:1: ReferenceError: Can't find variable: resizeContent"
- << "";
-
- QTest::newRow("returnToBounds") << "Component.onCompleted: returnToBounds()"
- << "<Unknown File>:1: ReferenceError: Can't find variable: returnToBounds"
- << "";
-
-}
-
-void tst_qdeclarativeflickable::wheel()
-{
- QDeclarativeView *canvas = new QDeclarativeView;
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/wheel.qml"));
- canvas->show();
- canvas->setFocus();
- QVERIFY(canvas->rootObject() != 0);
-
- QDeclarative1Flickable *flick = canvas->rootObject()->findChild<QDeclarative1Flickable*>("flick");
- QVERIFY(flick != 0);
-
- QGraphicsScene *scene = canvas->scene();
- QGraphicsSceneWheelEvent event(QEvent::GraphicsSceneWheel);
- event.setScenePos(QPointF(200, 200));
- event.setDelta(-120);
- event.setOrientation(Qt::Vertical);
- event.setAccepted(false);
- QApplication::sendEvent(scene, &event);
-
- QTRY_VERIFY(flick->contentY() > 0);
- QVERIFY(flick->contentX() == 0);
-
- flick->setContentY(0);
- QVERIFY(flick->contentY() == 0);
-
- event.setScenePos(QPointF(200, 200));
- event.setDelta(-120);
- event.setOrientation(Qt::Horizontal);
- event.setAccepted(false);
- QApplication::sendEvent(scene, &event);
-
- QTRY_VERIFY(flick->contentX() > 0);
- QVERIFY(flick->contentY() == 0);
-
- delete canvas;
-}
-
-void tst_qdeclarativeflickable::disabled()
-{
- QDeclarativeView *canvas = new QDeclarativeView;
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/disabled.qml"));
- canvas->show();
- canvas->setFocus();
- QVERIFY(canvas->rootObject() != 0);
-
- QDeclarative1Flickable *flick = canvas->rootObject()->findChild<QDeclarative1Flickable*>("flickable");
- QVERIFY(flick != 0);
-
- QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(50,90)));
-
- QMouseEvent moveEvent(QEvent::MouseMove, canvas->mapFromScene(QPoint(50, 80)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(canvas, &moveEvent);
-
- moveEvent = QMouseEvent(QEvent::MouseMove, canvas->mapFromScene(QPoint(50, 70)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(canvas, &moveEvent);
-
- moveEvent = QMouseEvent(QEvent::MouseMove, canvas->mapFromScene(QPoint(50, 60)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(canvas, &moveEvent);
-
- QVERIFY(flick->isMoving() == false);
-
- QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(50, 60)));
-
- // verify that mouse clicks on other elements still work (QTBUG-20584)
- QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(50, 10)));
- QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(50, 10)));
-
- QVERIFY(canvas->rootObject()->property("clicked").toBool() == true);
-}
-
-void tst_qdeclarativeflickable::flickVelocity()
-{
-#ifdef Q_WS_MAC
- QSKIP("Producing flicks on Mac CI impossible due to timing problems");
-#endif
-
- QDeclarativeView *canvas = new QDeclarativeView;
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/flickable03.qml"));
- canvas->show();
- canvas->setFocus();
- QVERIFY(canvas->rootObject() != 0);
-
- QDeclarative1Flickable *flickable = qobject_cast<QDeclarative1Flickable*>(canvas->rootObject());
- QVERIFY(flickable != 0);
-
- // flick up
- flick(canvas, QPoint(20,190), QPoint(20, 50), 200);
- QVERIFY(flickable->verticalVelocity() > 0.0);
- QTRY_VERIFY(flickable->verticalVelocity() == 0.0);
-
- // flick down
- flick(canvas, QPoint(20,10), QPoint(20, 140), 200);
- QVERIFY(flickable->verticalVelocity() < 0.0);
- QTRY_VERIFY(flickable->verticalVelocity() == 0.0);
-
- delete canvas;
-}
-
-void tst_qdeclarativeflickable::flick(QGraphicsView *canvas, const QPoint &from, const QPoint &to, int duration)
-{
- const int pointCount = 5;
- QPoint diff = to - from;
-
- // send press, five equally spaced moves, and release.
- QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(from));
-
- for (int i = 0; i < pointCount; ++i) {
- QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(from + (i+1)*diff/pointCount), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(canvas->viewport(), &mv);
- QTest::qWait(duration/pointCount);
- QCoreApplication::processEvents();
- }
-
- QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(to));
-}
-
-
-template<typename T>
-T *tst_qdeclarativeflickable::findItem(QGraphicsObject *parent, const QString &objectName)
-{
- const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->childItems().count() << "children";
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QGraphicsObject *item = qobject_cast<QGraphicsObject*>(parent->childItems().at(i));
- if(!item)
- continue;
- //qDebug() << "try" << item;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
- return static_cast<T*>(item);
- }
- item = findItem<T>(item, objectName);
- if (item)
- return static_cast<T*>(item);
- }
-
- return 0;
-}
-
-QTEST_MAIN(tst_qdeclarativeflickable)
-
-#include "tst_qdeclarativeflickable.moc"
diff --git a/tests/auto/qtquick1/qdeclarativeflipable/data/crash.qml b/tests/auto/qtquick1/qdeclarativeflipable/data/crash.qml
deleted file mode 100644
index bc5229b529..0000000000
--- a/tests/auto/qtquick1/qdeclarativeflipable/data/crash.qml
+++ /dev/null
@@ -1,9 +0,0 @@
-import QtQuick 1.0
-
-Flipable {
- transform: Rotation {
- axis.y: 1
- axis.z: 0
- angle: 180
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeflipable/data/flipable-abort.qml b/tests/auto/qtquick1/qdeclarativeflipable/data/flipable-abort.qml
deleted file mode 100644
index 69ff4a2228..0000000000
--- a/tests/auto/qtquick1/qdeclarativeflipable/data/flipable-abort.qml
+++ /dev/null
@@ -1,10 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- Flipable {
- id: flipable
- }
- Rectangle {
- visible: flipable.side == Flipable.Front
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeflipable/data/test-flipable.qml b/tests/auto/qtquick1/qdeclarativeflipable/data/test-flipable.qml
deleted file mode 100644
index 02b69e0799..0000000000
--- a/tests/auto/qtquick1/qdeclarativeflipable/data/test-flipable.qml
+++ /dev/null
@@ -1,9 +0,0 @@
-import QtQuick 1.0
-
-Flipable {
- id: flipable
- width: 640; height: 480
-
- front: Rectangle { anchors.fill: flipable }
- back: Rectangle { anchors.fill: flipable }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeflipable/qdeclarativeflipable.pro b/tests/auto/qtquick1/qdeclarativeflipable/qdeclarativeflipable.pro
deleted file mode 100644
index eefb4d5902..0000000000
--- a/tests/auto/qtquick1/qdeclarativeflipable/qdeclarativeflipable.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeflipable
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeflipable.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
-QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib
-contains(QT_CONFIG,xcb):CONFIG+=insignificant_test # QTBUG-21012 fails on exit (X11-specific)
diff --git a/tests/auto/qtquick1/qdeclarativeflipable/tst_qdeclarativeflipable.cpp b/tests/auto/qtquick1/qdeclarativeflipable/tst_qdeclarativeflipable.cpp
deleted file mode 100644
index 2c0dbaa5de..0000000000
--- a/tests/auto/qtquick1/qdeclarativeflipable/tst_qdeclarativeflipable.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick1/qdeclarativeview.h>
-#include <QtQuick1/private/qdeclarativeflipable_p.h>
-#include <private/qdeclarativevaluetype_p.h>
-#include <QFontMetrics>
-#include <QtQuick1/private/qdeclarativerectangle_p.h>
-#include <math.h>
-
-class tst_qdeclarativeflipable : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativeflipable();
-
-private slots:
- void create();
- void checkFrontAndBack();
- void setFrontAndBack();
-
- // below here task issues
- void QTBUG_9161_crash();
- void QTBUG_8474_qgv_abort();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_qdeclarativeflipable::tst_qdeclarativeflipable()
-{
-}
-
-void tst_qdeclarativeflipable::create()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-flipable.qml"));
- QDeclarative1Flipable *obj = qobject_cast<QDeclarative1Flipable*>(c.create());
-
- QVERIFY(obj != 0);
- delete obj;
-}
-
-void tst_qdeclarativeflipable::checkFrontAndBack()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-flipable.qml"));
- QDeclarative1Flipable *obj = qobject_cast<QDeclarative1Flipable*>(c.create());
-
- QVERIFY(obj != 0);
- QVERIFY(obj->front() != 0);
- QVERIFY(obj->back() != 0);
- delete obj;
-}
-
-void tst_qdeclarativeflipable::setFrontAndBack()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-flipable.qml"));
- QDeclarative1Flipable *obj = qobject_cast<QDeclarative1Flipable*>(c.create());
-
- QVERIFY(obj != 0);
- QVERIFY(obj->front() != 0);
- QVERIFY(obj->back() != 0);
-
- QString message = c.url().toString() + ":3:1: QML Flipable: front is a write-once property";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- obj->setFront(new QDeclarative1Rectangle());
-
- message = c.url().toString() + ":3:1: QML Flipable: back is a write-once property";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- obj->setBack(new QDeclarative1Rectangle());
- delete obj;
-}
-
-void tst_qdeclarativeflipable::QTBUG_9161_crash()
-{
- QDeclarativeView *canvas = new QDeclarativeView;
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/crash.qml"));
- QGraphicsObject *root = canvas->rootObject();
- QVERIFY(root != 0);
- canvas->show();
- delete canvas;
-}
-
-void tst_qdeclarativeflipable::QTBUG_8474_qgv_abort()
-{
- QDeclarativeView *canvas = new QDeclarativeView;
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/flipable-abort.qml"));
- QGraphicsObject *root = canvas->rootObject();
- QVERIFY(root != 0);
- canvas->show();
- delete canvas;
-}
-
-QTEST_MAIN(tst_qdeclarativeflipable)
-
-#include "tst_qdeclarativeflipable.moc"
diff --git a/tests/auto/qtquick1/qdeclarativefocusscope/data/chain.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/chain.qml
deleted file mode 100644
index a40bc2cdd6..0000000000
--- a/tests/auto/qtquick1/qdeclarativefocusscope/data/chain.qml
+++ /dev/null
@@ -1,28 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: root
- width:300; height:400
-
- property bool focus1: root.activeFocus
- property bool focus2: item1.activeFocus
- property bool focus3: fs1.activeFocus
- property bool focus4: fs2.activeFocus
- property bool focus5: theItem.activeFocus
-
- Item {
- id: item1
- FocusScope {
- id: fs1
- focus: true
- FocusScope {
- id: fs2
- focus: true
- Item {
- id: theItem
- focus: true
- }
- }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativefocusscope/data/forceActiveFocus.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/forceActiveFocus.qml
deleted file mode 100644
index 6c39d4a432..0000000000
--- a/tests/auto/qtquick1/qdeclarativefocusscope/data/forceActiveFocus.qml
+++ /dev/null
@@ -1,26 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- objectName: "root"
- FocusScope {
- objectName: "scope"
- Item {
- objectName: "item-a1"
- FocusScope {
- objectName: "scope-a"
- Item {
- objectName: "item-a2"
- }
- }
- }
- Item {
- objectName: "item-b1"
- FocusScope {
- objectName: "scope-b"
- Item {
- objectName: "item-b2"
- }
- }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativefocusscope/data/forcefocus.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/forcefocus.qml
deleted file mode 100644
index 708e899146..0000000000
--- a/tests/auto/qtquick1/qdeclarativefocusscope/data/forcefocus.qml
+++ /dev/null
@@ -1,81 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 800; height: 600
-
- FocusScope {
- focus: true
-
- FocusScope {
- id: firstScope
- objectName: "item0"
- focus: true
-
- Rectangle {
- height: 120; width: 420
-
- color: "transparent"
- border.width: 5; border.color: firstScope.activeFocus?"blue":"black"
-
- Rectangle {
- id: item1; objectName: "item1"
- x: 10; y: 10; width: 100; height: 100; color: "green"
- border.width: 5; border.color: activeFocus?"blue":"black"
- focus: true
-
- Rectangle {
- width: 50; height: 50; anchors.centerIn: parent
- color: parent.activeFocus?"red":"transparent"
- }
- }
-
- Rectangle {
- id: item2; objectName: "item2"
- x: 310; y: 10; width: 100; height: 100; color: "green"
- border.width: 5; border.color: activeFocus?"blue":"black"
-
- Rectangle {
- width: 50; height: 50; anchors.centerIn: parent
- color: parent.activeFocus?"red":"transparent"
- }
- }
- }
- }
-
- FocusScope {
- id: secondScope
- objectName: "item3"
-
- Rectangle {
- y: 160; height: 120; width: 420
-
- color: "transparent"
- border.width: 5; border.color: secondScope.activeFocus?"blue":"black"
-
- Rectangle {
- id: item4; objectName: "item4"
- x: 10; y: 10; width: 100; height: 100; color: "green"
- border.width: 5; border.color: activeFocus?"blue":"black"
-
- Rectangle {
- width: 50; height: 50; anchors.centerIn: parent
- color: parent.activeFocus?"red":"transparent"
- }
- }
-
- Rectangle {
- id: item5; objectName: "item5"
- x: 310; y: 10; width: 100; height: 100; color: "green"
- border.width: 5; border.color: activeFocus?"blue":"black"
-
- Rectangle {
- width: 50; height: 50; anchors.centerIn: parent
- color: parent.activeFocus?"red":"transparent"
- }
- }
- }
- }
- }
- Keys.onDigit4Pressed: item4.focus = true
- Keys.onDigit5Pressed: item5.forceActiveFocus()
-}
diff --git a/tests/auto/qtquick1/qdeclarativefocusscope/data/qtBug13380.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/qtBug13380.qml
deleted file mode 100644
index 1784202e77..0000000000
--- a/tests/auto/qtquick1/qdeclarativefocusscope/data/qtBug13380.qml
+++ /dev/null
@@ -1,24 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 400; height: 400
-
- property bool showRect: false
- onShowRectChanged: if (showRect) rect.visible = true
- property bool noFocus: !fs2.activeFocus
-
- FocusScope {
- id: fs1
- focus: true
- }
- Rectangle {
- id: rect
- visible: false
- FocusScope {
- id: fs2
- Rectangle {
- focus: true
- }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativefocusscope/data/signalEmission.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/signalEmission.qml
deleted file mode 100644
index 5850791704..0000000000
--- a/tests/auto/qtquick1/qdeclarativefocusscope/data/signalEmission.qml
+++ /dev/null
@@ -1,33 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 200
- height: 200
-
- FocusScope {
- focus: true
- Rectangle {
- objectName: "item1"
- color: "blue"
- onFocusChanged: focus ? color = "red" : color = "blue"
- }
- Rectangle {
- objectName: "item2"
- color: "blue"
- onFocusChanged: focus ? color = "red" : color = "blue"
- }
- }
-
- FocusScope {
- Rectangle {
- objectName: "item3"
- color: "blue"
- onFocusChanged: focus ? color = "red" : color = "blue"
- }
- Rectangle {
- objectName: "item4"
- color: "blue"
- onFocusChanged: focus ? color = "red" : color = "blue"
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativefocusscope/data/test.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/test.qml
deleted file mode 100644
index 5983c19015..0000000000
--- a/tests/auto/qtquick1/qdeclarativefocusscope/data/test.qml
+++ /dev/null
@@ -1,77 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- color: "white"
- width: 800
- height: 600
-
- Keys.onDigit9Pressed: console.log("Error - Root")
-
- FocusScope {
- id: myScope
- objectName: "item0"
- focus: true
-
- Keys.onDigit9Pressed: console.log("Error - FocusScope")
-
- Rectangle {
- height: 120
- width: 420
-
- color: "transparent"
- border.width: 5
- border.color: myScope.activeFocus?"blue":"black"
-
- Rectangle {
- id: item1; objectName: "item1"
- x: 10; y: 10
- width: 100; height: 100; color: "green"
- border.width: 5
- border.color: activeFocus?"blue":"black"
- Keys.onDigit9Pressed: console.debug("Top Left");
- KeyNavigation.right: item2
- focus: true
-
- Rectangle {
- width: 50; height: 50; anchors.centerIn: parent
- color: parent.activeFocus?"red":"transparent"
- }
- }
-
- Rectangle {
- id: item2; objectName: "item2"
- x: 310; y: 10
- width: 100; height: 100; color: "green"
- border.width: 5
- border.color: activeFocus?"blue":"black"
- KeyNavigation.left: item1
- Keys.onDigit9Pressed: console.log("Top Right");
-
- Rectangle {
- width: 50; height: 50; anchors.centerIn: parent
- color: parent.activeFocus?"red":"transparent"
- }
- }
- }
- KeyNavigation.down: item3
- }
-
- Text { x:100; y:170; text: "Blue border indicates scoped focus\nBlack border indicates NOT scoped focus\nRed box indicates active focus\nUse arrow keys to navigate\nPress \"9\" to print currently focused item" }
-
- Rectangle {
- id: item3; objectName: "item3"
- x: 10; y: 300
- width: 100; height: 100; color: "green"
- border.width: 5
- border.color: activeFocus?"blue":"black"
-
- Keys.onDigit9Pressed: console.log("Bottom Left");
- KeyNavigation.up: myScope
-
- Rectangle {
- width: 50; height: 50; anchors.centerIn: parent
- color: parent.activeFocus?"red":"transparent"
- }
- }
-
-}
diff --git a/tests/auto/qtquick1/qdeclarativefocusscope/data/test2.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/test2.qml
deleted file mode 100644
index 8c0b3b4267..0000000000
--- a/tests/auto/qtquick1/qdeclarativefocusscope/data/test2.qml
+++ /dev/null
@@ -1,39 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- color: "white"
- width: 800
- height: 600
-
- Text { text: "All five rectangles should be red" }
-
- FocusScope {
- y: 100
- focus: true; objectName: "item1"
- Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" }
-
- FocusScope {
- y: 100
- focus: true; objectName: "item2"
- Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" }
-
- FocusScope {
- y: 100
- focus: true; objectName: "item3"
- Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" }
-
- FocusScope {
- y: 100
- focus: true; objectName: "item4"
- Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" }
-
- FocusScope {
- y: 100
- focus: true; objectName: "item5"
- Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" }
- }
- }
- }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativefocusscope/data/test3.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/test3.qml
deleted file mode 100644
index 2e025cb6cc..0000000000
--- a/tests/auto/qtquick1/qdeclarativefocusscope/data/test3.qml
+++ /dev/null
@@ -1,52 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- color: "white"
- width: 800
- height: 600
-
- ListModel {
- id: model
- ListElement { name: "1" }
- ListElement { name: "2" }
- ListElement { name: "3" }
- ListElement { name: "4" }
- ListElement { name: "5" }
- ListElement { name: "6" }
- ListElement { name: "7" }
- ListElement { name: "8" }
- ListElement { name: "9" }
- }
-
- Component {
- id: verticalDelegate
- FocusScope {
- id: root
- width: 50; height: 50;
- Keys.onDigit9Pressed: console.log("Error - " + name)
- Rectangle {
- focus: true
- Keys.onDigit9Pressed: console.log(name)
- width: 50; height: 50;
- color: root.ListView.isCurrentItem?"red":"green"
- Text { text: name; anchors.centerIn: parent }
- }
- }
- }
-
- ListView {
- width: 800; height: 50; orientation: "Horizontal"
- focus: true
- model: model
- delegate: verticalDelegate
- preferredHighlightBegin: 100
- preferredHighlightEnd: 100
- highlightRangeMode: "StrictlyEnforceRange"
- }
-
-
- Text {
- y: 100; x: 50
- text: "Currently selected element should be red\nPressing \"9\" should print the number of the currently selected item\nBe sure to scroll all the way to the right, pause, and then all the way to the left."
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativefocusscope/data/test4.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/test4.qml
deleted file mode 100644
index 7192dee6db..0000000000
--- a/tests/auto/qtquick1/qdeclarativefocusscope/data/test4.qml
+++ /dev/null
@@ -1,76 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- color: "white"
- width: 800
- height: 600
-
- Keys.onDigit9Pressed: console.log("Error - Root")
-
- FocusScope {
- id: myScope
-
- Keys.onDigit9Pressed: console.log("Error - FocusScope")
-
- Rectangle {
- objectName: "item0"
- height: 120
- width: 420
-
- color: "transparent"
- border.width: 5
- border.color: myScope.activeFocus?"blue":"black"
-
- Rectangle {
- id: item1; objectName: "item1"
- x: 10; y: 10
- width: 100; height: 100; color: "green"
- border.width: 5
- border.color: activeFocus?"blue":"black"
- Keys.onDigit9Pressed: console.log("Error - Top Left");
- KeyNavigation.right: item2
- focus: true
-
- Rectangle {
- width: 50; height: 50; anchors.centerIn: parent
- color: parent.activeFocus?"red":"transparent"
- }
- }
-
- Rectangle {
- id: item2; objectName: "item2"
- x: 310; y: 10
- width: 100; height: 100; color: "green"
- border.width: 5
- border.color: activeFocus?"blue":"black"
- KeyNavigation.left: item1
- Keys.onDigit9Pressed: console.log("Error - Top Right");
-
- Rectangle {
- width: 50; height: 50; anchors.centerIn: parent
- color: parent.activeFocus?"red":"transparent"
- }
- }
- }
- KeyNavigation.down: item3
- }
-
- Text { x:100; y:170; text: "There should be no blue borders, or red squares.\nPressing \"9\" should do nothing.\nArrow keys should have no effect." }
-
- Rectangle {
- id: item3; objectName: "item3"
- x: 10; y: 300
- width: 100; height: 100; color: "green"
- border.width: 5
- border.color: activeFocus?"blue":"black"
-
- Keys.onDigit9Pressed: console.log("Error - Bottom Left");
- KeyNavigation.up: myScope
-
- Rectangle {
- width: 50; height: 50; anchors.centerIn: parent
- color: parent.activeFocus?"red":"transparent"
- }
- }
-
-}
diff --git a/tests/auto/qtquick1/qdeclarativefocusscope/data/test5.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/test5.qml
deleted file mode 100644
index 01dada5d37..0000000000
--- a/tests/auto/qtquick1/qdeclarativefocusscope/data/test5.qml
+++ /dev/null
@@ -1,84 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- color: "white"
- width: 800
- height: 600
-
- Keys.onReturnPressed: console.log("Error - Root")
-
- FocusScope {
- id: myScope
- objectName: "item0"
- focus: true
-
- Keys.onReturnPressed: console.log("Error - FocusScope")
-
- Rectangle {
- height: 120
- width: 420
-
- color: "transparent"
- border.width: 5
- border.color: myScope.activeFocus?"blue":"black"
-
- Rectangle {
- x: 10; y: 10
- width: 100; height: 100; color: "green"
- border.width: 5
- border.color: item1.activeFocus?"blue":"black"
- }
-
- TextEdit {
- id: item1; objectName: "item1"
- x: 20; y: 20
- width: 90; height: 90
- color: "white"
- font.pixelSize: 20
- Keys.onReturnPressed: console.log("Top Left");
- KeyNavigation.right: item2
- focus: true
- wrapMode: TextEdit.WordWrap
- text: "Box 1"
- }
-
- Rectangle {
- id: item2; objectName: "item2"
- x: 310; y: 10
- width: 100; height: 100; color: "green"
- border.width: 5
- border.color: activeFocus?"blue":"black"
- KeyNavigation.left: item1
- Keys.onReturnPressed: console.log("Top Right");
-
- Rectangle {
- width: 50; height: 50; anchors.centerIn: parent
- color: parent.activeFocus?"red":"transparent"
- }
- }
- }
- KeyNavigation.down: item3
- }
-
- Text { x:100; y:170; text: "Blue border indicates scoped focus\nBlack border indicates NOT scoped focus\nRed box or flashing cursor indicates active focus\nUse arrow keys to navigate\nPress Ctrl-Return to print currently focused item" }
-
- Rectangle {
- x: 10; y: 300
- width: 100; height: 100; color: "green"
- border.width: 5
- border.color: item3.activeFocus?"blue":"black"
- }
-
- TextEdit {
- id: item3; objectName: "item3"
- x: 20; y: 310
- width: 90; height: 90
- color: "white"
- font.pixelSize: 20
- text: "Box 3"
-
- Keys.onReturnPressed: console.log("Bottom Left");
- KeyNavigation.up: myScope
- wrapMode: TextEdit.WordWrap
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativefocusscope/qdeclarativefocusscope.pro b/tests/auto/qtquick1/qdeclarativefocusscope/qdeclarativefocusscope.pro
deleted file mode 100644
index 67bd8ae6d4..0000000000
--- a/tests/auto/qtquick1/qdeclarativefocusscope/qdeclarativefocusscope.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativefocusscope
-SOURCES += tst_qdeclarativefocusscope.cpp
-macx:CONFIG -= app_bundle
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-QT += core-private gui-private widgets-private declarative-private qtquick1-private testlib
-CONFIG+=insignificant_test # QTBUG-21013 unstable
diff --git a/tests/auto/qtquick1/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp b/tests/auto/qtquick1/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp
deleted file mode 100644
index a311a84603..0000000000
--- a/tests/auto/qtquick1/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp
+++ /dev/null
@@ -1,513 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QSignalSpy>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick1/qdeclarativeview.h>
-#include <QtQuick1/private/qdeclarativerectangle_p.h>
-#include <QtQuick1/private/qdeclarativetextedit_p.h>
-#include <QtQuick1/private/qdeclarativetext_p.h>
-#include <QtQuick1/private/qdeclarativefocusscope_p.h>
-
-class tst_qdeclarativefocusscope : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativefocusscope() {}
-
- template<typename T>
- T *findItem(QGraphicsObject *parent, const QString &id);
-
-private slots:
- void basic();
- void nested();
- void noFocus();
- void textEdit();
- void forceFocus();
- void noParentFocus();
- void signalEmission();
- void qtBug13380();
- void forceActiveFocus();
-};
-
-/*
- Find an item with the specified id.
-*/
-template<typename T>
-T *tst_qdeclarativefocusscope::findItem(QGraphicsObject *parent, const QString &objectName)
-{
- const QMetaObject &mo = T::staticMetaObject;
- QList<QGraphicsItem *> children = parent->childItems();
- for (int i = 0; i < children.count(); ++i) {
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(children.at(i)->toGraphicsObject());
- if (item) {
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
- return static_cast<T*>(item);
- }
- item = findItem<T>(item, objectName);
- if (item)
- return static_cast<T*>(item);
- }
- }
- return 0;
-}
-
-void tst_qdeclarativefocusscope::basic()
-{
- QDeclarativeView *view = new QDeclarativeView;
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/test.qml"));
-
- QDeclarative1FocusScope *item0 = findItem<QDeclarative1FocusScope>(view->rootObject(), QLatin1String("item0"));
- QDeclarative1Rectangle *item1 = findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("item1"));
- QDeclarative1Rectangle *item2 = findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("item2"));
- QDeclarative1Rectangle *item3 = findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("item3"));
- QVERIFY(item0 != 0);
- QVERIFY(item1 != 0);
- QVERIFY(item2 != 0);
- QVERIFY(item3 != 0);
-
- view->show();
- qApp->setActiveWindow(view);
-
- QTest::qWaitForWindowShown(view);
-
- QTRY_VERIFY(view->hasFocus());
- QVERIFY(view->scene()->hasFocus());
- QVERIFY(item0->hasActiveFocus() == true);
- QVERIFY(item1->hasActiveFocus() == true);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
-
- QTest::keyClick(view, Qt::Key_Right);
- QVERIFY(item0->hasActiveFocus() == true);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == true);
- QVERIFY(item3->hasActiveFocus() == false);
-
- QTest::keyClick(view, Qt::Key_Down);
- QVERIFY(item0->hasActiveFocus() == false);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == true);
-
- delete view;
-}
-
-void tst_qdeclarativefocusscope::nested()
-{
- QDeclarativeView *view = new QDeclarativeView;
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/test2.qml"));
-
- QDeclarative1FocusScope *item1 = findItem<QDeclarative1FocusScope>(view->rootObject(), QLatin1String("item1"));
- QDeclarative1FocusScope *item2 = findItem<QDeclarative1FocusScope>(view->rootObject(), QLatin1String("item2"));
- QDeclarative1FocusScope *item3 = findItem<QDeclarative1FocusScope>(view->rootObject(), QLatin1String("item3"));
- QDeclarative1FocusScope *item4 = findItem<QDeclarative1FocusScope>(view->rootObject(), QLatin1String("item4"));
- QDeclarative1FocusScope *item5 = findItem<QDeclarative1FocusScope>(view->rootObject(), QLatin1String("item5"));
- QVERIFY(item1 != 0);
- QVERIFY(item2 != 0);
- QVERIFY(item3 != 0);
- QVERIFY(item4 != 0);
- QVERIFY(item5 != 0);
-
- view->show();
- qApp->setActiveWindow(view);
-
- QTest::qWaitForWindowShown(view);
-
- QTRY_VERIFY(view->hasFocus());
- QVERIFY(view->scene()->hasFocus());
-
- QVERIFY(item1->hasActiveFocus() == true);
- QVERIFY(item2->hasActiveFocus() == true);
- QVERIFY(item3->hasActiveFocus() == true);
- QVERIFY(item4->hasActiveFocus() == true);
- QVERIFY(item5->hasActiveFocus() == true);
- delete view;
-}
-
-void tst_qdeclarativefocusscope::noFocus()
-{
- QDeclarativeView *view = new QDeclarativeView;
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/test4.qml"));
-
- QDeclarative1Rectangle *item0 = findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("item0"));
- QDeclarative1Rectangle *item1 = findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("item1"));
- QDeclarative1Rectangle *item2 = findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("item2"));
- QDeclarative1Rectangle *item3 = findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("item3"));
- QVERIFY(item0 != 0);
- QVERIFY(item1 != 0);
- QVERIFY(item2 != 0);
- QVERIFY(item3 != 0);
-
- view->show();
- qApp->setActiveWindow(view);
-
- QTest::qWaitForWindowShown(view);
-
- QTRY_VERIFY(view->hasFocus());
- QVERIFY(view->scene()->hasFocus());
- QVERIFY(item0->hasActiveFocus() == false);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
-
- QTest::keyClick(view, Qt::Key_Right);
- QVERIFY(item0->hasActiveFocus() == false);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
-
- QTest::keyClick(view, Qt::Key_Down);
- QVERIFY(item0->hasActiveFocus() == false);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
-
- delete view;
-}
-
-void tst_qdeclarativefocusscope::textEdit()
-{
- QDeclarativeView *view = new QDeclarativeView;
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/test5.qml"));
-
- QDeclarative1FocusScope *item0 = findItem<QDeclarative1FocusScope>(view->rootObject(), QLatin1String("item0"));
- QDeclarative1TextEdit *item1 = findItem<QDeclarative1TextEdit>(view->rootObject(), QLatin1String("item1"));
- QDeclarative1Rectangle *item2 = findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("item2"));
- QDeclarative1TextEdit *item3 = findItem<QDeclarative1TextEdit>(view->rootObject(), QLatin1String("item3"));
- QVERIFY(item0 != 0);
- QVERIFY(item1 != 0);
- QVERIFY(item2 != 0);
- QVERIFY(item3 != 0);
-
- view->show();
- qApp->setActiveWindow(view);
-
- QTest::qWaitForWindowShown(view);
-
- QTRY_VERIFY(view->hasFocus());
- QVERIFY(view->scene()->hasFocus());
- QVERIFY(item0->hasActiveFocus() == true);
- QVERIFY(item1->hasActiveFocus() == true);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
-
- QTest::keyClick(view, Qt::Key_Right);
- QVERIFY(item0->hasActiveFocus() == true);
- QVERIFY(item1->hasActiveFocus() == true);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
-
- QTest::keyClick(view, Qt::Key_Right);
- QTest::keyClick(view, Qt::Key_Right);
- QTest::keyClick(view, Qt::Key_Right);
- QTest::keyClick(view, Qt::Key_Right);
- QTest::keyClick(view, Qt::Key_Right);
- QVERIFY(item0->hasActiveFocus() == true);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == true);
- QVERIFY(item3->hasActiveFocus() == false);
-
- QTest::keyClick(view, Qt::Key_Down);
- QVERIFY(item0->hasActiveFocus() == false);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == true);
-
- delete view;
-}
-
-void tst_qdeclarativefocusscope::forceFocus()
-{
- QDeclarativeView *view = new QDeclarativeView;
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/forcefocus.qml"));
-
- QDeclarative1FocusScope *item0 = findItem<QDeclarative1FocusScope>(view->rootObject(), QLatin1String("item0"));
- QDeclarative1Rectangle *item1 = findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("item1"));
- QDeclarative1Rectangle *item2 = findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("item2"));
- QDeclarative1FocusScope *item3 = findItem<QDeclarative1FocusScope>(view->rootObject(), QLatin1String("item3"));
- QDeclarative1Rectangle *item4 = findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("item4"));
- QDeclarative1Rectangle *item5 = findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("item5"));
- QVERIFY(item0 != 0);
- QVERIFY(item1 != 0);
- QVERIFY(item2 != 0);
- QVERIFY(item3 != 0);
- QVERIFY(item4 != 0);
- QVERIFY(item5 != 0);
-
- view->show();
- qApp->setActiveWindow(view);
-
- QTest::qWaitForWindowShown(view);
-
- QTRY_VERIFY(view->hasFocus());
- QVERIFY(view->scene()->hasFocus());
- QVERIFY(item0->hasActiveFocus() == true);
- QVERIFY(item1->hasActiveFocus() == true);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
- QVERIFY(item4->hasActiveFocus() == false);
- QVERIFY(item5->hasActiveFocus() == false);
-
- QTest::keyClick(view, Qt::Key_4);
- QVERIFY(item0->hasActiveFocus() == true);
- QVERIFY(item1->hasActiveFocus() == true);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
- QVERIFY(item4->hasActiveFocus() == false);
- QVERIFY(item5->hasActiveFocus() == false);
-
- QTest::keyClick(view, Qt::Key_5);
- QVERIFY(item0->hasActiveFocus() == false);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == true);
- QVERIFY(item4->hasActiveFocus() == false);
- QVERIFY(item5->hasActiveFocus() == true);
-
- delete view;
-}
-
-void tst_qdeclarativefocusscope::noParentFocus()
-{
- QDeclarativeView *view = new QDeclarativeView;
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/chain.qml"));
- QVERIFY(view->rootObject());
-
- QVERIFY(view->rootObject()->property("focus1") == false);
- QVERIFY(view->rootObject()->property("focus2") == false);
- QVERIFY(view->rootObject()->property("focus3") == true);
- QVERIFY(view->rootObject()->property("focus4") == true);
- QVERIFY(view->rootObject()->property("focus5") == true);
-
- delete view;
-}
-
-void tst_qdeclarativefocusscope::signalEmission()
-{
- QDeclarativeView *view = new QDeclarativeView;
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/signalEmission.qml"));
-
- QDeclarative1Rectangle *item1 = findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("item1"));
- QDeclarative1Rectangle *item2 = findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("item2"));
- QDeclarative1Rectangle *item3 = findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("item3"));
- QDeclarative1Rectangle *item4 = findItem<QDeclarative1Rectangle>(view->rootObject(), QLatin1String("item4"));
- QVERIFY(item1 != 0);
- QVERIFY(item2 != 0);
- QVERIFY(item3 != 0);
- QVERIFY(item4 != 0);
-
- view->show();
- qApp->setActiveWindow(view);
-
- QTest::qWaitForWindowShown(view);
-
- QVariant blue(QColor("blue"));
- QVariant red(QColor("red"));
-
- QTRY_VERIFY(view->hasFocus());
- QVERIFY(view->scene()->hasFocus());
- item1->setFocus(true);
- QCOMPARE(item1->property("color"), red);
- QCOMPARE(item2->property("color"), blue);
- QCOMPARE(item3->property("color"), blue);
- QCOMPARE(item4->property("color"), blue);
-
- item2->setFocus(true);
- QCOMPARE(item1->property("color"), blue);
- QCOMPARE(item2->property("color"), red);
- QCOMPARE(item3->property("color"), blue);
- QCOMPARE(item4->property("color"), blue);
-
- item3->setFocus(true);
- QCOMPARE(item1->property("color"), blue);
- QCOMPARE(item2->property("color"), red);
- QCOMPARE(item3->property("color"), red);
- QCOMPARE(item4->property("color"), blue);
-
- item4->setFocus(true);
- QCOMPARE(item1->property("color"), blue);
- QCOMPARE(item2->property("color"), red);
- QCOMPARE(item3->property("color"), blue);
- QCOMPARE(item4->property("color"), red);
-
- item4->setFocus(false);
- QCOMPARE(item1->property("color"), blue);
- QCOMPARE(item2->property("color"), red);
- QCOMPARE(item3->property("color"), blue);
- QCOMPARE(item4->property("color"), blue);
-
- delete view;
-}
-
-void tst_qdeclarativefocusscope::qtBug13380()
-{
- QDeclarativeView *view = new QDeclarativeView;
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/qtBug13380.qml"));
-
- view->show();
- QVERIFY(view->rootObject());
- qApp->setActiveWindow(view);
-
- QTest::qWaitForWindowShown(view);
-
- QTRY_VERIFY(view->hasFocus());
- QVERIFY(view->scene()->hasFocus());
- QVERIFY(view->rootObject()->property("noFocus").toBool());
-
- view->rootObject()->setProperty("showRect", true);
- QVERIFY(view->rootObject()->property("noFocus").toBool());
-
- delete view;
-}
-
-void tst_qdeclarativefocusscope::forceActiveFocus()
-{
- QDeclarativeView *view = new QDeclarativeView;
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/forceActiveFocus.qml"));
-
- QGraphicsObject *rootObject = view->rootObject();
- QVERIFY(rootObject);
-
- QDeclarativeItem *scope = findItem<QDeclarativeItem>(rootObject, QLatin1String("scope"));
- QDeclarativeItem *itemA1 = findItem<QDeclarativeItem>(rootObject, QLatin1String("item-a1"));
- QDeclarativeItem *scopeA = findItem<QDeclarativeItem>(rootObject, QLatin1String("scope-a"));
- QDeclarativeItem *itemA2 = findItem<QDeclarativeItem>(rootObject, QLatin1String("item-a2"));
- QDeclarativeItem *itemB1 = findItem<QDeclarativeItem>(rootObject, QLatin1String("item-b1"));
- QDeclarativeItem *scopeB = findItem<QDeclarativeItem>(rootObject, QLatin1String("scope-b"));
- QDeclarativeItem *itemB2 = findItem<QDeclarativeItem>(rootObject, QLatin1String("item-b2"));
-
- QVERIFY(scope);
- QVERIFY(itemA1);
- QVERIFY(scopeA);
- QVERIFY(itemA2);
- QVERIFY(itemB1);
- QVERIFY(scopeB);
- QVERIFY(itemB2);
-
- QSignalSpy rootSpy(rootObject, SIGNAL(activeFocusChanged(bool)));
- QSignalSpy scopeSpy(scope, SIGNAL(activeFocusChanged(bool)));
- QSignalSpy scopeASpy(scopeA, SIGNAL(activeFocusChanged(bool)));
- QSignalSpy scopeBSpy(scopeB, SIGNAL(activeFocusChanged(bool)));
-
- // First, walk the focus from item-a1 down to item-a2 and back again
- itemA1->forceActiveFocus();
- QVERIFY(itemA1->hasActiveFocus());
- QCOMPARE(rootSpy.count(), 1);
- QCOMPARE(scopeSpy.count(), 1);
-
- scopeA->forceActiveFocus();
- QVERIFY(!itemA1->hasActiveFocus());
- QVERIFY(scopeA->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 1);
- QCOMPARE(rootSpy.count(), 1);
- QCOMPARE(scopeSpy.count(), 1);
-
- itemA2->forceActiveFocus();
- QVERIFY(!itemA1->hasActiveFocus());
- QVERIFY(itemA2->hasActiveFocus());
- QVERIFY(scopeA->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 1);
- QCOMPARE(rootSpy.count(), 1);
- QCOMPARE(scopeSpy.count(), 1);
-
- scopeA->forceActiveFocus();
- QVERIFY(!itemA1->hasActiveFocus());
- QVERIFY(itemA2->hasActiveFocus());
- QVERIFY(scopeA->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 1);
- QCOMPARE(rootSpy.count(), 1);
- QCOMPARE(scopeSpy.count(), 1);
-
- itemA1->forceActiveFocus();
- QVERIFY(itemA1->hasActiveFocus());
- QVERIFY(!scopeA->hasActiveFocus());
- QVERIFY(!itemA2->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 2);
- QCOMPARE(rootSpy.count(), 1);
- QCOMPARE(scopeSpy.count(), 1);
-
- // Then jump back and forth between branch 'a' and 'b'
- itemB1->forceActiveFocus();
- QVERIFY(itemB1->hasActiveFocus());
- QCOMPARE(rootSpy.count(), 1);
- QCOMPARE(scopeSpy.count(), 1);
-
- scopeA->forceActiveFocus();
- QVERIFY(!itemA1->hasActiveFocus());
- QVERIFY(!itemB1->hasActiveFocus());
- QVERIFY(scopeA->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 3);
- QCOMPARE(rootSpy.count(), 1);
- QCOMPARE(scopeSpy.count(), 1);
-
- scopeB->forceActiveFocus();
- QVERIFY(!scopeA->hasActiveFocus());
- QVERIFY(!itemB1->hasActiveFocus());
- QVERIFY(scopeB->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 4);
- QCOMPARE(scopeBSpy.count(), 1);
- QCOMPARE(rootSpy.count(), 1);
- QCOMPARE(scopeSpy.count(), 1);
-
- itemA2->forceActiveFocus();
- QVERIFY(!scopeB->hasActiveFocus());
- QVERIFY(itemA2->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 5);
- QCOMPARE(scopeBSpy.count(), 2);
- QCOMPARE(rootSpy.count(), 1);
- QCOMPARE(scopeSpy.count(), 1);
-
- itemB2->forceActiveFocus();
- QVERIFY(!itemA2->hasActiveFocus());
- QVERIFY(itemB2->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 6);
- QCOMPARE(scopeBSpy.count(), 3);
- QCOMPARE(rootSpy.count(), 1);
- QCOMPARE(scopeSpy.count(), 1);
-
- delete view;
-}
-
-QTEST_MAIN(tst_qdeclarativefocusscope)
-
-#include "tst_qdeclarativefocusscope.moc"
diff --git a/tests/auto/qtquick1/qdeclarativefontloader/data/daniel.ttf b/tests/auto/qtquick1/qdeclarativefontloader/data/daniel.ttf
deleted file mode 100644
index aae50d5035..0000000000
--- a/tests/auto/qtquick1/qdeclarativefontloader/data/daniel.ttf
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativefontloader/data/dummy.ttf b/tests/auto/qtquick1/qdeclarativefontloader/data/dummy.ttf
deleted file mode 100644
index e69de29bb2..0000000000
--- a/tests/auto/qtquick1/qdeclarativefontloader/data/dummy.ttf
+++ /dev/null
diff --git a/tests/auto/qtquick1/qdeclarativefontloader/data/tarzeau_ocr_a.ttf b/tests/auto/qtquick1/qdeclarativefontloader/data/tarzeau_ocr_a.ttf
deleted file mode 100644
index cf93f9651f..0000000000
--- a/tests/auto/qtquick1/qdeclarativefontloader/data/tarzeau_ocr_a.ttf
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativefontloader/qdeclarativefontloader.pro b/tests/auto/qtquick1/qdeclarativefontloader/qdeclarativefontloader.pro
deleted file mode 100644
index fbe72b072c..0000000000
--- a/tests/auto/qtquick1/qdeclarativefontloader/qdeclarativefontloader.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativefontloader
-macx:CONFIG -= app_bundle
-
-HEADERS += ../../shared/testhttpserver.h
-SOURCES += tst_qdeclarativefontloader.cpp ../../shared/testhttpserver.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
-QT += core-private gui-private widgets-private declarative-private qtquick1-private network testlib
diff --git a/tests/auto/qtquick1/qdeclarativefontloader/tst_qdeclarativefontloader.cpp b/tests/auto/qtquick1/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
deleted file mode 100644
index ed973525fe..0000000000
--- a/tests/auto/qtquick1/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
+++ /dev/null
@@ -1,224 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QSignalSpy>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtQuick1/private/qdeclarativefontloader_p.h>
-#include "../../shared/testhttpserver.h"
-
-#define SERVER_PORT 14448
-
-class tst_qdeclarativefontloader : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativefontloader();
-
-private slots:
- void init();
- void noFont();
- void namedFont();
- void localFont();
- void failLocalFont();
- void webFont();
- void redirWebFont();
- void failWebFont();
- void changeFont();
-
-private:
- QDeclarativeEngine engine;
- TestHTTPServer server;
-};
-
-tst_qdeclarativefontloader::tst_qdeclarativefontloader() :
- server(SERVER_PORT)
-{
- server.serveDirectory(SRCDIR "/data");
-}
-
-void tst_qdeclarativefontloader::init()
-{
- QVERIFY(server.isValid());
-}
-
-void tst_qdeclarativefontloader::noFont()
-{
- QString componentStr = "import QtQuick 1.0\nFontLoader { }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1FontLoader *fontObject = qobject_cast<QDeclarative1FontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QCOMPARE(fontObject->name(), QString(""));
- QCOMPARE(fontObject->source(), QUrl(""));
- QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Null);
-
- delete fontObject;
-}
-
-void tst_qdeclarativefontloader::namedFont()
-{
- QString componentStr = "import QtQuick 1.0\nFontLoader { name: \"Helvetica\" }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1FontLoader *fontObject = qobject_cast<QDeclarative1FontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QCOMPARE(fontObject->source(), QUrl(""));
- QCOMPARE(fontObject->name(), QString("Helvetica"));
- QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Ready);
-}
-
-void tst_qdeclarativefontloader::localFont()
-{
- QString componentStr = "import QtQuick 1.0\nFontLoader { source: \"" SRCDIR "/data/tarzeau_ocr_a.ttf\" }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1FontLoader *fontObject = qobject_cast<QDeclarative1FontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QVERIFY(fontObject->source() != QUrl(""));
- QTRY_COMPARE(fontObject->name(), QString("OCRA"));
- QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Ready);
-}
-
-void tst_qdeclarativefontloader::failLocalFont()
-{
- QString componentStr = "import QtQuick 1.0\nFontLoader { source: \"" + QUrl::fromLocalFile(SRCDIR "/data/dummy.ttf").toString() + "\" }";
- QTest::ignoreMessage(QtWarningMsg, QString("file::2:1: QML FontLoader: Cannot load font: \"" + QUrl::fromLocalFile(SRCDIR "/data/dummy.ttf").toString() + "\"").toUtf8().constData());
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1FontLoader *fontObject = qobject_cast<QDeclarative1FontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QVERIFY(fontObject->source() != QUrl(""));
- QTRY_COMPARE(fontObject->name(), QString(""));
- QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Error);
-}
-
-void tst_qdeclarativefontloader::webFont()
-{
- QString componentStr = "import QtQuick 1.0\nFontLoader { source: \"http://localhost:14448/tarzeau_ocr_a.ttf\" }";
- QDeclarativeComponent component(&engine);
-
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1FontLoader *fontObject = qobject_cast<QDeclarative1FontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QVERIFY(fontObject->source() != QUrl(""));
- QTRY_COMPARE(fontObject->name(), QString("OCRA"));
- QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Ready);
-}
-
-void tst_qdeclarativefontloader::redirWebFont()
-{
- server.addRedirect("olddir/oldname.ttf","../tarzeau_ocr_a.ttf");
-
- QString componentStr = "import QtQuick 1.0\nFontLoader { source: \"http://localhost:14448/olddir/oldname.ttf\" }";
- QDeclarativeComponent component(&engine);
-
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1FontLoader *fontObject = qobject_cast<QDeclarative1FontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QVERIFY(fontObject->source() != QUrl(""));
- QTRY_COMPARE(fontObject->name(), QString("OCRA"));
- QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Ready);
-}
-
-void tst_qdeclarativefontloader::failWebFont()
-{
- QString componentStr = "import QtQuick 1.0\nFontLoader { source: \"http://localhost:14448/nonexist.ttf\" }";
- QTest::ignoreMessage(QtWarningMsg, "file::2:1: QML FontLoader: Cannot load font: \"http://localhost:14448/nonexist.ttf\"");
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1FontLoader *fontObject = qobject_cast<QDeclarative1FontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QVERIFY(fontObject->source() != QUrl(""));
- QTRY_COMPARE(fontObject->name(), QString(""));
- QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Error);
-}
-
-void tst_qdeclarativefontloader::changeFont()
-{
- QString componentStr = "import QtQuick 1.0\nFontLoader { source: font }";
- QDeclarativeContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("font", QUrl::fromLocalFile(SRCDIR "/data/tarzeau_ocr_a.ttf"));
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1FontLoader *fontObject = qobject_cast<QDeclarative1FontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
-
- QSignalSpy nameSpy(fontObject, SIGNAL(nameChanged()));
- QSignalSpy statusSpy(fontObject, SIGNAL(statusChanged()));
-
- QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Ready);
- QCOMPARE(nameSpy.count(), 0);
- QCOMPARE(statusSpy.count(), 0);
- QTRY_COMPARE(fontObject->name(), QString("OCRA"));
-
- ctxt->setContextProperty("font", "http://localhost:14448/daniel.ttf");
- QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Loading);
- QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Ready);
- QCOMPARE(nameSpy.count(), 1);
- QCOMPARE(statusSpy.count(), 2);
- QTRY_COMPARE(fontObject->name(), QString("Daniel"));
-
- ctxt->setContextProperty("font", QUrl::fromLocalFile(SRCDIR "/data/tarzeau_ocr_a.ttf"));
- QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Ready);
- QCOMPARE(nameSpy.count(), 2);
- QCOMPARE(statusSpy.count(), 2);
- QTRY_COMPARE(fontObject->name(), QString("OCRA"));
-
- ctxt->setContextProperty("font", "http://localhost:14448/daniel.ttf");
- QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Ready);
- QCOMPARE(nameSpy.count(), 3);
- QCOMPARE(statusSpy.count(), 2);
- QTRY_COMPARE(fontObject->name(), QString("Daniel"));
-}
-
-QTEST_MAIN(tst_qdeclarativefontloader)
-
-#include "tst_qdeclarativefontloader.moc"
diff --git a/tests/auto/qtquick1/qdeclarativegridview/data/attachedSignals.qml b/tests/auto/qtquick1/qdeclarativegridview/data/attachedSignals.qml
deleted file mode 100644
index d527e9d256..0000000000
--- a/tests/auto/qtquick1/qdeclarativegridview/data/attachedSignals.qml
+++ /dev/null
@@ -1,27 +0,0 @@
-import QtQuick 1.0
-
-GridView {
- id: view
- width: 240; height: 320
-
- property variant addedDelegates: []
- property int removedDelegateCount
-
- model: testModel
-
- cellWidth: delegateWidth; cellHeight: delegateHeight
-
- delegate: Rectangle {
- width: delegateWidth; height: delegateHeight
- border.width: 1
- GridView.onAdd: {
- var obj = GridView.view.addedDelegates
- obj.push(model.name)
- GridView.view.addedDelegates = obj
- }
- GridView.onRemove: {
- view.removedDelegateCount += 1
- }
- }
-}
-
diff --git a/tests/auto/qtquick1/qdeclarativegridview/data/displaygrid.qml b/tests/auto/qtquick1/qdeclarativegridview/data/displaygrid.qml
deleted file mode 100644
index 93f39ffd96..0000000000
--- a/tests/auto/qtquick1/qdeclarativegridview/data/displaygrid.qml
+++ /dev/null
@@ -1,39 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 240
- height: 320
- color: "#ffffff"
- resources: [
- Component {
- id: myDelegate
- Rectangle {
- id: wrapper
- objectName: "wrapper"
- width: 80
- height: 60
- border.color: "blue"
- Text {
- text: index
- }
- Text {
- y: 20
- id: displayText
- objectName: "displayText"
- text: display
- }
- color: GridView.isCurrentItem ? "lightsteelblue" : "white"
- }
- }
- ]
- GridView {
- id: grid
- objectName: "grid"
- width: 240
- height: 320
- cellWidth: 80
- cellHeight: 60
- model: testModel
- delegate: myDelegate
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativegridview/data/footer.qml b/tests/auto/qtquick1/qdeclarativegridview/data/footer.qml
deleted file mode 100644
index b41e2ac0b2..0000000000
--- a/tests/auto/qtquick1/qdeclarativegridview/data/footer.qml
+++ /dev/null
@@ -1,40 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- function changeFooter() {
- grid.footer = footer2
- }
- width: 240
- height: 320
- color: "#ffffff"
- Component {
- id: myDelegate
- Rectangle {
- id: wrapper
- objectName: "wrapper"
- width: 80
- height: 60
- border.color: "blue"
- Text {
- text: index
- }
- color: GridView.isCurrentItem ? "lightsteelblue" : "white"
- }
- }
- GridView {
- id: grid
- objectName: "grid"
- width: 240
- height: 320
- cellWidth: 80
- cellHeight: 60
- model: testModel
- delegate: myDelegate
- footer: Text { objectName: "footer"; text: "Footer"; height: 30 }
- }
-
- Component {
- id: footer2
- Text { objectName: "footer2"; text: "Footer 2"; height: 20 }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativegridview/data/gridview-enforcerange.qml b/tests/auto/qtquick1/qdeclarativegridview/data/gridview-enforcerange.qml
deleted file mode 100644
index 69eaa4774c..0000000000
--- a/tests/auto/qtquick1/qdeclarativegridview/data/gridview-enforcerange.qml
+++ /dev/null
@@ -1,58 +0,0 @@
-import QtQuick 1.1
-
-Rectangle {
- width: 240
- height: 320
- color: "#ffffff"
- Component {
- id: myDelegate
- Item {
- id: wrapper
- objectName: "wrapper"
- height: 100
- width: 100
- Text {
- text: index
- }
- Text {
- y: 25
- id: textName
- objectName: "textName"
- text: name
- }
- Text {
- y: 50
- id: textNumber
- objectName: "textNumber"
- text: number
- }
- Text {
- y: 75
- text: wrapper.y
- }
- }
- }
-
- Component {
- id: myHighlight
- Rectangle {
- color: "lightsteelblue"
- }
- }
-
- GridView {
- id: grid
- objectName: "grid"
- width: 240
- height: 320
- model: testModel
- delegate: myDelegate
- highlight: myHighlight
- flow: (testTopToBottom == true) ? GridView.TopToBottom : GridView.LeftToRight
- layoutDirection: (testRightToLeft == true) ? Qt.RightToLeft : Qt.LeftToRight
- preferredHighlightBegin: 100
- preferredHighlightEnd: 100
- highlightRangeMode: "StrictlyEnforceRange"
- focus: true
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativegridview/data/gridview-initCurrent.qml b/tests/auto/qtquick1/qdeclarativegridview/data/gridview-initCurrent.qml
deleted file mode 100644
index 421f810f2c..0000000000
--- a/tests/auto/qtquick1/qdeclarativegridview/data/gridview-initCurrent.qml
+++ /dev/null
@@ -1,52 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- property int current: grid.currentIndex
- width: 240
- height: 320
- color: "#ffffff"
- resources: [
- Component {
- id: myDelegate
- Rectangle {
- id: wrapper
- objectName: "wrapper"
- width: 80
- height: 60
- border.color: "blue"
- Text {
- text: index
- }
- Text {
- x: 40
- text: wrapper.x + ", " + wrapper.y
- }
- Text {
- y: 20
- id: textName
- objectName: "textName"
- text: name
- }
- Text {
- y: 40
- id: textNumber
- objectName: "textNumber"
- text: number
- }
- color: GridView.isCurrentItem ? "lightsteelblue" : "white"
- }
- }
- ]
- GridView {
- id: grid
- objectName: "grid"
- focus: true
- width: 240
- height: 320
- currentIndex: 35
- cellWidth: 80
- cellHeight: 60
- delegate: myDelegate
- model: testModel
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativegridview/data/gridview-noCurrent.qml b/tests/auto/qtquick1/qdeclarativegridview/data/gridview-noCurrent.qml
deleted file mode 100644
index 1189649ea1..0000000000
--- a/tests/auto/qtquick1/qdeclarativegridview/data/gridview-noCurrent.qml
+++ /dev/null
@@ -1,52 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- property int current: grid.currentIndex
- width: 240
- height: 320
- color: "#ffffff"
- resources: [
- Component {
- id: myDelegate
- Rectangle {
- id: wrapper
- objectName: "wrapper"
- width: 80
- height: 60
- border.color: "blue"
- Text {
- text: index
- }
- Text {
- x: 40
- text: wrapper.x + ", " + wrapper.y
- }
- Text {
- y: 20
- id: textName
- objectName: "textName"
- text: name
- }
- Text {
- y: 40
- id: textNumber
- objectName: "textNumber"
- text: number
- }
- color: GridView.isCurrentItem ? "lightsteelblue" : "white"
- }
- }
- ]
- GridView {
- id: grid
- objectName: "grid"
- focus: true
- width: 240
- height: 320
- currentIndex: -1
- cellWidth: 80
- cellHeight: 60
- delegate: myDelegate
- model: testModel
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativegridview/data/gridview1.qml b/tests/auto/qtquick1/qdeclarativegridview/data/gridview1.qml
deleted file mode 100644
index a2b0a915d9..0000000000
--- a/tests/auto/qtquick1/qdeclarativegridview/data/gridview1.qml
+++ /dev/null
@@ -1,66 +0,0 @@
-import QtQuick 1.1
-
-Rectangle {
- id: root
- property int count: grid.count
- property bool showHeader: false
- property bool showFooter: false
- property int added: -1
- property variant removed
-
- width: 240
- height: 320
- color: "#ffffff"
- resources: [
- Component {
- id: myDelegate
- Rectangle {
- id: wrapper
- objectName: "wrapper"
- width: 80
- height: 60
- border.color: "blue"
- Text {
- text: index
- }
- Text {
- x: 40
- text: wrapper.x + ", " + wrapper.y
- }
- Text {
- y: 20
- id: textName
- objectName: "textName"
- text: name
- }
- Text {
- y: 40
- id: textNumber
- objectName: "textNumber"
- text: number
- }
- color: GridView.isCurrentItem ? "lightsteelblue" : "white"
- GridView.onAdd: root.added = index
- GridView.onRemove: root.removed = name
- }
- },
- Component {
- id: headerFooter
- Rectangle { width: 30; height: 320; color: "blue" }
- }
- ]
- GridView {
- id: grid
- objectName: "grid"
- width: 240
- height: 320
- cellWidth: 80
- cellHeight: 60
- flow: (testTopToBottom == false) ? GridView.LeftToRight : GridView.TopToBottom
- layoutDirection: (testRightToLeft == true) ? Qt.RightToLeft : Qt.LeftToRight
- model: testModel
- delegate: myDelegate
- header: root.showHeader ? headerFooter : null
- footer: root.showFooter ? headerFooter : null
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativegridview/data/gridview2.qml b/tests/auto/qtquick1/qdeclarativegridview/data/gridview2.qml
deleted file mode 100644
index 7559a7ff36..0000000000
--- a/tests/auto/qtquick1/qdeclarativegridview/data/gridview2.qml
+++ /dev/null
@@ -1,26 +0,0 @@
-import QtQuick 1.0
-
-GridView {
- anchors.fill: parent
- width: 320; height: 200
- cellWidth: 100; cellHeight: 100; cacheBuffer: 200; focus: true
- keyNavigationWraps: true; highlightFollowsCurrentItem: false
-
- model: ListModel {
- id: appModel
- ListElement { lColor: "red" }
- ListElement { lColor: "yellow" }
- ListElement { lColor: "green" }
- ListElement { lColor: "blue" }
- }
-
- delegate: Item {
- width: 100; height: 100
- Rectangle {
- color: lColor; x: 4; y: 4
- width: 92; height: 92
- }
- }
-
- highlight: Rectangle { width: 100; height: 100; color: "black" }
-}
diff --git a/tests/auto/qtquick1/qdeclarativegridview/data/gridview3.qml b/tests/auto/qtquick1/qdeclarativegridview/data/gridview3.qml
deleted file mode 100644
index ab4ceeb76d..0000000000
--- a/tests/auto/qtquick1/qdeclarativegridview/data/gridview3.qml
+++ /dev/null
@@ -1,6 +0,0 @@
-import QtQuick 1.0
-
-GridView {
- anchors.fill: parent
- width: 320; height: 200
-}
diff --git a/tests/auto/qtquick1/qdeclarativegridview/data/header.qml b/tests/auto/qtquick1/qdeclarativegridview/data/header.qml
deleted file mode 100644
index f39da55dda..0000000000
--- a/tests/auto/qtquick1/qdeclarativegridview/data/header.qml
+++ /dev/null
@@ -1,40 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- function changeHeader() {
- grid.header = header2
- }
- width: 240
- height: 320
- color: "#ffffff"
- Component {
- id: myDelegate
- Rectangle {
- id: wrapper
- objectName: "wrapper"
- width: 80
- height: 60
- border.color: "blue"
- Text {
- text: index
- }
- color: GridView.isCurrentItem ? "lightsteelblue" : "white"
- }
- }
- GridView {
- id: grid
- objectName: "grid"
- width: 240
- height: 320
- cellWidth: 80
- cellHeight: 60
- model: testModel
- delegate: myDelegate
- header: Text { objectName: "header"; text: "Header"; height: 30 }
- }
-
- Component {
- id: header2
- Text { objectName: "header2"; text: "Header 2"; height: 20 }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativegridview/data/manual-highlight.qml b/tests/auto/qtquick1/qdeclarativegridview/data/manual-highlight.qml
deleted file mode 100644
index d08284792e..0000000000
--- a/tests/auto/qtquick1/qdeclarativegridview/data/manual-highlight.qml
+++ /dev/null
@@ -1,48 +0,0 @@
-import QtQuick 1.0
-
-Item {
-
- ListModel {
- id: model
- ListElement {
- name: "Bill Smith"
- number: "555 3264"
- }
- ListElement {
- name: "John Brown"
- number: "555 8426"
- }
- ListElement {
- name: "Sam Wise"
- number: "555 0473"
- }
- ListElement {
- name: "Bob Brown"
- number: "555 5845"
- }
- }
-
- Component {
- id: highlight
- Rectangle {
- objectName: "highlight"
- width: 80; height: 80
- color: "lightsteelblue"; radius: 5
- y: grid.currentItem.y+5
- x: grid.currentItem.x+5
- }
- }
-
- GridView {
- id: grid
- objectName: "grid"
- anchors.fill: parent
- model: model
- delegate: Text { objectName: "wrapper"; text: name; width: 80; height: 80 }
-
- highlight: highlight
- highlightFollowsCurrentItem: false
- focus: true
- }
-
-}
diff --git a/tests/auto/qtquick1/qdeclarativegridview/data/mirroring.qml b/tests/auto/qtquick1/qdeclarativegridview/data/mirroring.qml
deleted file mode 100644
index 54de16bc41..0000000000
--- a/tests/auto/qtquick1/qdeclarativegridview/data/mirroring.qml
+++ /dev/null
@@ -1,43 +0,0 @@
-// This example demonstrates how item positioning
-// changes in right-to-left layout direction
-
-import QtQuick 1.1
-
-Rectangle {
- color: "lightgray"
- width: 340
- height: 370
-
- VisualItemModel {
- id: itemModel
- objectName: "itemModel"
- Rectangle {
- objectName: "item1"
- height: 110; width: 120; color: "#FFFEF0"
- Text { objectName: "text1"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent }
- }
- Rectangle {
- objectName: "item2"
- height: 130; width: 150; color: "#F0FFF7"
- Text { objectName: "text2"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent }
- }
- Rectangle {
- objectName: "item3"
- height: 170; width: 190; color: "#F4F0FF"
- Text { objectName: "text3"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent }
- }
- }
-
- GridView {
- id: view
- objectName: "view"
- cellWidth: 190
- cellHeight: 170
- anchors.fill: parent
- anchors.bottomMargin: 30
- model: itemModel
- highlightRangeMode: "StrictlyEnforceRange"
- flow: GridView.TopToBottom
- flickDeceleration: 2000
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativegridview/data/propertychangestest.qml b/tests/auto/qtquick1/qdeclarativegridview/data/propertychangestest.qml
deleted file mode 100644
index 10df234261..0000000000
--- a/tests/auto/qtquick1/qdeclarativegridview/data/propertychangestest.qml
+++ /dev/null
@@ -1,69 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 360; height: 120; color: "white"
- Component {
- id: delegate
- Item {
- id: wrapper
- width: 180; height: 40;
- Column {
- x: 5; y: 5
- Text { text: '<b>Name:</b> ' + name }
- Text { text: '<b>Number:</b> ' + number }
- }
- }
- }
- Component {
- id: highlightRed
- Rectangle {
- color: "red"
- radius: 10
- opacity: 0.5
- }
- }
- GridView {
- cellWidth:180
- cellHeight:40
- objectName: "gridView"
- anchors.fill: parent
- model: listModel
- delegate: delegate
- highlight: highlightRed
- focus: true
- keyNavigationWraps: true
- cacheBuffer: 10
- flow: GridView.LeftToRight
- }
-
- data:[
- ListModel {
- id: listModel
- ListElement {
- name: "Bill Smith"
- number: "555 3264"
- }
- ListElement {
- name: "John Brown"
- number: "555 8426"
- }
- ListElement {
- name: "Sam Wise"
- number: "555 0473"
- }
- },
- ListModel {
- objectName: "alternateModel"
- ListElement {
- name: "Jack"
- number: "555 8426"
- }
- ListElement {
- name: "Mary"
- number: "555 3264"
- }
- }
- ]
-}
-
-
diff --git a/tests/auto/qtquick1/qdeclarativegridview/data/setindex.qml b/tests/auto/qtquick1/qdeclarativegridview/data/setindex.qml
deleted file mode 100644
index 36bf67de15..0000000000
--- a/tests/auto/qtquick1/qdeclarativegridview/data/setindex.qml
+++ /dev/null
@@ -1,29 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 200
- height: 200
- Component {
- id: appDelegate
-
- Item {
- id : wrapper
- function startupFunction() {
- if (index == 5) view.currentIndex = index;
- }
- Component.onCompleted: startupFunction();
- width: 30; height: 30
- Text { text: index }
- }
- }
-
- GridView {
- id: view
- objectName: "grid"
- anchors.fill: parent
- cellWidth: 30; cellHeight: 30
- model: 35
- delegate: appDelegate
- focus: true
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativegridview/qdeclarativegridview.pro b/tests/auto/qtquick1/qdeclarativegridview/qdeclarativegridview.pro
deleted file mode 100644
index 299b6a3273..0000000000
--- a/tests/auto/qtquick1/qdeclarativegridview/qdeclarativegridview.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativegridview
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativegridview.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
-QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib
diff --git a/tests/auto/qtquick1/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/qtquick1/qdeclarativegridview/tst_qdeclarativegridview.cpp
deleted file mode 100644
index bf14b5c378..0000000000
--- a/tests/auto/qtquick1/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ /dev/null
@@ -1,2217 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtCore/qstringlistmodel.h>
-#include <QtQuick1/qdeclarativeview.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtQuick1/private/qdeclarativeitem_p.h>
-#include <QtQuick1/private/qdeclarativegridview_p.h>
-#include <QtQuick1/private/qdeclarativetext_p.h>
-
-class tst_QDeclarative1GridView : public QObject
-{
- Q_OBJECT
-public:
- tst_QDeclarative1GridView();
-
-private slots:
- void items();
- void changed();
- void inserted();
- void removed();
- void clear();
- void moved();
- void changeFlow();
- void currentIndex();
- void noCurrentIndex();
- void defaultValues();
- void properties();
- void propertyChanges();
- void componentChanges();
- void modelChanges();
- void positionViewAtIndex();
- void positionViewAtIndex_rightToLeft();
- void mirroring();
- void snapping();
- void resetModel();
- void enforceRange();
- void enforceRange_rightToLeft();
- void QTBUG_8456();
- void manualHighlight();
- void footer();
- void header();
- void indexAt();
- void onAdd();
- void onAdd_data();
- void onRemove();
- void onRemove_data();
- void testQtQuick11Attributes();
- void testQtQuick11Attributes_data();
- void contentPosJump();
-
-private:
- QDeclarativeView *createView();
- template<typename T>
- T *findItem(QGraphicsObject *parent, const QString &id, int index=-1);
- template<typename T>
- QList<T*> findItems(QGraphicsObject *parent, const QString &objectName);
- void dumpTree(QDeclarativeItem *parent, int depth = 0);
-};
-
-class TestModel : public QAbstractListModel
-{
-public:
- enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 };
-
- TestModel(QObject *parent=0) : QAbstractListModel(parent) {
- QHash<int, QByteArray> roles;
- roles[Name] = "name";
- roles[Number] = "number";
- setRoleNames(roles);
- }
-
- int rowCount(const QModelIndex &parent=QModelIndex()) const { Q_UNUSED(parent); return list.count(); }
- QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const {
- QVariant rv;
- if (role == Name)
- rv = list.at(index.row()).first;
- else if (role == Number)
- rv = list.at(index.row()).second;
-
- return rv;
- }
-
- int count() const { return rowCount(); }
- QString name(int index) const { return list.at(index).first; }
- QString number(int index) const { return list.at(index).second; }
-
- void addItem(const QString &name, const QString &number) {
- emit beginInsertRows(QModelIndex(), list.count(), list.count());
- list.append(QPair<QString,QString>(name, number));
- emit endInsertRows();
- }
-
- void addItems(const QList<QPair<QString, QString> > &items) {
- emit beginInsertRows(QModelIndex(), list.count(), list.count()+items.count()-1);
- for (int i=0; i<items.count(); i++)
- list.append(QPair<QString,QString>(items[i].first, items[i].second));
- emit endInsertRows();
- }
-
- void insertItem(int index, const QString &name, const QString &number) {
- emit beginInsertRows(QModelIndex(), index, index);
- list.insert(index, QPair<QString,QString>(name, number));
- emit endInsertRows();
- }
-
- void removeItem(int index) {
- emit beginRemoveRows(QModelIndex(), index, index);
- list.removeAt(index);
- emit endRemoveRows();
- }
-
- void removeItems(int index, int count) {
- emit beginRemoveRows(QModelIndex(), index, index+count-1);
- while (count--)
- list.removeAt(index);
- emit endRemoveRows();
- }
-
- void moveItem(int from, int to) {
- emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
- list.move(from, to);
- emit endMoveRows();
- }
-
- void modifyItem(int idx, const QString &name, const QString &number) {
- list[idx] = QPair<QString,QString>(name, number);
- emit dataChanged(index(idx,0), index(idx,0));
- }
-
- void clear() {
- int count = list.count();
- emit beginRemoveRows(QModelIndex(), 0, count-1);
- list.clear();
- emit endRemoveRows();
- }
-
-
-private:
- QList<QPair<QString,QString> > list;
-};
-
-tst_QDeclarative1GridView::tst_QDeclarative1GridView()
-{
-}
-
-void tst_QDeclarative1GridView::items()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
- model.addItem("Billy", "22345");
- model.addItem("Sam", "2945");
- model.addItem("Ben", "04321");
- model.addItem("Jim", "0780");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml"));
- qApp->processEvents();
-
- QDeclarative1GridView *gridview = findItem<QDeclarative1GridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QDeclarativeItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QTRY_COMPARE(gridview->count(), model.count());
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
- QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- for (int i = 0; i < model.count(); ++i) {
- QDeclarative1Text *name = findItem<QDeclarative1Text>(contentItem, "textName", i);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- QDeclarative1Text *number = findItem<QDeclarative1Text>(contentItem, "textNumber", i);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
-
- // set an empty model and confirm that items are destroyed
- TestModel model2;
- ctxt->setContextProperty("testModel", &model2);
-
- int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- QTRY_VERIFY(itemCount == 0);
-
- delete canvas;
-}
-
-void tst_QDeclarative1GridView::changed()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
- model.addItem("Billy", "22345");
- model.addItem("Sam", "2945");
- model.addItem("Ben", "04321");
- model.addItem("Jim", "0780");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml"));
- qApp->processEvents();
-
- QDeclarative1Flickable *gridview = findItem<QDeclarative1Flickable>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QDeclarativeItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- model.modifyItem(1, "Will", "9876");
- QDeclarative1Text *name = findItem<QDeclarative1Text>(contentItem, "textName", 1);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(1));
- QDeclarative1Text *number = findItem<QDeclarative1Text>(contentItem, "textNumber", 1);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(1));
-
- delete canvas;
-}
-
-void tst_QDeclarative1GridView::inserted()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml"));
- qApp->processEvents();
-
- QDeclarative1GridView *gridview = findItem<QDeclarative1GridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QDeclarativeItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- model.insertItem(1, "Will", "9876");
- QCOMPARE(canvas->rootObject()->property("count").toInt(), model.count());
-
- QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- QDeclarative1Text *name = findItem<QDeclarative1Text>(contentItem, "textName", 1);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(1));
- QDeclarative1Text *number = findItem<QDeclarative1Text>(contentItem, "textNumber", 1);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(1));
-
- // Checks that onAdd is called
- int added = canvas->rootObject()->property("added").toInt();
- QTRY_COMPARE(added, 1);
-
- // Confirm items positioned correctly
- for (int i = 0; i < model.count(); ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- QTRY_COMPARE(item->x(), (i%3)*80.0);
- QTRY_COMPARE(item->y(), (i/3)*60.0);
- }
-
- model.insertItem(0, "Foo", "1111"); // zero index, and current item
-
- QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- name = findItem<QDeclarative1Text>(contentItem, "textName", 0);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(0));
- number = findItem<QDeclarative1Text>(contentItem, "textNumber", 0);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(0));
-
- QTRY_COMPARE(gridview->currentIndex(), 1);
-
- // Confirm items positioned correctly
- for (int i = 0; i < model.count(); ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- QTRY_VERIFY(item->x() == (i%3)*80);
- QTRY_VERIFY(item->y() == (i/3)*60);
- }
-
- for (int i = model.count(); i < 30; ++i)
- model.insertItem(i, "Hello", QString::number(i));
-
- gridview->setContentY(120);
-
- // Insert item outside visible area
- model.insertItem(1, "Hello", "1324");
-
- QTRY_VERIFY(gridview->contentY() == 120);
-
- delete canvas;
-}
-
-void tst_QDeclarative1GridView::removed()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml"));
- qApp->processEvents();
-
- QDeclarative1GridView *gridview = findItem<QDeclarative1GridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QDeclarativeItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- model.removeItem(1);
- QCOMPARE(canvas->rootObject()->property("count").toInt(), model.count());
-
- QDeclarative1Text *name = findItem<QDeclarative1Text>(contentItem, "textName", 1);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(1));
- QDeclarative1Text *number = findItem<QDeclarative1Text>(contentItem, "textNumber", 1);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(1));
-
- // Checks that onRemove is called
- QString removed = canvas->rootObject()->property("removed").toString();
- QTRY_COMPARE(removed, QString("Item1"));
-
- // Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_VERIFY(item->x() == (i%3)*80);
- QTRY_VERIFY(item->y() == (i/3)*60);
- }
-
- // Remove first item (which is the current item);
- model.removeItem(0);
-
- name = findItem<QDeclarative1Text>(contentItem, "textName", 0);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(0));
- number = findItem<QDeclarative1Text>(contentItem, "textNumber", 0);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(0));
-
- // Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_VERIFY(item->x() == (i%3)*80);
- QTRY_VERIFY(item->y() == (i/3)*60);
- }
-
- // Remove items not visible
- model.removeItem(25);
-
- // Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_VERIFY(item->x() == (i%3)*80);
- QTRY_VERIFY(item->y() == (i/3)*60);
- }
-
- // Remove items before visible
- gridview->setContentY(120);
- gridview->setCurrentIndex(10);
-
- // Setting currentIndex above shouldn't cause view to scroll
- QTRY_COMPARE(gridview->contentY(), 120.0);
-
- model.removeItem(1);
-
- // Confirm items positioned correctly
- for (int i = 3; i < 15; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), (i%3)*80.0);
- QTRY_COMPARE(item->y(), 60+(i/3)*60.0);
- }
-
- // Remove currentIndex
- QDeclarativeItem *oldCurrent = gridview->currentItem();
- model.removeItem(9);
-
- QTRY_COMPARE(gridview->currentIndex(), 9);
- QTRY_VERIFY(gridview->currentItem() != oldCurrent);
-
- gridview->setContentY(0);
- // let transitions settle.
- QTest::qWait(100);
-
- // Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_VERIFY(item->x() == (i%3)*80);
- QTRY_VERIFY(item->y() == 60+(i/3)*60);
- }
-
- // remove item outside current view.
- gridview->setCurrentIndex(32);
- gridview->setContentY(240);
-
- model.removeItem(30);
- QTRY_VERIFY(gridview->currentIndex() == 31);
-
- // remove current item beyond visible items.
- gridview->setCurrentIndex(20);
- gridview->setContentY(0);
- model.removeItem(20);
-
- QTRY_COMPARE(gridview->currentIndex(), 20);
- QTRY_VERIFY(gridview->currentItem() != 0);
-
- // remove item before current, but visible
- gridview->setCurrentIndex(8);
- gridview->setContentY(240);
- oldCurrent = gridview->currentItem();
- model.removeItem(6);
-
- QTRY_COMPARE(gridview->currentIndex(), 7);
- QTRY_VERIFY(gridview->currentItem() == oldCurrent);
-
- delete canvas;
-}
-
-void tst_QDeclarative1GridView::clear()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml"));
- qApp->processEvents();
-
- QDeclarative1GridView *gridview = findItem<QDeclarative1GridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
-
- QDeclarativeItem *contentItem = gridview->contentItem();
- QVERIFY(contentItem != 0);
-
- model.clear();
-
- QVERIFY(gridview->count() == 0);
- QVERIFY(gridview->currentItem() == 0);
- QVERIFY(gridview->contentY() == 0);
- QVERIFY(gridview->currentIndex() == -1);
-
- // confirm sanity when adding an item to cleared list
- model.addItem("New", "1");
- QVERIFY(gridview->count() == 1);
- QVERIFY(gridview->currentItem() != 0);
- QVERIFY(gridview->currentIndex() == 0);
-
- delete canvas;
-}
-
-void tst_QDeclarative1GridView::moved()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml"));
- qApp->processEvents();
-
- QDeclarative1GridView *gridview = findItem<QDeclarative1GridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QDeclarativeItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- model.moveItem(1, 8);
-
- QDeclarative1Text *name = findItem<QDeclarative1Text>(contentItem, "textName", 1);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(1));
- QDeclarative1Text *number = findItem<QDeclarative1Text>(contentItem, "textNumber", 1);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(1));
-
- name = findItem<QDeclarative1Text>(contentItem, "textName", 8);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(8));
- number = findItem<QDeclarative1Text>(contentItem, "textNumber", 8);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(8));
-
- // Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_VERIFY(item->x() == (i%3)*80);
- QTRY_VERIFY(item->y() == (i/3)*60);
- }
-
- gridview->setContentY(120);
-
- // move outside visible area
- model.moveItem(1, 25);
-
- // Confirm items positioned correctly and indexes correct
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count()-1;
- for (int i = 6; i < model.count()-6 && i < itemCount+6; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal((i%3)*80));
- QTRY_COMPARE(item->y(), qreal((i/3)*60));
- name = findItem<QDeclarative1Text>(contentItem, "textName", i);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- number = findItem<QDeclarative1Text>(contentItem, "textNumber", i);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
-
- // move from outside visible into visible
- model.moveItem(28, 8);
-
- // Confirm items positioned correctly and indexes correct
- for (int i = 6; i < model.count()-6 && i < itemCount+6; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_VERIFY(item->x() == (i%3)*80);
- QTRY_VERIFY(item->y() == (i/3)*60);
- name = findItem<QDeclarative1Text>(contentItem, "textName", i);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- number = findItem<QDeclarative1Text>(contentItem, "textNumber", i);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
-
- // ensure content position is stable
- gridview->setContentY(0);
- model.moveItem(10, 0);
- QTRY_VERIFY(gridview->contentY() == 0);
-
- delete canvas;
-}
-
-void tst_QDeclarative1GridView::currentIndex()
-{
- TestModel model;
- for (int i = 0; i < 60; i++)
- model.addItem("Item" + QString::number(i), QString::number(i));
-
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setFixedSize(240,320);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- QString filename(SRCDIR "/data/gridview-initCurrent.qml");
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- qApp->processEvents();
-
- QDeclarative1GridView *gridview = findItem<QDeclarative1GridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
-
- QDeclarativeItem *contentItem = gridview->contentItem();
- QVERIFY(contentItem != 0);
-
- // current item should be third item
- QCOMPARE(gridview->currentIndex(), 35);
- QCOMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 35));
- QCOMPARE(gridview->currentItem()->y(), gridview->highlightItem()->y());
- QCOMPARE(gridview->contentY(), 400.0);
-
- gridview->moveCurrentIndexRight();
- QCOMPARE(gridview->currentIndex(), 36);
- gridview->moveCurrentIndexDown();
- QCOMPARE(gridview->currentIndex(), 39);
- gridview->moveCurrentIndexUp();
- QCOMPARE(gridview->currentIndex(), 36);
- gridview->moveCurrentIndexLeft();
- QCOMPARE(gridview->currentIndex(), 35);
-
- // no wrap
- gridview->setCurrentIndex(0);
- QCOMPARE(gridview->currentIndex(), 0);
- // confirm that the velocity is updated
- QTRY_VERIFY(gridview->verticalVelocity() != 0.0);
-
- gridview->moveCurrentIndexUp();
- QCOMPARE(gridview->currentIndex(), 0);
-
- gridview->moveCurrentIndexLeft();
- QCOMPARE(gridview->currentIndex(), 0);
-
- gridview->setCurrentIndex(model.count()-1);
- QCOMPARE(gridview->currentIndex(), model.count()-1);
-
- gridview->moveCurrentIndexRight();
- QCOMPARE(gridview->currentIndex(), model.count()-1);
-
- gridview->moveCurrentIndexDown();
- QCOMPARE(gridview->currentIndex(), model.count()-1);
-
- // with wrap
- gridview->setWrapEnabled(true);
-
- gridview->setCurrentIndex(0);
- QCOMPARE(gridview->currentIndex(), 0);
-
- gridview->moveCurrentIndexLeft();
- QCOMPARE(gridview->currentIndex(), model.count()-1);
-
- QTRY_COMPARE(gridview->contentY(), 880.0);
-
- gridview->moveCurrentIndexRight();
- QCOMPARE(gridview->currentIndex(), 0);
-
- QTRY_COMPARE(gridview->contentY(), 0.0);
-
- // Test keys
- canvas->show();
- qApp->setActiveWindow(canvas);
-#ifdef Q_WS_X11
- // to be safe and avoid failing setFocus with window managers
- qt_x11_wait_for_window_manager(canvas);
-#endif
- QTRY_VERIFY(canvas->hasFocus());
- QTRY_VERIFY(canvas->scene()->hasFocus());
- qApp->processEvents();
-
- QTest::keyClick(canvas, Qt::Key_Down);
- QCOMPARE(gridview->currentIndex(), 3);
-
- QTest::keyClick(canvas, Qt::Key_Up);
- QCOMPARE(gridview->currentIndex(), 0);
-
- gridview->setFlow(QDeclarative1GridView::TopToBottom);
-
- qApp->setActiveWindow(canvas);
-#ifdef Q_WS_X11
- // to be safe and avoid failing setFocus with window managers
- qt_x11_wait_for_window_manager(canvas);
-#endif
- QTRY_VERIFY(canvas->hasFocus());
- QTRY_VERIFY(canvas->scene()->hasFocus());
- qApp->processEvents();
-
- QTest::keyClick(canvas, Qt::Key_Right);
- QCOMPARE(gridview->currentIndex(), 5);
-
- QTest::keyClick(canvas, Qt::Key_Left);
- QCOMPARE(gridview->currentIndex(), 0);
-
- QTest::keyClick(canvas, Qt::Key_Down);
- QCOMPARE(gridview->currentIndex(), 1);
-
- QTest::keyClick(canvas, Qt::Key_Up);
- QCOMPARE(gridview->currentIndex(), 0);
-
-
- // turn off auto highlight
- gridview->setHighlightFollowsCurrentItem(false);
- QVERIFY(gridview->highlightFollowsCurrentItem() == false);
- QVERIFY(gridview->highlightItem());
- qreal hlPosX = gridview->highlightItem()->x();
- qreal hlPosY = gridview->highlightItem()->y();
-
- gridview->setCurrentIndex(5);
- QTRY_COMPARE(gridview->highlightItem()->x(), hlPosX);
- QTRY_COMPARE(gridview->highlightItem()->y(), hlPosY);
-
- // insert item before currentIndex
- gridview->setCurrentIndex(28);
- model.insertItem(0, "Foo", "1111");
- QTRY_COMPARE(canvas->rootObject()->property("current").toInt(), 29);
-
- // check removing highlight by setting currentIndex to -1;
- gridview->setCurrentIndex(-1);
-
- QCOMPARE(gridview->currentIndex(), -1);
- QVERIFY(!gridview->highlightItem());
- QVERIFY(!gridview->currentItem());
-
- gridview->setHighlightFollowsCurrentItem(true);
-
- gridview->setFlow(QDeclarative1GridView::LeftToRight);
- gridview->setLayoutDirection(Qt::RightToLeft);
-
- qApp->setActiveWindow(canvas);
-#ifdef Q_WS_X11
- // to be safe and avoid failing setFocus with window managers
- qt_x11_wait_for_window_manager(canvas);
-#endif
- QTRY_VERIFY(canvas->hasFocus());
- QTRY_VERIFY(canvas->scene()->hasFocus());
- qApp->processEvents();
-
- gridview->setCurrentIndex(35);
-
- QTest::keyClick(canvas, Qt::Key_Right);
- QCOMPARE(gridview->currentIndex(), 34);
-
- QTest::keyClick(canvas, Qt::Key_Down);
- QCOMPARE(gridview->currentIndex(), 37);
-
- QTest::keyClick(canvas, Qt::Key_Up);
- QCOMPARE(gridview->currentIndex(), 34);
-
- QTest::keyClick(canvas, Qt::Key_Left);
- QCOMPARE(gridview->currentIndex(), 35);
-
-
- // turn off auto highlight
- gridview->setHighlightFollowsCurrentItem(false);
- QVERIFY(gridview->highlightFollowsCurrentItem() == false);
- QVERIFY(gridview->highlightItem());
- hlPosX = gridview->highlightItem()->x();
- hlPosY = gridview->highlightItem()->y();
-
- gridview->setCurrentIndex(5);
- QTRY_COMPARE(gridview->highlightItem()->x(), hlPosX);
- QTRY_COMPARE(gridview->highlightItem()->y(), hlPosY);
-
- // insert item before currentIndex
- gridview->setCurrentIndex(28);
- model.insertItem(0, "Foo", "1111");
- QTRY_COMPARE(canvas->rootObject()->property("current").toInt(), 29);
-
- // check removing highlight by setting currentIndex to -1;
- gridview->setCurrentIndex(-1);
-
- QCOMPARE(gridview->currentIndex(), -1);
- QVERIFY(!gridview->highlightItem());
- QVERIFY(!gridview->currentItem());
-
- delete canvas;
-}
-
-void tst_QDeclarative1GridView::noCurrentIndex()
-{
- TestModel model;
- for (int i = 0; i < 60; i++)
- model.addItem("Item" + QString::number(i), QString::number(i));
-
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setFixedSize(240,320);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- QString filename(SRCDIR "/data/gridview-noCurrent.qml");
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- qApp->processEvents();
-
- QDeclarative1GridView *gridview = findItem<QDeclarative1GridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
-
- QDeclarativeItem *contentItem = gridview->contentItem();
- QVERIFY(contentItem != 0);
-
- // current index should be -1
- QCOMPARE(gridview->currentIndex(), -1);
- QVERIFY(!gridview->currentItem());
- QVERIFY(!gridview->highlightItem());
- QCOMPARE(gridview->contentY(), 0.0);
-
- gridview->setCurrentIndex(5);
- QCOMPARE(gridview->currentIndex(), 5);
- QVERIFY(gridview->currentItem());
- QVERIFY(gridview->highlightItem());
-
- delete canvas;
-}
-
-void tst_QDeclarative1GridView::changeFlow()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), QString::number(i));
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml"));
- qApp->processEvents();
-
- QDeclarative1GridView *gridview = findItem<QDeclarative1GridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QDeclarativeItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // Confirm items positioned correctly and indexes correct
- int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal((i%3)*80));
- QTRY_COMPARE(item->y(), qreal((i/3)*60));
- QDeclarative1Text *name = findItem<QDeclarative1Text>(contentItem, "textName", i);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- QDeclarative1Text *number = findItem<QDeclarative1Text>(contentItem, "textNumber", i);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
-
- ctxt->setContextProperty("testTopToBottom", QVariant(true));
-
- // Confirm items positioned correctly and indexes correct
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal((i/5)*80));
- QTRY_COMPARE(item->y(), qreal((i%5)*60));
- QDeclarative1Text *name = findItem<QDeclarative1Text>(contentItem, "textName", i);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- QDeclarative1Text *number = findItem<QDeclarative1Text>(contentItem, "textNumber", i);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
-
- ctxt->setContextProperty("testRightToLeft", QVariant(true));
-
- // Confirm items positioned correctly and indexes correct
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal(-(i/5)*80 - item->width()));
- QTRY_COMPARE(item->y(), qreal((i%5)*60));
- QDeclarative1Text *name = findItem<QDeclarative1Text>(contentItem, "textName", i);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- QDeclarative1Text *number = findItem<QDeclarative1Text>(contentItem, "textNumber", i);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
- gridview->setContentX(100);
- QTRY_COMPARE(gridview->contentX(), 100.);
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
- QTRY_COMPARE(gridview->contentX(), 0.);
-
- // Confirm items positioned correctly and indexes correct
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal(240 - (i%3+1)*80));
- QTRY_COMPARE(item->y(), qreal((i/3)*60));
- QDeclarative1Text *name = findItem<QDeclarative1Text>(contentItem, "textName", i);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- QDeclarative1Text *number = findItem<QDeclarative1Text>(contentItem, "textNumber", i);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
-
- delete canvas;
-}
-
-void tst_QDeclarative1GridView::defaultValues()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/gridview3.qml"));
- QDeclarative1GridView *obj = qobject_cast<QDeclarative1GridView*>(c.create());
-
- QTRY_VERIFY(obj != 0);
- QTRY_VERIFY(obj->model() == QVariant());
- QTRY_VERIFY(obj->delegate() == 0);
- QTRY_COMPARE(obj->currentIndex(), -1);
- QTRY_VERIFY(obj->currentItem() == 0);
- QTRY_COMPARE(obj->count(), 0);
- QTRY_VERIFY(obj->highlight() == 0);
- QTRY_VERIFY(obj->highlightItem() == 0);
- QTRY_COMPARE(obj->highlightFollowsCurrentItem(), true);
- QTRY_VERIFY(obj->flow() == 0);
- QTRY_COMPARE(obj->isWrapEnabled(), false);
- QTRY_COMPARE(obj->cacheBuffer(), 0);
- QTRY_COMPARE(obj->cellWidth(), 100); //### Should 100 be the default?
- QTRY_COMPARE(obj->cellHeight(), 100);
- delete obj;
-}
-
-void tst_QDeclarative1GridView::properties()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/gridview2.qml"));
- QDeclarative1GridView *obj = qobject_cast<QDeclarative1GridView*>(c.create());
-
- QTRY_VERIFY(obj != 0);
- QTRY_VERIFY(obj->model() != QVariant());
- QTRY_VERIFY(obj->delegate() != 0);
- QTRY_COMPARE(obj->currentIndex(), 0);
- QTRY_VERIFY(obj->currentItem() != 0);
- QTRY_COMPARE(obj->count(), 4);
- QTRY_VERIFY(obj->highlight() != 0);
- QTRY_VERIFY(obj->highlightItem() != 0);
- QTRY_COMPARE(obj->highlightFollowsCurrentItem(), false);
- QTRY_VERIFY(obj->flow() == 0);
- QTRY_COMPARE(obj->isWrapEnabled(), true);
- QTRY_COMPARE(obj->cacheBuffer(), 200);
- QTRY_COMPARE(obj->cellWidth(), 100);
- QTRY_COMPARE(obj->cellHeight(), 100);
- delete obj;
-}
-
-void tst_QDeclarative1GridView::propertyChanges()
-{
- QDeclarativeView *canvas = createView();
- QTRY_VERIFY(canvas);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml"));
-
- QDeclarative1GridView *gridView = canvas->rootObject()->findChild<QDeclarative1GridView*>("gridView");
- QTRY_VERIFY(gridView);
-
- QSignalSpy keyNavigationWrapsSpy(gridView, SIGNAL(keyNavigationWrapsChanged()));
- QSignalSpy cacheBufferSpy(gridView, SIGNAL(cacheBufferChanged()));
- QSignalSpy layoutSpy(gridView, SIGNAL(layoutDirectionChanged()));
- QSignalSpy flowSpy(gridView, SIGNAL(flowChanged()));
-
- QTRY_COMPARE(gridView->isWrapEnabled(), true);
- QTRY_COMPARE(gridView->cacheBuffer(), 10);
- QTRY_COMPARE(gridView->flow(), QDeclarative1GridView::LeftToRight);
-
- gridView->setWrapEnabled(false);
- gridView->setCacheBuffer(3);
- gridView->setFlow(QDeclarative1GridView::TopToBottom);
-
- QTRY_COMPARE(gridView->isWrapEnabled(), false);
- QTRY_COMPARE(gridView->cacheBuffer(), 3);
- QTRY_COMPARE(gridView->flow(), QDeclarative1GridView::TopToBottom);
-
- QTRY_COMPARE(keyNavigationWrapsSpy.count(),1);
- QTRY_COMPARE(cacheBufferSpy.count(),1);
- QTRY_COMPARE(flowSpy.count(),1);
-
- gridView->setWrapEnabled(false);
- gridView->setCacheBuffer(3);
- gridView->setFlow(QDeclarative1GridView::TopToBottom);
-
- QTRY_COMPARE(keyNavigationWrapsSpy.count(),1);
- QTRY_COMPARE(cacheBufferSpy.count(),1);
- QTRY_COMPARE(flowSpy.count(),1);
-
- gridView->setFlow(QDeclarative1GridView::LeftToRight);
- QTRY_COMPARE(gridView->flow(), QDeclarative1GridView::LeftToRight);
-
- gridView->setWrapEnabled(true);
- gridView->setCacheBuffer(5);
- gridView->setLayoutDirection(Qt::RightToLeft);
-
- QTRY_COMPARE(gridView->isWrapEnabled(), true);
- QTRY_COMPARE(gridView->cacheBuffer(), 5);
- QTRY_COMPARE(gridView->layoutDirection(), Qt::RightToLeft);
-
- QTRY_COMPARE(keyNavigationWrapsSpy.count(),2);
- QTRY_COMPARE(cacheBufferSpy.count(),2);
- QTRY_COMPARE(layoutSpy.count(),1);
- QTRY_COMPARE(flowSpy.count(),2);
-
- gridView->setWrapEnabled(true);
- gridView->setCacheBuffer(5);
- gridView->setLayoutDirection(Qt::RightToLeft);
-
- QTRY_COMPARE(keyNavigationWrapsSpy.count(),2);
- QTRY_COMPARE(cacheBufferSpy.count(),2);
- QTRY_COMPARE(layoutSpy.count(),1);
- QTRY_COMPARE(flowSpy.count(),2);
-
- gridView->setFlow(QDeclarative1GridView::TopToBottom);
- QTRY_COMPARE(gridView->flow(), QDeclarative1GridView::TopToBottom);
- QTRY_COMPARE(flowSpy.count(),3);
-
- gridView->setFlow(QDeclarative1GridView::TopToBottom);
- QTRY_COMPARE(flowSpy.count(),3);
-
- delete canvas;
-}
-
-void tst_QDeclarative1GridView::componentChanges()
-{
- QDeclarativeView *canvas = createView();
- QTRY_VERIFY(canvas);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml"));
-
- QDeclarative1GridView *gridView = canvas->rootObject()->findChild<QDeclarative1GridView*>("gridView");
- QTRY_VERIFY(gridView);
-
- QDeclarativeComponent component(canvas->engine());
- component.setData("import QtQuick 1.0; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile(""));
-
- QDeclarativeComponent delegateComponent(canvas->engine());
- delegateComponent.setData("import QtQuick 1.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()));
-
- gridView->setHighlight(&component);
- gridView->setDelegate(&delegateComponent);
- gridView->setHeader(&component);
- gridView->setFooter(&component);
-
- QTRY_COMPARE(gridView->highlight(), &component);
- QTRY_COMPARE(gridView->delegate(), &delegateComponent);
- QTRY_COMPARE(gridView->header(), &component);
- QTRY_COMPARE(gridView->footer(), &component);
-
- QTRY_COMPARE(highlightSpy.count(),1);
- QTRY_COMPARE(delegateSpy.count(),1);
- QTRY_COMPARE(headerSpy.count(),1);
- QTRY_COMPARE(footerSpy.count(),1);
-
- gridView->setHighlight(&component);
- gridView->setDelegate(&delegateComponent);
- gridView->setHeader(&component);
- gridView->setFooter(&component);
-
- QTRY_COMPARE(highlightSpy.count(),1);
- QTRY_COMPARE(delegateSpy.count(),1);
- QTRY_COMPARE(headerSpy.count(),1);
- QTRY_COMPARE(footerSpy.count(),1);
-
- delete canvas;
-}
-
-void tst_QDeclarative1GridView::modelChanges()
-{
- QDeclarativeView *canvas = createView();
- QTRY_VERIFY(canvas);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml"));
-
- QDeclarative1GridView *gridView = canvas->rootObject()->findChild<QDeclarative1GridView*>("gridView");
- QTRY_VERIFY(gridView);
-
- QObject *alternateModel = canvas->rootObject()->findChild<QObject*>("alternateModel");
- QTRY_VERIFY(alternateModel);
- QVariant modelVariant = QVariant::fromValue(alternateModel);
- QSignalSpy modelSpy(gridView, SIGNAL(modelChanged()));
-
- gridView->setModel(modelVariant);
- QTRY_COMPARE(gridView->model(), modelVariant);
- QTRY_COMPARE(modelSpy.count(),1);
-
- gridView->setModel(modelVariant);
- QTRY_COMPARE(modelSpy.count(),1);
-
- gridView->setModel(QVariant());
- QTRY_COMPARE(modelSpy.count(),2);
- delete canvas;
-}
-
-void tst_QDeclarative1GridView::positionViewAtIndex()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml"));
- qApp->processEvents();
-
- QDeclarative1GridView *gridview = findItem<QDeclarative1GridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QDeclarativeItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), (i%3)*80.);
- QTRY_COMPARE(item->y(), (i/3)*60.);
- }
-
- // Position on a currently visible item
- gridview->positionViewAtIndex(4, QDeclarative1GridView::Beginning);
- QTRY_COMPARE(gridview->indexAt(120, 90), 4);
- QTRY_COMPARE(gridview->contentY(), 60.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), (i%3)*80.);
- QTRY_COMPARE(item->y(), (i/3)*60.);
- }
-
- // Position on an item beyond the visible items
- gridview->positionViewAtIndex(21, QDeclarative1GridView::Beginning);
- QTRY_COMPARE(gridview->indexAt(40, 450), 21);
- QTRY_COMPARE(gridview->contentY(), 420.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), (i%3)*80.);
- QTRY_COMPARE(item->y(), (i/3)*60.);
- }
-
- // Position on an item that would leave empty space if positioned at the top
- gridview->positionViewAtIndex(31, QDeclarative1GridView::Beginning);
- QTRY_COMPARE(gridview->indexAt(120, 630), 31);
- QTRY_COMPARE(gridview->contentY(), 520.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), (i%3)*80.);
- QTRY_COMPARE(item->y(), (i/3)*60.);
- }
-
- // Position at the beginning again
- gridview->positionViewAtIndex(0, QDeclarative1GridView::Beginning);
- QTRY_COMPARE(gridview->indexAt(0, 0), 0);
- QTRY_COMPARE(gridview->indexAt(40, 30), 0);
- QTRY_COMPARE(gridview->indexAt(80, 60), 4);
- QTRY_COMPARE(gridview->contentY(), 0.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), (i%3)*80.);
- QTRY_COMPARE(item->y(), (i/3)*60.);
- }
-
- // Position at End
- gridview->positionViewAtIndex(30, QDeclarative1GridView::End);
- QTRY_COMPARE(gridview->contentY(), 340.);
-
- // Position in Center
- gridview->positionViewAtIndex(15, QDeclarative1GridView::Center);
- QTRY_COMPARE(gridview->contentY(), 170.);
-
- // Ensure at least partially visible
- gridview->positionViewAtIndex(15, QDeclarative1GridView::Visible);
- QTRY_COMPARE(gridview->contentY(), 170.);
-
- gridview->setContentY(302);
- gridview->positionViewAtIndex(15, QDeclarative1GridView::Visible);
- QTRY_COMPARE(gridview->contentY(), 302.);
-
- gridview->setContentY(360);
- gridview->positionViewAtIndex(15, QDeclarative1GridView::Visible);
- QTRY_COMPARE(gridview->contentY(), 300.);
-
- gridview->setContentY(60);
- gridview->positionViewAtIndex(20, QDeclarative1GridView::Visible);
- QTRY_COMPARE(gridview->contentY(), 60.);
-
- gridview->setContentY(20);
- gridview->positionViewAtIndex(20, QDeclarative1GridView::Visible);
- QTRY_COMPARE(gridview->contentY(), 100.);
-
- // Ensure completely visible
- gridview->setContentY(120);
- gridview->positionViewAtIndex(20, QDeclarative1GridView::Contain);
- QTRY_COMPARE(gridview->contentY(), 120.);
-
- gridview->setContentY(302);
- gridview->positionViewAtIndex(15, QDeclarative1GridView::Contain);
- QTRY_COMPARE(gridview->contentY(), 300.);
-
- gridview->setContentY(60);
- gridview->positionViewAtIndex(20, QDeclarative1GridView::Contain);
- QTRY_COMPARE(gridview->contentY(), 100.);
-
- // Test for Top To Bottom layout
- ctxt->setContextProperty("testTopToBottom", QVariant(true));
-
- // Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), (i/5)*80.);
- QTRY_COMPARE(item->y(), (i%5)*60.);
- }
-
- // Position at End
- gridview->positionViewAtIndex(30, QDeclarative1GridView::End);
- QTRY_COMPARE(gridview->contentX(), 320.);
- QTRY_COMPARE(gridview->contentY(), 0.);
-
- // Position in Center
- gridview->positionViewAtIndex(15, QDeclarative1GridView::Center);
- QTRY_COMPARE(gridview->contentX(), 160.);
-
- // Ensure at least partially visible
- gridview->positionViewAtIndex(15, QDeclarative1GridView::Visible);
- QTRY_COMPARE(gridview->contentX(), 160.);
-
- gridview->setContentX(170);
- gridview->positionViewAtIndex(25, QDeclarative1GridView::Visible);
- QTRY_COMPARE(gridview->contentX(), 170.);
-
- gridview->positionViewAtIndex(30, QDeclarative1GridView::Visible);
- QTRY_COMPARE(gridview->contentX(), 320.);
-
- gridview->setContentX(170);
- gridview->positionViewAtIndex(25, QDeclarative1GridView::Contain);
- QTRY_COMPARE(gridview->contentX(), 240.);
-
- // positionViewAtBeginning
- gridview->positionViewAtBeginning();
- QTRY_COMPARE(gridview->contentX(), 0.);
-
- gridview->setContentX(80);
- canvas->rootObject()->setProperty("showHeader", true);
- gridview->positionViewAtBeginning();
- QTRY_COMPARE(gridview->contentX(), -30.);
-
- // positionViewAtEnd
- gridview->positionViewAtEnd();
- QTRY_COMPARE(gridview->contentX(), 430.);
-
- gridview->setContentX(80);
- canvas->rootObject()->setProperty("showFooter", true);
- gridview->positionViewAtEnd();
- QTRY_COMPARE(gridview->contentX(), 460.);
-
- delete canvas;
-}
-
-void tst_QDeclarative1GridView::snapping()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml"));
- qApp->processEvents();
-
- QDeclarative1GridView *gridview = findItem<QDeclarative1GridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- gridview->setHeight(220);
- QCOMPARE(gridview->height(), 220.);
-
- gridview->positionViewAtIndex(12, QDeclarative1GridView::Visible);
- QCOMPARE(gridview->contentY(), 80.);
-
- gridview->setContentY(0);
- QCOMPARE(gridview->contentY(), 0.);
-
- gridview->setSnapMode(QDeclarative1GridView::SnapToRow);
- QCOMPARE(gridview->snapMode(), QDeclarative1GridView::SnapToRow);
-
- gridview->positionViewAtIndex(12, QDeclarative1GridView::Visible);
- QCOMPARE(gridview->contentY(), 60.);
-
- gridview->positionViewAtIndex(15, QDeclarative1GridView::End);
- QCOMPARE(gridview->contentY(), 120.);
-
- delete canvas;
-
-}
-
-void tst_QDeclarative1GridView::mirroring()
-{
- QDeclarativeView *canvasA = createView();
- canvasA->setSource(QUrl::fromLocalFile(SRCDIR "/data/mirroring.qml"));
- QDeclarative1GridView *gridviewA = findItem<QDeclarative1GridView>(canvasA->rootObject(), "view");
- QTRY_VERIFY(gridviewA != 0);
-
- QDeclarativeView *canvasB = createView();
- canvasB->setSource(QUrl::fromLocalFile(SRCDIR "/data/mirroring.qml"));
- QDeclarative1GridView *gridviewB = findItem<QDeclarative1GridView>(canvasB->rootObject(), "view");
- QTRY_VERIFY(gridviewA != 0);
- qApp->processEvents();
-
- QList<QString> objectNames;
- objectNames << "item1" << "item2"; // << "item3"
-
- gridviewA->setProperty("layoutDirection", Qt::LeftToRight);
- gridviewB->setProperty("layoutDirection", Qt::RightToLeft);
- QCOMPARE(gridviewA->layoutDirection(), gridviewA->effectiveLayoutDirection());
-
- // LTR != RTL
- foreach(const QString objectName, objectNames)
- QVERIFY(findItem<QDeclarativeItem>(gridviewA, objectName)->x() != findItem<QDeclarativeItem>(gridviewB, objectName)->x());
-
- gridviewA->setProperty("layoutDirection", Qt::LeftToRight);
- gridviewB->setProperty("layoutDirection", Qt::LeftToRight);
-
- // LTR == LTR
- foreach(const QString objectName, objectNames)
- QCOMPARE(findItem<QDeclarativeItem>(gridviewA, objectName)->x(), findItem<QDeclarativeItem>(gridviewB, objectName)->x());
-
- QVERIFY(gridviewB->layoutDirection() == gridviewB->effectiveLayoutDirection());
- QDeclarativeItemPrivate::get(gridviewB)->setLayoutMirror(true);
- QVERIFY(gridviewB->layoutDirection() != gridviewB->effectiveLayoutDirection());
-
- // LTR != LTR+mirror
- foreach(const QString objectName, objectNames)
- QVERIFY(findItem<QDeclarativeItem>(gridviewA, objectName)->x() != findItem<QDeclarativeItem>(gridviewB, objectName)->x());
-
- gridviewA->setProperty("layoutDirection", Qt::RightToLeft);
-
- // RTL == LTR+mirror
- foreach(const QString objectName, objectNames)
- QCOMPARE(findItem<QDeclarativeItem>(gridviewA, objectName)->x(), findItem<QDeclarativeItem>(gridviewB, objectName)->x());
-
- gridviewB->setProperty("layoutDirection", Qt::RightToLeft);
-
- // RTL != RTL+mirror
- foreach(const QString objectName, objectNames)
- QVERIFY(findItem<QDeclarativeItem>(gridviewA, objectName)->x() != findItem<QDeclarativeItem>(gridviewB, objectName)->x());
-
- gridviewA->setProperty("layoutDirection", Qt::LeftToRight);
-
- // LTR == RTL+mirror
- foreach(const QString objectName, objectNames)
- QCOMPARE(findItem<QDeclarativeItem>(gridviewA, objectName)->x(), findItem<QDeclarativeItem>(gridviewB, objectName)->x());
-
- delete canvasA;
- delete canvasB;
-}
-
-void tst_QDeclarative1GridView::positionViewAtIndex_rightToLeft()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testTopToBottom", QVariant(true));
- ctxt->setContextProperty("testRightToLeft", QVariant(true));
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml"));
- qApp->processEvents();
-
- QDeclarative1GridView *gridview = findItem<QDeclarative1GridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QDeclarativeItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width()));
- QTRY_COMPARE(item->y(), qreal((i%5)*60));
- }
-
- // Position on a currently visible item
- gridview->positionViewAtIndex(6, QDeclarative1GridView::Beginning);
- QTRY_COMPARE(gridview->contentX(), -320.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width()));
- QTRY_COMPARE(item->y(), qreal((i%5)*60));
- }
-
- // Position on an item beyond the visible items
- gridview->positionViewAtIndex(21, QDeclarative1GridView::Beginning);
- QTRY_COMPARE(gridview->contentX(), -560.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width()));
- QTRY_COMPARE(item->y(), qreal((i%5)*60));
- }
-
- // Position on an item that would leave empty space if positioned at the top
- gridview->positionViewAtIndex(31, QDeclarative1GridView::Beginning);
- QTRY_COMPARE(gridview->contentX(), -639.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width()));
- QTRY_COMPARE(item->y(), qreal((i%5)*60));
- }
-
- // Position at the beginning again
- gridview->positionViewAtIndex(0, QDeclarative1GridView::Beginning);
- QTRY_COMPARE(gridview->contentX(), -240.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width()));
- QTRY_COMPARE(item->y(), qreal((i%5)*60));
- }
-
- // Position at End
- gridview->positionViewAtIndex(30, QDeclarative1GridView::End);
- QTRY_COMPARE(gridview->contentX(), -560.);
-
- // Position in Center
- gridview->positionViewAtIndex(15, QDeclarative1GridView::Center);
- QTRY_COMPARE(gridview->contentX(), -400.);
-
- // Ensure at least partially visible
- gridview->positionViewAtIndex(15, QDeclarative1GridView::Visible);
- QTRY_COMPARE(gridview->contentX(), -400.);
-
- gridview->setContentX(-555.);
- gridview->positionViewAtIndex(15, QDeclarative1GridView::Visible);
- QTRY_COMPARE(gridview->contentX(), -555.);
-
- gridview->setContentX(-239);
- gridview->positionViewAtIndex(15, QDeclarative1GridView::Visible);
- QTRY_COMPARE(gridview->contentX(), -320.);
-
- gridview->setContentX(-239);
- gridview->positionViewAtIndex(20, QDeclarative1GridView::Visible);
- QTRY_COMPARE(gridview->contentX(), -400.);
-
- gridview->setContentX(-640);
- gridview->positionViewAtIndex(20, QDeclarative1GridView::Visible);
- QTRY_COMPARE(gridview->contentX(), -560.);
-
- // Ensure completely visible
- gridview->setContentX(-400);
- gridview->positionViewAtIndex(20, QDeclarative1GridView::Contain);
- QTRY_COMPARE(gridview->contentX(), -400.);
-
- gridview->setContentX(-315);
- gridview->positionViewAtIndex(15, QDeclarative1GridView::Contain);
- QTRY_COMPARE(gridview->contentX(), -320.);
-
- gridview->setContentX(-640);
- gridview->positionViewAtIndex(20, QDeclarative1GridView::Contain);
- QTRY_COMPARE(gridview->contentX(), -560.);
-
- delete canvas;
-}
-
-void tst_QDeclarative1GridView::resetModel()
-{
- QDeclarativeView *canvas = createView();
-
- QStringList strings;
- strings << "one" << "two" << "three";
- QStringListModel model(strings);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/displaygrid.qml"));
- qApp->processEvents();
-
- QDeclarative1GridView *gridview = findItem<QDeclarative1GridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QDeclarativeItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QTRY_COMPARE(gridview->count(), model.rowCount());
-
- for (int i = 0; i < model.rowCount(); ++i) {
- QDeclarative1Text *display = findItem<QDeclarative1Text>(contentItem, "displayText", i);
- QTRY_VERIFY(display != 0);
- QTRY_COMPARE(display->text(), strings.at(i));
- }
-
- strings.clear();
- strings << "four" << "five" << "six" << "seven";
- model.setStringList(strings);
-
- QTRY_COMPARE(gridview->count(), model.rowCount());
-
- for (int i = 0; i < model.rowCount(); ++i) {
- QDeclarative1Text *display = findItem<QDeclarative1Text>(contentItem, "displayText", i);
- QTRY_VERIFY(display != 0);
- QTRY_COMPARE(display->text(), strings.at(i));
- }
-
- delete canvas;
-}
-
-void tst_QDeclarative1GridView::enforceRange()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview-enforcerange.qml"));
- qApp->processEvents();
- QVERIFY(canvas->rootObject() != 0);
-
- QDeclarative1GridView *gridview = findItem<QDeclarative1GridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QTRY_COMPARE(gridview->preferredHighlightBegin(), 100.0);
- QTRY_COMPARE(gridview->preferredHighlightEnd(), 100.0);
- QTRY_COMPARE(gridview->highlightRangeMode(), QDeclarative1GridView::StrictlyEnforceRange);
-
- QDeclarativeItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // view should be positioned at the top of the range.
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", 0);
- QTRY_VERIFY(item);
- QTRY_COMPARE(gridview->contentY(), -100.0);
-
- QDeclarative1Text *name = findItem<QDeclarative1Text>(contentItem, "textName", 0);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(0));
- QDeclarative1Text *number = findItem<QDeclarative1Text>(contentItem, "textNumber", 0);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(0));
-
- // Check currentIndex is updated when contentItem moves
- gridview->setContentY(0);
- QTRY_COMPARE(gridview->currentIndex(), 2);
-
- gridview->setCurrentIndex(5);
- QTRY_COMPARE(gridview->contentY(), 100.);
-
- TestModel model2;
- for (int i = 0; i < 5; i++)
- model2.addItem("Item" + QString::number(i), "");
-
- ctxt->setContextProperty("testModel", &model2);
- QCOMPARE(gridview->count(), 5);
-
- delete canvas;
-}
-
-void tst_QDeclarative1GridView::enforceRange_rightToLeft()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(true));
- ctxt->setContextProperty("testTopToBottom", QVariant(true));
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview-enforcerange.qml"));
- qApp->processEvents();
- QVERIFY(canvas->rootObject() != 0);
-
- QDeclarative1GridView *gridview = findItem<QDeclarative1GridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QTRY_COMPARE(gridview->preferredHighlightBegin(), 100.0);
- QTRY_COMPARE(gridview->preferredHighlightEnd(), 100.0);
- QTRY_COMPARE(gridview->highlightRangeMode(), QDeclarative1GridView::StrictlyEnforceRange);
-
- QDeclarativeItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // view should be positioned at the top of the range.
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", 0);
- QTRY_VERIFY(item);
- QTRY_COMPARE(gridview->contentX(), -100.);
- QTRY_COMPARE(gridview->contentY(), 0.0);
-
- QDeclarative1Text *name = findItem<QDeclarative1Text>(contentItem, "textName", 0);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(0));
- QDeclarative1Text *number = findItem<QDeclarative1Text>(contentItem, "textNumber", 0);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(0));
-
- // Check currentIndex is updated when contentItem moves
- gridview->setContentX(-200);
- QTRY_COMPARE(gridview->currentIndex(), 3);
-
- gridview->setCurrentIndex(7);
- QTRY_COMPARE(gridview->contentX(), -300.);
- QTRY_COMPARE(gridview->contentY(), 0.0);
-
- TestModel model2;
- for (int i = 0; i < 5; i++)
- model2.addItem("Item" + QString::number(i), "");
-
- ctxt->setContextProperty("testModel", &model2);
- QCOMPARE(gridview->count(), 5);
-
- delete canvas;
-}
-
-void tst_QDeclarative1GridView::QTBUG_8456()
-{
- QDeclarativeView *canvas = createView();
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/setindex.qml"));
- qApp->processEvents();
-
- QDeclarative1GridView *gridview = findItem<QDeclarative1GridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QTRY_COMPARE(gridview->currentIndex(), 0);
-
- delete canvas;
-}
-
-void tst_QDeclarative1GridView::manualHighlight()
-{
- QDeclarativeView *canvas = createView();
-
- QString filename(SRCDIR "/data/manual-highlight.qml");
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- qApp->processEvents();
-
- QDeclarative1GridView *gridview = findItem<QDeclarative1GridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QDeclarativeItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QTRY_COMPARE(gridview->currentIndex(), 0);
- QTRY_COMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 0));
- QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y());
- QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x());
-
- gridview->setCurrentIndex(2);
-
- QTRY_COMPARE(gridview->currentIndex(), 2);
- QTRY_COMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 2));
- QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y());
- QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x());
-
- gridview->positionViewAtIndex(8, QDeclarative1GridView::Contain);
-
- QTRY_COMPARE(gridview->currentIndex(), 2);
- QTRY_COMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 2));
- QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y());
- QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x());
-
- gridview->setFlow(QDeclarative1GridView::TopToBottom);
- QTRY_COMPARE(gridview->flow(), QDeclarative1GridView::TopToBottom);
-
- gridview->setCurrentIndex(0);
- QTRY_COMPARE(gridview->currentIndex(), 0);
- QTRY_COMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 0));
- QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y());
- QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x());
-
- delete canvas;
-}
-
-void tst_QDeclarative1GridView::footer()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- for (int i = 0; i < 7; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/footer.qml"));
- qApp->processEvents();
-
- QDeclarative1GridView *gridview = findItem<QDeclarative1GridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QDeclarativeItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QDeclarative1Text *footer = findItem<QDeclarative1Text>(contentItem, "footer");
- QVERIFY(footer);
-
- QCOMPARE(footer->y(), 180.0);
- QCOMPARE(footer->height(), 30.0);
-
- model.removeItem(2);
- QTRY_COMPARE(footer->y(), 120.0);
-
- model.clear();
- QTRY_COMPARE(footer->y(), 0.0);
-
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QMetaObject::invokeMethod(canvas->rootObject(), "changeFooter");
-
- footer = findItem<QDeclarative1Text>(contentItem, "footer");
- QVERIFY(!footer);
- footer = findItem<QDeclarative1Text>(contentItem, "footer2");
- QVERIFY(footer);
-
- QCOMPARE(footer->y(), 600.0);
- QCOMPARE(footer->height(), 20.0);
- QCOMPARE(gridview->contentY(), 0.0);
-
- delete canvas;
-}
-
-void tst_QDeclarative1GridView::header()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/header.qml"));
- qApp->processEvents();
-
- QDeclarative1GridView *gridview = findItem<QDeclarative1GridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QDeclarativeItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QDeclarative1Text *header = findItem<QDeclarative1Text>(contentItem, "header");
- QVERIFY(header);
-
- QCOMPARE(header->y(), 0.0);
- QCOMPARE(header->height(), 30.0);
- QCOMPARE(gridview->contentY(), 0.0);
-
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->y(), 30.0);
-
- model.clear();
- QTRY_COMPARE(header->y(), 0.0);
-
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QMetaObject::invokeMethod(canvas->rootObject(), "changeHeader");
-
- header = findItem<QDeclarative1Text>(contentItem, "header");
- QVERIFY(!header);
- header = findItem<QDeclarative1Text>(contentItem, "header2");
- QVERIFY(header);
-
- QCOMPARE(header->y(), 10.0);
- QCOMPARE(header->height(), 20.0);
- QCOMPARE(gridview->contentY(), 10.0);
-
- delete canvas;
-}
-
-void tst_QDeclarative1GridView::indexAt()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
- model.addItem("Billy", "22345");
- model.addItem("Sam", "2945");
- model.addItem("Ben", "04321");
- model.addItem("Jim", "0780");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml"));
- qApp->processEvents();
-
- QDeclarative1GridView *gridview = findItem<QDeclarative1GridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QDeclarativeItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QTRY_COMPARE(gridview->count(), model.count());
-
- QCOMPARE(gridview->indexAt(0, 0), 0);
- QCOMPARE(gridview->indexAt(79, 59), 0);
- QCOMPARE(gridview->indexAt(80, 0), 1);
- QCOMPARE(gridview->indexAt(0, 60), 3);
- QCOMPARE(gridview->indexAt(240, 0), -1);
-
- delete canvas;
-}
-
-void tst_QDeclarative1GridView::onAdd()
-{
- QFETCH(int, initialItemCount);
- QFETCH(int, itemsToAdd);
-
- const int delegateWidth = 50;
- const int delegateHeight = 100;
- TestModel model;
- QDeclarativeView *canvas = createView();
- canvas->setFixedSize(5 * delegateWidth, 5 * delegateHeight); // just ensure all items fit
-
- // these initial items should not trigger GridView.onAdd
- for (int i=0; i<initialItemCount; i++)
- model.addItem("dummy value", "dummy value");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("delegateWidth", delegateWidth);
- ctxt->setContextProperty("delegateHeight", delegateHeight);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/attachedSignals.qml"));
-
- QObject *object = canvas->rootObject();
- object->setProperty("width", canvas->width());
- object->setProperty("height", canvas->height());
- qApp->processEvents();
-
- QList<QPair<QString, QString> > items;
- for (int i=0; i<itemsToAdd; i++)
- items << qMakePair(QString("value %1").arg(i), QString::number(i));
- model.addItems(items);
-
- qApp->processEvents();
-
- QVariantList result = object->property("addedDelegates").toList();
- QCOMPARE(result.count(), items.count());
- for (int i=0; i<items.count(); i++)
- QCOMPARE(result[i].toString(), items[i].first);
-
- delete canvas;
-}
-
-void tst_QDeclarative1GridView::onAdd_data()
-{
- QTest::addColumn<int>("initialItemCount");
- QTest::addColumn<int>("itemsToAdd");
-
- QTest::newRow("0, add 1") << 0 << 1;
- QTest::newRow("0, add 2") << 0 << 2;
- QTest::newRow("0, add 10") << 0 << 10;
-
- QTest::newRow("1, add 1") << 1 << 1;
- QTest::newRow("1, add 2") << 1 << 2;
- QTest::newRow("1, add 10") << 1 << 10;
-
- QTest::newRow("5, add 1") << 5 << 1;
- QTest::newRow("5, add 2") << 5 << 2;
- QTest::newRow("5, add 10") << 5 << 10;
-}
-
-void tst_QDeclarative1GridView::onRemove()
-{
- QFETCH(int, initialItemCount);
- QFETCH(int, indexToRemove);
- QFETCH(int, removeCount);
-
- const int delegateWidth = 50;
- const int delegateHeight = 100;
- TestModel model;
- for (int i=0; i<initialItemCount; i++)
- model.addItem(QString("value %1").arg(i), "dummy value");
-
- QDeclarativeView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("delegateWidth", delegateWidth);
- ctxt->setContextProperty("delegateHeight", delegateHeight);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/attachedSignals.qml"));
- QObject *object = canvas->rootObject();
-
- qApp->processEvents();
-
- model.removeItems(indexToRemove, removeCount);
- qApp->processEvents();
- QCOMPARE(object->property("removedDelegateCount"), QVariant(removeCount));
-
- delete canvas;
-}
-
-void tst_QDeclarative1GridView::onRemove_data()
-{
- QTest::addColumn<int>("initialItemCount");
- QTest::addColumn<int>("indexToRemove");
- QTest::addColumn<int>("removeCount");
-
- QTest::newRow("remove first") << 1 << 0 << 1;
- QTest::newRow("two items, remove first") << 2 << 0 << 1;
- QTest::newRow("two items, remove last") << 2 << 1 << 1;
- QTest::newRow("two items, remove all") << 2 << 0 << 2;
-
- QTest::newRow("four items, remove first") << 4 << 0 << 1;
- QTest::newRow("four items, remove 0-2") << 4 << 0 << 2;
- QTest::newRow("four items, remove 1-3") << 4 << 1 << 2;
- QTest::newRow("four items, remove 2-4") << 4 << 2 << 2;
- QTest::newRow("four items, remove last") << 4 << 3 << 1;
- QTest::newRow("four items, remove all") << 4 << 0 << 4;
-
- QTest::newRow("ten items, remove 1-8") << 10 << 0 << 8;
- QTest::newRow("ten items, remove 2-7") << 10 << 2 << 5;
- QTest::newRow("ten items, remove 4-10") << 10 << 4 << 6;
-}
-
-void tst_QDeclarative1GridView::testQtQuick11Attributes()
-{
- QFETCH(QString, code);
- QFETCH(QString, warning);
- QFETCH(QString, error);
-
- QDeclarativeEngine engine;
- QObject *obj;
-
- QDeclarativeComponent valid(&engine);
- valid.setData("import QtQuick 1.1; GridView { " + code.toUtf8() + " }", QUrl(""));
- obj = valid.create();
- QVERIFY(obj);
- QVERIFY(valid.errorString().isEmpty());
- delete obj;
-
- QDeclarativeComponent invalid(&engine);
- invalid.setData("import QtQuick 1.0; GridView { " + code.toUtf8() + " }", QUrl(""));
- QTest::ignoreMessage(QtWarningMsg, warning.toUtf8());
- obj = invalid.create();
- QCOMPARE(invalid.errorString(), error);
- delete obj;
-}
-
-void tst_QDeclarative1GridView::testQtQuick11Attributes_data()
-{
- QTest::addColumn<QString>("code");
- QTest::addColumn<QString>("warning");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("positionViewAtBeginning") << "Component.onCompleted: positionViewAtBeginning()"
- << "<Unknown File>:1: ReferenceError: Can't find variable: positionViewAtBeginning"
- << "";
-
- QTest::newRow("positionViewAtEnd") << "Component.onCompleted: positionViewAtEnd()"
- << "<Unknown File>:1: ReferenceError: Can't find variable: positionViewAtEnd"
- << "";
-}
-
-void tst_QDeclarative1GridView::contentPosJump()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- for (int i = 0; i < 100; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml"));
- qApp->processEvents();
-
- QDeclarative1GridView *gridview = findItem<QDeclarative1GridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
-
- QDeclarativeItem *contentItem = gridview->contentItem();
- QVERIFY(contentItem != 0);
-
- // Test jumping more than a page of items.
- gridview->setContentY(500);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 24; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->x() == (i%3)*80);
- QVERIFY(item->y() == (i/3)*60);
- }
-
- gridview->setContentY(-100);
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- QVERIFY(itemCount < 15);
- // Confirm items positioned correctly
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->x() == (i%3)*80);
- QVERIFY(item->y() == (i/3)*60);
- }
-
- delete canvas;
-}
-
-QDeclarativeView *tst_QDeclarative1GridView::createView()
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setFixedSize(240,320);
-
- return canvas;
-}
-
-/*
- Find an item with the specified objectName. If index is supplied then the
- item must also evaluate the {index} expression equal to index
-*/
-template<typename T>
-T *tst_QDeclarative1GridView::findItem(QGraphicsObject *parent, const QString &objectName, int index)
-{
- const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->childItems().count() << "children";
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- //qDebug() << "try" << item;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
- if (index != -1) {
- QDeclarativeContext *context = QDeclarativeEngine::contextForObject(item);
- if (context) {
- if (context->contextProperty("index").toInt() == index) {
- return static_cast<T*>(item);
- }
- }
- } else {
- return static_cast<T*>(item);
- }
- }
- item = findItem<T>(item, objectName, index);
- if (item)
- return static_cast<T*>(item);
- }
-
- return 0;
-}
-
-template<typename T>
-QList<T*> tst_QDeclarative1GridView::findItems(QGraphicsObject *parent, const QString &objectName)
-{
- QList<T*> items;
- const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->childItems().count() << "children";
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- //qDebug() << "try" << item;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
- items.append(static_cast<T*>(item));
- //qDebug() << " found:" << item;
- }
- items += findItems<T>(item, objectName);
- }
-
- return items;
-}
-
-void tst_QDeclarative1GridView::dumpTree(QDeclarativeItem *parent, int depth)
-{
- static QString padding(" ");
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- QDeclarativeContext *context = QDeclarativeEngine::contextForObject(item);
- qDebug() << padding.left(depth*2) << item << (context ? context->contextProperty("index").toInt() : -1);
- dumpTree(item, depth+1);
- }
-}
-
-
-QTEST_MAIN(tst_QDeclarative1GridView)
-
-#include "tst_qdeclarativegridview.moc"
diff --git a/tests/auto/qtquick1/qdeclarativeimage/data/aspectratio.qml b/tests/auto/qtquick1/qdeclarativeimage/data/aspectratio.qml
deleted file mode 100644
index cd092bc760..0000000000
--- a/tests/auto/qtquick1/qdeclarativeimage/data/aspectratio.qml
+++ /dev/null
@@ -1,10 +0,0 @@
-import QtQuick 1.0
-
-Image {
- property int widthChange: 0
- property int heightChange: 0
- source: "heart.png"
- fillMode: Image.PreserveAspectFit;
- onWidthChanged: widthChange += 1
- onHeightChanged: heightChange += 1
-}
diff --git a/tests/auto/qtquick1/qdeclarativeimage/data/big.jpeg b/tests/auto/qtquick1/qdeclarativeimage/data/big.jpeg
deleted file mode 100644
index bed7bd65c3..0000000000
--- a/tests/auto/qtquick1/qdeclarativeimage/data/big.jpeg
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativeimage/data/big256.png b/tests/auto/qtquick1/qdeclarativeimage/data/big256.png
deleted file mode 100644
index 1dc1596d03..0000000000
--- a/tests/auto/qtquick1/qdeclarativeimage/data/big256.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativeimage/data/colors.png b/tests/auto/qtquick1/qdeclarativeimage/data/colors.png
deleted file mode 100644
index dfb62f3d64..0000000000
--- a/tests/auto/qtquick1/qdeclarativeimage/data/colors.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativeimage/data/colors1.png b/tests/auto/qtquick1/qdeclarativeimage/data/colors1.png
deleted file mode 100644
index dfb62f3d64..0000000000
--- a/tests/auto/qtquick1/qdeclarativeimage/data/colors1.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativeimage/data/green.png b/tests/auto/qtquick1/qdeclarativeimage/data/green.png
deleted file mode 100644
index 0a2e153ba1..0000000000
--- a/tests/auto/qtquick1/qdeclarativeimage/data/green.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativeimage/data/heart-win32.png b/tests/auto/qtquick1/qdeclarativeimage/data/heart-win32.png
deleted file mode 100644
index 351da13772..0000000000
--- a/tests/auto/qtquick1/qdeclarativeimage/data/heart-win32.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativeimage/data/heart.png b/tests/auto/qtquick1/qdeclarativeimage/data/heart.png
deleted file mode 100644
index abe97fee4b..0000000000
--- a/tests/auto/qtquick1/qdeclarativeimage/data/heart.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativeimage/data/heart.svg b/tests/auto/qtquick1/qdeclarativeimage/data/heart.svg
deleted file mode 100644
index 8c982cd93c..0000000000
--- a/tests/auto/qtquick1/qdeclarativeimage/data/heart.svg
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) --><svg viewBox="100 200 550 500" height="841.88976pt" id="svg1" inkscape:version="0.40+cvs" sodipodi:docbase="C:\Documents and Settings\Jon Phillips\My Documents\projects\clipart-project\submissions" sodipodi:docname="heart-left-highlight.svg" sodipodi:version="0.32" width="595.27559pt" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:svg="http://www.w3.org/2000/svg">
-<metadata>
-<rdf:RDF xmlns:cc="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
-<cc:Work rdf:about="">
-<dc:title>Heart Left-Highlight</dc:title>
-<dc:description>This is a normal valentines day heart.</dc:description>
-<dc:subject>
-<rdf:Bag>
-<rdf:li>holiday</rdf:li>
-<rdf:li>valentines</rdf:li>
-<rdf:li></rdf:li>
-<rdf:li>valentine</rdf:li>
-<rdf:li>hash(0x8a091c0)</rdf:li>
-<rdf:li>hash(0x8a0916c)</rdf:li>
-<rdf:li>signs_and_symbols</rdf:li>
-<rdf:li>hash(0x8a091f0)</rdf:li>
-<rdf:li>day</rdf:li>
-</rdf:Bag>
-</dc:subject>
-<dc:publisher>
-<cc:Agent rdf:about="http://www.openclipart.org">
-<dc:title>Jon Phillips</dc:title>
-</cc:Agent>
-</dc:publisher>
-<dc:creator>
-<cc:Agent>
-<dc:title>Jon Phillips</dc:title>
-</cc:Agent>
-</dc:creator>
-<dc:rights>
-<cc:Agent>
-<dc:title>Jon Phillips</dc:title>
-</cc:Agent>
-</dc:rights>
-<dc:date></dc:date>
-<dc:format>image/svg+xml</dc:format>
-<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
-<cc:license rdf:resource="http://web.resource.org/cc/PublicDomain"/>
-<dc:language>en</dc:language>
-</cc:Work>
-<cc:License rdf:about="http://web.resource.org/cc/PublicDomain">
-<cc:permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
-<cc:permits rdf:resource="http://web.resource.org/cc/Distribution"/>
-<cc:permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/>
-</cc:License>
-</rdf:RDF>
-</metadata>
-<defs id="defs3"/>
-<sodipodi:namedview bordercolor="#666666" borderopacity="1.0" id="base" inkscape:current-layer="layer1" inkscape:cx="549.40674" inkscape:cy="596.00159" inkscape:document-units="px" inkscape:guide-bbox="true" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:window-height="615" inkscape:window-width="866" inkscape:window-x="88" inkscape:window-y="116" inkscape:zoom="0.35000000" pagecolor="#ffffff" showguides="true"/>
-<g id="layer1" inkscape:groupmode="layer" inkscape:label="Layer 1">
-<path d="M 263.41570,235.14588 C 197.17570,235.14588 143.41575,288.90587 143.41575,355.14588 C 143.41575,489.90139 279.34890,525.23318 371.97820,658.45392 C 459.55244,526.05056 600.54070,485.59932 600.54070,355.14588 C 600.54070,288.90588 546.78080,235.14587 480.54070,235.14588 C 432.49280,235.14588 391.13910,263.51631 371.97820,304.33338 C 352.81740,263.51630 311.46370,235.14587 263.41570,235.14588 z " id="path7" sodipodi:nodetypes="ccccccc" style="fill:#e60000;fill-opacity:1.0000000;stroke:#000000;stroke-width:18.700001;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"/>
-<path d="M 265.00000,253.59375 C 207.04033,253.59375 160.00000,300.63407 160.00000,358.59375 C 160.00000,476.50415 278.91857,507.43251 359.96875,624.00000 C 366.52868,614.08205 220.00000,478.47309 220.00000,378.59375 C 220.00000,320.63407 267.04033,273.59375 325.00000,273.59375 C 325.50453,273.59375 325.99718,273.64912 326.50000,273.65625 C 309.22436,261.07286 288.00557,253.59374 265.00000,253.59375 z " id="path220" sodipodi:nodetypes="ccccccc" style="fill:#e6e6e6;fill-opacity:0.64556962;stroke:none;stroke-width:18.700001;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"/>
-</g>
-</svg>
diff --git a/tests/auto/qtquick1/qdeclarativeimage/data/heart200-win32.png b/tests/auto/qtquick1/qdeclarativeimage/data/heart200-win32.png
deleted file mode 100644
index 4976ff98ba..0000000000
--- a/tests/auto/qtquick1/qdeclarativeimage/data/heart200-win32.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativeimage/data/heart200.png b/tests/auto/qtquick1/qdeclarativeimage/data/heart200.png
deleted file mode 100644
index 7fbb13c5bb..0000000000
--- a/tests/auto/qtquick1/qdeclarativeimage/data/heart200.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativeimage/data/qtbug_16389.qml b/tests/auto/qtquick1/qdeclarativeimage/data/qtbug_16389.qml
deleted file mode 100644
index 29fba400ef..0000000000
--- a/tests/auto/qtquick1/qdeclarativeimage/data/qtbug_16389.qml
+++ /dev/null
@@ -1,30 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- width: 400
- height: 400
-
- Item {
- anchors.top: parent.top
- anchors.left: parent.left
- anchors.bottom: blueHandle.top
- anchors.right: blueHandle.left
-
- Image {
- id: iconImage
- objectName: "iconImage"
- anchors.top: parent.top
- anchors.bottom: parent.bottom
- source: "heart200.png"
- fillMode: Image.PreserveAspectFit
- smooth: true
- }
- }
-
- Rectangle {
- id: blueHandle
- objectName: "blueHandle"
- color: "blue"
- width: 25
- height: 25
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeimage/data/rect.png b/tests/auto/qtquick1/qdeclarativeimage/data/rect.png
deleted file mode 100644
index d564a2d5a5..0000000000
--- a/tests/auto/qtquick1/qdeclarativeimage/data/rect.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativeimage/data/tiling.qml b/tests/auto/qtquick1/qdeclarativeimage/data/tiling.qml
deleted file mode 100644
index 49715ab3e7..0000000000
--- a/tests/auto/qtquick1/qdeclarativeimage/data/tiling.qml
+++ /dev/null
@@ -1,16 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 800; height: 600
-
- Image {
- objectName: "vTiling"; height: 550; width: 200
- source: "green.png"; fillMode: Image.TileVertically
- }
-
- Image {
- objectName: "hTiling"; x: 225; height: 250; width: 550
- source: "green.png"; fillMode: Image.TileHorizontally
- }
-}
-
diff --git a/tests/auto/qtquick1/qdeclarativeimage/qdeclarativeimage.pro b/tests/auto/qtquick1/qdeclarativeimage/qdeclarativeimage.pro
deleted file mode 100644
index 28570ab093..0000000000
--- a/tests/auto/qtquick1/qdeclarativeimage/qdeclarativeimage.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeimage
-macx:CONFIG -= app_bundle
-
-HEADERS += ../../shared/testhttpserver.h
-SOURCES += tst_qdeclarativeimage.cpp ../../shared/testhttpserver.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
-QT += core-private gui-private widgets-private declarative-private qtquick1-private network testlib
diff --git a/tests/auto/qtquick1/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/qtquick1/qdeclarativeimage/tst_qdeclarativeimage.cpp
deleted file mode 100644
index 990bf7754c..0000000000
--- a/tests/auto/qtquick1/qdeclarativeimage/tst_qdeclarativeimage.cpp
+++ /dev/null
@@ -1,801 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QTextDocument>
-#include <QTcpServer>
-#include <QTcpSocket>
-#include <QDir>
-
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick1/qdeclarativeview.h>
-#include <QtQuick1/private/qdeclarativeimage_p.h>
-#include <QtQuick1/private/qdeclarativeimagebase_p.h>
-#include <QtQuick1/private/qdeclarativeloader_p.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtTest/QSignalSpy>
-
-#include "../../shared/testhttpserver.h"
-
-#define SERVER_PORT 14451
-#define SERVER_ADDR "http://127.0.0.1:14451"
-
-class tst_qdeclarativeimage : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativeimage();
-
-private slots:
- void noSource();
- void imageSource();
- void imageSource_data();
- void clearSource();
- void resized();
- void preserveAspectRatio();
- void smooth();
- void mirror();
- void mirror_data();
- void svg();
- void geometry();
- void geometry_data();
- void big();
- void tiling_QTBUG_6716();
- void noLoading();
- void paintedWidthHeight();
- void sourceSize_QTBUG_14303();
- void sourceSize_QTBUG_16389();
- void nullPixmapPaint();
- void resetSourceSize();
- void testQtQuick11Attributes();
- void testQtQuick11Attributes_data();
-
-private:
- template<typename T>
- T *findItem(QGraphicsObject *parent, const QString &id, int index=-1);
-
- QDeclarativeEngine engine;
-};
-
-tst_qdeclarativeimage::tst_qdeclarativeimage()
-{
-}
-
-void tst_qdeclarativeimage::noSource()
-{
- QString componentStr = "import QtQuick 1.0\nImage { source: \"\" }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Image *obj = qobject_cast<QDeclarative1Image*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->source(), QUrl());
- QVERIFY(obj->status() == QDeclarative1Image::Null);
- QCOMPARE(obj->width(), 0.);
- QCOMPARE(obj->height(), 0.);
- QCOMPARE(obj->fillMode(), QDeclarative1Image::Stretch);
- QCOMPARE(obj->progress(), 0.0);
-
- delete obj;
-}
-
-void tst_qdeclarativeimage::imageSource_data()
-{
- QTest::addColumn<QString>("source");
- QTest::addColumn<double>("width");
- QTest::addColumn<double>("height");
- QTest::addColumn<bool>("remote");
- QTest::addColumn<bool>("async");
- QTest::addColumn<bool>("cache");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() << 120.0 << 120.0 << false << false << true << "";
- QTest::newRow("local no cache") << QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() << 120.0 << 120.0 << false << false << false << "";
- QTest::newRow("local async") << QUrl::fromLocalFile(SRCDIR "/data/colors1.png").toString() << 120.0 << 120.0 << false << true << true << "";
- QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() << 0.0 << 0.0 << false
- << false << true << "file::2:1: QML Image: Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString();
- QTest::newRow("local async not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString() << 0.0 << 0.0 << false
- << true << true << "file::2:1: QML Image: Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString();
- QTest::newRow("remote") << SERVER_ADDR "/colors.png" << 120.0 << 120.0 << true << false << true << "";
- QTest::newRow("remote redirected") << SERVER_ADDR "/oldcolors.png" << 120.0 << 120.0 << true << false << false << "";
- QTest::newRow("remote svg") << SERVER_ADDR "/heart.svg" << 550.0 << 500.0 << true << false << false << "";
- QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << 0.0 << 0.0 << true
- << false << true << "file::2:1: QML Image: Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found";
-
-}
-
-void tst_qdeclarativeimage::imageSource()
-{
- QFETCH(QString, source);
- QFETCH(double, width);
- QFETCH(double, height);
- QFETCH(bool, remote);
- QFETCH(bool, async);
- QFETCH(bool, cache);
- QFETCH(QString, error);
-
- TestHTTPServer server(SERVER_PORT);
- if (remote) {
- QVERIFY(server.isValid());
- server.serveDirectory(SRCDIR "/data");
- server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png");
- }
-
- if (!error.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
-
- QString componentStr = "import QtQuick 1.1\nImage { source: \"" + source + "\"; asynchronous: "
- + (async ? QLatin1String("true") : QLatin1String("false")) + "; cache: "
- + (cache ? QLatin1String("true") : QLatin1String("false")) + " }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Image *obj = qobject_cast<QDeclarative1Image*>(component.create());
- QVERIFY(obj != 0);
-
- if (async)
- QVERIFY(obj->asynchronous() == true);
- else
- QVERIFY(obj->asynchronous() == false);
-
- if (cache)
- QVERIFY(obj->cache() == true);
- else
- QVERIFY(obj->cache() == false);
-
- if (remote || async)
- QTRY_VERIFY(obj->status() == QDeclarative1Image::Loading);
-
- QCOMPARE(obj->source(), remote ? source : QUrl(source));
-
- if (error.isEmpty()) {
- QTRY_VERIFY(obj->status() == QDeclarative1Image::Ready);
- QCOMPARE(obj->width(), qreal(width));
- QCOMPARE(obj->height(), qreal(height));
- QCOMPARE(obj->fillMode(), QDeclarative1Image::Stretch);
- QCOMPARE(obj->progress(), 1.0);
- } else {
- QTRY_VERIFY(obj->status() == QDeclarative1Image::Error);
- }
-
- delete obj;
-}
-
-void tst_qdeclarativeimage::clearSource()
-{
- QString componentStr = "import QtQuick 1.0\nImage { source: srcImage }";
- QDeclarativeContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.png"));
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Image *obj = qobject_cast<QDeclarative1Image*>(component.create());
- QVERIFY(obj != 0);
- QVERIFY(obj->status() == QDeclarative1Image::Ready);
- QCOMPARE(obj->width(), 120.);
- QCOMPARE(obj->height(), 120.);
- QCOMPARE(obj->progress(), 1.0);
-
- ctxt->setContextProperty("srcImage", "");
- QVERIFY(obj->source().isEmpty());
- QVERIFY(obj->status() == QDeclarative1Image::Null);
- QCOMPARE(obj->width(), 0.);
- QCOMPARE(obj->height(), 0.);
- QCOMPARE(obj->progress(), 0.0);
-
- delete obj;
-}
-
-void tst_qdeclarativeimage::resized()
-{
- QString componentStr = "import QtQuick 1.0\nImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 300 }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Image *obj = qobject_cast<QDeclarative1Image*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->fillMode(), QDeclarative1Image::Stretch);
- delete obj;
-}
-
-
-void tst_qdeclarativeimage::preserveAspectRatio()
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->show();
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/aspectratio.qml"));
- QDeclarative1Image *image = qobject_cast<QDeclarative1Image*>(canvas->rootObject());
- QVERIFY(image != 0);
- QCOMPARE(image->property("widthChange").toInt(), 1);
- QCOMPARE(image->property("heightChange").toInt(), 1);
- image->setWidth(80.0);
- QCOMPARE(image->property("widthChange").toInt(), 2);
- QCOMPARE(image->property("heightChange").toInt(), 2);
- QCOMPARE(image->width(), 80.);
- QCOMPARE(image->height(), 80.);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/aspectratio.qml"));
- image = qobject_cast<QDeclarative1Image*>(canvas->rootObject());
- QVERIFY(image != 0);
- QCOMPARE(image->property("widthChange").toInt(), 1);
- QCOMPARE(image->property("heightChange").toInt(), 1);
- image->setHeight(60.0);
- QCOMPARE(image->property("widthChange").toInt(), 2);
- QCOMPARE(image->property("heightChange").toInt(), 2);
- QCOMPARE(image->height(), 60.);
- QCOMPARE(image->width(), 60.);
- delete canvas;
-}
-
-void tst_qdeclarativeimage::smooth()
-{
- QString componentStr = "import QtQuick 1.0\nImage { source: \"" SRCDIR "/data/colors.png\"; smooth: true; width: 300; height: 300 }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Image *obj = qobject_cast<QDeclarative1Image*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->smooth(), true);
- QCOMPARE(obj->fillMode(), QDeclarative1Image::Stretch);
-
- delete obj;
-}
-
-void tst_qdeclarativeimage::mirror()
-{
- QFETCH(int, fillMode);
-
- qreal width = 300;
- qreal height = 250;
-
- QString src = QUrl::fromLocalFile(SRCDIR "/data/heart200.png").toString();
- QString componentStr = "import QtQuick 1.1\nImage { source: \"" + src + "\"; }";
-
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Image *obj = qobject_cast<QDeclarative1Image*>(component.create());
- QVERIFY(obj != 0);
-
- obj->setProperty("width", width);
- obj->setProperty("height", height);
- obj->setFillMode((QDeclarative1Image::FillMode)fillMode);
- obj->setProperty("mirror", true);
-
- QGraphicsScene scene;
- scene.addItem(qobject_cast<QGraphicsObject *>(obj));
- QPixmap screenshot(width, height);
- screenshot.fill();
- QPainter p_screenshot(&screenshot);
- scene.render(&p_screenshot, QRect(0, 0, width, height), QRect(0, 0, width, height));
-
- QPixmap srcPixmap;
- QVERIFY(srcPixmap.load(SRCDIR "/data/heart200.png"));
-
- QPixmap expected(width, height);
- expected.fill();
- QPainter p_e(&expected);
- QTransform transform;
- transform.translate(width, 0).scale(-1, 1.0);
- p_e.setTransform(transform);
-
- switch (fillMode) {
- case QDeclarative1Image::Stretch:
- p_e.drawPixmap(QRect(0, 0, width, height), srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height()));
- break;
- case QDeclarative1Image::PreserveAspectFit:
- QEXPECT_FAIL("", "QTBUG-19538", Continue);
- p_e.drawPixmap(QRect(25, 0, width / (width/height), height), srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height()));
- break;
- case QDeclarative1Image::PreserveAspectCrop:
- {
- qreal ratio = width/srcPixmap.width(); // width is the longer side
- QRect rect(0, 0, srcPixmap.width()*ratio, srcPixmap.height()*ratio);
- rect.moveCenter(QRect(0, 0, width, height).center());
- p_e.drawPixmap(rect, srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height()));
- break;
- }
- case QDeclarative1Image::Tile:
- p_e.drawTiledPixmap(QRect(0, 0, width, height), srcPixmap);
- break;
- case QDeclarative1Image::TileVertically:
- transform.scale(width / srcPixmap.width(), 1.0);
- p_e.setTransform(transform);
- p_e.drawTiledPixmap(QRect(0, 0, width, height), srcPixmap);
- break;
- case QDeclarative1Image::TileHorizontally:
- transform.scale(1.0, height / srcPixmap.height());
- p_e.setTransform(transform);
- p_e.drawTiledPixmap(QRect(0, 0, width, height), srcPixmap);
- break;
- }
-
- QCOMPARE(screenshot, expected);
-
- delete obj;
-}
-
-void tst_qdeclarativeimage::mirror_data()
-{
- QTest::addColumn<int>("fillMode");
-
- QTest::newRow("Stretch") << int(QDeclarative1Image::Stretch);
- QTest::newRow("PreserveAspectFit") << int(QDeclarative1Image::PreserveAspectFit);
- QTest::newRow("PreserveAspectCrop") << int(QDeclarative1Image::PreserveAspectCrop);
- QTest::newRow("Tile") << int(QDeclarative1Image::Tile);
- QTest::newRow("TileVertically") << int(QDeclarative1Image::TileVertically);
- QTest::newRow("TileHorizontally") << int(QDeclarative1Image::TileHorizontally);
-}
-
-void tst_qdeclarativeimage::svg()
-{
- QString src = QUrl::fromLocalFile(SRCDIR "/data/heart.svg").toString();
- QString componentStr = "import QtQuick 1.0\nImage { source: \"" + src + "\"; sourceSize.width: 300; sourceSize.height: 300 }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Image *obj = qobject_cast<QDeclarative1Image*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->pixmap().width(), 300);
- QCOMPARE(obj->pixmap().height(), 300);
- QCOMPARE(obj->width(), 300.0);
- QCOMPARE(obj->height(), 300.0);
-#if defined(Q_OS_LINUX)
- QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart.png"));
-#elif defined(Q_OS_WIN32)
- QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart-win32.png"));
-#endif
-
- obj->setSourceSize(QSize(200,200));
-
- QCOMPARE(obj->pixmap().width(), 200);
- QCOMPARE(obj->pixmap().height(), 200);
- QCOMPARE(obj->width(), 200.0);
- QCOMPARE(obj->height(), 200.0);
-#if defined(Q_OS_LINUX)
- QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200.png"));
-#elif defined(Q_OS_WIN32)
- QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200-win32.png"));
-#endif
- delete obj;
-}
-
-void tst_qdeclarativeimage::geometry_data()
-{
- QTest::addColumn<QString>("fillMode");
- QTest::addColumn<bool>("explicitWidth");
- QTest::addColumn<bool>("explicitHeight");
- QTest::addColumn<double>("itemWidth");
- QTest::addColumn<double>("paintedWidth");
- QTest::addColumn<double>("boundingWidth");
- QTest::addColumn<double>("itemHeight");
- QTest::addColumn<double>("paintedHeight");
- QTest::addColumn<double>("boundingHeight");
-
- // tested image has width 200, height 100
-
- // bounding rect and item rect are equal with fillMode PreserveAspectFit, painted rect may be smaller if the aspect ratio doesn't match
- QTest::newRow("PreserveAspectFit") << "PreserveAspectFit" << false << false << 200.0 << 200.0 << 200.0 << 100.0 << 100.0 << 100.0;
- QTest::newRow("PreserveAspectFit explicit width 300") << "PreserveAspectFit" << true << false << 300.0 << 200.0 << 300.0 << 100.0 << 100.0 << 100.0;
- QTest::newRow("PreserveAspectFit explicit height 400") << "PreserveAspectFit" << false << true << 200.0 << 200.0 << 200.0 << 400.0 << 100.0 << 400.0;
- QTest::newRow("PreserveAspectFit explicit width 300, height 400") << "PreserveAspectFit" << true << true << 300.0 << 300.0 << 300.0 << 400.0 << 150.0 << 400.0;
-
- // bounding rect and painted rect are equal with fillMode PreserveAspectCrop, item rect may be smaller if the aspect ratio doesn't match
- QTest::newRow("PreserveAspectCrop") << "PreserveAspectCrop" << false << false << 200.0 << 200.0 << 200.0 << 100.0 << 100.0 << 100.0;
- QTest::newRow("PreserveAspectCrop explicit width 300") << "PreserveAspectCrop" << true << false << 300.0 << 300.0 << 300.0 << 100.0 << 150.0 << 150.0;
- QTest::newRow("PreserveAspectCrop explicit height 400") << "PreserveAspectCrop" << false << true << 200.0 << 800.0 << 800.0 << 400.0 << 400.0 << 400.0;
- QTest::newRow("PreserveAspectCrop explicit width 300, height 400") << "PreserveAspectCrop" << true << true << 300.0 << 800.0 << 800.0 << 400.0 << 400.0 << 400.0;
-
- // bounding rect, painted rect and item rect are equal in stretching and tiling images
- QStringList fillModes;
- fillModes << "Stretch" << "Tile" << "TileVertically" << "TileHorizontally";
- foreach (QString fillMode, fillModes) {
- QTest::newRow(fillMode.toLatin1()) << fillMode << false << false << 200.0 << 200.0 << 200.0 << 100.0 << 100.0 << 100.0;
- QTest::newRow(QString(fillMode + " explicit width 300").toLatin1()) << fillMode << true << false << 300.0 << 300.0 << 300.0 << 100.0 << 100.0 << 100.0;
- QTest::newRow(QString(fillMode + " explicit height 400").toLatin1()) << fillMode << false << true << 200.0 << 200.0 << 200.0 << 400.0 << 400.0 << 400.0;
- QTest::newRow(QString(fillMode + " explicit width 300, height 400").toLatin1()) << fillMode << true << true << 300.0 << 300.0 << 300.0 << 400.0 << 400.0 << 400.0;
- }
-}
-
-void tst_qdeclarativeimage::geometry()
-{
- QFETCH(QString, fillMode);
- QFETCH(bool, explicitWidth);
- QFETCH(bool, explicitHeight);
- QFETCH(double, itemWidth);
- QFETCH(double, itemHeight);
- QFETCH(double, paintedWidth);
- QFETCH(double, paintedHeight);
- QFETCH(double, boundingWidth);
- QFETCH(double, boundingHeight);
-
- QString src = QUrl::fromLocalFile(SRCDIR "/data/rect.png").toString();
- QString componentStr = "import QtQuick 1.0\nImage { source: \"" + src + "\"; fillMode: Image." + fillMode + "; ";
-
- if (explicitWidth)
- componentStr.append("width: 300; ");
- if (explicitHeight)
- componentStr.append("height: 400; ");
- componentStr.append("}");
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Image *obj = qobject_cast<QDeclarative1Image*>(component.create());
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->width(), itemWidth);
- QCOMPARE(obj->paintedWidth(), paintedWidth);
- QCOMPARE(obj->boundingRect().width(), boundingWidth);
-
- QCOMPARE(obj->height(), itemHeight);
- QCOMPARE(obj->paintedHeight(), paintedHeight);
- QCOMPARE(obj->boundingRect().height(), boundingHeight);
- delete obj;
-}
-
-void tst_qdeclarativeimage::big()
-{
- // If the JPEG loader does not implement scaling efficiently, it would
- // have to build a 400 MB image. That would be a bug in the JPEG loader.
-
- QString src = QUrl::fromLocalFile(SRCDIR "/data/big.jpeg").toString();
- QString componentStr = "import QtQuick 1.0\nImage { source: \"" + src + "\"; width: 100; sourceSize.height: 256 }";
-
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Image *obj = qobject_cast<QDeclarative1Image*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->pixmap().width(), 256);
- QCOMPARE(obj->pixmap().height(), 256);
- QCOMPARE(obj->width(), 100.0);
- QCOMPARE(obj->height(), 256.0);
- QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/big256.png"));
-
- delete obj;
-}
-
-void tst_qdeclarativeimage::tiling_QTBUG_6716()
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/tiling.qml"));
- canvas->show();
- qApp->processEvents();
-
- QDeclarative1Image *vTiling = findItem<QDeclarative1Image>(canvas->rootObject(), "vTiling");
- QDeclarative1Image *hTiling = findItem<QDeclarative1Image>(canvas->rootObject(), "hTiling");
-
- QVERIFY(vTiling != 0);
- QVERIFY(hTiling != 0);
-
- {
- QPixmap pm(vTiling->width(), vTiling->height());
- QPainter p(&pm);
- vTiling->paint(&p, 0, 0);
-
- QImage img = pm.toImage();
- for (int x = 0; x < vTiling->width(); ++x) {
- for (int y = 0; y < vTiling->height(); ++y) {
- QVERIFY(img.pixel(x, y) == qRgb(0, 255, 0));
- }
- }
- }
-
- {
- QPixmap pm(hTiling->width(), hTiling->height());
- QPainter p(&pm);
- hTiling->paint(&p, 0, 0);
-
- QImage img = pm.toImage();
- for (int x = 0; x < hTiling->width(); ++x) {
- for (int y = 0; y < hTiling->height(); ++y) {
- QVERIFY(img.pixel(x, y) == qRgb(0, 255, 0));
- }
- }
- }
-
- delete canvas;
-}
-
-void tst_qdeclarativeimage::noLoading()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.serveDirectory(SRCDIR "/data");
- server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png");
-
- QString componentStr = "import QtQuick 1.1\nImage { source: srcImage; cache: true }";
- QDeclarativeContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/heart.png"));
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Image *obj = qobject_cast<QDeclarative1Image*>(component.create());
- QVERIFY(obj != 0);
- QVERIFY(obj->status() == QDeclarative1Image::Ready);
-
- QSignalSpy sourceSpy(obj, SIGNAL(sourceChanged(const QUrl &)));
- QSignalSpy progressSpy(obj, SIGNAL(progressChanged(qreal)));
- QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QDeclarative1ImageBase::Status)));
-
- // Loading local file
- ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/green.png"));
- QTRY_VERIFY(obj->status() == QDeclarative1Image::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
- QTRY_COMPARE(sourceSpy.count(), 1);
- QTRY_COMPARE(progressSpy.count(), 0);
- QTRY_COMPARE(statusSpy.count(), 0);
-
- // Loading remote file
- ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/rect.png");
- QTRY_VERIFY(obj->status() == QDeclarative1Image::Loading);
- QTRY_VERIFY(obj->progress() == 0.0);
- QTRY_VERIFY(obj->status() == QDeclarative1Image::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
- QTRY_COMPARE(sourceSpy.count(), 2);
- QTRY_COMPARE(progressSpy.count(), 2);
- QTRY_COMPARE(statusSpy.count(), 2);
-
- // Loading remote file again - should not go through 'Loading' state.
- ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/green.png"));
- ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/rect.png");
- QTRY_VERIFY(obj->status() == QDeclarative1Image::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
- QTRY_COMPARE(sourceSpy.count(), 4);
- QTRY_COMPARE(progressSpy.count(), 2);
- QTRY_COMPARE(statusSpy.count(), 2);
-
- delete obj;
-}
-
-void tst_qdeclarativeimage::paintedWidthHeight()
-{
- {
- QString src = QUrl::fromLocalFile(SRCDIR "/data/heart.png").toString();
- QString componentStr = "import QtQuick 1.0\nImage { source: \"" + src + "\"; width: 200; height: 25; fillMode: Image.PreserveAspectFit }";
-
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Image *obj = qobject_cast<QDeclarative1Image*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->pixmap().width(), 300);
- QCOMPARE(obj->pixmap().height(), 300);
- QCOMPARE(obj->width(), 200.0);
- QCOMPARE(obj->height(), 25.0);
- QCOMPARE(obj->paintedWidth(), 25.0);
- QCOMPARE(obj->paintedHeight(), 25.0);
- QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart.png"));
-
- delete obj;
- }
-
- {
- QString src = QUrl::fromLocalFile(SRCDIR "/data/heart.png").toString();
- QString componentStr = "import QtQuick 1.0\nImage { source: \"" + src + "\"; width: 26; height: 175; fillMode: Image.PreserveAspectFit }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Image *obj = qobject_cast<QDeclarative1Image*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->pixmap().width(), 300);
- QCOMPARE(obj->pixmap().height(), 300);
- QCOMPARE(obj->width(), 26.0);
- QCOMPARE(obj->height(), 175.0);
- QCOMPARE(obj->paintedWidth(), 26.0);
- QCOMPARE(obj->paintedHeight(), 26.0);
- QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart.png"));
-
- delete obj;
- }
-}
-
-void tst_qdeclarativeimage::sourceSize_QTBUG_14303()
-{
- QString componentStr = "import QtQuick 1.0\nImage { source: srcImage }";
- QDeclarativeContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/heart200.png"));
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Image *obj = qobject_cast<QDeclarative1Image*>(component.create());
-
- QSignalSpy sourceSizeSpy(obj, SIGNAL(sourceSizeChanged()));
-
- QTRY_VERIFY(obj != 0);
- QTRY_VERIFY(obj->status() == QDeclarative1Image::Ready);
-
- QTRY_COMPARE(obj->sourceSize().width(), 200);
- QTRY_COMPARE(obj->sourceSize().height(), 200);
- QTRY_COMPARE(sourceSizeSpy.count(), 0);
-
- ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.png"));
- QTRY_COMPARE(obj->sourceSize().width(), 120);
- QTRY_COMPARE(obj->sourceSize().height(), 120);
- QTRY_COMPARE(sourceSizeSpy.count(), 1);
-
- ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/heart200.png"));
- QTRY_COMPARE(obj->sourceSize().width(), 200);
- QTRY_COMPARE(obj->sourceSize().height(), 200);
- QTRY_COMPARE(sourceSizeSpy.count(), 2);
-
- delete obj;
-}
-
-void tst_qdeclarativeimage::sourceSize_QTBUG_16389()
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/qtbug_16389.qml"));
- canvas->show();
- qApp->processEvents();
-
- QDeclarative1Image *image = findItem<QDeclarative1Image>(canvas->rootObject(), "iconImage");
- QDeclarativeItem *handle = findItem<QDeclarativeItem>(canvas->rootObject(), "blueHandle");
-
- QCOMPARE(image->sourceSize().width(), 200);
- QCOMPARE(image->sourceSize().height(), 200);
- QCOMPARE(image->paintedWidth(), 0.0);
- QCOMPARE(image->paintedHeight(), 0.0);
-
- handle->setY(20);
-
- QCOMPARE(image->sourceSize().width(), 200);
- QCOMPARE(image->sourceSize().height(), 200);
- QCOMPARE(image->paintedWidth(), 20.0);
- QCOMPARE(image->paintedHeight(), 20.0);
-}
-
-static int numberOfWarnings = 0;
-static void checkWarnings(QtMsgType, const char *)
-{
- numberOfWarnings++;
-}
-
-// QTBUG-15690
-void tst_qdeclarativeimage::nullPixmapPaint()
-{
- QString componentStr = QString("import QtQuick 1.0\nImage { width: 10; height:10; fillMode: Image.PreserveAspectFit; source: \"")
- + SERVER_ADDR + QString("/no-such-file.png\" }");
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Image *image = qobject_cast<QDeclarative1Image*>(component.create());
-
- QTRY_VERIFY(image != 0);
-
- QtMsgHandler previousMsgHandler = qInstallMsgHandler(checkWarnings);
-
- QPixmap pm(100, 100);
- QPainter p(&pm);
-
- // used to print "QTransform::translate with NaN called"
- image->paint(&p, 0, 0);
- qInstallMsgHandler(previousMsgHandler);
- QVERIFY(numberOfWarnings == 0);
- delete image;
-}
-
-void tst_qdeclarativeimage::resetSourceSize()
-{
- QString src = QUrl::fromLocalFile(SRCDIR "/data/heart200.png").toString();
- QString componentStr = "import QtQuick 1.1\nImage { function reset() { sourceSize = undefined }\nsource: \"" + src + "\"; sourceSize: Qt.size(100,100) }";
-
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Image *obj = qobject_cast<QDeclarative1Image*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->pixmap().width(), 100);
- QCOMPARE(obj->pixmap().height(), 100);
- QCOMPARE(obj->sourceSize().height(), 100);
- QCOMPARE(obj->sourceSize().width(), 100);
-
- QMetaObject::invokeMethod(obj, "reset");
- QCOMPARE(obj->pixmap().width(), 200);
- QCOMPARE(obj->pixmap().height(), 200);
- QCOMPARE(obj->sourceSize().height(), 200);
- QCOMPARE(obj->sourceSize().width(), 200);
-}
-
-void tst_qdeclarativeimage::testQtQuick11Attributes()
-{
- QFETCH(QString, code);
- QFETCH(QString, warning);
- QFETCH(QString, error);
-
- QDeclarativeEngine engine;
- QObject *obj;
-
- QDeclarativeComponent valid(&engine);
- valid.setData("import QtQuick 1.1; Image { " + code.toUtf8() + " }", QUrl(""));
- obj = valid.create();
- QVERIFY(obj);
- QVERIFY(valid.errorString().isEmpty());
- delete obj;
-
- QDeclarativeComponent invalid(&engine);
- invalid.setData("import QtQuick 1.0; Image { " + code.toUtf8() + " }", QUrl(""));
- QTest::ignoreMessage(QtWarningMsg, warning.toUtf8());
- obj = invalid.create();
- QCOMPARE(invalid.errorString(), error);
- delete obj;
-}
-
-void tst_qdeclarativeimage::testQtQuick11Attributes_data()
-{
- QTest::addColumn<QString>("code");
- QTest::addColumn<QString>("warning");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("mirror") << "mirror: true"
- << "QDeclarativeComponent: Component is not ready"
- << ":1 \"Image.mirror\" is not available in QtQuick 1.0.\n";
-
- QTest::newRow("cache") << "cache: true"
- << "QDeclarativeComponent: Component is not ready"
- << ":1 \"Image.cache\" is not available in QtQuick 1.0.\n";
-}
-
-/*
- Find an item with the specified objectName. If index is supplied then the
- item must also evaluate the {index} expression equal to index
-*/
-template<typename T>
-T *tst_qdeclarativeimage::findItem(QGraphicsObject *parent, const QString &objectName, int index)
-{
- const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->childItems().count() << "children";
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- //qDebug() << "try" << item;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
- if (index != -1) {
- QDeclarativeExpression e(qmlContext(item), item, "index");
- if (e.evaluate().toInt() == index)
- return static_cast<T*>(item);
- } else {
- return static_cast<T*>(item);
- }
- }
- item = findItem<T>(item, objectName, index);
- if (item)
- return static_cast<T*>(item);
- }
-
- return 0;
-}
-
-QTEST_MAIN(tst_qdeclarativeimage)
-
-#include "tst_qdeclarativeimage.moc"
diff --git a/tests/auto/qtquick1/qdeclarativeimageprovider/qdeclarativeimageprovider.pro b/tests/auto/qtquick1/qdeclarativeimageprovider/qdeclarativeimageprovider.pro
deleted file mode 100644
index ec1d87e589..0000000000
--- a/tests/auto/qtquick1/qdeclarativeimageprovider/qdeclarativeimageprovider.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeimageprovider
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeimageprovider.cpp
-
-# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
-# LIBS += -lgcov
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
-QT += core-private gui-private widgets-private declarative-private qtquick1-private network testlib
diff --git a/tests/auto/qtquick1/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp b/tests/auto/qtquick1/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp
deleted file mode 100644
index a11103293c..0000000000
--- a/tests/auto/qtquick1/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp
+++ /dev/null
@@ -1,426 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QtTest>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativeimageprovider.h>
-#include <QtQuick1/private/qdeclarativeimage_p.h>
-#include <QImageReader>
-#include <QWaitCondition>
-
-Q_DECLARE_METATYPE(QDeclarativeImageProvider*);
-
-class tst_qdeclarativeimageprovider : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativeimageprovider()
- {
- }
-
-private slots:
- void requestImage_sync_data();
- void requestImage_sync();
- void requestImage_async_data();
- void requestImage_async();
-
- void requestPixmap_sync_data();
- void requestPixmap_sync();
- void requestPixmap_async();
-
- void removeProvider_data();
- void removeProvider();
-
- void threadTest();
-
-private:
- QString newImageFileName() const;
- void fillRequestTestsData(const QString &id);
- void runTest(bool async, QDeclarativeImageProvider *provider);
-};
-
-
-class TestQImageProvider : public QDeclarativeImageProvider
-{
-public:
- TestQImageProvider(bool *deleteWatch = 0)
- : QDeclarativeImageProvider(Image), deleteWatch(deleteWatch)
- {
- }
-
- ~TestQImageProvider()
- {
- if (deleteWatch)
- *deleteWatch = true;
- }
-
- QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize)
- {
- lastImageId = id;
-
- if (id == QLatin1String("no-such-file.png"))
- return QImage();
-
- int width = 100;
- int height = 100;
- QImage image(width, height, QImage::Format_RGB32);
- if (size)
- *size = QSize(width, height);
- if (requestedSize.isValid())
- image = image.scaled(requestedSize);
- return image;
- }
-
- bool *deleteWatch;
- QString lastImageId;
-};
-Q_DECLARE_METATYPE(TestQImageProvider*);
-
-
-class TestQPixmapProvider : public QDeclarativeImageProvider
-{
-public:
- TestQPixmapProvider(bool *deleteWatch = 0)
- : QDeclarativeImageProvider(Pixmap), deleteWatch(deleteWatch)
- {
- }
-
- ~TestQPixmapProvider()
- {
- if (deleteWatch)
- *deleteWatch = true;
- }
-
- QPixmap requestPixmap(const QString &id, QSize *size, const QSize& requestedSize)
- {
- lastImageId = id;
-
- if (id == QLatin1String("no-such-file.png"))
- return QPixmap();
-
- int width = 100;
- int height = 100;
- QPixmap image(width, height);
- if (size)
- *size = QSize(width, height);
- if (requestedSize.isValid())
- image = image.scaled(requestedSize);
- return image;
- }
-
- bool *deleteWatch;
- QString lastImageId;
-};
-Q_DECLARE_METATYPE(TestQPixmapProvider*);
-
-
-QString tst_qdeclarativeimageprovider::newImageFileName() const
-{
- // need to generate new filenames each time or else images are loaded
- // from cache and we won't get loading status changes when testing
- // async loading
- static int count = 0;
- return QString("image://test/image-%1.png").arg(count++);
-}
-
-void tst_qdeclarativeimageprovider::fillRequestTestsData(const QString &id)
-{
- QTest::addColumn<QString>("source");
- QTest::addColumn<QString>("imageId");
- QTest::addColumn<QString>("properties");
- QTest::addColumn<QSize>("size");
- QTest::addColumn<QString>("error");
-
- QString fileName = newImageFileName();
- QTest::newRow(QTest::toString(id + " simple test"))
- << "image://test/" + fileName << fileName << "" << QSize(100,100) << "";
-
- fileName = newImageFileName();
- QTest::newRow(QTest::toString(id + " simple test with capitalization"))//As it's a URL, should make no difference
- << "image://Test/" + fileName << fileName << "" << QSize(100,100) << "";
-
- fileName = newImageFileName();
- QTest::newRow(QTest::toString(id + " url with no id"))
- << "image://test/" + fileName << "" + fileName << "" << QSize(100,100) << "";
-
- fileName = newImageFileName();
- QTest::newRow(QTest::toString(id + " url with path"))
- << "image://test/test/path" + fileName << "test/path" + fileName << "" << QSize(100,100) << "";
-
- fileName = newImageFileName();
- QTest::newRow(QTest::toString(id + " url with fragment"))
- << "image://test/faq.html?#question13" + fileName << "faq.html?#question13" + fileName << "" << QSize(100,100) << "";
-
- fileName = newImageFileName();
- QTest::newRow(QTest::toString(id + " url with query"))
- << "image://test/cgi-bin/drawgraph.cgi?type=pie&color=green" + fileName << "cgi-bin/drawgraph.cgi?type=pie&color=green" + fileName
- << "" << QSize(100,100) << "";
-
- fileName = newImageFileName();
- QTest::newRow(QTest::toString(id + " scaled image"))
- << "image://test/" + fileName << fileName << "sourceSize: \"80x30\"" << QSize(80,30) << "";
-
- QTest::newRow(QTest::toString(id + " missing"))
- << "image://test/no-such-file.png" << "no-such-file.png" << "" << QSize(100,100)
- << "file::2:1: QML Image: Failed to get image from provider: image://test/no-such-file.png";
-
- QTest::newRow(QTest::toString(id + " unknown provider"))
- << "image://bogus/exists.png" << "" << "" << QSize()
- << "file::2:1: QML Image: Failed to get image from provider: image://bogus/exists.png";
-}
-
-void tst_qdeclarativeimageprovider::runTest(bool async, QDeclarativeImageProvider *provider)
-{
- QFETCH(QString, source);
- QFETCH(QString, imageId);
- QFETCH(QString, properties);
- QFETCH(QSize, size);
- QFETCH(QString, error);
-
- if (!error.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
-
- QDeclarativeEngine engine;
-
- engine.addImageProvider("test", provider);
- QVERIFY(engine.imageProvider("test") != 0);
-
- QString componentStr = "import QtQuick 1.0\nImage { source: \"" + source + "\"; "
- + (async ? "asynchronous: true; " : "")
- + properties + " }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Image *obj = qobject_cast<QDeclarative1Image*>(component.create());
- QVERIFY(obj != 0);
-
- if (async)
- QTRY_VERIFY(obj->status() == QDeclarative1Image::Loading);
-
- QCOMPARE(obj->source(), QUrl(source));
-
- if (error.isEmpty()) {
- if (async)
- QTRY_VERIFY(obj->status() == QDeclarative1Image::Ready);
- else
- QVERIFY(obj->status() == QDeclarative1Image::Ready);
- if (QByteArray(QTest::currentDataTag()).startsWith("qimage"))
- QCOMPARE(static_cast<TestQImageProvider*>(provider)->lastImageId, imageId);
- else
- QCOMPARE(static_cast<TestQPixmapProvider*>(provider)->lastImageId, imageId);
-
- QCOMPARE(obj->width(), qreal(size.width()));
- QCOMPARE(obj->height(), qreal(size.height()));
- QCOMPARE(obj->pixmap().width(), size.width());
- QCOMPARE(obj->pixmap().height(), size.height());
- QCOMPARE(obj->fillMode(), QDeclarative1Image::Stretch);
- QCOMPARE(obj->progress(), 1.0);
- } else {
- if (async)
- QTRY_VERIFY(obj->status() == QDeclarative1Image::Error);
- else
- QVERIFY(obj->status() == QDeclarative1Image::Error);
- }
-
- delete obj;
-}
-
-void tst_qdeclarativeimageprovider::requestImage_sync_data()
-{
- fillRequestTestsData("qimage|sync");
-}
-
-void tst_qdeclarativeimageprovider::requestImage_sync()
-{
- bool deleteWatch = false;
- runTest(false, new TestQImageProvider(&deleteWatch));
- QVERIFY(deleteWatch);
-}
-
-void tst_qdeclarativeimageprovider::requestImage_async_data()
-{
- fillRequestTestsData("qimage|async");
-}
-
-void tst_qdeclarativeimageprovider::requestImage_async()
-{
- bool deleteWatch = false;
- runTest(true, new TestQImageProvider(&deleteWatch));
- QVERIFY(deleteWatch);
-}
-
-void tst_qdeclarativeimageprovider::requestPixmap_sync_data()
-{
- fillRequestTestsData("qpixmap");
-}
-
-void tst_qdeclarativeimageprovider::requestPixmap_sync()
-{
- bool deleteWatch = false;
- runTest(false, new TestQPixmapProvider(&deleteWatch));
- QVERIFY(deleteWatch);
-}
-
-void tst_qdeclarativeimageprovider::requestPixmap_async()
-{
- QDeclarativeEngine engine;
- QDeclarativeImageProvider *provider = new TestQPixmapProvider();
-
- engine.addImageProvider("test", provider);
- QVERIFY(engine.imageProvider("test") != 0);
-
- // pixmaps are loaded synchronously regardless of 'asynchronous' value
- QString componentStr = "import QtQuick 1.0\nImage { asynchronous: true; source: \"image://test/pixmap-async-test.png\" }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Image *obj = qobject_cast<QDeclarative1Image*>(component.create());
- QVERIFY(obj != 0);
-
- delete obj;
-}
-
-void tst_qdeclarativeimageprovider::removeProvider_data()
-{
- QTest::addColumn<QDeclarativeImageProvider*>("provider");
-
- QTest::newRow("qimage") << static_cast<QDeclarativeImageProvider*>(new TestQImageProvider);
- QTest::newRow("qpixmap") << static_cast<QDeclarativeImageProvider*>(new TestQPixmapProvider);
-}
-
-void tst_qdeclarativeimageprovider::removeProvider()
-{
- QFETCH(QDeclarativeImageProvider*, provider);
-
- QDeclarativeEngine engine;
-
- engine.addImageProvider("test", provider);
- QVERIFY(engine.imageProvider("test") != 0);
-
- // add provider, confirm it works
- QString componentStr = "import QtQuick 1.0\nImage { source: \"" + newImageFileName() + "\" }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Image *obj = qobject_cast<QDeclarative1Image*>(component.create());
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->status(), QDeclarative1Image::Ready);
-
- // remove the provider and confirm
- QString fileName = newImageFileName();
- QString error("file::2:1: QML Image: Failed to get image from provider: " + fileName);
- QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
-
- engine.removeImageProvider("test");
-
- obj->setSource(QUrl(fileName));
- QCOMPARE(obj->status(), QDeclarative1Image::Error);
-
- delete obj;
-}
-
-class TestThreadProvider : public QDeclarativeImageProvider
-{
- public:
- TestThreadProvider() : QDeclarativeImageProvider(Image), ok(false) {}
-
- ~TestThreadProvider() {}
-
- QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize)
- {
- mutex.lock();
- if (!ok)
- cond.wait(&mutex);
- mutex.unlock();
- QVector<int> v;
- for (int i = 0; i < 10000; i++)
- v.prepend(i); //do some computation
- QImage image(50,50, QImage::Format_RGB32);
- image.fill(QColor(id).rgb());
- if (size)
- *size = image.size();
- if (requestedSize.isValid())
- image = image.scaled(requestedSize);
- return image;
- }
-
- QWaitCondition cond;
- QMutex mutex;
- bool ok;
-};
-
-
-void tst_qdeclarativeimageprovider::threadTest()
-{
- QDeclarativeEngine engine;
-
- TestThreadProvider *provider = new TestThreadProvider;
-
- engine.addImageProvider("test_thread", provider);
- QVERIFY(engine.imageProvider("test_thread") != 0);
-
- QString componentStr = "import QtQuick 1.0\nItem { \n"
- "Image { source: \"image://test_thread/blue\"; asynchronous: true; }\n"
- "Image { source: \"image://test_thread/red\"; asynchronous: true; }\n"
- "Image { source: \"image://test_thread/green\"; asynchronous: true; }\n"
- "Image { source: \"image://test_thread/yellow\"; asynchronous: true; }\n"
- " }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QObject *obj = component.create();
- //MUST not deadlock
- QVERIFY(obj != 0);
- QList<QDeclarative1Image *> images = obj->findChildren<QDeclarative1Image *>();
- QCOMPARE(images.count(), 4);
- QTest::qWait(100);
- foreach(QDeclarative1Image *img, images) {
- QCOMPARE(img->status(), QDeclarative1Image::Loading);
- }
- provider->ok = true;
- provider->cond.wakeAll();
- QTest::qWait(250);
- foreach(QDeclarative1Image *img, images) {
- QTRY_VERIFY(img->status() == QDeclarative1Image::Ready);
- }
-}
-
-
-QTEST_MAIN(tst_qdeclarativeimageprovider)
-
-#include "tst_qdeclarativeimageprovider.moc"
diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/childrenProperty.qml b/tests/auto/qtquick1/qdeclarativeitem/data/childrenProperty.qml
deleted file mode 100644
index fab2367504..0000000000
--- a/tests/auto/qtquick1/qdeclarativeitem/data/childrenProperty.qml
+++ /dev/null
@@ -1,14 +0,0 @@
-import QtQuick 1.0
-
-Item {
- id: root
-
- property bool test1: root.children.length == 3
- property bool test2: root.children[0] == item1
- property bool test3: root.children[1] == item2
- property bool test4: root.children[2] == item3
- property bool test5: root.children[3] == null
-
- children: [ Item { id: item1 }, Item { id: item2 }, Item { id: item3 } ]
-}
-
diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/childrenRect.qml b/tests/auto/qtquick1/qdeclarativeitem/data/childrenRect.qml
deleted file mode 100644
index 84f362fe16..0000000000
--- a/tests/auto/qtquick1/qdeclarativeitem/data/childrenRect.qml
+++ /dev/null
@@ -1,27 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 400
- height: 400
-
- property int childCount: 0;
-
- Item {
- objectName: "testItem"
- width: childrenRect.width
- height: childrenRect.height
-
- Repeater {
- id: repeater
- model: childCount
- delegate: Rectangle {
- x: index*10
- y: index*20
- width: 10
- height: 20
-
- color: "red"
- }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/childrenRectBug.qml b/tests/auto/qtquick1/qdeclarativeitem/data/childrenRectBug.qml
deleted file mode 100644
index 2ab73a1ff6..0000000000
--- a/tests/auto/qtquick1/qdeclarativeitem/data/childrenRectBug.qml
+++ /dev/null
@@ -1,23 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 400
- height: 200
-
- Item {
- objectName: "theItem"
- anchors.centerIn: parent
- width: childrenRect.width
- height: childrenRect.height
- Rectangle {
- id: text1
- anchors.verticalCenter: parent.verticalCenter
- width: 100; height: 100; color: "green"
- }
- Rectangle {
- anchors.left: text1.right
- anchors.verticalCenter: parent.verticalCenter
- width: 100; height: 100; color: "green"
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/childrenRectBug2.qml b/tests/auto/qtquick1/qdeclarativeitem/data/childrenRectBug2.qml
deleted file mode 100644
index d67ad0e3d8..0000000000
--- a/tests/auto/qtquick1/qdeclarativeitem/data/childrenRectBug2.qml
+++ /dev/null
@@ -1,53 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width:360;
- height: 200
-
- Item {
- objectName: "theItem"
- anchors.centerIn: parent
- width: childrenRect.width
- height: childrenRect.height
- Rectangle {
- id: header1
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.top: parent.top
- width: 100; height: 50
- color: "green"
- }
- Rectangle {
- id: text1
- anchors.top: header1.bottom
- anchors.topMargin: 10
- anchors.horizontalCenter: parent.horizontalCenter
- width: 100; height: 50
- color: "blue"
- }
- }
-
- states: [
- State {
- name: "row"
- AnchorChanges {
- target: header1
- anchors.horizontalCenter: undefined
- anchors.verticalCenter: parent.verticalCenter
- anchors.left: parent.left
- anchors.top: undefined
- }
- AnchorChanges {
- target: text1
- anchors.horizontalCenter: undefined
- anchors.verticalCenter: parent.verticalCenter
- anchors.top: undefined
- anchors.left: header1.right
- }
- PropertyChanges {
- target: text1
- anchors.leftMargin: 10
- anchors.topMargin: 0
- }
- }
- ]
-}
diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/childrenRectBug3.qml b/tests/auto/qtquick1/qdeclarativeitem/data/childrenRectBug3.qml
deleted file mode 100644
index 9d8e1e863a..0000000000
--- a/tests/auto/qtquick1/qdeclarativeitem/data/childrenRectBug3.qml
+++ /dev/null
@@ -1,15 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 300
- height: 300
-
- Rectangle {
- height: childrenRect.height
-
- Repeater {
- model: 1
- Rectangle { }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/implicitsize.qml b/tests/auto/qtquick1/qdeclarativeitem/data/implicitsize.qml
deleted file mode 100644
index 869c0fcec6..0000000000
--- a/tests/auto/qtquick1/qdeclarativeitem/data/implicitsize.qml
+++ /dev/null
@@ -1,19 +0,0 @@
-import QtQuick 1.1
-
-Item {
- implicitWidth: 200
- implicitHeight: 100
-
- width: 80
- height: 60
-
- function resetSize() {
- width = undefined
- height = undefined
- }
-
- function changeImplicit() {
- implicitWidth = 150
- implicitHeight = 80
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/keynavigationtest.qml b/tests/auto/qtquick1/qdeclarativeitem/data/keynavigationtest.qml
deleted file mode 100644
index f614a12e30..0000000000
--- a/tests/auto/qtquick1/qdeclarativeitem/data/keynavigationtest.qml
+++ /dev/null
@@ -1,87 +0,0 @@
-import QtQuick 1.0
-
-Grid {
- columns: 2
- width: 100; height: 100
- function verify() {
- if (item1.KeyNavigation.right != item2)
- return false;
- if (item1.KeyNavigation.down != item3)
- return false;
- if (item1.KeyNavigation.tab != item2)
- return false;
- if (item1.KeyNavigation.backtab != item4)
- return false;
-
- if (item2.KeyNavigation.left != item1)
- return false;
- if (item2.KeyNavigation.down != item4)
- return false;
- if (item2.KeyNavigation.tab != item3)
- return false;
- if (item2.KeyNavigation.backtab != item1)
- return false;
-
- if (item3.KeyNavigation.right != item4)
- return false;
- if (item3.KeyNavigation.up != item1)
- return false;
- if (item3.KeyNavigation.tab != item4)
- return false;
- if (item3.KeyNavigation.backtab != item2)
- return false;
-
- if (item4.KeyNavigation.left != item3)
- return false;
- if (item4.KeyNavigation.up != item2)
- return false;
- if (item4.KeyNavigation.tab != item1)
- return false;
- if (item4.KeyNavigation.backtab != item3)
- return false;
-
- return true;
- }
-
- Rectangle {
- id: item1
- objectName: "item1"
- focus: true
- width: 50; height: 50
- color: focus ? "red" : "lightgray"
- KeyNavigation.right: item2
- KeyNavigation.down: item3
- KeyNavigation.tab: item2
- KeyNavigation.backtab: item4
- }
- Rectangle {
- id: item2
- objectName: "item2"
- width: 50; height: 50
- color: focus ? "red" : "lightgray"
- KeyNavigation.left: item1
- KeyNavigation.down: item4
- KeyNavigation.tab: item3
- KeyNavigation.backtab: item1
- }
- Rectangle {
- id: item3
- objectName: "item3"
- width: 50; height: 50
- color: focus ? "red" : "lightgray"
- KeyNavigation.right: item4
- KeyNavigation.up: item1
- KeyNavigation.tab: item4
- KeyNavigation.backtab: item2
- }
- Rectangle {
- id: item4
- objectName: "item4"
- width: 50; height: 50
- color: focus ? "red" : "lightgray"
- KeyNavigation.left: item3
- KeyNavigation.up: item2
- KeyNavigation.tab: item1
- KeyNavigation.backtab: item3
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/keynavigationtest_implicit.qml b/tests/auto/qtquick1/qdeclarativeitem/data/keynavigationtest_implicit.qml
deleted file mode 100644
index 52ffaea0ec..0000000000
--- a/tests/auto/qtquick1/qdeclarativeitem/data/keynavigationtest_implicit.qml
+++ /dev/null
@@ -1,68 +0,0 @@
-import QtQuick 1.0
-
-Grid {
- columns: 2
- width: 100; height: 100
- function verify() {
- if (item1.KeyNavigation.tab != item2)
- return false;
- if (item1.KeyNavigation.backtab != item4)
- return false;
-
- if (item2.KeyNavigation.left != item1)
- return false;
- if (item2.KeyNavigation.down != item4)
- return false;
- if (item2.KeyNavigation.tab != item3)
- return false;
- if (item2.KeyNavigation.backtab != item1)
- return false;
-
- if (item3.KeyNavigation.right != item4)
- return false;
- if (item3.KeyNavigation.up != item1)
- return false;
- if (item3.KeyNavigation.tab != item4)
- return false;
- if (item3.KeyNavigation.backtab != item2)
- return false;
-
- return true;
- }
-
- Rectangle {
- id: item1
- objectName: "item1"
- focus: true
- width: 50; height: 50
- color: focus ? "red" : "lightgray"
- KeyNavigation.tab: item2
- KeyNavigation.backtab: item4
- }
- Rectangle {
- id: item2
- objectName: "item2"
- width: 50; height: 50
- color: focus ? "red" : "lightgray"
- KeyNavigation.left: item1
- KeyNavigation.down: item4
- KeyNavigation.tab: item3
- KeyNavigation.backtab: item1
- }
- Rectangle {
- id: item3
- objectName: "item3"
- width: 50; height: 50
- color: focus ? "red" : "lightgray"
- KeyNavigation.right: item4
- KeyNavigation.up: item1
- KeyNavigation.tab: item4
- KeyNavigation.backtab: item2
- }
- Rectangle {
- id: item4
- objectName: "item4"
- width: 50; height: 50
- color: focus ? "red" : "lightgray"
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/keyspriority.qml b/tests/auto/qtquick1/qdeclarativeitem/data/keyspriority.qml
deleted file mode 100644
index 375a6b61a5..0000000000
--- a/tests/auto/qtquick1/qdeclarativeitem/data/keyspriority.qml
+++ /dev/null
@@ -1,9 +0,0 @@
-import QtQuick 1.0
-import Test 1.0
-
-KeyTestItem {
- focus: true
- Keys.onPressed: keysTestObject.keyPress(event.key, event.text, event.modifiers)
- Keys.onReleased: { keysTestObject.keyRelease(event.key, event.text, event.modifiers); event.accepted = true; }
- Keys.priority: keysTestObject.processLast ? Keys.AfterItem : Keys.BeforeItem
-}
diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/keystest.qml b/tests/auto/qtquick1/qdeclarativeitem/data/keystest.qml
deleted file mode 100644
index 9af6e9fb43..0000000000
--- a/tests/auto/qtquick1/qdeclarativeitem/data/keystest.qml
+++ /dev/null
@@ -1,24 +0,0 @@
-import QtQuick 1.0
-
-Item {
- focus: true
-
- property bool isEnabled: Keys.enabled
-
- Keys.onPressed: keysTestObject.keyPress(event.key, event.text, event.modifiers)
- Keys.onReleased: { keysTestObject.keyRelease(event.key, event.text, event.modifiers); event.accepted = true; }
- Keys.onReturnPressed: keysTestObject.keyPress(event.key, "Return", event.modifiers)
- Keys.onDigit0Pressed: keysTestObject.keyPress(event.key, event.text, event.modifiers)
- Keys.onDigit9Pressed: { event.accepted = false; keysTestObject.keyPress(event.key, event.text, event.modifiers) }
- Keys.onTabPressed: keysTestObject.keyPress(event.key, "Tab", event.modifiers)
- Keys.onBacktabPressed: keysTestObject.keyPress(event.key, "Backtab", event.modifiers)
- Keys.forwardTo: [ item2 ]
- Keys.enabled: enableKeyHanding
-
- Item {
- id: item2
- visible: forwardeeVisible
- Keys.onPressed: keysTestObject.forwardedKey(event.key)
- Keys.onReleased: keysTestObject.forwardedKey(event.key)
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/layoutmirroring.qml b/tests/auto/qtquick1/qdeclarativeitem/data/layoutmirroring.qml
deleted file mode 100644
index 866b615310..0000000000
--- a/tests/auto/qtquick1/qdeclarativeitem/data/layoutmirroring.qml
+++ /dev/null
@@ -1,54 +0,0 @@
-import QtQuick 1.1
-
-Item {
- property bool childrenInherit: true
- Item {
- objectName: "mirrored1"
- LayoutMirroring.enabled: true
- LayoutMirroring.childrenInherit: parent.childrenInherit
- Item {
- Item {
- objectName: "notMirrored1"
- LayoutMirroring.enabled: false
- Item {
- objectName: "inheritedMirror1"
- }
- }
- Item {
- objectName: "inheritedMirror2"
- }
- }
- }
- Item {
- objectName: "mirrored2"
- LayoutMirroring.enabled: true
- LayoutMirroring.childrenInherit: false
- Item {
- objectName: "notMirrored2"
- }
- }
- Item {
- LayoutMirroring.enabled: true
- LayoutMirroring.childrenInherit: true
- Loader {
- id: loader
- }
- }
- states: State {
- name: "newContent"
- PropertyChanges {
- target: loader
- sourceComponent: component
- }
- }
- Component {
- id: component
- Item {
- objectName: "notMirrored3"
- LayoutMirroring.enabled: false
- Item {
- objectName: "inheritedMirror3"
- }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/mapCoordinates.qml b/tests/auto/qtquick1/qdeclarativeitem/data/mapCoordinates.qml
deleted file mode 100644
index 48fb38da2b..0000000000
--- a/tests/auto/qtquick1/qdeclarativeitem/data/mapCoordinates.qml
+++ /dev/null
@@ -1,43 +0,0 @@
-import QtQuick 1.0
-
-Item {
- id: root; objectName: "root"
- width: 200; height: 200
-
- Item { id: itemA; objectName: "itemA"; x: 50; y: 50 }
-
- Item {
- x: 50; y: 50
- Item { id: itemB; objectName: "itemB"; x: 100; y: 100 }
- }
-
- function mapAToB(x, y) {
- var pos = itemA.mapToItem(itemB, x, y)
- return Qt.point(pos.x, pos.y)
- }
-
- function mapAFromB(x, y) {
- var pos = itemA.mapFromItem(itemB, x, y)
- return Qt.point(pos.x, pos.y)
- }
-
- function mapAToNull(x, y) {
- var pos = itemA.mapToItem(null, x, y)
- return Qt.point(pos.x, pos.y)
- }
-
- function mapAFromNull(x, y) {
- var pos = itemA.mapFromItem(null, x, y)
- return Qt.point(pos.x, pos.y)
- }
-
- function checkMapAToInvalid(x, y) {
- var pos = itemA.mapToItem(1122, x, y)
- return pos == undefined;
- }
-
- function checkMapAFromInvalid(x, y) {
- var pos = itemA.mapFromItem(1122, x, y)
- return pos == undefined;
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/mouseFocus.qml b/tests/auto/qtquick1/qdeclarativeitem/data/mouseFocus.qml
deleted file mode 100644
index afa5397a33..0000000000
--- a/tests/auto/qtquick1/qdeclarativeitem/data/mouseFocus.qml
+++ /dev/null
@@ -1,20 +0,0 @@
-import QtQuick 1.0
-
-QGraphicsWidget {
- size: "200x100"
- focusPolicy: QGraphicsWidget.ClickFocus
- Item {
- objectName: "declarativeItem"
- id: item
- width: 200
- height: 100
- MouseArea {
- anchors.fill: parent
- onPressed: {
- if (!item.focus) {
- item.focus = true;
- }
- }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/propertychanges.qml b/tests/auto/qtquick1/qdeclarativeitem/data/propertychanges.qml
deleted file mode 100644
index f1ea93349d..0000000000
--- a/tests/auto/qtquick1/qdeclarativeitem/data/propertychanges.qml
+++ /dev/null
@@ -1,10 +0,0 @@
-import QtQuick 1.0
-
-Item {
- Item {
- objectName: "item"
- }
- Item {
- objectName: "parentItem"
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/qtbug_16871.qml b/tests/auto/qtquick1/qdeclarativeitem/data/qtbug_16871.qml
deleted file mode 100644
index 8102df165c..0000000000
--- a/tests/auto/qtquick1/qdeclarativeitem/data/qtbug_16871.qml
+++ /dev/null
@@ -1,5 +0,0 @@
-import QtQuick 1.0
-
-Item {
- children: [ 10 ]
-}
diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/resourcesProperty.qml b/tests/auto/qtquick1/qdeclarativeitem/data/resourcesProperty.qml
deleted file mode 100644
index e82cd029ad..0000000000
--- a/tests/auto/qtquick1/qdeclarativeitem/data/resourcesProperty.qml
+++ /dev/null
@@ -1,21 +0,0 @@
-import QtQuick 1.0
-
-Item {
- id: root
-
- property bool test1
- property bool test2
- property bool test3
- property bool test4
- property bool test5
-
- Component.onCompleted: {
- test1 = (root.resources.length >= 3)
- test2 = root.resources[0] == item1
- test3 = root.resources[1] == item2
- test4 = root.resources[2] == item3
- test5 = root.resources[10] == null
- }
-
- resources: [ Item { id: item1 }, Item { id: item2 }, Item { id: item3 } ]
-}
diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/transformCrash.qml b/tests/auto/qtquick1/qdeclarativeitem/data/transformCrash.qml
deleted file mode 100644
index 35c1a9ab42..0000000000
--- a/tests/auto/qtquick1/qdeclarativeitem/data/transformCrash.qml
+++ /dev/null
@@ -1,13 +0,0 @@
-import QtQuick 1.0
-
-Item {
- id: wrapper
- width: 200
- height: 200
-
- QtObject {
- id: object
- }
-
- Component.onCompleted: wrapper.transform = object
-}
diff --git a/tests/auto/qtquick1/qdeclarativeitem/qdeclarativeitem.pro b/tests/auto/qtquick1/qdeclarativeitem/qdeclarativeitem.pro
deleted file mode 100644
index 8663c69ea4..0000000000
--- a/tests/auto/qtquick1/qdeclarativeitem/qdeclarativeitem.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeitem
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeitem.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
-QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib
-contains(QT_CONFIG,xcb):CONFIG+=insignificant_test # QTBUG-21012 fails on exit (X11-specific)
diff --git a/tests/auto/qtquick1/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/qtquick1/qdeclarativeitem/tst_qdeclarativeitem.cpp
deleted file mode 100644
index 14368be001..0000000000
--- a/tests/auto/qtquick1/qdeclarativeitem/tst_qdeclarativeitem.cpp
+++ /dev/null
@@ -1,1376 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QSignalSpy>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtQuick1/qdeclarativeview.h>
-#include <QtQuick1/private/qdeclarativerectangle_p.h>
-#include <QtQuick1/private/qdeclarativeitem_p.h>
-
-class tst_QDeclarativeItem : public QObject
-{
- Q_OBJECT
-public:
- tst_QDeclarativeItem();
-
-private slots:
- void initTestCase();
- void keys();
- void keysProcessingOrder();
- void keyNavigation();
- void keyNavigation_RightToLeft();
- void keyNavigation_skipNotVisible();
- void keyNavigation_implicitSetting();
- void layoutMirroring();
- void layoutMirroringIllegalParent();
- void smooth();
- void clip();
- void mapCoordinates();
- void mapCoordinates_data();
- void propertyChanges();
- void transforms();
- void transforms_data();
- void childrenRect();
- void childrenRectBug();
- void childrenRectBug2();
- void childrenRectBug3();
-
- void childrenProperty();
- void resourcesProperty();
- void mouseFocus();
-
- void transformCrash();
- void implicitSize();
- void testQtQuick11Attributes();
- void testQtQuick11Attributes_data();
- void qtbug_16871();
- void qtbug_21045();
-private:
- QDeclarativeEngine engine;
-};
-
-template<typename T>
-T *findItem(QGraphicsObject *parent, const QString &objectName)
-{
- if (!parent)
- return 0;
-
- const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->QGraphicsObject::children().count() << "children";
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- //qDebug() << "try" << item;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName))
- return static_cast<T*>(item);
- item = findItem<T>(item, objectName);
- if (item)
- return static_cast<T*>(item);
- }
-
- return 0;
-}
-
-class KeysTestObject : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(bool processLast READ processLast NOTIFY processLastChanged)
-
-public:
- KeysTestObject() : mKey(0), mModifiers(0), mForwardedKey(0), mLast(false) {}
-
- void reset() {
- mKey = 0;
- mText = QString();
- mModifiers = 0;
- mForwardedKey = 0;
- }
-
- bool processLast() const { return mLast; }
- void setProcessLast(bool b) {
- if (b != mLast) {
- mLast = b;
- emit processLastChanged();
- }
- }
-
-public slots:
- void keyPress(int key, QString text, int modifiers) {
- mKey = key;
- mText = text;
- mModifiers = modifiers;
- }
- void keyRelease(int key, QString text, int modifiers) {
- mKey = key;
- mText = text;
- mModifiers = modifiers;
- }
- void forwardedKey(int key) {
- mForwardedKey = key;
- }
-
-signals:
- void processLastChanged();
-
-public:
- int mKey;
- QString mText;
- int mModifiers;
- int mForwardedKey;
- bool mLast;
-
-private:
-};
-
-class KeyTestItem : public QDeclarativeItem
-{
- Q_OBJECT
-public:
- KeyTestItem(QDeclarativeItem *parent=0) : QDeclarativeItem(parent), mKey(0) {}
-
-protected:
- void keyPressEvent(QKeyEvent *e) {
- keyPressPreHandler(e);
- if (e->isAccepted())
- return;
-
- mKey = e->key();
-
- if (e->key() == Qt::Key_A)
- e->accept();
- else
- e->ignore();
-
- if (!e->isAccepted())
- QDeclarativeItem::keyPressEvent(e);
- }
-
- void keyReleaseEvent(QKeyEvent *e) {
- keyReleasePreHandler(e);
-
- if (e->isAccepted())
- return;
-
- if (e->key() == Qt::Key_B)
- e->accept();
- else
- e->ignore();
-
- if (!e->isAccepted())
- QDeclarativeItem::keyReleaseEvent(e);
- }
-
-public:
- int mKey;
-};
-
-QML_DECLARE_TYPE(KeyTestItem);
-
-
-tst_QDeclarativeItem::tst_QDeclarativeItem()
-{
-}
-
-void tst_QDeclarativeItem::initTestCase()
-{
- qmlRegisterType<KeyTestItem>("Test",1,0,"KeyTestItem");
-}
-
-void tst_QDeclarativeItem::keys()
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setFixedSize(240,320);
-
- KeysTestObject *testObject = new KeysTestObject;
- canvas->rootContext()->setContextProperty("keysTestObject", testObject);
-
- canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true));
- canvas->rootContext()->setContextProperty("forwardeeVisible", QVariant(true));
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keystest.qml"));
- canvas->show();
- qApp->processEvents();
-
- QEvent wa(QEvent::WindowActivate);
- QApplication::sendEvent(canvas, &wa);
- QFocusEvent fe(QEvent::FocusIn);
- QApplication::sendEvent(canvas, &fe);
-
- QVERIFY(canvas->rootObject());
- QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), true);
-
- QKeyEvent key(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1);
- QApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_A));
- QCOMPARE(testObject->mForwardedKey, int(Qt::Key_A));
- QCOMPARE(testObject->mText, QLatin1String("A"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(!key.isAccepted());
-
- testObject->reset();
-
- key = QKeyEvent(QEvent::KeyRelease, Qt::Key_A, Qt::ShiftModifier, "A", false, 1);
- QApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_A));
- QCOMPARE(testObject->mForwardedKey, int(Qt::Key_A));
- QCOMPARE(testObject->mText, QLatin1String("A"));
- QVERIFY(testObject->mModifiers == Qt::ShiftModifier);
- QVERIFY(key.isAccepted());
-
- testObject->reset();
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_Return));
- QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Return));
- QCOMPARE(testObject->mText, QLatin1String("Return"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(key.isAccepted());
-
- testObject->reset();
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_0, Qt::NoModifier, "0", false, 1);
- QApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_0));
- QCOMPARE(testObject->mForwardedKey, int(Qt::Key_0));
- QCOMPARE(testObject->mText, QLatin1String("0"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(key.isAccepted());
-
- testObject->reset();
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_9, Qt::NoModifier, "9", false, 1);
- QApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_9));
- QCOMPARE(testObject->mForwardedKey, int(Qt::Key_9));
- QCOMPARE(testObject->mText, QLatin1String("9"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(!key.isAccepted());
-
- testObject->reset();
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_Tab));
- QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Tab));
- QCOMPARE(testObject->mText, QLatin1String("Tab"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(key.isAccepted());
-
- testObject->reset();
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_Backtab));
- QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Backtab));
- QCOMPARE(testObject->mText, QLatin1String("Backtab"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(key.isAccepted());
-
- testObject->reset();
-
- canvas->rootContext()->setContextProperty("forwardeeVisible", QVariant(false));
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1);
- QApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_A));
- QCOMPARE(testObject->mForwardedKey, 0);
- QCOMPARE(testObject->mText, QLatin1String("A"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(!key.isAccepted());
-
- testObject->reset();
-
- canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(false));
- QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), false);
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, 0);
- QVERIFY(!key.isAccepted());
-
- canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true));
- QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), true);
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_Return));
- QVERIFY(key.isAccepted());
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QDeclarativeItem::keysProcessingOrder()
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setFixedSize(240,320);
-
- KeysTestObject *testObject = new KeysTestObject;
- canvas->rootContext()->setContextProperty("keysTestObject", testObject);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keyspriority.qml"));
- canvas->show();
- qApp->processEvents();
-
- KeyTestItem *testItem = qobject_cast<KeyTestItem*>(canvas->rootObject());
- QVERIFY(testItem);
-
- QEvent wa(QEvent::WindowActivate);
- QApplication::sendEvent(canvas, &wa);
- QFocusEvent fe(QEvent::FocusIn);
- QApplication::sendEvent(canvas, &fe);
-
- QKeyEvent key(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1);
- QApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_A));
- QCOMPARE(testObject->mText, QLatin1String("A"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(key.isAccepted());
-
- testObject->reset();
-
- testObject->setProcessLast(true);
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1);
- QApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, 0);
- QVERIFY(key.isAccepted());
-
- testObject->reset();
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_B, Qt::NoModifier, "B", false, 1);
- QApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_B));
- QCOMPARE(testObject->mText, QLatin1String("B"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(!key.isAccepted());
-
- testObject->reset();
-
- key = QKeyEvent(QEvent::KeyRelease, Qt::Key_B, Qt::NoModifier, "B", false, 1);
- QApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, 0);
- QVERIFY(key.isAccepted());
-
- delete canvas;
- delete testObject;
-}
-
-QDeclarativeItemPrivate *childPrivate(QGraphicsObject *rootItem, const char * itemString)
-{
- QDeclarativeItem *item = findItem<QDeclarativeItem>(rootItem, QString(QLatin1String(itemString)));
- QDeclarativeItemPrivate* itemPrivate = QDeclarativeItemPrivate::get(item);
- return itemPrivate;
-}
-
-QVariant childProperty(QGraphicsObject *rootItem, const char * itemString, const char * property)
-{
- QDeclarativeItem *item = findItem<QDeclarativeItem>(rootItem, QString(QLatin1String(itemString)));
- return item->property(property);
-}
-
-bool anchorsMirrored(QGraphicsObject *rootItem, const char * itemString)
-{
- QDeclarativeItem *item = findItem<QDeclarativeItem>(rootItem, QString(QLatin1String(itemString)));
- QDeclarativeItemPrivate* itemPrivate = QDeclarativeItemPrivate::get(item);
- return itemPrivate->anchors()->mirrored();
-}
-
-void tst_QDeclarativeItem::layoutMirroring()
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/layoutmirroring.qml"));
- canvas->show();
-
- QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(canvas->rootObject());
- QVERIFY(rootItem);
- QDeclarativeItemPrivate *rootPrivate = QDeclarativeItemPrivate::get(rootItem);
- QVERIFY(rootPrivate);
-
- QCOMPARE(childPrivate(rootItem, "mirrored1")->effectiveLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "mirrored2")->effectiveLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "notMirrored1")->effectiveLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "notMirrored2")->effectiveLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->effectiveLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->effectiveLayoutMirror, true);
-
- QCOMPARE(anchorsMirrored(rootItem, "mirrored1"), true);
- QCOMPARE(anchorsMirrored(rootItem, "mirrored2"), true);
- QCOMPARE(anchorsMirrored(rootItem, "notMirrored1"), false);
- QCOMPARE(anchorsMirrored(rootItem, "notMirrored2"), false);
- QCOMPARE(anchorsMirrored(rootItem, "inheritedMirror1"), true);
- QCOMPARE(anchorsMirrored(rootItem, "inheritedMirror2"), true);
-
- QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritedLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "mirrored2")->inheritedLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritedLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "notMirrored2")->inheritedLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritedLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritedLayoutMirror, true);
-
- QCOMPARE(childPrivate(rootItem, "mirrored1")->isMirrorImplicit, false);
- QCOMPARE(childPrivate(rootItem, "mirrored2")->isMirrorImplicit, false);
- QCOMPARE(childPrivate(rootItem, "notMirrored1")->isMirrorImplicit, false);
- QCOMPARE(childPrivate(rootItem, "notMirrored2")->isMirrorImplicit, true);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->isMirrorImplicit, true);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->isMirrorImplicit, true);
-
- QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritMirrorFromParent, true);
- QCOMPARE(childPrivate(rootItem, "mirrored2")->inheritMirrorFromParent, false);
- QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritMirrorFromParent, true);
- QCOMPARE(childPrivate(rootItem, "notMirrored2")->inheritMirrorFromParent, false);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritMirrorFromParent, true);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritMirrorFromParent, true);
-
- QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritMirrorFromItem, true);
- QCOMPARE(childPrivate(rootItem, "mirrored2")->inheritMirrorFromItem, false);
- QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritMirrorFromItem, false);
- QCOMPARE(childPrivate(rootItem, "notMirrored2")->inheritMirrorFromItem, false);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritMirrorFromItem, false);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritMirrorFromItem, false);
-
- // load dynamic content using Loader that needs to inherit mirroring
- rootItem->setProperty("state", "newContent");
- QCOMPARE(childPrivate(rootItem, "notMirrored3")->effectiveLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->effectiveLayoutMirror, true);
-
- QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritedLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->inheritedLayoutMirror, true);
-
- QCOMPARE(childPrivate(rootItem, "notMirrored3")->isMirrorImplicit, false);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->isMirrorImplicit, true);
-
- QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritMirrorFromParent, true);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->inheritMirrorFromParent, true);
-
- QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritMirrorFromItem, false);
- QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritMirrorFromItem, false);
-
- // disable inheritance
- rootItem->setProperty("childrenInherit", false);
-
- QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->effectiveLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->effectiveLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "mirrored1")->effectiveLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "notMirrored1")->effectiveLayoutMirror, false);
-
- QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritedLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritedLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritedLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritedLayoutMirror, false);
-
- // re-enable inheritance
- rootItem->setProperty("childrenInherit", true);
-
- QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->effectiveLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->effectiveLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "mirrored1")->effectiveLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "notMirrored1")->effectiveLayoutMirror, false);
-
- QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritedLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritedLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritedLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritedLayoutMirror, true);
-
- //
- // dynamic parenting
- //
- QDeclarativeItem *parentItem1 = new QDeclarativeItem();
- QDeclarativeItemPrivate::get(parentItem1)->effectiveLayoutMirror = true; // LayoutMirroring.enabled: true
- QDeclarativeItemPrivate::get(parentItem1)->isMirrorImplicit = false;
- QDeclarativeItemPrivate::get(parentItem1)->inheritMirrorFromItem = true; // LayoutMirroring.childrenInherit: true
- QDeclarativeItemPrivate::get(parentItem1)->resolveLayoutMirror();
-
- // inherit in constructor
- QDeclarativeItem *childItem1 = new QDeclarativeItem(parentItem1);
- QCOMPARE(QDeclarativeItemPrivate::get(childItem1)->effectiveLayoutMirror, true);
- QCOMPARE(QDeclarativeItemPrivate::get(childItem1)->inheritMirrorFromParent, true);
-
- // inherit through a parent change
- QDeclarativeItem *childItem2 = new QDeclarativeItem();
- QCOMPARE(QDeclarativeItemPrivate::get(childItem2)->effectiveLayoutMirror, false);
- QCOMPARE(QDeclarativeItemPrivate::get(childItem2)->inheritMirrorFromParent, false);
- childItem2->setParentItem(parentItem1);
- QCOMPARE(QDeclarativeItemPrivate::get(childItem2)->effectiveLayoutMirror, true);
- QCOMPARE(QDeclarativeItemPrivate::get(childItem2)->inheritMirrorFromParent, true);
-
- // stop inherting through a parent change
- QDeclarativeItem *parentItem2 = new QDeclarativeItem();
- QDeclarativeItemPrivate::get(parentItem2)->effectiveLayoutMirror = true; // LayoutMirroring.enabled: true
- QDeclarativeItemPrivate::get(parentItem2)->resolveLayoutMirror();
- childItem2->setParentItem(parentItem2);
- QCOMPARE(QDeclarativeItemPrivate::get(childItem2)->effectiveLayoutMirror, false);
- QCOMPARE(QDeclarativeItemPrivate::get(childItem2)->inheritMirrorFromParent, false);
-
- delete parentItem1;
- delete parentItem2;
-}
-
-void tst_QDeclarativeItem::layoutMirroringIllegalParent()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 1.1; QtObject { LayoutMirroring.enabled: true; LayoutMirroring.childrenInherit: true }", QUrl::fromLocalFile(""));
- QTest::ignoreMessage(QtWarningMsg, "file::1:21: QML QtObject: LayoutDirection attached property only works with Items");
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
-
-void tst_QDeclarativeItem::keyNavigation()
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setFixedSize(240,320);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keynavigationtest.qml"));
- canvas->show();
- qApp->processEvents();
-
- QEvent wa(QEvent::WindowActivate);
- QApplication::sendEvent(canvas, &wa);
- QFocusEvent fe(QEvent::FocusIn);
- QApplication::sendEvent(canvas, &fe);
-
- QDeclarativeItem *item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- QVariant result;
- QVERIFY(QMetaObject::invokeMethod(canvas->rootObject(), "verify",
- Q_RETURN_ARG(QVariant, result)));
- QVERIFY(result.toBool());
-
- // right
- QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QDeclarativeItem>(canvas->rootObject(), "item2");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // down
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QDeclarativeItem>(canvas->rootObject(), "item4");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // left
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QDeclarativeItem>(canvas->rootObject(), "item3");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // up
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // tab
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QDeclarativeItem>(canvas->rootObject(), "item2");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // backtab
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- delete canvas;
-}
-
-void tst_QDeclarativeItem::keyNavigation_RightToLeft()
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setFixedSize(240,320);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keynavigationtest.qml"));
- canvas->show();
- qApp->processEvents();
-
- QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(canvas->rootObject());
- QVERIFY(rootItem);
- QDeclarativeItemPrivate* rootItemPrivate = QDeclarativeItemPrivate::get(rootItem);
-
- rootItemPrivate->effectiveLayoutMirror = true; // LayoutMirroring.mirror: true
- rootItemPrivate->isMirrorImplicit = false;
- rootItemPrivate->inheritMirrorFromItem = true; // LayoutMirroring.inherit: true
- rootItemPrivate->resolveLayoutMirror();
-
- QEvent wa(QEvent::WindowActivate);
- QApplication::sendEvent(canvas, &wa);
- QFocusEvent fe(QEvent::FocusIn);
- QApplication::sendEvent(canvas, &fe);
-
- QDeclarativeItem *item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- QVariant result;
- QVERIFY(QMetaObject::invokeMethod(canvas->rootObject(), "verify",
- Q_RETURN_ARG(QVariant, result)));
- QVERIFY(result.toBool());
-
- // right
- QKeyEvent key(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QDeclarativeItem>(canvas->rootObject(), "item2");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // left
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- delete canvas;
-}
-
-void tst_QDeclarativeItem::keyNavigation_skipNotVisible()
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setFixedSize(240,320);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keynavigationtest.qml"));
- canvas->show();
- qApp->processEvents();
-
- QEvent wa(QEvent::WindowActivate);
- QApplication::sendEvent(canvas, &wa);
- QFocusEvent fe(QEvent::FocusIn);
- QApplication::sendEvent(canvas, &fe);
-
- QDeclarativeItem *item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // Set item 2 to not visible
- item = findItem<QDeclarativeItem>(canvas->rootObject(), "item2");
- QVERIFY(item);
- item->setVisible(false);
- QVERIFY(!item->isVisible());
-
- // right
- QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // tab
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QDeclarativeItem>(canvas->rootObject(), "item3");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // backtab
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- //Set item 3 to not visible
- item = findItem<QDeclarativeItem>(canvas->rootObject(), "item3");
- QVERIFY(item);
- item->setVisible(false);
- QVERIFY(!item->isVisible());
-
- // tab
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QDeclarativeItem>(canvas->rootObject(), "item4");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // backtab
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- delete canvas;
-}
-
-void tst_QDeclarativeItem::keyNavigation_implicitSetting()
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setFixedSize(240,320);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keynavigationtest_implicit.qml"));
- canvas->show();
- qApp->processEvents();
-
- QEvent wa(QEvent::WindowActivate);
- QApplication::sendEvent(canvas, &wa);
- QFocusEvent fe(QEvent::FocusIn);
- QApplication::sendEvent(canvas, &fe);
-
- QDeclarativeItem *item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- QVariant result;
- QVERIFY(QMetaObject::invokeMethod(canvas->rootObject(), "verify",
- Q_RETURN_ARG(QVariant, result)));
- QVERIFY(result.toBool());
-
- // right
- QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QDeclarativeItem>(canvas->rootObject(), "item2");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // back to item1
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // down
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QDeclarativeItem>(canvas->rootObject(), "item3");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // move to item4
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QDeclarativeItem>(canvas->rootObject(), "item4");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // left
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QDeclarativeItem>(canvas->rootObject(), "item3");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // back to item4
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QDeclarativeItem>(canvas->rootObject(), "item4");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // up
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QDeclarativeItem>(canvas->rootObject(), "item2");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // back to item4
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QDeclarativeItem>(canvas->rootObject(), "item4");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // tab
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // back to item4
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QDeclarativeItem>(canvas->rootObject(), "item4");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // backtab
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QDeclarativeItem>(canvas->rootObject(), "item3");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- delete canvas;
-}
-
-void tst_QDeclarativeItem::smooth()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 1.0; Item { smooth: false; }", QUrl::fromLocalFile(""));
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
- QSignalSpy spy(item, SIGNAL(smoothChanged(bool)));
-
- QVERIFY(item);
- QVERIFY(!item->smooth());
-
- item->setSmooth(true);
- QVERIFY(item->smooth());
- QCOMPARE(spy.count(),1);
- QList<QVariant> arguments = spy.first();
- QVERIFY(arguments.count() == 1);
- QVERIFY(arguments.at(0).toBool() == true);
-
- item->setSmooth(true);
- QCOMPARE(spy.count(),1);
-
- item->setSmooth(false);
- QVERIFY(!item->smooth());
- QCOMPARE(spy.count(),2);
- item->setSmooth(false);
- QCOMPARE(spy.count(),2);
-
- delete item;
-}
-
-void tst_QDeclarativeItem::clip()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 1.0\nItem { clip: false\n }", QUrl::fromLocalFile(""));
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
- QSignalSpy spy(item, SIGNAL(clipChanged(bool)));
-
- QVERIFY(item);
- QVERIFY(!item->clip());
-
- item->setClip(true);
- QVERIFY(item->clip());
-
- QList<QVariant> arguments = spy.first();
- QVERIFY(arguments.count() == 1);
- QVERIFY(arguments.at(0).toBool() == true);
-
- QCOMPARE(spy.count(),1);
- item->setClip(true);
- QCOMPARE(spy.count(),1);
-
- item->setClip(false);
- QVERIFY(!item->clip());
- QCOMPARE(spy.count(),2);
- item->setClip(false);
- QCOMPARE(spy.count(),2);
-
- delete item;
-}
-
-void tst_QDeclarativeItem::mapCoordinates()
-{
- QFETCH(int, x);
- QFETCH(int, y);
-
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setFixedSize(300, 300);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/mapCoordinates.qml"));
- canvas->show();
- qApp->processEvents();
-
- QDeclarativeItem *root = qobject_cast<QDeclarativeItem*>(canvas->rootObject());
- QVERIFY(root != 0);
- QDeclarativeItem *a = findItem<QDeclarativeItem>(canvas->rootObject(), "itemA");
- QVERIFY(a != 0);
- QDeclarativeItem *b = findItem<QDeclarativeItem>(canvas->rootObject(), "itemB");
- QVERIFY(b != 0);
-
- QVariant result;
-
- QVERIFY(QMetaObject::invokeMethod(root, "mapAToB",
- Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
- QCOMPARE(result.value<QPointF>(), qobject_cast<QGraphicsItem*>(a)->mapToItem(b, x, y));
-
- QVERIFY(QMetaObject::invokeMethod(root, "mapAFromB",
- Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
- QCOMPARE(result.value<QPointF>(), qobject_cast<QGraphicsItem*>(a)->mapFromItem(b, x, y));
-
- QVERIFY(QMetaObject::invokeMethod(root, "mapAToNull",
- Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
- QCOMPARE(result.value<QPointF>(), qobject_cast<QGraphicsItem*>(a)->mapToScene(x, y));
-
- QVERIFY(QMetaObject::invokeMethod(root, "mapAFromNull",
- Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
- QCOMPARE(result.value<QPointF>(), qobject_cast<QGraphicsItem*>(a)->mapFromScene(x, y));
-
- QString warning1 = QUrl::fromLocalFile(SRCDIR "/data/mapCoordinates.qml").toString() + ":7:5: QML Item: mapToItem() given argument \"1122\" which is neither null nor an Item";
- QString warning2 = QUrl::fromLocalFile(SRCDIR "/data/mapCoordinates.qml").toString() + ":7:5: QML Item: mapFromItem() given argument \"1122\" which is neither null nor an Item";
-
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QVERIFY(QMetaObject::invokeMethod(root, "checkMapAToInvalid",
- Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
- QVERIFY(result.toBool());
-
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
- QVERIFY(QMetaObject::invokeMethod(root, "checkMapAFromInvalid",
- Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
- QVERIFY(result.toBool());
-
- delete canvas;
-}
-
-void tst_QDeclarativeItem::mapCoordinates_data()
-{
- QTest::addColumn<int>("x");
- QTest::addColumn<int>("y");
-
- for (int i=-20; i<=20; i+=10)
- QTest::newRow(QTest::toString(i)) << i << i;
-}
-
-void tst_QDeclarativeItem::transforms_data()
-{
- QTest::addColumn<QByteArray>("qml");
- QTest::addColumn<QMatrix>("matrix");
- QTest::newRow("translate") << QByteArray("Translate { x: 10; y: 20 }")
- << QMatrix(1,0,0,1,10,20);
- QTest::newRow("rotation") << QByteArray("Rotation { angle: 90 }")
- << QMatrix(0,1,-1,0,0,0);
- QTest::newRow("scale") << QByteArray("Scale { xScale: 1.5; yScale: -2 }")
- << QMatrix(1.5,0,0,-2,0,0);
- QTest::newRow("sequence") << QByteArray("[ Translate { x: 10; y: 20 }, Scale { xScale: 1.5; yScale: -2 } ]")
- << QMatrix(1,0,0,1,10,20) * QMatrix(1.5,0,0,-2,0,0);
-}
-
-void tst_QDeclarativeItem::transforms()
-{
- QFETCH(QByteArray, qml);
- QFETCH(QMatrix, matrix);
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 1.0\nItem { transform: "+qml+"}", QUrl::fromLocalFile(""));
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(item);
- QCOMPARE(item->sceneMatrix(), matrix);
-}
-
-void tst_QDeclarativeItem::childrenProperty()
-{
- QDeclarativeComponent component(&engine, SRCDIR "/data/childrenProperty.qml");
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test1").toBool(), true);
- QCOMPARE(o->property("test2").toBool(), true);
- QCOMPARE(o->property("test3").toBool(), true);
- QCOMPARE(o->property("test4").toBool(), true);
- QCOMPARE(o->property("test5").toBool(), true);
- delete o;
-}
-
-void tst_QDeclarativeItem::resourcesProperty()
-{
- QDeclarativeComponent component(&engine, SRCDIR "/data/resourcesProperty.qml");
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test1").toBool(), true);
- QCOMPARE(o->property("test2").toBool(), true);
- QCOMPARE(o->property("test3").toBool(), true);
- QCOMPARE(o->property("test4").toBool(), true);
- QCOMPARE(o->property("test5").toBool(), true);
- delete o;
-}
-
-void tst_QDeclarativeItem::mouseFocus()
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
- QVERIFY(canvas);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/mouseFocus.qml"));
- canvas->show();
- QVERIFY(canvas->rootObject());
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
-
- QDeclarativeItem *item = findItem<QDeclarativeItem>(canvas->rootObject(), "declarativeItem");
- QVERIFY(item);
- QSignalSpy focusSpy(item, SIGNAL(activeFocusChanged(bool)));
-
- QTest::mouseClick(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(item->scenePos()));
- QApplication::processEvents();
- QCOMPARE(focusSpy.count(), 1);
- QVERIFY(item->hasActiveFocus());
-
- // make sure focusable graphics widget underneath does not steal focus
- QTest::mouseClick(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(item->scenePos()));
- QApplication::processEvents();
- QCOMPARE(focusSpy.count(), 1);
- QVERIFY(item->hasActiveFocus());
-
- item->setFocus(false);
- QVERIFY(!item->hasActiveFocus());
- QCOMPARE(focusSpy.count(), 2);
- item->setFocus(true);
- QCOMPARE(focusSpy.count(), 3);
-
- delete canvas;
-}
-
-void tst_QDeclarativeItem::propertyChanges()
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setFixedSize(240,320);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
- canvas->show();
-
- QEvent wa(QEvent::WindowActivate);
- QApplication::sendEvent(canvas, &wa);
- QFocusEvent fe(QEvent::FocusIn);
- QApplication::sendEvent(canvas, &fe);
-
- QDeclarativeItem *item = findItem<QDeclarativeItem>(canvas->rootObject(), "item");
- QDeclarativeItem *parentItem = findItem<QDeclarativeItem>(canvas->rootObject(), "parentItem");
-
- QVERIFY(item);
- QVERIFY(parentItem);
-
- QSignalSpy parentSpy(item, SIGNAL(parentChanged(QDeclarativeItem *)));
- QSignalSpy widthSpy(item, SIGNAL(widthChanged()));
- QSignalSpy heightSpy(item, SIGNAL(heightChanged()));
- QSignalSpy baselineOffsetSpy(item, SIGNAL(baselineOffsetChanged(qreal)));
- QSignalSpy childrenRectSpy(parentItem, SIGNAL(childrenRectChanged(QRectF)));
- QSignalSpy focusSpy(item, SIGNAL(focusChanged(bool)));
- QSignalSpy wantsFocusSpy(parentItem, SIGNAL(activeFocusChanged(bool)));
- QSignalSpy childrenChangedSpy(parentItem, SIGNAL(childrenChanged()));
- QSignalSpy xSpy(item, SIGNAL(xChanged()));
- QSignalSpy ySpy(item, SIGNAL(yChanged()));
-
- item->setParentItem(parentItem);
- item->setWidth(100.0);
- item->setHeight(200.0);
- item->setFocus(true);
- item->setBaselineOffset(10.0);
-
- QCOMPARE(item->parentItem(), parentItem);
- QCOMPARE(parentSpy.count(),1);
- QList<QVariant> parentArguments = parentSpy.first();
- QVERIFY(parentArguments.count() == 1);
- QCOMPARE(item->parentItem(), qvariant_cast<QDeclarativeItem *>(parentArguments.at(0)));
- QCOMPARE(childrenChangedSpy.count(),1);
-
- item->setParentItem(parentItem);
- QCOMPARE(childrenChangedSpy.count(),1);
-
- QCOMPARE(item->width(), 100.0);
- QCOMPARE(widthSpy.count(),1);
-
- QCOMPARE(item->height(), 200.0);
- QCOMPARE(heightSpy.count(),1);
-
- QCOMPARE(item->baselineOffset(), 10.0);
- QCOMPARE(baselineOffsetSpy.count(),1);
- QList<QVariant> baselineOffsetArguments = baselineOffsetSpy.first();
- QVERIFY(baselineOffsetArguments.count() == 1);
- QCOMPARE(item->baselineOffset(), baselineOffsetArguments.at(0).toReal());
-
- QCOMPARE(parentItem->childrenRect(), QRectF(0.0,0.0,100.0,200.0));
- QCOMPARE(childrenRectSpy.count(),2);
- QList<QVariant> childrenRectArguments = childrenRectSpy.at(1);
- QVERIFY(childrenRectArguments.count() == 1);
- QCOMPARE(parentItem->childrenRect(), childrenRectArguments.at(0).toRectF());
-
- QCOMPARE(item->hasActiveFocus(), true);
- QCOMPARE(focusSpy.count(),1);
- QList<QVariant> focusArguments = focusSpy.first();
- QVERIFY(focusArguments.count() == 1);
- QCOMPARE(focusArguments.at(0).toBool(), true);
-
- QCOMPARE(parentItem->hasActiveFocus(), false);
- QCOMPARE(parentItem->hasFocus(), false);
- QCOMPARE(wantsFocusSpy.count(),0);
-
- item->setX(10.0);
- QCOMPARE(item->x(), 10.0);
- QCOMPARE(xSpy.count(), 1);
-
- item->setY(10.0);
- QCOMPARE(item->y(), 10.0);
- QCOMPARE(ySpy.count(), 1);
-
- delete canvas;
-}
-
-void tst_QDeclarativeItem::childrenRect()
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setFixedSize(240,320);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/childrenRect.qml"));
- canvas->show();
-
- QGraphicsObject *o = canvas->rootObject();
- QDeclarativeItem *item = o->findChild<QDeclarativeItem*>("testItem");
- QCOMPARE(item->width(), qreal(0));
- QCOMPARE(item->height(), qreal(0));
-
- o->setProperty("childCount", 1);
- QCOMPARE(item->width(), qreal(10));
- QCOMPARE(item->height(), qreal(20));
-
- o->setProperty("childCount", 5);
- QCOMPARE(item->width(), qreal(50));
- QCOMPARE(item->height(), qreal(100));
-
- o->setProperty("childCount", 0);
- QCOMPARE(item->width(), qreal(0));
- QCOMPARE(item->height(), qreal(0));
-
- delete o;
- delete canvas;
-}
-
-// QTBUG-11383
-void tst_QDeclarativeItem::childrenRectBug()
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/childrenRectBug.qml"));
- canvas->show();
-
- QGraphicsObject *o = canvas->rootObject();
- QDeclarativeItem *item = o->findChild<QDeclarativeItem*>("theItem");
- QCOMPARE(item->width(), qreal(200));
- QCOMPARE(item->height(), qreal(100));
- QCOMPARE(item->x(), qreal(100));
-
- delete canvas;
-}
-
-// QTBUG-11465
-void tst_QDeclarativeItem::childrenRectBug2()
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/childrenRectBug2.qml"));
- canvas->show();
-
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(canvas->rootObject());
- QVERIFY(rect);
- QDeclarativeItem *item = rect->findChild<QDeclarativeItem*>("theItem");
- QCOMPARE(item->width(), qreal(100));
- QCOMPARE(item->height(), qreal(110));
- QCOMPARE(item->x(), qreal(130));
-
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
- rectPrivate->setState("row");
- QCOMPARE(item->width(), qreal(210));
- QCOMPARE(item->height(), qreal(50));
- QCOMPARE(item->x(), qreal(75));
-
- delete canvas;
-}
-
-// QTBUG-12722
-void tst_QDeclarativeItem::childrenRectBug3()
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/childrenRectBug3.qml"));
- canvas->show();
-
- //don't crash on delete
- delete canvas;
-}
-
-// QTBUG-13893
-void tst_QDeclarativeItem::transformCrash()
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/transformCrash.qml"));
- canvas->show();
-
- delete canvas;
-}
-
-void tst_QDeclarativeItem::implicitSize()
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/implicitsize.qml"));
- canvas->show();
-
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(canvas->rootObject());
- QVERIFY(item);
- QCOMPARE(item->width(), qreal(80));
- QCOMPARE(item->height(), qreal(60));
-
- QCOMPARE(item->implicitWidth(), qreal(200));
- QCOMPARE(item->implicitHeight(), qreal(100));
-
- QMetaObject::invokeMethod(item, "resetSize");
-
- QCOMPARE(item->width(), qreal(200));
- QCOMPARE(item->height(), qreal(100));
-
- QMetaObject::invokeMethod(item, "changeImplicit");
-
- QCOMPARE(item->implicitWidth(), qreal(150));
- QCOMPARE(item->implicitHeight(), qreal(80));
- QCOMPARE(item->width(), qreal(150));
- QCOMPARE(item->height(), qreal(80));
-
- delete canvas;
-}
-
-void tst_QDeclarativeItem::testQtQuick11Attributes()
-{
- QFETCH(QString, code);
- QFETCH(QString, warning);
- QFETCH(QString, error);
-
- QDeclarativeEngine engine;
- QObject *obj;
-
- QDeclarativeComponent valid(&engine);
- valid.setData("import QtQuick 1.1; Item { " + code.toUtf8() + " }", QUrl(""));
- obj = valid.create();
- QVERIFY(obj);
- QVERIFY(valid.errorString().isEmpty());
- delete obj;
-
- QDeclarativeComponent invalid(&engine);
- invalid.setData("import QtQuick 1.0; Item { " + code.toUtf8() + " }", QUrl(""));
- QTest::ignoreMessage(QtWarningMsg, warning.toUtf8());
- obj = invalid.create();
- QCOMPARE(invalid.errorString(), error);
- delete obj;
-}
-
-void tst_QDeclarativeItem::testQtQuick11Attributes_data()
-{
- QTest::addColumn<QString>("code");
- QTest::addColumn<QString>("warning");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("implicitWidth") << "implicitWidth: 100"
- << "QDeclarativeComponent: Component is not ready"
- << ":1 \"Item.implicitWidth\" is not available in QtQuick 1.0.\n";
-
- QTest::newRow("implicitHeight") << "implicitHeight: 100"
- << "QDeclarativeComponent: Component is not ready"
- << ":1 \"Item.implicitHeight\" is not available in QtQuick 1.0.\n";
-
- QTest::newRow("onImplicitWidthChanged") << "onImplicitWidthChanged: x"
- << "QDeclarativeComponent: Component is not ready"
- << ":1 \"Item.onImplicitWidthChanged\" is not available in QtQuick 1.0.\n";
-
- QTest::newRow("onImplicitHeightChanged") << "onImplicitHeightChanged: x"
- << "QDeclarativeComponent: Component is not ready"
- << ":1 \"Item.onImplicitHeightChanged\" is not available in QtQuick 1.0.\n";
-}
-
-void tst_QDeclarativeItem::qtbug_16871()
-{
- QDeclarativeComponent component(&engine, SRCDIR "/data/qtbug_16871.qml");
- QObject *o = component.create();
- QVERIFY(o != 0);
- delete o;
-}
-
-void tst_QDeclarativeItem::qtbug_21045()
-{
- QDeclarativeComponent component(&engine);
- QGraphicsScene scene;
- component.setData("import QtQuick 1.1\nItem{visible: false; focus: true}", QUrl::fromLocalFile("file:"));
- QObject *o = component.create();
- QDeclarativeItem* i = qobject_cast<QDeclarativeItem*>(o);
- QVERIFY(i);
- scene.addItem(i);
- QVERIFY(!i->hasActiveFocus());
-}
-
-QTEST_MAIN(tst_QDeclarativeItem)
-
-#include "tst_qdeclarativeitem.moc"
diff --git a/tests/auto/qtquick1/qdeclarativelayoutitem/data/layoutItem.qml b/tests/auto/qtquick1/qdeclarativelayoutitem/data/layoutItem.qml
deleted file mode 100644
index 349713397c..0000000000
--- a/tests/auto/qtquick1/qdeclarativelayoutitem/data/layoutItem.qml
+++ /dev/null
@@ -1,9 +0,0 @@
-import QtQuick 1.0
-
-LayoutItem {//Sized by the layout
- id: resizable
- objectName: "resizable"
- minimumSize: "100x100"
- maximumSize: "300x300"
- preferredSize: "200x200"
-}
diff --git a/tests/auto/qtquick1/qdeclarativelayoutitem/qdeclarativelayoutitem.pro b/tests/auto/qtquick1/qdeclarativelayoutitem/qdeclarativelayoutitem.pro
deleted file mode 100644
index 1471884752..0000000000
--- a/tests/auto/qtquick1/qdeclarativelayoutitem/qdeclarativelayoutitem.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativelayoutitem
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativelayoutitem.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-QT += core-private gui-private widgets-private declarative-private qtquick1-private testlib
diff --git a/tests/auto/qtquick1/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp b/tests/auto/qtquick1/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp
deleted file mode 100644
index 59ec258809..0000000000
--- a/tests/auto/qtquick1/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtTest/QtTest>
-#include <qdeclarativecomponent.h>
-#include <qdeclarativeengine.h>
-#include <QtQuick1/qdeclarativeitem.h>
-#include <QtQuick1/private/qdeclarativelayoutitem_p.h>
-#include <qgraphicsview.h>
-#include <qgraphicsscene.h>
-#include <qgraphicswidget.h>
-#include <qgraphicslinearlayout.h>
-
-class tst_qdeclarativelayoutitem : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativelayoutitem();
-
-private slots:
- void test_resizing();
-};
-
-tst_qdeclarativelayoutitem::tst_qdeclarativelayoutitem()
-{
-}
-
-void tst_qdeclarativelayoutitem::test_resizing()
-{
- //Create Layout (must be done in C++)
- QGraphicsView view;
- QGraphicsScene scene;
- QGraphicsWidget *widget = new QGraphicsWidget();
- QGraphicsLinearLayout *layout = new QGraphicsLinearLayout();
- widget->setLayout(layout);
- scene.addItem(widget);
- view.setScene(&scene);
- //Add the QML snippet into the layout
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/layoutItem.qml"));
- QDeclarative1LayoutItem* obj = static_cast<QDeclarative1LayoutItem*>(c.create());
- QVERIFY(obj);
- QCOMPARE(obj->minimumSize(), QSizeF(100,100));
- QCOMPARE(obj->preferredSize(), QSizeF(200,200));
- QCOMPARE(obj->maximumSize(), QSizeF(300,300));
-
- layout->addItem(obj);
- layout->setContentsMargins(0,0,0,0);
- widget->setContentsMargins(0,0,0,0);
- view.show();
-
- QVERIFY(obj!= 0);
-
- widget->setGeometry(QRectF(0,0, 400,400));
- QCOMPARE(obj->width(), 300.0);
- QCOMPARE(obj->height(), 300.0);
-
- widget->setGeometry(QRectF(0,0, 300,300));
- QCOMPARE(obj->width(), 300.0);
- QCOMPARE(obj->height(), 300.0);
-
- widget->setGeometry(QRectF(0,0, 200,200));
- QCOMPARE(obj->width(), 200.0);
- QCOMPARE(obj->height(), 200.0);
-
- widget->setGeometry(QRectF(0,0, 100,100));
- QCOMPARE(obj->width(), 100.0);
- QCOMPARE(obj->height(), 100.0);
-
- widget->setGeometry(QRectF(0,0, 40,40));
- QCOMPARE(obj->width(), 100.0);
- QCOMPARE(obj->height(), 100.0);
-
- widget->setGeometry(QRectF(0,0, 412,112));
- QCOMPARE(obj->width(), 300.0);
- QCOMPARE(obj->height(), 112.0);
-}
-
-
-QTEST_MAIN(tst_qdeclarativelayoutitem)
-
-#include "tst_qdeclarativelayoutitem.moc"
diff --git a/tests/auto/qtquick1/qdeclarativelistmodel/data/enumerate.qml b/tests/auto/qtquick1/qdeclarativelistmodel/data/enumerate.qml
deleted file mode 100644
index 93697f3307..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistmodel/data/enumerate.qml
+++ /dev/null
@@ -1,24 +0,0 @@
-import QtQuick 1.0
-
-Item {
- property string result
-
- ListModel {
- id: model
-
- ListElement {
- val1: 1
- val2: 2
- val3: "str"
- val4: false
- val5: true
- }
- }
-
- Component.onCompleted: {
- var element = model.get(0);
-
- for (var i in element)
- result += i+"="+element[i]+(element[i] ? "Y" : "N")+":";
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativelistmodel/data/model.qml b/tests/auto/qtquick1/qdeclarativelistmodel/data/model.qml
deleted file mode 100644
index bfd547ed32..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistmodel/data/model.qml
+++ /dev/null
@@ -1,22 +0,0 @@
-import QtQuick 1.0
-
-Item {
- id: item
- property variant model
- property bool done: false
- property variant result
-
- function evalExpressionViaWorker(commands) {
- done = false
- worker.sendMessage({'commands': commands, 'model': model})
- }
-
- WorkerScript {
- id: worker
- source: "script.js"
- onMessage: {
- item.result = messageObject.result
- item.done = true
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativelistmodel/data/multipleroles.qml b/tests/auto/qtquick1/qdeclarativelistmodel/data/multipleroles.qml
deleted file mode 100644
index cc6d9de8a0..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistmodel/data/multipleroles.qml
+++ /dev/null
@@ -1,25 +0,0 @@
-import QtQuick 1.0
-ListView {
- width: 100
- height: 250
- delegate: Rectangle {
- width: 100
- height: 50
- color: black ? "black": "white"
- }
- model: ListModel {
- objectName: "listModel"
- ListElement {
- black: false
- rounded: false
- }
- ListElement {
- black: true
- rounded: false
- }
- ListElement {
- black: true
- rounded: false
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativelistmodel/data/script.js b/tests/auto/qtquick1/qdeclarativelistmodel/data/script.js
deleted file mode 100644
index 66a4acb8a8..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistmodel/data/script.js
+++ /dev/null
@@ -1,13 +0,0 @@
-WorkerScript.onMessage = function(msg) {
- var result = null
- try {
- for (var i=0; i<msg.commands.length; i++) {
- var c = 'msg.model.' + msg.commands[i]
- result = eval(c)
- }
- msg.model.sync()
- } catch(e) { }
- WorkerScript.sendMessage({'done': true, 'result': result})
-}
-
-
diff --git a/tests/auto/qtquick1/qdeclarativelistmodel/data/setmodelcachelist.qml b/tests/auto/qtquick1/qdeclarativelistmodel/data/setmodelcachelist.qml
deleted file mode 100644
index ffe417ae2a..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistmodel/data/setmodelcachelist.qml
+++ /dev/null
@@ -1,20 +0,0 @@
-import QtQuick 1.0
-
-ListModel {
- id: model
- property bool ok : false
-
- Component.onCompleted: {
- model.append({"attrs": []})
- model.get(0)
- model.set(0, {"attrs": [{'abc': 123, 'def': 456}] } )
- ok = ( model.get(0).attrs.get(0).abc == 123
- && model.get(0).attrs.get(0).def == 456 )
-
- model.set(0, {"attrs": [{'abc': 789, 'def': 101}] } )
- ok = ( model.get(0).attrs.get(0).abc == 789
- && model.get(0).attrs.get(0).def == 101 )
-
- }
-}
-
diff --git a/tests/auto/qtquick1/qdeclarativelistmodel/qdeclarativelistmodel.pro b/tests/auto/qtquick1/qdeclarativelistmodel/qdeclarativelistmodel.pro
deleted file mode 100644
index c928f1f33a..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistmodel/qdeclarativelistmodel.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativelistmodel
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativelistmodel.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private widgets-private declarative-private qtquick1-private testlib
diff --git a/tests/auto/qtquick1/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/qtquick1/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
deleted file mode 100644
index fdfd877685..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
+++ /dev/null
@@ -1,1118 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtQuick1/private/qdeclarativeitem_p.h>
-#include <QtQuick1/private/qdeclarativetext_p.h>
-#include <QtQuick1/private/qdeclarativelistmodel_p.h>
-#include <QtDeclarative/private/qdeclarativeengine_p.h>
-#include <QtDeclarative/private/qdeclarativeexpression_p.h>
-#include <QDeclarativeComponent>
-
-#include <QtCore/qtimer.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/qtranslator.h>
-#include <QSignalSpy>
-
-Q_DECLARE_METATYPE(QList<int>)
-Q_DECLARE_METATYPE(QList<QVariantHash>)
-
-class tst_qdeclarativelistmodel : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativelistmodel() {}
-
-private:
- int roleFromName(const QDeclarative1ListModel *model, const QString &roleName);
- QDeclarativeItem *createWorkerTest(QDeclarativeEngine *eng, QDeclarativeComponent *component, QDeclarative1ListModel *model);
- void waitForWorker(QDeclarativeItem *item);
-
-private slots:
- void static_types();
- void static_types_data();
- void static_i18n();
- void static_nestedElements();
- void static_nestedElements_data();
- void dynamic_data();
- void dynamic();
- void dynamic_worker_data();
- void dynamic_worker();
- void dynamic_worker_sync_data();
- void dynamic_worker_sync();
- void convertNestedToFlat_fail();
- void convertNestedToFlat_fail_data();
- void convertNestedToFlat_ok();
- void convertNestedToFlat_ok_data();
- void enumerate();
- void error_data();
- void error();
- void syncError();
- void set();
- void get();
- void get_data();
- void get_worker();
- void get_worker_data();
- void get_nested();
- void get_nested_data();
- void crash_model_with_multiple_roles();
- void set_model_cache();
- void property_changes();
- void property_changes_data();
- void property_changes_worker();
- void property_changes_worker_data();
- void clear();
-};
-
-int tst_qdeclarativelistmodel::roleFromName(const QDeclarative1ListModel *model, const QString &roleName)
-{
- QList<int> roles = model->roles();
- for (int i=0; i<roles.count(); i++) {
- if (model->toString(roles[i]) == roleName)
- return roles[i];
- }
- return -1;
-}
-
-QDeclarativeItem *tst_qdeclarativelistmodel::createWorkerTest(QDeclarativeEngine *eng, QDeclarativeComponent *component, QDeclarative1ListModel *model)
-{
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component->create());
- QDeclarativeEngine::setContextForObject(model, eng->rootContext());
- if (item)
- item->setProperty("model", qVariantFromValue(model));
- return item;
-}
-
-void tst_qdeclarativelistmodel::waitForWorker(QDeclarativeItem *item)
-{
- QEventLoop loop;
- QTimer timer;
- timer.setSingleShot(true);
- connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
-
- QDeclarativeProperty prop(item, "done");
- QVERIFY(prop.isValid());
- QVERIFY(prop.connectNotifySignal(&loop, SLOT(quit())));
- timer.start(10000);
- loop.exec();
- QVERIFY(timer.isActive());
-}
-
-void tst_qdeclarativelistmodel::static_types_data()
-{
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QVariant>("value");
-
- QTest::newRow("string")
- << "ListElement { foo: \"bar\" }"
- << QVariant(QString("bar"));
-
- QTest::newRow("real")
- << "ListElement { foo: 10.5 }"
- << QVariant(10.5);
-
- QTest::newRow("real0")
- << "ListElement { foo: 0 }"
- << QVariant(double(0));
-
- QTest::newRow("bool")
- << "ListElement { foo: false }"
- << QVariant(false);
-
- QTest::newRow("bool")
- << "ListElement { foo: true }"
- << QVariant(true);
-
- QTest::newRow("enum")
- << "ListElement { foo: Text.AlignHCenter }"
- << QVariant(double(QDeclarativeText::AlignHCenter));
-}
-
-void tst_qdeclarativelistmodel::static_types()
-{
- QFETCH(QString, qml);
- QFETCH(QVariant, value);
-
- qml = "import QtQuick 1.0\nItem { property variant test: model.get(0).foo; ListModel { id: model; " + qml + " } }";
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(qml.toUtf8(),
- QUrl::fromLocalFile(QString("dummy.qml")));
-
- QVERIFY(!component.isError());
-
- QObject *obj = component.create();
- QVERIFY(obj != 0);
-
- QVariant actual = obj->property("test");
-
- QCOMPARE(actual, value);
- QCOMPARE(actual.toString(), value.toString());
-
- delete obj;
-}
-
-void tst_qdeclarativelistmodel::static_i18n()
-{
- QString expect = QString::fromUtf8("na\303\257ve");
-
- QString componentStr = "import QtQuick 1.0\nItem { property string prop1: model.get(0).prop1; property string prop2: model.get(0).prop2; ListModel { id: model; ListElement { prop1: \""+expect+"\"; prop2: QT_TR_NOOP(\""+expect+"\") } } }";
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toUtf8(), QUrl::fromLocalFile(""));
- QObject *obj = component.create();
- QVERIFY(obj != 0);
- QString prop1 = obj->property("prop1").toString();
- QCOMPARE(prop1,expect);
- QString prop2 = obj->property("prop2").toString();
- QCOMPARE(prop2,expect); // (no, not translated, QT_TR_NOOP is a no-op)
- delete obj;
-}
-
-void tst_qdeclarativelistmodel::static_nestedElements()
-{
- QFETCH(int, elementCount);
-
- QStringList elements;
- for (int i=0; i<elementCount; i++)
- elements.append("ListElement { a: 1; b: 2 }");
- QString elementsStr = elements.join(",\n") + "\n";
-
- QString componentStr =
- "import QtQuick 1.0\n"
- "Item {\n"
- " property variant count: model.get(0).attributes.count\n"
- " ListModel {\n"
- " id: model\n"
- " ListElement {\n"
- " attributes: [\n";
- componentStr += elementsStr.toUtf8().constData();
- componentStr +=
- " ]\n"
- " }\n"
- " }\n"
- "}";
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toUtf8(), QUrl::fromLocalFile(""));
-
- QDeclarativeListModel *obj = qobject_cast<QDeclarativeListModel*>(component.create());
- QVERIFY(obj != 0);
-
- QVariant count = obj->property("count");
- QCOMPARE(count.type(), QVariant::Int);
- QCOMPARE(count.toInt(), elementCount);
-
- delete obj;
-}
-
-void tst_qdeclarativelistmodel::static_nestedElements_data()
-{
- QTest::addColumn<int>("elementCount");
-
- QTest::newRow("0 items") << 0;
- QTest::newRow("1 item") << 1;
- QTest::newRow("2 items") << 2;
- QTest::newRow("many items") << 5;
-}
-
-void tst_qdeclarativelistmodel::dynamic_data()
-{
- QTest::addColumn<QString>("script");
- QTest::addColumn<int>("result");
- QTest::addColumn<QString>("warning");
-
- // Simple flat model
-
- QTest::newRow("count") << "count" << 0 << "";
-
- QTest::newRow("get1") << "{get(0) === undefined}" << 1 << "";
- QTest::newRow("get2") << "{get(-1) === undefined}" << 1 << "";
- QTest::newRow("get3") << "{append({'foo':123});get(0) != undefined}" << 1 << "";
- QTest::newRow("get4") << "{append({'foo':123});get(0).foo}" << 123 << "";
-
- QTest::newRow("get-modify1") << "{append({'foo':123,'bar':456});get(0).foo = 333;get(0).foo}" << 333 << "";
- QTest::newRow("get-modify2") << "{append({'z':1});append({'foo':123,'bar':456});get(1).bar = 999;get(1).bar}" << 999 << "";
-
- QTest::newRow("append1") << "{append({'foo':123});count}" << 1 << "";
- QTest::newRow("append2") << "{append({'foo':123,'bar':456});count}" << 1 << "";
- QTest::newRow("append3a") << "{append({'foo':123});append({'foo':456});get(0).foo}" << 123 << "";
- QTest::newRow("append3b") << "{append({'foo':123});append({'foo':456});get(1).foo}" << 456 << "";
- QTest::newRow("append4a") << "{append(123)}" << 0 << "<Unknown File>: QML ListModel: append: value is not an object";
- QTest::newRow("append4b") << "{append([1,2,3])}" << 0 << "<Unknown File>: QML ListModel: append: value is not an object";
-
- QTest::newRow("clear1") << "{append({'foo':456});clear();count}" << 0 << "";
- QTest::newRow("clear2") << "{append({'foo':123});append({'foo':456});clear();count}" << 0 << "";
- QTest::newRow("clear3") << "{append({'foo':123});clear()}" << 0 << "";
-
- QTest::newRow("remove1") << "{append({'foo':123});remove(0);count}" << 0 << "";
- QTest::newRow("remove2a") << "{append({'foo':123});append({'foo':456});remove(0);count}" << 1 << "";
- QTest::newRow("remove2b") << "{append({'foo':123});append({'foo':456});remove(0);get(0).foo}" << 456 << "";
- QTest::newRow("remove2c") << "{append({'foo':123});append({'foo':456});remove(1);get(0).foo}" << 123 << "";
- QTest::newRow("remove3") << "{append({'foo':123});remove(0)}" << 0 << "";
- QTest::newRow("remove3a") << "{append({'foo':123});remove(-1);count}" << 1 << "<Unknown File>: QML ListModel: remove: index -1 out of range";
- QTest::newRow("remove4a") << "{remove(0)}" << 0 << "<Unknown File>: QML ListModel: remove: index 0 out of range";
- QTest::newRow("remove4b") << "{append({'foo':123});remove(0);remove(0);count}" << 0 << "<Unknown File>: QML ListModel: remove: index 0 out of range";
- QTest::newRow("remove4c") << "{append({'foo':123});remove(1);count}" << 1 << "<Unknown File>: QML ListModel: remove: index 1 out of range";
-
- QTest::newRow("insert1") << "{insert(0,{'foo':123});count}" << 1 << "";
- QTest::newRow("insert2") << "{insert(1,{'foo':123});count}" << 0 << "<Unknown File>: QML ListModel: insert: index 1 out of range";
- QTest::newRow("insert3a") << "{append({'foo':123});insert(1,{'foo':456});count}" << 2 << "";
- QTest::newRow("insert3b") << "{append({'foo':123});insert(1,{'foo':456});get(0).foo}" << 123 << "";
- QTest::newRow("insert3c") << "{append({'foo':123});insert(1,{'foo':456});get(1).foo}" << 456 << "";
- QTest::newRow("insert3d") << "{append({'foo':123});insert(0,{'foo':456});get(0).foo}" << 456 << "";
- QTest::newRow("insert3e") << "{append({'foo':123});insert(0,{'foo':456});get(1).foo}" << 123 << "";
- QTest::newRow("insert4") << "{append({'foo':123});insert(-1,{'foo':456});count}" << 1 << "<Unknown File>: QML ListModel: insert: index -1 out of range";
- QTest::newRow("insert5a") << "{insert(0,123)}" << 0 << "<Unknown File>: QML ListModel: insert: value is not an object";
- QTest::newRow("insert5b") << "{insert(0,[1,2,3])}" << 0 << "<Unknown File>: QML ListModel: insert: value is not an object";
-
- QTest::newRow("set1") << "{append({'foo':123});set(0,{'foo':456});count}" << 1 << "";
- QTest::newRow("set2") << "{append({'foo':123});set(0,{'foo':456});get(0).foo}" << 456 << "";
- QTest::newRow("set3a") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).foo}" << 999 << "";
- QTest::newRow("set3b") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).bar}" << 456 << "";
- QTest::newRow("set4a") << "{set(0,{'foo':456});count}" << 1 << "";
- QTest::newRow("set4c") << "{set(-1,{'foo':456})}" << 0 << "<Unknown File>: QML ListModel: set: index -1 out of range";
- QTest::newRow("set5a") << "{append({'foo':123,'bar':456});set(0,123);count}" << 1 << "<Unknown File>: QML ListModel: set: value is not an object";
- QTest::newRow("set5b") << "{append({'foo':123,'bar':456});set(0,[1,2,3]);count}" << 1 << "<Unknown File>: QML ListModel: set: value is not an object";
- QTest::newRow("set6") << "{append({'foo':123});set(1,{'foo':456});count}" << 2 << "";
-
- QTest::newRow("setprop1") << "{append({'foo':123});setProperty(0,'foo',456);count}" << 1 << "";
- QTest::newRow("setprop2") << "{append({'foo':123});setProperty(0,'foo',456);get(0).foo}" << 456 << "";
- QTest::newRow("setprop3a") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).foo}" << 999 << "";
- QTest::newRow("setprop3b") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).bar}" << 456 << "";
- QTest::newRow("setprop4a") << "{setProperty(0,'foo',456)}" << 0 << "<Unknown File>: QML ListModel: set: index 0 out of range";
- QTest::newRow("setprop4b") << "{setProperty(-1,'foo',456)}" << 0 << "<Unknown File>: QML ListModel: set: index -1 out of range";
- QTest::newRow("setprop4c") << "{append({'foo':123,'bar':456});setProperty(1,'foo',456);count}" << 1 << "<Unknown File>: QML ListModel: set: index 1 out of range";
- QTest::newRow("setprop5") << "{append({'foo':123,'bar':456});append({'foo':111});setProperty(1,'bar',222);get(1).bar}" << 222 << "";
-
- QTest::newRow("move1a") << "{append({'foo':123});append({'foo':456});move(0,1,1);count}" << 2 << "";
- QTest::newRow("move1b") << "{append({'foo':123});append({'foo':456});move(0,1,1);get(0).foo}" << 456 << "";
- QTest::newRow("move1c") << "{append({'foo':123});append({'foo':456});move(0,1,1);get(1).foo}" << 123 << "";
- QTest::newRow("move1d") << "{append({'foo':123});append({'foo':456});move(1,0,1);get(0).foo}" << 456 << "";
- QTest::newRow("move1e") << "{append({'foo':123});append({'foo':456});move(1,0,1);get(1).foo}" << 123 << "";
- QTest::newRow("move2a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);count}" << 3 << "";
- QTest::newRow("move2b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(0).foo}" << 789 << "";
- QTest::newRow("move2c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(1).foo}" << 123 << "";
- QTest::newRow("move2d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(2).foo}" << 456 << "";
- QTest::newRow("move3a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,3);count}" << 3 << "<Unknown File>: QML ListModel: move: out of range";
- QTest::newRow("move3b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,-1,1);count}" << 3 << "<Unknown File>: QML ListModel: move: out of range";
- QTest::newRow("move3c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,-1);count}" << 3 << "<Unknown File>: QML ListModel: move: out of range";
- QTest::newRow("move3d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,3,1);count}" << 3 << "<Unknown File>: QML ListModel: move: out of range";
-
- // Nested models
-
- QTest::newRow("nested-append1") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});count}" << 1 << "";
- QTest::newRow("nested-append2") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.get(1).a}" << 2 << "";
- QTest::newRow("nested-append3") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.append({'a':4});get(0).bars.get(3).a}" << 4 << "";
-
- QTest::newRow("nested-insert") << "{append({'foo':123});insert(0,{'bars':[{'a':1},{'b':2},{'c':3}]});get(0).bars.get(0).a}" << 1 << "";
- QTest::newRow("nested-set") << "{append({'foo':[{'x':1}]});set(0,{'foo':[{'x':123}]});get(0).foo.get(0).x}" << 123 << "";
-
- QTest::newRow("nested-count") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]}); get(0).bars.count}" << 3 << "";
- QTest::newRow("nested-clear") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]}); get(0).bars.clear(); get(0).bars.count}" << 0 << "";
-}
-
-void tst_qdeclarativelistmodel::dynamic()
-{
- QFETCH(QString, script);
- QFETCH(int, result);
- QFETCH(QString, warning);
-
- QDeclarativeEngine engine;
- QDeclarative1ListModel model;
- QDeclarativeEngine::setContextForObject(&model,engine.rootContext());
- engine.rootContext()->setContextObject(&model);
- QDeclarativeExpression e(engine.rootContext(), &model, script);
- if (!warning.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
-
- QSignalSpy spyCount(&model, SIGNAL(countChanged()));
-
- int actual = e.evaluate().toInt();
- if (e.hasError())
- qDebug() << e.error(); // errors not expected
-
- QCOMPARE(actual,result);
-
- if (model.count() > 0)
- QVERIFY(spyCount.count() > 0);
-}
-
-void tst_qdeclarativelistmodel::dynamic_worker_data()
-{
- dynamic_data();
-}
-
-void tst_qdeclarativelistmodel::dynamic_worker()
-{
- QFETCH(QString, script);
- QFETCH(int, result);
- QFETCH(QString, warning);
-
- if (QByteArray(QTest::currentDataTag()).startsWith("nested"))
- return;
-
- // This is same as dynamic() except it applies the test to a ListModel called
- // from a WorkerScript (i.e. testing the internal FlatListModel that is created
- // by the WorkerListModelAgent)
-
- QDeclarative1ListModel model;
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/model.qml"));
- QDeclarativeItem *item = createWorkerTest(&eng, &component, &model);
- QVERIFY(item != 0);
-
- QSignalSpy spyCount(&model, SIGNAL(countChanged()));
-
- if (script[0] == QLatin1Char('{') && script[script.length()-1] == QLatin1Char('}'))
- script = script.mid(1, script.length() - 2);
- QVariantList operations;
- foreach (const QString &s, script.split(';')) {
- if (!s.isEmpty())
- operations << s;
- }
-
- if (!warning.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
-
- QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
- Q_ARG(QVariant, operations)));
- waitForWorker(item);
- QCOMPARE(QDeclarativeProperty(item, "result").read().toInt(), result);
-
- if (model.count() > 0)
- QVERIFY(spyCount.count() > 0);
-
- delete item;
- qApp->processEvents();
-}
-
-void tst_qdeclarativelistmodel::dynamic_worker_sync_data()
-{
- dynamic_data();
-}
-
-void tst_qdeclarativelistmodel::dynamic_worker_sync()
-{
- QFETCH(QString, script);
- QFETCH(int, result);
- QFETCH(QString, warning);
-
- // This is the same as dynamic_worker() except that it executes a set of list operations
- // from the worker script, calls sync(), and tests the changes are reflected in the
- // list in the main thread
-
- QDeclarative1ListModel model;
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/model.qml"));
- QDeclarativeItem *item = createWorkerTest(&eng, &component, &model);
- QVERIFY(item != 0);
-
- if (script[0] == QLatin1Char('{') && script[script.length()-1] == QLatin1Char('}'))
- script = script.mid(1, script.length() - 2);
- QVariantList operations;
- foreach (const QString &s, script.split(';')) {
- if (!s.isEmpty())
- operations << s;
- }
-
- if (!warning.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
-
- // execute a set of commands on the worker list model, then check the
- // changes are reflected in the list model in the main thread
- if (QByteArray(QTest::currentDataTag()).startsWith("nested"))
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML ListModel: Cannot add list-type data when modifying or after modification from a worker script");
-
- if (QByteArray(QTest::currentDataTag()).startsWith("nested-set"))
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML ListModel: Cannot add list-type data when modifying or after modification from a worker script");
-
- QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
- Q_ARG(QVariant, operations.mid(0, operations.length()-1))));
- waitForWorker(item);
-
- QDeclarativeExpression e(eng.rootContext(), &model, operations.last().toString());
- if (!QByteArray(QTest::currentDataTag()).startsWith("nested"))
- QCOMPARE(e.evaluate().toInt(), result);
-
- delete item;
- qApp->processEvents();
-}
-
-#define RUNEVAL(object, string) \
- QVERIFY(QMetaObject::invokeMethod(object, "runEval", Q_ARG(QVariant, QString(string))));
-
-inline QVariant runexpr(QDeclarativeEngine *engine, const QString &str)
-{
- QDeclarativeExpression expr(engine->rootContext(), 0, str);
- return expr.evaluate();
-}
-
-#define RUNEXPR(string) runexpr(&engine, QString(string))
-
-void tst_qdeclarativelistmodel::convertNestedToFlat_fail()
-{
- // If a model has nested data, it cannot be used at all from a worker script
-
- QFETCH(QString, script);
-
- QDeclarative1ListModel model;
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/model.qml"));
- QDeclarativeItem *item = createWorkerTest(&eng, &component, &model);
- QVERIFY(item != 0);
-
- RUNEVAL(item, "model.append({foo: 123})");
- RUNEVAL(item, "model.append({foo: [{}, {}]})");
-
- QCOMPARE(model.count(), 2);
-
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML ListModel: List contains list-type data and cannot be used from a worker script");
- QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", Q_ARG(QVariant, script)));
- waitForWorker(item);
-
- QCOMPARE(model.count(), 2);
-
- delete item;
- qApp->processEvents();
-}
-
-void tst_qdeclarativelistmodel::convertNestedToFlat_fail_data()
-{
- QTest::addColumn<QString>("script");
-
- QTest::newRow("clear") << "clear()";
- QTest::newRow("remove") << "remove(0)";
- QTest::newRow("append") << "append({'x':1})";
- QTest::newRow("insert") << "insert(0, {'x':1})";
- QTest::newRow("set") << "set(0, {'foo':1})";
- QTest::newRow("setProperty") << "setProperty(0, 'foo', 1})";
- QTest::newRow("move") << "move(0, 1, 1})";
- QTest::newRow("get") << "get(0)";
-}
-
-void tst_qdeclarativelistmodel::convertNestedToFlat_ok()
-
-{
- // If a model only has plain data, it can be modified from a worker script. However,
- // once the model is used from a worker script, it no longer accepts nested data
-
- QFETCH(QString, script);
-
- QDeclarative1ListModel model;
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/model.qml"));
- QDeclarativeItem *item = createWorkerTest(&eng, &component, &model);
- QVERIFY(item != 0);
-
- RUNEVAL(item, "model.append({foo: 123})");
-
- QCOMPARE(model.count(), 1);
-
- QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", Q_ARG(QVariant, script)));
- waitForWorker(item);
-
- // can still add plain data
- int count = model.count();
-
- RUNEVAL(item, "model.append({foo: 123})");
-
- QCOMPARE(model.count(), count+1);
-
- const char *warning = "<Unknown File>: QML ListModel: Cannot add list-type data when modifying or after modification from a worker script";
-
- QTest::ignoreMessage(QtWarningMsg, warning);
- RUNEVAL(item, "model.append({foo: [{}, {}]})");
-
- QTest::ignoreMessage(QtWarningMsg, warning);
- RUNEVAL(item, "model.insert(0, {foo: [{}, {}]})");
-
- QTest::ignoreMessage(QtWarningMsg, warning);
- RUNEVAL(item, "model.set(0, {foo: [{}, {}]})");
-
- QCOMPARE(model.count(), count+1);
-
- delete item;
- qApp->processEvents();
-}
-
-void tst_qdeclarativelistmodel::convertNestedToFlat_ok_data()
-{
- convertNestedToFlat_fail_data();
-}
-
-void tst_qdeclarativelistmodel::enumerate()
-{
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/enumerate.qml"));
- QVERIFY(!component.isError());
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(item != 0);
- QStringList r = item->property("result").toString().split(":");
- QCOMPARE(r[0],QLatin1String("val1=1Y"));
- QCOMPARE(r[1],QLatin1String("val2=2Y"));
- QCOMPARE(r[2],QLatin1String("val3=strY"));
- QCOMPARE(r[3],QLatin1String("val4=falseN"));
- QCOMPARE(r[4],QLatin1String("val5=trueY"));
- delete item;
-}
-
-void tst_qdeclarativelistmodel::error_data()
-{
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("id not allowed in ListElement")
- << "import QtQuick 1.0\nListModel { ListElement { id: fred } }"
- << "ListElement: cannot use reserved \"id\" property";
-
- QTest::newRow("id allowed in ListModel")
- << "import QtQuick 1.0\nListModel { id:model }"
- << "";
-
- QTest::newRow("random properties not allowed in ListModel")
- << "import QtQuick 1.0\nListModel { foo:123 }"
- << "ListModel: undefined property 'foo'";
-
- QTest::newRow("random properties allowed in ListElement")
- << "import QtQuick 1.0\nListModel { ListElement { foo:123 } }"
- << "";
-
- QTest::newRow("bindings not allowed in ListElement")
- << "import QtQuick 1.0\nRectangle { id: rect; ListModel { ListElement { foo: rect.color } } }"
- << "ListElement: cannot use script for property value";
-
- QTest::newRow("random object list properties allowed in ListElement")
- << "import QtQuick 1.0\nListModel { ListElement { foo: [ ListElement { bar: 123 } ] } }"
- << "";
-
- QTest::newRow("default properties not allowed in ListElement")
- << "import QtQuick 1.0\nListModel { ListElement { Item { } } }"
- << "ListElement: cannot contain nested elements";
-
- QTest::newRow("QML elements not allowed in ListElement")
- << "import QtQuick 1.0\nListModel { ListElement { a: Item { } } }"
- << "ListElement: cannot contain nested elements";
-
- QTest::newRow("qualified ListElement supported")
- << "import QtQuick 1.0 as Foo\nFoo.ListModel { Foo.ListElement { a: 123 } }"
- << "";
-
- QTest::newRow("qualified ListElement required")
- << "import QtQuick 1.0 as Foo\nFoo.ListModel { ListElement { a: 123 } }"
- << "ListElement is not a type";
-
- QTest::newRow("unknown qualified ListElement not allowed")
- << "import QtQuick 1.0\nListModel { Foo.ListElement { a: 123 } }"
- << "Foo.ListElement - Foo is not a namespace";
-}
-
-void tst_qdeclarativelistmodel::error()
-{
- QFETCH(QString, qml);
- QFETCH(QString, error);
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(qml.toUtf8(),
- QUrl::fromLocalFile(QString("dummy.qml")));
- if (error.isEmpty()) {
- QVERIFY(!component.isError());
- } else {
- QVERIFY(component.isError());
- QList<QDeclarativeError> errors = component.errors();
- QCOMPARE(errors.count(),1);
- QCOMPARE(errors.at(0).description(),error);
- }
-}
-
-void tst_qdeclarativelistmodel::syncError()
-{
- QString qml = "import QtQuick 1.0\nListModel { id: lm; Component.onCompleted: lm.sync() }";
- QString error = "file:dummy.qml:2:1: QML ListModel: List sync() can only be called from a WorkerScript";
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(qml.toUtf8(),
- QUrl::fromLocalFile(QString("dummy.qml")));
- QTest::ignoreMessage(QtWarningMsg,error.toUtf8());
- QObject *obj = component.create();
- QVERIFY(obj);
- delete obj;
-}
-
-/*
- Test model changes from set() are available to the view
-*/
-void tst_qdeclarativelistmodel::set()
-{
- QDeclarativeEngine engine;
- QDeclarative1ListModel model;
- QDeclarativeEngine::setContextForObject(&model,engine.rootContext());
- engine.rootContext()->setContextProperty("model", &model);
-
- RUNEXPR("model.append({test:false})");
- RUNEXPR("model.set(0, {test:true})");
-
- QCOMPARE(RUNEXPR("model.get(0).test").toBool(), true); // triggers creation of model cache
- QCOMPARE(model.data(0, model.roles()[0]), qVariantFromValue(true));
-
- RUNEXPR("model.set(0, {test:false})");
- QCOMPARE(RUNEXPR("model.get(0).test").toBool(), false); // tests model cache is updated
- QCOMPARE(model.data(0, model.roles()[0]), qVariantFromValue(false));
-}
-
-/*
- Test model changes on values returned by get() are available to the view
-*/
-void tst_qdeclarativelistmodel::get()
-{
- QFETCH(QString, expression);
- QFETCH(int, index);
- QFETCH(QString, roleName);
- QFETCH(QVariant, roleValue);
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 1.0\n"
- "ListModel { \n"
- "ListElement { roleA: 100 }\n"
- "ListElement { roleA: 200; roleB: 400 } \n"
- "ListElement { roleA: 200; roleB: 400 } \n"
- "}", QUrl());
- QDeclarative1ListModel *model = qobject_cast<QDeclarative1ListModel*>(component.create());
- int role = roleFromName(model, roleName);
- QVERIFY(role >= 0);
-
- QSignalSpy spy(model, SIGNAL(itemsChanged(int, int, QList<int>)));
- QDeclarativeExpression expr(engine.rootContext(), model, expression);
- expr.evaluate();
- QVERIFY(!expr.hasError());
-
- QCOMPARE(model->data(index, role), roleValue);
- QCOMPARE(spy.count(), 1);
-
- QList<QVariant> spyResult = spy.takeFirst();
- QCOMPARE(spyResult.at(0).toInt(), index);
- QCOMPARE(spyResult.at(1).toInt(), 1); // only 1 item is modified at a time
- QCOMPARE(spyResult.at(2).value<QList<int> >(), (QList<int>() << role));
-
- delete model;
-}
-
-void tst_qdeclarativelistmodel::get_data()
-{
- QTest::addColumn<QString>("expression");
- QTest::addColumn<int>("index");
- QTest::addColumn<QString>("roleName");
- QTest::addColumn<QVariant>("roleValue");
-
- QTest::newRow("simple value") << "get(0).roleA = 500" << 0 << "roleA" << QVariant(500);
- QTest::newRow("simple value 2") << "get(1).roleB = 500" << 1 << "roleB" << QVariant(500);
-
- QVariantMap map;
- map["zzz"] = 123;
- QTest::newRow("object value") << "get(1).roleB = {'zzz':123}" << 1 << "roleB" << QVariant::fromValue(map);
-
- QVariantList list;
- map.clear(); map["a"] = 50; map["b"] = 500;
- list << map;
- map.clear(); map["c"] = 1000;
- list << map;
- QTest::newRow("list of objects") << "get(2).roleB = [{'a': 50, 'b': 500}, {'c': 1000}]" << 2 << "roleB" << QVariant::fromValue(list);
-}
-
-void tst_qdeclarativelistmodel::get_worker()
-{
- QFETCH(QString, expression);
- QFETCH(int, index);
- QFETCH(QString, roleName);
- QFETCH(QVariant, roleValue);
-
- QDeclarative1ListModel model;
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/model.qml"));
- QDeclarativeItem *item = createWorkerTest(&eng, &component, &model);
- QVERIFY(item != 0);
-
- // Add some values like get() test
- RUNEVAL(item, "model.append({roleA: 100})");
- RUNEVAL(item, "model.append({roleA: 200, roleB: 400})");
- RUNEVAL(item, "model.append({roleA: 200, roleB: 400})");
-
- int role = roleFromName(&model, roleName);
- QVERIFY(role >= 0);
-
- const char *warning = "<Unknown File>: QML ListModel: Cannot add list-type data when modifying or after modification from a worker script";
- if (roleValue.type() == QVariant::List || roleValue.type() == QVariant::Map)
- QTest::ignoreMessage(QtWarningMsg, warning);
- QSignalSpy spy(&model, SIGNAL(itemsChanged(int, int, QList<int>)));
-
- // in the worker thread, change the model data and call sync()
- QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
- Q_ARG(QVariant, QStringList(expression))));
- waitForWorker(item);
-
- // see if we receive the model changes in the main thread's model
- if (roleValue.type() == QVariant::List || roleValue.type() == QVariant::Map) {
- QVERIFY(model.data(index, role) != roleValue);
- QCOMPARE(spy.count(), 0);
- } else {
- QCOMPARE(model.data(index, role), roleValue);
- QCOMPARE(spy.count(), 1);
-
- QList<QVariant> spyResult = spy.takeFirst();
- QCOMPARE(spyResult.at(0).toInt(), index);
- QCOMPARE(spyResult.at(1).toInt(), 1); // only 1 item is modified at a time
- QVERIFY(spyResult.at(2).value<QList<int> >().contains(role));
- }
-}
-
-void tst_qdeclarativelistmodel::get_worker_data()
-{
- get_data();
-}
-
-/*
- Test that the tests run in get() also work for nested list data
-*/
-void tst_qdeclarativelistmodel::get_nested()
-{
- QFETCH(QString, expression);
- QFETCH(int, index);
- QFETCH(QString, roleName);
- QFETCH(QVariant, roleValue);
-
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng);
- component.setData(
- "import QtQuick 1.0\n"
- "ListModel { \n"
- "ListElement {\n"
- "listRoleA: [\n"
- "ListElement { roleA: 100 },\n"
- "ListElement { roleA: 200; roleB: 400 },\n"
- "ListElement { roleA: 200; roleB: 400 } \n"
- "]\n"
- "}\n"
- "ListElement {\n"
- "listRoleA: [\n"
- "ListElement { roleA: 100 },\n"
- "ListElement { roleA: 200; roleB: 400 },\n"
- "ListElement { roleA: 200; roleB: 400 } \n"
- "]\n"
- "listRoleB: [\n"
- "ListElement { roleA: 100 },\n"
- "ListElement { roleA: 200; roleB: 400 },\n"
- "ListElement { roleA: 200; roleB: 400 } \n"
- "]\n"
- "listRoleC: [\n"
- "ListElement { roleA: 100 },\n"
- "ListElement { roleA: 200; roleB: 400 },\n"
- "ListElement { roleA: 200; roleB: 400 } \n"
- "]\n"
- "}\n"
- "}", QUrl());
- QDeclarative1ListModel *model = qobject_cast<QDeclarative1ListModel*>(component.create());
- QVERIFY(component.errorString().isEmpty());
- QDeclarative1ListModel *childModel;
-
- // Test setting the inner list data for:
- // get(0).listRoleA
- // get(1).listRoleA
- // get(1).listRoleB
- // get(1).listRoleC
-
- QList<QPair<int, QString> > testData;
- testData << qMakePair(0, QString("listRoleA"));
- testData << qMakePair(1, QString("listRoleA"));
- testData << qMakePair(1, QString("listRoleB"));
- testData << qMakePair(1, QString("listRoleC"));
-
- for (int i=0; i<testData.count(); i++) {
- int outerListIndex = testData[i].first;
- QString outerListRoleName = testData[i].second;
- int outerListRole = roleFromName(model, outerListRoleName);
- QVERIFY(outerListRole >= 0);
-
- childModel = qobject_cast<QDeclarative1ListModel*>(model->data(outerListIndex, outerListRole).value<QObject*>());
- QVERIFY(childModel);
-
- QString extendedExpression = QString("get(%1).%2.%3").arg(outerListIndex).arg(outerListRoleName).arg(expression);
- QDeclarativeExpression expr(eng.rootContext(), model, extendedExpression);
-
- QSignalSpy spy(childModel, SIGNAL(itemsChanged(int, int, QList<int>)));
- expr.evaluate();
- QVERIFY(!expr.hasError());
-
- int role = roleFromName(childModel, roleName);
- QVERIFY(role >= 0);
- QCOMPARE(childModel->data(index, role), roleValue);
- QCOMPARE(spy.count(), 1);
-
- QList<QVariant> spyResult = spy.takeFirst();
- QCOMPARE(spyResult.at(0).toInt(), index);
- QCOMPARE(spyResult.at(1).toInt(), 1); // only 1 item is modified at a time
- QCOMPARE(spyResult.at(2).value<QList<int> >(), (QList<int>() << role));
- }
-
- delete model;
-}
-
-void tst_qdeclarativelistmodel::get_nested_data()
-{
- get_data();
-}
-
-//QTBUG-13754
-void tst_qdeclarativelistmodel::crash_model_with_multiple_roles()
-{
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/multipleroles.qml"));
- QObject *rootItem = component.create();
- QVERIFY(component.errorString().isEmpty());
- QVERIFY(rootItem != 0);
- QDeclarative1ListModel *model = rootItem->findChild<QDeclarative1ListModel*>("listModel");
- QVERIFY(model != 0);
-
- // used to cause a crash in QDeclarativeVisualDataModel
- model->setProperty(0, "black", true);
-
- delete rootItem;
-}
-
-//QTBUG-15190
-void tst_qdeclarativelistmodel::set_model_cache()
-{
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/setmodelcachelist.qml"));
- QObject *model = component.create();
- QVERIFY2(component.errorString().isEmpty(), QTest::toString(component.errorString()));
- QVERIFY(model != 0);
- QVERIFY(model->property("ok").toBool());
-
- delete model;
-}
-
-void tst_qdeclarativelistmodel::property_changes()
-{
- QFETCH(QString, script_setup);
- QFETCH(QString, script_change);
- QFETCH(QString, roleName);
- QFETCH(int, listIndex);
- QFETCH(bool, itemsChanged);
- QFETCH(QString, testExpression);
-
- QDeclarativeEngine engine;
- QDeclarative1ListModel model;
- QDeclarativeEngine::setContextForObject(&model, engine.rootContext());
- engine.rootContext()->setContextObject(&model);
-
- QDeclarativeExpression expr(engine.rootContext(), &model, script_setup);
- expr.evaluate();
- QVERIFY2(!expr.hasError(), QTest::toString(expr.error().toString()));
-
- QString signalHandler = "on" + QString(roleName[0].toUpper()) + roleName.mid(1, roleName.length()) + "Changed:";
- QString qml = "import QtQuick 1.0\n"
- "Connections {\n"
- "property bool gotSignal: false\n"
- "target: model.get(0)\n"
- + signalHandler + " gotSignal = true\n"
- "}\n";
- QDeclarativeComponent component(&engine);
- component.setData(qml.toUtf8(), QUrl::fromLocalFile(""));
- engine.rootContext()->setContextProperty("model", &model);
- QObject *connectionsObject = component.create();
- QVERIFY2(component.errorString().isEmpty(), QTest::toString(component.errorString()));
-
- QSignalSpy spyItemsChanged(&model, SIGNAL(itemsChanged(int, int, QList<int>)));
-
- expr.setExpression(script_change);
- expr.evaluate();
- QVERIFY2(!expr.hasError(), QTest::toString(expr.error()));
-
- // test the object returned by get() emits the correct signals
- QCOMPARE(connectionsObject->property("gotSignal").toBool(), itemsChanged);
-
- // test itemsChanged() is emitted correctly
- if (itemsChanged) {
- QCOMPARE(spyItemsChanged.count(), 1);
- QCOMPARE(spyItemsChanged.at(0).at(0).toInt(), listIndex);
- QCOMPARE(spyItemsChanged.at(0).at(1).toInt(), 1);
- } else {
- QCOMPARE(spyItemsChanged.count(), 0);
- }
-
- expr.setExpression(testExpression);
- QCOMPARE(expr.evaluate().toBool(), true);
-
- delete connectionsObject;
-}
-
-void tst_qdeclarativelistmodel::property_changes_data()
-{
- QTest::addColumn<QString>("script_setup");
- QTest::addColumn<QString>("script_change");
- QTest::addColumn<QString>("roleName");
- QTest::addColumn<int>("listIndex");
- QTest::addColumn<bool>("itemsChanged");
- QTest::addColumn<QString>("testExpression");
-
- QTest::newRow("set: plain") << "append({'a':123, 'b':456, 'c':789});" << "set(0,{'b':123});"
- << "b" << 0 << true << "get(0).b == 123";
- QTest::newRow("setProperty: plain") << "append({'a':123, 'b':456, 'c':789});" << "setProperty(0, 'b', 123);"
- << "b" << 0 << true << "get(0).b == 123";
-
- QTest::newRow("set: plain, no changes") << "append({'a':123, 'b':456, 'c':789});" << "set(0,{'b':456});"
- << "b" << 0 << false << "get(0).b == 456";
- QTest::newRow("setProperty: plain, no changes") << "append({'a':123, 'b':456, 'c':789});" << "setProperty(0, 'b', 456);"
- << "b" << 0 << false << "get(0).b == 456";
-
- // Following tests only call set() since setProperty() only allows plain
- // values, not lists, as the argument.
- // Note that when a list is changed, itemsChanged() is currently always
- // emitted regardless of whether it actually changed or not.
-
- QTest::newRow("nested-set: list, new size") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[{'a':1},{'a':2}]});"
- << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 2";
-
- QTest::newRow("nested-set: list, empty -> non-empty") << "append({'a':123, 'b':[], 'c':789});" << "set(0,{'b':[{'a':1},{'a':2},{'a':3}]});"
- << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 2 && get(0).b.get(2).a == 3";
-
- QTest::newRow("nested-set: list, non-empty -> empty") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[]});"
- << "b" << 0 << true << "get(0).b.count == 0";
-
- QTest::newRow("nested-set: list, same size, different values") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[{'a':1},{'a':222},{'a':3}]});"
- << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 222 && get(0).b.get(2).a == 3";
-
- QTest::newRow("nested-set: list, no changes") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[{'a':1},{'a':2},{'a':3}]});"
- << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 2 && get(0).b.get(2).a == 3";
-
- QTest::newRow("nested-set: list, no changes, empty") << "append({'a':123, 'b':[], 'c':789});" << "set(0,{'b':[]});"
- << "b" << 0 << true << "get(0).b.count == 0";
-}
-
-void tst_qdeclarativelistmodel::property_changes_worker()
-{
- // nested models are not supported when WorkerScript is involved
- if (QByteArray(QTest::currentDataTag()).startsWith("nested-"))
- return;
-
- QFETCH(QString, script_setup);
- QFETCH(QString, script_change);
- QFETCH(QString, roleName);
- QFETCH(int, listIndex);
- QFETCH(bool, itemsChanged);
-
- QDeclarative1ListModel model;
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml"));
- QVERIFY2(component.errorString().isEmpty(), component.errorString().toUtf8());
- QDeclarativeItem *item = createWorkerTest(&engine, &component, &model);
- QVERIFY(item != 0);
-
- QDeclarativeExpression expr(engine.rootContext(), &model, script_setup);
- expr.evaluate();
- QVERIFY2(!expr.hasError(), QTest::toString(expr.error().toString()));
-
- QSignalSpy spyItemsChanged(&model, SIGNAL(itemsChanged(int, int, QList<int>)));
-
- QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
- Q_ARG(QVariant, QStringList(script_change))));
- waitForWorker(item);
-
- // test itemsChanged() is emitted correctly
- if (itemsChanged) {
- QCOMPARE(spyItemsChanged.count(), 1);
- QCOMPARE(spyItemsChanged.at(0).at(0).toInt(), listIndex);
- QCOMPARE(spyItemsChanged.at(0).at(1).toInt(), 1);
- } else {
- QCOMPARE(spyItemsChanged.count(), 0);
- }
-
- delete item;
- qApp->processEvents();
-}
-
-void tst_qdeclarativelistmodel::property_changes_worker_data()
-{
- property_changes_data();
-}
-
-void tst_qdeclarativelistmodel::clear()
-{
- QDeclarativeEngine engine;
- QDeclarative1ListModel model;
- QDeclarativeEngine::setContextForObject(&model, engine.rootContext());
- engine.rootContext()->setContextProperty("model", &model);
-
- model.clear();
- QCOMPARE(model.count(), 0);
-
- RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\"})");
- QCOMPARE(model.count(), 1);
-
- model.clear();
- QCOMPARE(model.count(), 0);
-
- RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\"})");
- RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\"})");
- QCOMPARE(model.count(), 2);
-
- model.clear();
- QCOMPARE(model.count(), 0);
-
- // clearing does not remove the roles
- RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\", propertyC: \"value c\"})");
- QList<int> roles = model.roles();
- model.clear();
- QCOMPARE(model.count(), 0);
- QCOMPARE(model.roles(), roles);
- QCOMPARE(model.toString(roles[0]), QString("propertyA"));
- QCOMPARE(model.toString(roles[1]), QString("propertyB"));
- QCOMPARE(model.toString(roles[2]), QString("propertyC"));
-}
-
-QTEST_MAIN(tst_qdeclarativelistmodel)
-
-#include "tst_qdeclarativelistmodel.moc"
diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/attachedSignals.qml b/tests/auto/qtquick1/qdeclarativelistview/data/attachedSignals.qml
deleted file mode 100644
index 5ca1a45839..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistview/data/attachedSignals.qml
+++ /dev/null
@@ -1,24 +0,0 @@
-import QtQuick 1.0
-
-ListView {
- id: view
- width: 240; height: 320
-
- property variant addedDelegates: []
- property int removedDelegateCount
-
- model: testModel
-
- delegate: Rectangle {
- width: 200; height: delegateHeight
- border.width: 1
- ListView.onAdd: {
- var obj = ListView.view.addedDelegates
- obj.push(model.name)
- ListView.view.addedDelegates = obj
- }
- ListView.onRemove: {
- view.removedDelegateCount += 1
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/displaylist.qml b/tests/auto/qtquick1/qdeclarativelistview/data/displaylist.qml
deleted file mode 100644
index 9d58530252..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistview/data/displaylist.qml
+++ /dev/null
@@ -1,50 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: root
- property real delegateHeight: 20
- width: 240
- height: 320
- color: "#ffffff"
- resources: [
- Component {
- id: myDelegate
- Rectangle {
- id: wrapper
- objectName: "wrapper"
- height: root.delegateHeight
- Behavior on height { NumberAnimation {} }
- width: 240
- Text {
- text: index
- }
- Text {
- x: 30
- objectName: "displayText"
- text: display
- }
- Text {
- x: 200
- text: wrapper.y
- }
- color: ListView.isCurrentItem ? "lightsteelblue" : "white"
- }
- },
- Component {
- id: myHighlight
- Rectangle { color: "green" }
- }
- ]
- ListView {
- id: list
- objectName: "list"
- focus: true
- width: 240
- height: 320
- model: testModel
- delegate: myDelegate
- highlight: myHighlight
- highlightMoveSpeed: 1000
- highlightResizeSpeed: 1000
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/footer.qml b/tests/auto/qtquick1/qdeclarativelistview/data/footer.qml
deleted file mode 100644
index 33e04f1b0a..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistview/data/footer.qml
+++ /dev/null
@@ -1,38 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- function changeFooter() {
- list.footer = footer2
- }
- width: 240
- height: 320
- color: "#ffffff"
- Component {
- id: myDelegate
- Rectangle {
- id: wrapper
- objectName: "wrapper"
- height: 20
- width: 240
- Text {
- text: index
- }
- color: ListView.isCurrentItem ? "lightsteelblue" : "white"
- }
- }
- ListView {
- id: list
- objectName: "list"
- focus: true
- width: 240
- height: 320
- model: testModel
- delegate: myDelegate
- footer: Text { objectName: "footer"; text: "Footer"; height: 30 }
- }
-
- Component {
- id: footer2
- Text { objectName: "footer2"; text: "Footer 2"; height: 20 }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/header.qml b/tests/auto/qtquick1/qdeclarativelistview/data/header.qml
deleted file mode 100644
index 38cdd6e0c4..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistview/data/header.qml
+++ /dev/null
@@ -1,38 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- function changeHeader() {
- list.header = header2
- }
- width: 240
- height: 320
- color: "#ffffff"
- Component {
- id: myDelegate
- Rectangle {
- id: wrapper
- objectName: "wrapper"
- height: 30
- width: 240
- Text {
- text: index
- }
- color: ListView.isCurrentItem ? "lightsteelblue" : "white"
- }
- }
- ListView {
- id: list
- objectName: "list"
- focus: true
- width: 240
- height: 320
- snapMode: ListView.SnapToItem
- model: testModel
- delegate: myDelegate
- header: Text { objectName: "header"; text: "Header"; height: 20 }
- }
- Component {
- id: header2
- Text { objectName: "header2"; text: "Header 2"; height: 10 }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/header1.qml b/tests/auto/qtquick1/qdeclarativelistview/data/header1.qml
deleted file mode 100644
index f2ab4c1257..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistview/data/header1.qml
+++ /dev/null
@@ -1,33 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 240
- height: 320
- color: "#ffffff"
-
- ListModel { id: testModel }
-
- ListView {
- id: list
- objectName: "list"
- width: parent.width
- anchors.top: parent.top
- anchors.bottom: parent.bottom
- model: testModel
- delegate: Text {
- objectName: "wrapper"
- font.pointSize: 20
- text: index
- }
- footer: Rectangle {
- width: parent.width
- height: 40
- color: "green"
- }
- header: Text { objectName: "header"; text: "Header" }
- }
-
- Component.onCompleted: {
- for (var i=0; i<30; i++) testModel.append({"name" : i, "val": i})
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/headerfooter.qml b/tests/auto/qtquick1/qdeclarativelistview/data/headerfooter.qml
deleted file mode 100644
index 5633831925..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistview/data/headerfooter.qml
+++ /dev/null
@@ -1,26 +0,0 @@
-import QtQuick 1.1
-
-ListView {
- id: view
- property bool horizontal: false
- property bool rtl: false
- width: 240
- height: 320
-
- orientation: horizontal ? ListView.Horizontal : ListView.Vertical
- header: Rectangle {
- objectName: "header"
- width: horizontal ? 20 : view.width
- height: horizontal ? view.height : 20
- color: "red"
- }
- footer: Rectangle {
- objectName: "footer"
- width: horizontal ? 30 : view.width
- height: horizontal ? view.height : 30
- color: "blue"
- }
-// model: testModel
- delegate: Text { width: 30; height: 30; text: index + "(" + x + ")" }
- layoutDirection: rtl ? Qt.RightToLeft : Qt.LeftToRight
-}
diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/itemlist.qml b/tests/auto/qtquick1/qdeclarativelistview/data/itemlist.qml
deleted file mode 100644
index fca2901e97..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistview/data/itemlist.qml
+++ /dev/null
@@ -1,43 +0,0 @@
-// This example demonstrates placing items in a view using
-// a VisualItemModel
-
-import QtQuick 1.0
-
-Rectangle {
- color: "lightgray"
- width: 240
- height: 320
-
- VisualItemModel {
- id: itemModel
- objectName: "itemModel"
- Rectangle {
- objectName: "item1"
- height: ListView.view.height; width: view.width; color: "#FFFEF0"
- Text { objectName: "text1"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent }
- }
- Rectangle {
- objectName: "item2"
- height: ListView.view.height; width: view.width; color: "#F0FFF7"
- Text { objectName: "text2"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent }
- }
- Rectangle {
- objectName: "item3"
- height: ListView.view.height; width: view.width; color: "#F4F0FF"
- Text { objectName: "text3"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent }
- }
- }
-
- ListView {
- id: view
- objectName: "view"
- anchors.fill: parent
- anchors.bottomMargin: 30
- model: itemModel
- preferredHighlightBegin: 0
- preferredHighlightEnd: 0
- highlightRangeMode: "StrictlyEnforceRange"
- orientation: ListView.Horizontal
- flickDeceleration: 2000
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/listview-enforcerange.qml b/tests/auto/qtquick1/qdeclarativelistview/data/listview-enforcerange.qml
deleted file mode 100644
index 49dbcb38ea..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistview/data/listview-enforcerange.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 240
- height: 320
- color: "#ffffff"
- Component {
- id: myDelegate
- Item {
- id: wrapper
- objectName: "wrapper"
- height: 20
- width: 240
- Text {
- text: index
- }
- Text {
- x: 30
- id: textName
- objectName: "textName"
- text: name
- }
- Text {
- x: 120
- id: textNumber
- objectName: "textNumber"
- text: number
- }
- Text {
- x: 200
- text: wrapper.y
- }
- }
- }
-
- Component {
- id: myHighlight
- Rectangle {
- color: "lightsteelblue"
- }
- }
-
- ListView {
- id: list
- objectName: "list"
- width: 240
- height: 320
- model: testModel
- delegate: myDelegate
- highlight: myHighlight
- preferredHighlightBegin: 100
- preferredHighlightEnd: 100
- highlightRangeMode: "StrictlyEnforceRange"
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/listview-initCurrent.qml b/tests/auto/qtquick1/qdeclarativelistview/data/listview-initCurrent.qml
deleted file mode 100644
index 2c4cfab217..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistview/data/listview-initCurrent.qml
+++ /dev/null
@@ -1,51 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- property int current: list.currentIndex
- width: 240
- height: 320
- color: "#ffffff"
- resources: [
- Component {
- id: myDelegate
- Rectangle {
- id: wrapper
- objectName: "wrapper"
- height: 20
- width: 240
- Text {
- text: index
- }
- Text {
- x: 30
- id: textName
- objectName: "textName"
- text: name
- }
- Text {
- x: 120
- id: textNumber
- objectName: "textNumber"
- text: number
- }
- Text {
- x: 200
- text: wrapper.y
- }
- color: ListView.isCurrentItem ? "lightsteelblue" : "white"
- }
- }
- ]
- ListView {
- id: list
- objectName: "list"
- focus: true
- currentIndex: 20
- width: 240
- height: 320
- keyNavigationWraps: testWrap
- delegate: myDelegate
- highlightMoveSpeed: 1000
- model: testModel
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/listview-noCurrent.qml b/tests/auto/qtquick1/qdeclarativelistview/data/listview-noCurrent.qml
deleted file mode 100644
index 19970100f7..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistview/data/listview-noCurrent.qml
+++ /dev/null
@@ -1,50 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- property int current: list.currentIndex
- width: 240
- height: 320
- color: "#ffffff"
- resources: [
- Component {
- id: myDelegate
- Rectangle {
- id: wrapper
- objectName: "wrapper"
- height: 20
- width: 240
- Text {
- text: index
- }
- Text {
- x: 30
- id: textName
- objectName: "textName"
- text: name
- }
- Text {
- x: 120
- id: textNumber
- objectName: "textNumber"
- text: number
- }
- Text {
- x: 200
- text: wrapper.y
- }
- color: ListView.isCurrentItem ? "lightsteelblue" : "white"
- }
- }
- ]
- ListView {
- id: list
- objectName: "list"
- focus: true
- currentIndex: -1
- width: 240
- height: 320
- delegate: myDelegate
- highlightMoveSpeed: 1000
- model: testModel
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/listview-sections.qml b/tests/auto/qtquick1/qdeclarativelistview/data/listview-sections.qml
deleted file mode 100644
index 283678b6f1..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistview/data/listview-sections.qml
+++ /dev/null
@@ -1,64 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 240
- height: 320
- color: "#ffffff"
- resources: [
- Component {
- id: myDelegate
- Item {
- id: wrapper
- objectName: "wrapper"
- height: ListView.previousSection != ListView.section ? 40 : 20;
- width: 240
- Rectangle {
- y: wrapper.ListView.previousSection != wrapper.ListView.section ? 20 : 0
- height: 20
- width: parent.width
- color: wrapper.ListView.isCurrentItem ? "lightsteelblue" : "white"
- Text {
- text: index
- }
- Text {
- x: 30
- id: textName
- objectName: "textName"
- text: name
- }
- Text {
- x: 100
- id: textNumber
- objectName: "textNumber"
- text: number
- }
- Text {
- objectName: "nextSection"
- x: 150
- text: wrapper.ListView.nextSection
- }
- Text {
- x: 200
- text: wrapper.y
- }
- }
- Rectangle {
- color: "#99bb99"
- height: wrapper.ListView.previousSection != wrapper.ListView.section ? 20 : 0
- width: parent.width
- visible: wrapper.ListView.previousSection != wrapper.ListView.section ? true : false
- Text { text: wrapper.ListView.section }
- }
- }
- }
- ]
- ListView {
- id: list
- objectName: "list"
- width: 240
- height: 320
- model: testModel
- delegate: myDelegate
- section.property: "number"
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/listview-sections_delegate.qml b/tests/auto/qtquick1/qdeclarativelistview/data/listview-sections_delegate.qml
deleted file mode 100644
index b2d9213c3d..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistview/data/listview-sections_delegate.qml
+++ /dev/null
@@ -1,69 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- property string sectionProperty: "number"
- width: 240
- height: 320
- color: "#ffffff"
- resources: [
- Component {
- id: myDelegate
- Item {
- id: wrapper
- objectName: "wrapper"
- height: 20;
- width: 240
- Rectangle {
- height: 20
- width: parent.width
- color: wrapper.ListView.isCurrentItem ? "lightsteelblue" : "white"
- Text {
- text: index
- }
- Text {
- x: 30
- id: textName
- objectName: "textName"
- text: name
- }
- Text {
- x: 100
- id: textNumber
- objectName: "textNumber"
- text: number
- }
- Text {
- objectName: "nextSection"
- x: 150
- text: wrapper.ListView.nextSection
- }
- Text {
- x: 200
- text: wrapper.y
- }
- }
- ListView.onRemove: SequentialAnimation {
- PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true }
- NumberAnimation { target: wrapper; property: "height"; to: 0; duration: 100; easing.type: Easing.InOutQuad }
- PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false }
- }
- }
- }
- ]
- ListView {
- id: list
- objectName: "list"
- width: 240
- height: 320
- model: testModel
- delegate: myDelegate
- section.property: sectionProperty
- section.delegate: Rectangle {
- objectName: "sect_" + section
- color: "#99bb99"
- height: 20
- width: list.width
- Text { text: section }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/listviewtest.qml b/tests/auto/qtquick1/qdeclarativelistview/data/listviewtest.qml
deleted file mode 100644
index 75ddabbb86..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistview/data/listviewtest.qml
+++ /dev/null
@@ -1,133 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: root
- width: 240
- height: 320
- color: "#ffffff"
-
- property int count: list.count
- property bool showHeader: false
- property bool showFooter: false
- property real hr: list.visibleArea.heightRatio
- function heightRatio() {
- return list.visibleArea.heightRatio
- }
-
- function checkProperties() {
- testObject.error = false;
- if (list.model != testModel) {
- console.log("model property incorrect");
- testObject.error = true;
- }
- if (!testObject.animate && list.delegate != myDelegate) {
- console.log("delegate property incorrect - expected myDelegate");
- testObject.error = true;
- }
- if (testObject.animate && list.delegate != animatedDelegate) {
- console.log("delegate property incorrect - expected animatedDelegate");
- testObject.error = true;
- }
- if (testObject.invalidHighlight && list.highlight != invalidHl) {
- console.log("highlight property incorrect - expected invalidHl");
- testObject.error = true;
- }
- if (!testObject.invalidHighlight && list.highlight != myHighlight) {
- console.log("highlight property incorrect - expected myHighlight");
- testObject.error = true;
- }
- }
- resources: [
- Component {
- id: myDelegate
- Rectangle {
- id: wrapper
- objectName: "wrapper"
- height: 20
- width: 240
- Text {
- text: index
- }
- Text {
- x: 30
- id: textName
- objectName: "textName"
- text: name
- }
- Text {
- x: 120
- id: textNumber
- objectName: "textNumber"
- text: number
- }
- Text {
- x: 200
- text: wrapper.y
- }
- color: ListView.isCurrentItem ? "lightsteelblue" : "white"
- }
- },
- Component {
- id: animatedDelegate
- Rectangle {
- id: wrapper
- objectName: "wrapper"
- height: 20
- width: 240
- Text {
- text: index
- }
- Text {
- x: 30
- id: textName
- objectName: "textName"
- text: name
- }
- Text {
- x: 120
- id: textNumber
- objectName: "textNumber"
- text: number
- }
- Text {
- x: 200
- text: wrapper.y
- }
- color: ListView.isCurrentItem ? "lightsteelblue" : "white"
- ListView.onRemove: SequentialAnimation {
- PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true }
- NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing.type: "InOutQuad" }
- PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false }
-
- }
- }
- },
- Component {
- id: myHighlight
- Rectangle { color: "green" }
- },
- Component {
- id: invalidHl
- SmoothedAnimation {}
- },
- Component {
- id: headerFooter
- Rectangle { height: 30; width: 240; color: "blue" }
- }
- ]
- ListView {
- id: list
- objectName: "list"
- focus: true
- width: 240
- height: 320
- model: testModel
- delegate: testObject.animate ? animatedDelegate : myDelegate
- highlight: testObject.invalidHighlight ? invalidHl : myHighlight
- highlightMoveSpeed: 1000
- highlightResizeSpeed: 1000
- cacheBuffer: testObject.cacheBuffer
- header: root.showHeader ? headerFooter : null
- footer: root.showFooter ? headerFooter : null
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/manual-highlight.qml b/tests/auto/qtquick1/qdeclarativelistview/data/manual-highlight.qml
deleted file mode 100644
index a32a19492c..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistview/data/manual-highlight.qml
+++ /dev/null
@@ -1,47 +0,0 @@
-import QtQuick 1.0
-
-Item {
-
- ListModel {
- id: model
- ListElement {
- name: "Bill Smith"
- number: "555 3264"
- }
- ListElement {
- name: "John Brown"
- number: "555 8426"
- }
- ListElement {
- name: "Sam Wise"
- number: "555 0473"
- }
- ListElement {
- name: "Bob Brown"
- number: "555 5845"
- }
- }
-
- Component {
- id: highlight
- Rectangle {
- objectName: "highlight"
- width: 180; height: 20
- color: "lightsteelblue"; radius: 5
- y: list.currentItem.y+5
- }
- }
-
- ListView {
- id: list
- objectName: "list"
- anchors.fill: parent
- model: model
- delegate: Text { objectName: "wrapper"; text: name }
-
- highlight: highlight
- highlightFollowsCurrentItem: false
- focus: true
- }
-
-}
diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/orientchange.qml b/tests/auto/qtquick1/qdeclarativelistview/data/orientchange.qml
deleted file mode 100644
index c7aa0cd1d3..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistview/data/orientchange.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import QtQuick 1.0
-
-ListView {
- width: 240; height: 320
- delegate: Rectangle { objectName: "wrapper"; width: 80; height: 80 }
- model: 100
-}
diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/propertychangestest.qml b/tests/auto/qtquick1/qdeclarativelistview/data/propertychangestest.qml
deleted file mode 100644
index 04bec59abf..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistview/data/propertychangestest.qml
+++ /dev/null
@@ -1,71 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 180; height: 120; color: "white"
- Component {
- id: delegate
- Item {
- id: wrapper
- width: 180; height: 40;
- Column {
- x: 5; y: 5
- Text { text: '<b>Name:</b> ' + name }
- Text { text: '<b>Number:</b> ' + number }
- }
- }
- }
- Component {
- id: highlightRed
- Rectangle {
- color: "red"
- radius: 10
- opacity: 0.5
- }
- }
- ListView {
- objectName: "listView"
- anchors.fill: parent
- model: listModel
- delegate: delegate
- highlight: highlightRed
- focus: true
- highlightFollowsCurrentItem: true
- preferredHighlightBegin: 0.0
- preferredHighlightEnd: 0.0
- highlightRangeMode: ListView.ApplyRange
- keyNavigationWraps: true
- cacheBuffer: 10
- snapMode: ListView.SnapToItem
- }
-
- data:[
- ListModel {
- id: listModel
- ListElement {
- name: "Bill Smith"
- number: "555 3264"
- }
- ListElement {
- name: "John Brown"
- number: "555 8426"
- }
- ListElement {
- name: "Sam Wise"
- number: "555 0473"
- }
- },
- ListModel {
- objectName: "alternateModel"
- ListElement {
- name: "Jack"
- number: "555 8426"
- }
- ListElement {
- name: "Mary"
- number: "555 3264"
- }
- }
- ]
-}
-
-
diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/qtbug14821.qml b/tests/auto/qtquick1/qdeclarativelistview/data/qtbug14821.qml
deleted file mode 100644
index e0303ecaa3..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistview/data/qtbug14821.qml
+++ /dev/null
@@ -1,31 +0,0 @@
-import QtQuick 1.0
-
-ListView {
- id: view
- width: 300; height: 200
- focus: true
- keyNavigationWraps: true
-
- model: 100
-
- preferredHighlightBegin: 90
- preferredHighlightEnd: 110
-
- highlightRangeMode: ListView.StrictlyEnforceRange
- highlight: Component {
- Rectangle {
- border.color: "blue"
- border.width: 3
- color: "transparent"
- width: 300; height: 15
- }
- }
-
- delegate: Component {
- Item {
- height: 15 + (view.currentIndex == index ? 20 : 0)
- width: 200
- Text { text: 'Index: ' + index; anchors.verticalCenter: parent.verticalCenter }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/qtbug16037.qml b/tests/auto/qtquick1/qdeclarativelistview/data/qtbug16037.qml
deleted file mode 100644
index 0756618a60..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistview/data/qtbug16037.qml
+++ /dev/null
@@ -1,37 +0,0 @@
-import QtQuick 1.0
-
-Item {
- width: 640
- height: 480
-
- function setModel() {
- listView.model = listModel1
- }
-
- ListModel {
- id: listModel1
- ListElement { text: "Apple" }
- ListElement { text: "Banana" }
- ListElement { text: "Orange" }
- ListElement { text: "Coconut" }
- }
-
- Rectangle {
- width: 200
- height: listView.contentHeight
- color: "yellow"
- anchors.centerIn: parent
-
- ListView {
- id: listView
- objectName: "listview"
- anchors.fill: parent
-
- delegate: Item {
- width: 200
- height: 20
- Text { text: model.text; anchors.centerIn: parent }
- }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/rightToLeft.qml b/tests/auto/qtquick1/qdeclarativelistview/data/rightToLeft.qml
deleted file mode 100644
index 1e92bb3cbd..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistview/data/rightToLeft.qml
+++ /dev/null
@@ -1,42 +0,0 @@
-// This example demonstrates how item positioning
-// changes in right-to-left layout direction
-
-import QtQuick 1.1
-
-Rectangle {
- color: "lightgray"
- width: 640
- height: 320
-
- VisualItemModel {
- id: itemModel
- objectName: "itemModel"
- Rectangle {
- objectName: "item1"
- height: view.height; width: 100; color: "#FFFEF0"
- Text { objectName: "text1"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent }
- }
- Rectangle {
- objectName: "item2"
- height: view.height; width: 200; color: "#F0FFF7"
- Text { objectName: "text2"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent }
- }
- Rectangle {
- objectName: "item3"
- height: view.height; width: 240; color: "#F4F0FF"
- Text { objectName: "text3"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent }
- }
- }
-
- ListView {
- id: view
- objectName: "view"
- anchors.fill: parent
- anchors.bottomMargin: 30
- model: itemModel
- highlightRangeMode: "StrictlyEnforceRange"
- orientation: ListView.Horizontal
- flickDeceleration: 2000
- layoutDirection: Qt.RightToLeft
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/sizelessthan1.qml b/tests/auto/qtquick1/qdeclarativelistview/data/sizelessthan1.qml
deleted file mode 100644
index 77bfef8e57..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistview/data/sizelessthan1.qml
+++ /dev/null
@@ -1,26 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 240
- height: 320
- color: "#ffffff"
- Component {
- id: myDelegate
- Rectangle {
- id: wrapper
- objectName: "wrapper"
- height: 0.5
- width: 240
- color: ((index % 2) == 1 ? "red" : "blue")
- }
- }
- ListView {
- id: list
- objectName: "list"
- focus: true
- width: 240
- height: 320
- model: testModel
- delegate: myDelegate
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/strictlyenforcerange.qml b/tests/auto/qtquick1/qdeclarativelistview/data/strictlyenforcerange.qml
deleted file mode 100644
index bb77a77cf3..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistview/data/strictlyenforcerange.qml
+++ /dev/null
@@ -1,29 +0,0 @@
-import QtQuick 1.0
-
-ListView {
- id: list
- objectName: "list"
- width: 320
- height: 480
-
- function fillModel() {
- list.model.append({"col": "red"});
- list.currentIndex = list.count-1
- list.model.append({"col": "blue"});
- list.currentIndex = list.count-1
- list.model.append({"col": "green"});
- list.currentIndex = list.count-1
- }
-
- model: ListModel { id: listModel } // empty model
- delegate: Rectangle { id: wrapper; objectName: "wrapper"; color: col; width: 300; height: 400 }
- orientation: "Horizontal"
- snapMode: "SnapToItem"
- cacheBuffer: 1000
-
- preferredHighlightBegin: 10
- preferredHighlightEnd: 10
-
- highlightRangeMode: "StrictlyEnforceRange"
- focus: true
-}
diff --git a/tests/auto/qtquick1/qdeclarativelistview/incrementalmodel.cpp b/tests/auto/qtquick1/qdeclarativelistview/incrementalmodel.cpp
deleted file mode 100644
index 7db6c8b20a..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistview/incrementalmodel.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "incrementalmodel.h"
-#include <QApplication>
-#include <QDebug>
-
-IncrementalModel::IncrementalModel(QObject *parent)
- : QAbstractListModel(parent), count(0)
-{
- for (int i = 0; i < 100; ++i)
- list.append("Item " + QString::number(i));
-}
-
-int IncrementalModel::rowCount(const QModelIndex & /* parent */) const
-{
- return count;
-}
-
-QVariant IncrementalModel::data(const QModelIndex &index, int role) const
-{
- if (!index.isValid())
- return QVariant();
-
- if (index.row() >= list.size() || index.row() < 0)
- return QVariant();
-
- if (role == Qt::DisplayRole)
- return list.at(index.row());
- return QVariant();
-}
-
-bool IncrementalModel::canFetchMore(const QModelIndex & /* index */) const
-{
- if (count < list.size())
- return true;
- else
- return false;
-}
-
-void IncrementalModel::fetchMore(const QModelIndex & /* index */)
-{
- int remainder = list.size() - count;
- int itemsToFetch = qMin(5, remainder);
-
- beginInsertRows(QModelIndex(), count, count+itemsToFetch-1);
-
- count += itemsToFetch;
-
- endInsertRows();
-}
diff --git a/tests/auto/qtquick1/qdeclarativelistview/incrementalmodel.h b/tests/auto/qtquick1/qdeclarativelistview/incrementalmodel.h
deleted file mode 100644
index bf524d16e6..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistview/incrementalmodel.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef IncrementalModel_H
-#define IncrementalModel_H
-
-#include <QAbstractListModel>
-#include <QList>
-#include <QStringList>
-
-class IncrementalModel : public QAbstractListModel
-{
- Q_OBJECT
-
-public:
- IncrementalModel(QObject *parent = 0);
-
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
-
-protected:
- bool canFetchMore(const QModelIndex &parent) const;
- void fetchMore(const QModelIndex &parent);
-
-private:
- QStringList list;
- int count;
-};
-
-#endif
diff --git a/tests/auto/qtquick1/qdeclarativelistview/qdeclarativelistview.pro b/tests/auto/qtquick1/qdeclarativelistview/qdeclarativelistview.pro
deleted file mode 100644
index 1f66d7f45f..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistview/qdeclarativelistview.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativelistview
-macx:CONFIG -= app_bundle
-
-HEADERS += incrementalmodel.h
-SOURCES += tst_qdeclarativelistview.cpp incrementalmodel.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib
diff --git a/tests/auto/qtquick1/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/qtquick1/qdeclarativelistview/tst_qdeclarativelistview.cpp
deleted file mode 100644
index 909c118330..0000000000
--- a/tests/auto/qtquick1/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ /dev/null
@@ -1,2892 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtCore/QStringListModel>
-#include <QtQuick1/qdeclarativeview.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtQuick1/private/qdeclarativeitem_p.h>
-#include <QtQuick1/private/qdeclarativelistview_p.h>
-#include <QtQuick1/private/qdeclarativetext_p.h>
-#include <QtQuick1/private/qdeclarativevisualitemmodel_p.h>
-#include <QtDeclarative/private/qlistmodelinterface_p.h>
-#include "incrementalmodel.h"
-
-class tst_QDeclarative1ListView : public QObject
-{
- Q_OBJECT
-public:
- tst_QDeclarative1ListView();
-
-private slots:
- // Test both QListModelInterface and QAbstractItemModel model types
- void qListModelInterface_items();
- void qAbstractItemModel_items();
-
- void qListModelInterface_changed();
- void qAbstractItemModel_changed();
-
- void qListModelInterface_inserted();
- void qAbstractItemModel_inserted();
-
- void qListModelInterface_removed();
- void qAbstractItemModel_removed();
-
- void qListModelInterface_moved();
- void qAbstractItemModel_moved();
-
- void qListModelInterface_clear();
- void qAbstractItemModel_clear();
-
- void itemList();
- void currentIndex();
- void noCurrentIndex();
- void enforceRange();
- void spacing();
- void sections();
- void sectionsDelegate();
- void cacheBuffer();
- void positionViewAtIndex();
- void resetModel();
- void propertyChanges();
- void componentChanges();
- void modelChanges();
- void QTBUG_9791();
- void manualHighlight();
- void QTBUG_11105();
- void header();
- void footer();
- void headerFooter();
- void resizeView();
- void sizeLessThan1();
- void QTBUG_14821();
- void resizeDelegate();
- void QTBUG_16037();
- void indexAt();
- void incrementalModel();
- void onAdd();
- void onAdd_data();
- void onRemove();
- void onRemove_data();
- void testQtQuick11Attributes();
- void testQtQuick11Attributes_data();
- void rightToLeft();
- void test_mirroring();
- void orientationChange();
- void contentPosJump();
-
-private:
- template <class T> void items();
- template <class T> void changed();
- template <class T> void inserted();
- template <class T> void removed(bool animated);
- template <class T> void moved();
- template <class T> void clear();
- QDeclarativeView *createView();
- template<typename T>
- T *findItem(QGraphicsObject *parent, const QString &id, int index=-1);
- template<typename T>
- QList<T*> findItems(QGraphicsObject *parent, const QString &objectName);
- void dumpTree(QDeclarativeItem *parent, int depth = 0);
-};
-
-class TestObject : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(bool error READ error WRITE setError NOTIFY changedError)
- Q_PROPERTY(bool animate READ animate NOTIFY changedAnim)
- Q_PROPERTY(bool invalidHighlight READ invalidHighlight NOTIFY changedHl)
- Q_PROPERTY(int cacheBuffer READ cacheBuffer NOTIFY changedCacheBuffer)
-
-public:
- TestObject(QObject *parent = 0)
- : QObject(parent), mError(true), mAnimate(false), mInvalidHighlight(false)
- , mCacheBuffer(0) {}
-
- bool error() const { return mError; }
- void setError(bool err) { mError = err; emit changedError(); }
-
- bool animate() const { return mAnimate; }
- void setAnimate(bool anim) { mAnimate = anim; emit changedAnim(); }
-
- bool invalidHighlight() const { return mInvalidHighlight; }
- void setInvalidHighlight(bool invalid) { mInvalidHighlight = invalid; emit changedHl(); }
-
- int cacheBuffer() const { return mCacheBuffer; }
- void setCacheBuffer(int buffer) { mCacheBuffer = buffer; emit changedCacheBuffer(); }
-
-signals:
- void changedError();
- void changedAnim();
- void changedHl();
- void changedCacheBuffer();
-
-public:
- bool mError;
- bool mAnimate;
- bool mInvalidHighlight;
- int mCacheBuffer;
-};
-
-class TestModel : public QListModelInterface
-{
- Q_OBJECT
-public:
- TestModel(QObject *parent = 0) : QListModelInterface(parent) {}
- ~TestModel() {}
-
- enum Roles { Name, Number };
-
- QString name(int index) const { return list.at(index).first; }
- QString number(int index) const { return list.at(index).second; }
-
- int count() const { return list.count(); }
-
- QList<int> roles() const { return QList<int>() << Name << Number; }
- QString toString(int role) const {
- switch(role) {
- case Name:
- return "name";
- case Number:
- return "number";
- default:
- return "";
- }
- }
-
- QVariant data(int index, int role) const
- {
- if (role==0)
- return list.at(index).first;
- if (role==1)
- return list.at(index).second;
- return QVariant();
- }
- QHash<int, QVariant> data(int index, const QList<int> &roles) const {
- QHash<int,QVariant> returnHash;
-
- for (int i = 0; i < roles.size(); ++i) {
- int role = roles.at(i);
- QVariant info;
- switch(role) {
- case Name:
- info = list.at(index).first;
- break;
- case Number:
- info = list.at(index).second;
- break;
- default:
- break;
- }
- returnHash.insert(role, info);
- }
- return returnHash;
- }
-
- void addItem(const QString &name, const QString &number) {
- list.append(QPair<QString,QString>(name, number));
- emit itemsInserted(list.count()-1, 1);
- }
-
- void insertItem(int index, const QString &name, const QString &number) {
- list.insert(index, QPair<QString,QString>(name, number));
- emit itemsInserted(index, 1);
- }
-
- void removeItem(int index) {
- list.removeAt(index);
- emit itemsRemoved(index, 1);
- }
-
- void removeItems(int index, int count) {
- int c = count;
- while (c--)
- list.removeAt(index);
- emit itemsRemoved(index, count);
- }
-
- void moveItem(int from, int to) {
- list.move(from, to);
- emit itemsMoved(from, to, 1);
- }
-
- void modifyItem(int index, const QString &name, const QString &number) {
- list[index] = QPair<QString,QString>(name, number);
- emit itemsChanged(index, 1, roles());
- }
-
- void clear() {
- int count = list.count();
- list.clear();
- emit itemsRemoved(0, count);
- }
-
-private:
- QList<QPair<QString,QString> > list;
-};
-
-
-class TestModel2 : public QAbstractListModel
-{
-public:
- enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 };
-
- TestModel2(QObject *parent=0) : QAbstractListModel(parent) {
- QHash<int, QByteArray> roles;
- roles[Name] = "name";
- roles[Number] = "number";
- setRoleNames(roles);
- }
-
- int rowCount(const QModelIndex &parent=QModelIndex()) const { Q_UNUSED(parent); return list.count(); }
- QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const {
- QVariant rv;
- if (role == Name)
- rv = list.at(index.row()).first;
- else if (role == Number)
- rv = list.at(index.row()).second;
-
- return rv;
- }
-
- int count() const { return rowCount(); }
- QString name(int index) const { return list.at(index).first; }
- QString number(int index) const { return list.at(index).second; }
-
- void addItem(const QString &name, const QString &number) {
- emit beginInsertRows(QModelIndex(), list.count(), list.count());
- list.append(QPair<QString,QString>(name, number));
- emit endInsertRows();
- }
-
- void addItems(const QList<QPair<QString, QString> > &items) {
- emit beginInsertRows(QModelIndex(), list.count(), list.count()+items.count()-1);
- for (int i=0; i<items.count(); i++)
- list.append(QPair<QString,QString>(items[i].first, items[i].second));
- emit endInsertRows();
- }
-
- void insertItem(int index, const QString &name, const QString &number) {
- emit beginInsertRows(QModelIndex(), index, index);
- list.insert(index, QPair<QString,QString>(name, number));
- emit endInsertRows();
- }
-
- void removeItem(int index) {
- emit beginRemoveRows(QModelIndex(), index, index);
- list.removeAt(index);
- emit endRemoveRows();
- }
-
- void removeItems(int index, int count) {
- emit beginRemoveRows(QModelIndex(), index, index+count-1);
- while (count--)
- list.removeAt(index);
- emit endRemoveRows();
- }
-
- void moveItem(int from, int to) {
- emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
- list.move(from, to);
- emit endMoveRows();
- }
-
- void modifyItem(int idx, const QString &name, const QString &number) {
- list[idx] = QPair<QString,QString>(name, number);
- emit dataChanged(index(idx,0), index(idx,0));
- }
-
- void clear() {
- int count = list.count();
- emit beginRemoveRows(QModelIndex(), 0, count-1);
- list.clear();
- emit endRemoveRows();
- }
-
-private:
- QList<QPair<QString,QString> > list;
-};
-
-tst_QDeclarative1ListView::tst_QDeclarative1ListView()
-{
-}
-
-template <class T>
-void tst_QDeclarative1ListView::items()
-{
- QDeclarativeView *canvas = createView();
-
- T model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml"));
- qApp->processEvents();
-
- QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QTRY_VERIFY(testObject->error() == false);
-
- QTRY_VERIFY(listview->highlightItem() != 0);
- QTRY_COMPARE(listview->count(), model.count());
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
- QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- // current item should be first item
- QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 0));
-
- for (int i = 0; i < model.count(); ++i) {
- QDeclarative1Text *name = findItem<QDeclarative1Text>(contentItem, "textName", i);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- QDeclarative1Text *number = findItem<QDeclarative1Text>(contentItem, "textNumber", i);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
-
- // switch to other delegate
- testObject->setAnimate(true);
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QTRY_VERIFY(testObject->error() == false);
- QTRY_VERIFY(listview->currentItem());
-
- // set invalid highlight
- testObject->setInvalidHighlight(true);
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QTRY_VERIFY(testObject->error() == false);
- QTRY_VERIFY(listview->currentItem());
- QTRY_VERIFY(listview->highlightItem() == 0);
-
- // back to normal highlight
- testObject->setInvalidHighlight(false);
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QTRY_VERIFY(testObject->error() == false);
- QTRY_VERIFY(listview->currentItem());
- QTRY_VERIFY(listview->highlightItem() != 0);
-
- // set an empty model and confirm that items are destroyed
- T model2;
- ctxt->setContextProperty("testModel", &model2);
-
- int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- QTRY_VERIFY(itemCount == 0);
-
- QTRY_COMPARE(listview->highlightResizeSpeed(), 1000.0);
- QTRY_COMPARE(listview->highlightMoveSpeed(), 1000.0);
-
- delete canvas;
- delete testObject;
-}
-
-
-template <class T>
-void tst_QDeclarative1ListView::changed()
-{
- QDeclarativeView *canvas = createView();
-
- T model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml"));
- qApp->processEvents();
-
- QDeclarative1Flickable *listview = findItem<QDeclarative1Flickable>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- model.modifyItem(1, "Will", "9876");
- QDeclarative1Text *name = findItem<QDeclarative1Text>(contentItem, "textName", 1);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(1));
- QDeclarative1Text *number = findItem<QDeclarative1Text>(contentItem, "textNumber", 1);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(1));
-
- delete canvas;
- delete testObject;
-}
-
-template <class T>
-void tst_QDeclarative1ListView::inserted()
-{
- QDeclarativeView *canvas = createView();
-
- T model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml"));
- qApp->processEvents();
-
- QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- model.insertItem(1, "Will", "9876");
-
- QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- QDeclarative1Text *name = findItem<QDeclarative1Text>(contentItem, "textName", 1);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(1));
- QDeclarative1Text *number = findItem<QDeclarative1Text>(contentItem, "textNumber", 1);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(1));
-
- // Confirm items positioned correctly
- for (int i = 0; i < model.count(); ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- QTRY_COMPARE(item->y(), i*20.0);
- }
-
- model.insertItem(0, "Foo", "1111"); // zero index, and current item
-
- QCOMPARE(canvas->rootObject()->property("count").toInt(), model.count());
- QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- name = findItem<QDeclarative1Text>(contentItem, "textName", 0);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(0));
- number = findItem<QDeclarative1Text>(contentItem, "textNumber", 0);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(0));
-
- QTRY_COMPARE(listview->currentIndex(), 1);
-
- // Confirm items positioned correctly
- for (int i = 0; i < model.count(); ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- QTRY_COMPARE(item->y(), i*20.0);
- }
-
- for (int i = model.count(); i < 30; ++i)
- model.insertItem(i, "Hello", QString::number(i));
-
- listview->setContentY(80);
-
- // Insert item outside visible area
- model.insertItem(1, "Hello", "1324");
-
- QTRY_VERIFY(listview->contentY() == 80);
-
- // Confirm items positioned correctly
- for (int i = 5; i < 5+15; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.0 - 20.0);
- }
-
-// QTRY_COMPARE(listview->contentItemHeight(), model.count() * 20.0);
-
- // QTBUG-19675
- model.clear();
- model.insertItem(0, "Hello", "1234");
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->y(), 0.);
- QVERIFY(listview->contentY() == 0);
-
- delete canvas;
- delete testObject;
-}
-
-template <class T>
-void tst_QDeclarative1ListView::removed(bool animated)
-{
- QDeclarativeView *canvas = createView();
-
- T model;
- for (int i = 0; i < 50; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- testObject->setAnimate(animated);
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml"));
- qApp->processEvents();
-
- QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- model.removeItem(1);
- QCOMPARE(canvas->rootObject()->property("count").toInt(), model.count());
-
- QDeclarative1Text *name = findItem<QDeclarative1Text>(contentItem, "textName", 1);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(1));
- QDeclarative1Text *number = findItem<QDeclarative1Text>(contentItem, "textNumber", 1);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(1));
-
- // Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_VERIFY(item->y() == i*20);
- }
-
- // Remove first item (which is the current item);
- model.removeItem(0); // post: top item starts at 20
-
- QTest::qWait(300);
-
- name = findItem<QDeclarative1Text>(contentItem, "textName", 0);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(0));
- number = findItem<QDeclarative1Text>(contentItem, "textNumber", 0);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(0));
-
- // Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(),i*20.0 + 20.0);
- }
-
- // Remove items not visible
- model.removeItem(18);
- qApp->processEvents();
-
- // Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(),i*20.0+20.0);
- }
-
- // Remove items before visible
- listview->setContentY(80);
- listview->setCurrentIndex(10);
-
- model.removeItem(1); // post: top item will be at 40
- qApp->processEvents();
-
- // Confirm items positioned correctly
- for (int i = 2; i < 18; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(),40+i*20.0);
- }
-
- // Remove current index
- QTRY_VERIFY(listview->currentIndex() == 9);
- QDeclarativeItem *oldCurrent = listview->currentItem();
- model.removeItem(9);
-
- QTRY_COMPARE(listview->currentIndex(), 9);
- QTRY_VERIFY(listview->currentItem() != oldCurrent);
-
- listview->setContentY(40); // That's the top now
- // let transitions settle.
- QTest::qWait(300);
-
- // Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(),40+i*20.0);
- }
-
- // remove current item beyond visible items.
- listview->setCurrentIndex(20);
- listview->setContentY(40);
- model.removeItem(20);
-
- QTRY_COMPARE(listview->currentIndex(), 20);
- QTRY_VERIFY(listview->currentItem() != 0);
-
- // remove item before current, but visible
- listview->setCurrentIndex(8);
- oldCurrent = listview->currentItem();
- model.removeItem(6);
-
- QTRY_COMPARE(listview->currentIndex(), 7);
- QTRY_VERIFY(listview->currentItem() == oldCurrent);
-
- listview->setContentY(80);
- QTest::qWait(300);
-
- // remove all visible items
- model.removeItems(1, 18);
- QTest::qWait(300);
-
- // Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i+2);
- if (!item) qWarning() << "Item" << i+2 << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(),80+i*20.0);
- }
-
- model.removeItems(1, 17);
-// QTest::qWait(300);
-
- model.removeItems(2, 1);
- model.addItem("New", "1");
-
- QTRY_VERIFY(name = findItem<QDeclarative1Text>(contentItem, "textName", model.count()-1));
- QCOMPARE(name->text(), QString("New"));
-
- // Add some more items so that we don't run out
- model.clear();
- for (int i = 0; i < 50; i++)
- model.addItem("Item" + QString::number(i), "");
-
- // QTBUG-QTBUG-20575
- listview->setCurrentIndex(0);
- listview->setContentY(30);
- model.removeItem(0);
- QTRY_VERIFY(name = findItem<QDeclarative1Text>(contentItem, "textName", 0));
-
- // QTBUG-19198 move to end and remove all visible items one at a time.
- listview->positionViewAtEnd();
- for (int i = 0; i < 18; ++i)
- model.removeItems(model.count() - 1, 1);
- QTRY_VERIFY(findItems<QDeclarativeItem>(contentItem, "wrapper").count() > 16);
-
- delete canvas;
- delete testObject;
-}
-
-template <class T>
-void tst_QDeclarative1ListView::clear()
-{
- QDeclarativeView *canvas = createView();
-
- T model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml"));
- qApp->processEvents();
-
- QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- model.clear();
-
- QTRY_VERIFY(listview->count() == 0);
- QTRY_VERIFY(listview->currentItem() == 0);
- QTRY_VERIFY(listview->contentY() == 0);
- QVERIFY(listview->currentIndex() == -1);
-
- // confirm sanity when adding an item to cleared list
- model.addItem("New", "1");
- QTRY_VERIFY(listview->count() == 1);
- QVERIFY(listview->currentItem() != 0);
- QVERIFY(listview->currentIndex() == 0);
-
- delete canvas;
- delete testObject;
-}
-
-
-template <class T>
-void tst_QDeclarative1ListView::moved()
-{
- QDeclarativeView *canvas = createView();
-
- T model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml"));
- qApp->processEvents();
-
- QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- model.moveItem(1, 4);
-
- QDeclarative1Text *name = findItem<QDeclarative1Text>(contentItem, "textName", 1);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(1));
- QDeclarative1Text *number = findItem<QDeclarative1Text>(contentItem, "textNumber", 1);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(1));
-
- name = findItem<QDeclarative1Text>(contentItem, "textName", 4);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(4));
- number = findItem<QDeclarative1Text>(contentItem, "textNumber", 4);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(4));
-
- // Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_VERIFY(item->y() == i*20);
- }
-
- listview->setContentY(80);
-
- // move outside visible area
- model.moveItem(1, 18);
-
- // Confirm items positioned correctly and indexes correct
- for (int i = 3; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.0 + 20);
- name = findItem<QDeclarative1Text>(contentItem, "textName", i);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- number = findItem<QDeclarative1Text>(contentItem, "textNumber", i);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
-
- // move from outside visible into visible
- model.moveItem(20, 4);
-
- // Confirm items positioned correctly and indexes correct
- for (int i = 3; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.0 + 20);
- name = findItem<QDeclarative1Text>(contentItem, "textName", i);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- number = findItem<QDeclarative1Text>(contentItem, "textNumber", i);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QDeclarative1ListView::enforceRange()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview-enforcerange.qml"));
- qApp->processEvents();
-
- QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QTRY_COMPARE(listview->preferredHighlightBegin(), 100.0);
- QTRY_COMPARE(listview->preferredHighlightEnd(), 100.0);
- QTRY_COMPARE(listview->highlightRangeMode(), QDeclarative1ListView::StrictlyEnforceRange);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // view should be positioned at the top of the range.
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", 0);
- QTRY_VERIFY(item);
- QTRY_COMPARE(listview->contentY(), -100.0);
-
- QDeclarative1Text *name = findItem<QDeclarative1Text>(contentItem, "textName", 0);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(0));
- QDeclarative1Text *number = findItem<QDeclarative1Text>(contentItem, "textNumber", 0);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(0));
-
- // Check currentIndex is updated when contentItem moves
- listview->setContentY(20);
-
- QTRY_COMPARE(listview->currentIndex(), 6);
-
- // change model
- TestModel model2;
- for (int i = 0; i < 5; i++)
- model2.addItem("Item" + QString::number(i), "");
-
- ctxt->setContextProperty("testModel", &model2);
- QCOMPARE(listview->count(), 5);
-
- delete canvas;
-}
-
-void tst_QDeclarative1ListView::spacing()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml"));
- qApp->processEvents();
-
- QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_VERIFY(item->y() == i*20);
- }
-
- listview->setSpacing(10);
- QTRY_VERIFY(listview->spacing() == 10);
-
- // Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_VERIFY(item->y() == i*30);
- }
-
- listview->setSpacing(0);
-
- // Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.0);
- }
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QDeclarative1ListView::sections()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), QString::number(i/5));
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview-sections.qml"));
- qApp->processEvents();
-
- QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), qreal(i*20 + ((i+4)/5) * 20));
- QDeclarative1Text *next = findItem<QDeclarative1Text>(item, "nextSection");
- QCOMPARE(next->text().toInt(), (i+1)/5);
- }
-
- QSignalSpy currentSectionChangedSpy(listview, SIGNAL(currentSectionChanged()));
-
- // Remove section boundary
- model.removeItem(5);
-
- // New section header created
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", 5);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->height(), 40.0);
-
- model.insertItem(3, "New Item", "0");
-
- // Section header moved
- item = findItem<QDeclarativeItem>(contentItem, "wrapper", 5);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->height(), 20.0);
-
- item = findItem<QDeclarativeItem>(contentItem, "wrapper", 6);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->height(), 40.0);
-
- // insert item which will become a section header
- model.insertItem(6, "Replace header", "1");
-
- item = findItem<QDeclarativeItem>(contentItem, "wrapper", 6);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->height(), 40.0);
-
- item = findItem<QDeclarativeItem>(contentItem, "wrapper", 7);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->height(), 20.0);
-
- QTRY_COMPARE(listview->currentSection(), QString("0"));
-
- listview->setContentY(140);
- QTRY_COMPARE(listview->currentSection(), QString("1"));
-
- QTRY_COMPARE(currentSectionChangedSpy.count(), 1);
-
- listview->setContentY(20);
- QTRY_COMPARE(listview->currentSection(), QString("0"));
-
- QTRY_COMPARE(currentSectionChangedSpy.count(), 2);
-
- item = findItem<QDeclarativeItem>(contentItem, "wrapper", 1);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->height(), 20.0);
-
- // check that headers change when item changes
- listview->setContentY(0);
- model.modifyItem(0, "changed", "2");
-
- item = findItem<QDeclarativeItem>(contentItem, "wrapper", 1);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->height(), 40.0);
-
- delete canvas;
-}
-
-void tst_QDeclarative1ListView::sectionsDelegate()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), QString::number(i/5));
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview-sections_delegate.qml"));
- qApp->processEvents();
-
- QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), qreal(i*20 + ((i+5)/5) * 20));
- QDeclarative1Text *next = findItem<QDeclarative1Text>(item, "nextSection");
- QCOMPARE(next->text().toInt(), (i+1)/5);
- }
-
- for (int i = 0; i < 3; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "sect_" + QString::number(i));
- QVERIFY(item);
- QTRY_COMPARE(item->y(), qreal(i*20*6));
- }
-
- 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");
-
- for (int i = 0; i < 3; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem,
- "sect_" + (i == 0 ? QString("aaa") : QString::number(i)));
- QVERIFY(item);
- QTRY_COMPARE(item->y(), qreal(i*20*6));
- }
-
- // remove section boundary
- model.removeItem(5);
- qApp->processEvents();
- for (int i = 0; i < 3; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem,
- "sect_" + (i == 0 ? QString("aaa") : QString::number(i)));
- QVERIFY(item);
- }
-
- // QTBUG-17606
- QList<QDeclarativeItem*> items = findItems<QDeclarativeItem>(contentItem, "sect_1");
- QCOMPARE(items.count(), 1);
-
- // QTBUG-17759
- model.modifyItem(0, "One", "aaa");
- model.modifyItem(1, "One", "aaa");
- model.modifyItem(2, "One", "aaa");
- model.modifyItem(3, "Four", "aaa");
- model.modifyItem(4, "Four", "aaa");
- model.modifyItem(5, "Four", "aaa");
- model.modifyItem(6, "Five", "aaa");
- model.modifyItem(7, "Five", "aaa");
- model.modifyItem(8, "Five", "aaa");
- model.modifyItem(9, "Two", "aaa");
- model.modifyItem(10, "Two", "aaa");
- model.modifyItem(11, "Two", "aaa");
- QTRY_COMPARE(findItems<QDeclarativeItem>(contentItem, "sect_aaa").count(), 1);
- canvas->rootObject()->setProperty("sectionProperty", "name");
- // ensure view has settled.
- QTRY_COMPARE(findItems<QDeclarativeItem>(contentItem, "sect_Four").count(), 1);
- for (int i = 0; i < 4; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem,
- "sect_" + model.name(i*3));
- QVERIFY(item);
- QTRY_COMPARE(item->y(), qreal(i*20*4));
- }
-
- // QTBUG-17769
- model.removeItems(10, 20);
- // ensure view has settled.
- QTRY_COMPARE(findItems<QDeclarativeItem>(contentItem, "wrapper").count(), 10);
- // Drag view up beyond bounds
- QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(20,20)));
- {
- QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,0)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(canvas->viewport(), &mv);
- }
- {
- QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,-50)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(canvas->viewport(), &mv);
- }
- {
- QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,-200)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(canvas->viewport(), &mv);
- }
- QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(20,-200)));
- // view should settle back at 0
- QTRY_COMPARE(listview->contentY(), 0.0);
-
- delete canvas;
-}
-
-void tst_QDeclarative1ListView::currentIndex()
-{
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), QString::number(i));
-
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setFixedSize(240,320);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testWrap", QVariant(false));
-
- QString filename(SRCDIR "/data/listview-initCurrent.qml");
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- qApp->processEvents();
-
- QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // current item should be 20th item at startup
- // and current item should be in view
- QCOMPARE(listview->currentIndex(), 20);
- QCOMPARE(listview->contentY(), 100.0);
- QCOMPARE(listview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 20));
- QCOMPARE(listview->highlightItem()->y(), listview->currentItem()->y());
-
- // no wrap
- listview->setCurrentIndex(0);
- QCOMPARE(listview->currentIndex(), 0);
- // confirm that the velocity is updated
- QTRY_VERIFY(listview->verticalVelocity() != 0.0);
-
- listview->incrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), 1);
- listview->decrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), 0);
-
- listview->decrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), 0);
-
- // with wrap
- ctxt->setContextProperty("testWrap", QVariant(true));
- QVERIFY(listview->isWrapEnabled());
-
- listview->decrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), model.count()-1);
-
- QTRY_COMPARE(listview->contentY(), 280.0);
-
- listview->incrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), 0);
-
- QTRY_COMPARE(listview->contentY(), 0.0);
-
- // Test keys
- canvas->show();
- qApp->setActiveWindow(canvas);
-#ifdef Q_WS_X11
- // to be safe and avoid failing setFocus with window managers
- qt_x11_wait_for_window_manager(canvas);
-#endif
- QTRY_VERIFY(canvas->hasFocus());
- QTRY_VERIFY(canvas->scene()->hasFocus());
- qApp->processEvents();
-
- QTest::keyClick(canvas, Qt::Key_Down);
- QCOMPARE(listview->currentIndex(), 1);
-
- QTest::keyClick(canvas, Qt::Key_Up);
- QCOMPARE(listview->currentIndex(), 0);
-
- // turn off auto highlight
- listview->setHighlightFollowsCurrentItem(false);
- QVERIFY(listview->highlightFollowsCurrentItem() == false);
-
- QVERIFY(listview->highlightItem());
- qreal hlPos = listview->highlightItem()->y();
-
- listview->setCurrentIndex(4);
- QTRY_COMPARE(listview->highlightItem()->y(), hlPos);
-
- // insert item before currentIndex
- listview->setCurrentIndex(28);
- model.insertItem(0, "Foo", "1111");
- QTRY_COMPARE(canvas->rootObject()->property("current").toInt(), 29);
-
- // check removing highlight by setting currentIndex to -1;
- listview->setCurrentIndex(-1);
-
- QCOMPARE(listview->currentIndex(), -1);
- QVERIFY(!listview->highlightItem());
- QVERIFY(!listview->currentItem());
-
- delete canvas;
-}
-
-void tst_QDeclarative1ListView::noCurrentIndex()
-{
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), QString::number(i));
-
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setFixedSize(240,320);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- QString filename(SRCDIR "/data/listview-noCurrent.qml");
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- qApp->processEvents();
-
- QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // current index should be -1 at startup
- // and we should not have a currentItem or highlightItem
- QCOMPARE(listview->currentIndex(), -1);
- QCOMPARE(listview->contentY(), 0.0);
- QVERIFY(!listview->highlightItem());
- QVERIFY(!listview->currentItem());
-
- listview->setCurrentIndex(2);
- QCOMPARE(listview->currentIndex(), 2);
- QVERIFY(listview->highlightItem());
- QVERIFY(listview->currentItem());
-
- delete canvas;
-}
-
-void tst_QDeclarative1ListView::itemList()
-{
- QDeclarativeView *canvas = createView();
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/itemlist.qml"));
- qApp->processEvents();
-
- QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "view");
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QDeclarative1VisualItemModel *model = canvas->rootObject()->findChild<QDeclarative1VisualItemModel*>("itemModel");
- QTRY_VERIFY(model != 0);
-
- QTRY_VERIFY(model->count() == 3);
- QTRY_COMPARE(listview->currentIndex(), 0);
-
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "item1");
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), 0.0);
- QCOMPARE(item->height(), listview->height());
-
- QDeclarative1Text *text = findItem<QDeclarative1Text>(contentItem, "text1");
- QTRY_VERIFY(text);
- QTRY_COMPARE(text->text(), QLatin1String("index: 0"));
-
- listview->setCurrentIndex(2);
-
- item = findItem<QDeclarativeItem>(contentItem, "item3");
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), 480.0);
-
- text = findItem<QDeclarative1Text>(contentItem, "text3");
- QTRY_VERIFY(text);
- QTRY_COMPARE(text->text(), QLatin1String("index: 2"));
-
- delete canvas;
-}
-
-void tst_QDeclarative1ListView::cacheBuffer()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml"));
- qApp->processEvents();
-
- QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_VERIFY(listview->delegate() != 0);
- QTRY_VERIFY(listview->model() != 0);
- QTRY_VERIFY(listview->highlight() != 0);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_VERIFY(item->y() == i*20);
- }
-
- testObject->setCacheBuffer(400);
- QTRY_VERIFY(listview->cacheBuffer() == 400);
-
- int newItemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- QTRY_VERIFY(newItemCount > itemCount);
-
- // Confirm items positioned correctly
- for (int i = 0; i < model.count() && i < newItemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_VERIFY(item->y() == i*20);
- }
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QDeclarative1ListView::positionViewAtIndex()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml"));
- qApp->processEvents();
-
- QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.);
- }
-
- // Position on a currently visible item
- listview->positionViewAtIndex(3, QDeclarative1ListView::Beginning);
- QTRY_COMPARE(listview->contentY(), 60.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.);
- }
-
- // Position on an item beyond the visible items
- listview->positionViewAtIndex(22, QDeclarative1ListView::Beginning);
- QTRY_COMPARE(listview->contentY(), 440.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.);
- }
-
- // Position on an item that would leave empty space if positioned at the top
- listview->positionViewAtIndex(28, QDeclarative1ListView::Beginning);
- QTRY_COMPARE(listview->contentY(), 480.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.);
- }
-
- // Position at the beginning again
- listview->positionViewAtIndex(0, QDeclarative1ListView::Beginning);
- QTRY_COMPARE(listview->contentY(), 0.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.);
- }
-
- // Position at End using last index
- listview->positionViewAtIndex(model.count()-1, QDeclarative1ListView::End);
- QTRY_COMPARE(listview->contentY(), 480.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 24; i < model.count(); ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.);
- }
-
- // Position at End
- listview->positionViewAtIndex(20, QDeclarative1ListView::End);
- QTRY_COMPARE(listview->contentY(), 100.);
-
- // Position in Center
- listview->positionViewAtIndex(15, QDeclarative1ListView::Center);
- QTRY_COMPARE(listview->contentY(), 150.);
-
- // Ensure at least partially visible
- listview->positionViewAtIndex(15, QDeclarative1ListView::Visible);
- QTRY_COMPARE(listview->contentY(), 150.);
-
- listview->setContentY(302);
- listview->positionViewAtIndex(15, QDeclarative1ListView::Visible);
- QTRY_COMPARE(listview->contentY(), 302.);
-
- listview->setContentY(320);
- listview->positionViewAtIndex(15, QDeclarative1ListView::Visible);
- QTRY_COMPARE(listview->contentY(), 300.);
-
- listview->setContentY(85);
- listview->positionViewAtIndex(20, QDeclarative1ListView::Visible);
- QTRY_COMPARE(listview->contentY(), 85.);
-
- listview->setContentY(75);
- listview->positionViewAtIndex(20, QDeclarative1ListView::Visible);
- QTRY_COMPARE(listview->contentY(), 100.);
-
- // Ensure completely visible
- listview->setContentY(120);
- listview->positionViewAtIndex(20, QDeclarative1ListView::Contain);
- QTRY_COMPARE(listview->contentY(), 120.);
-
- listview->setContentY(302);
- listview->positionViewAtIndex(15, QDeclarative1ListView::Contain);
- QTRY_COMPARE(listview->contentY(), 300.);
-
- listview->setContentY(85);
- listview->positionViewAtIndex(20, QDeclarative1ListView::Contain);
- QTRY_COMPARE(listview->contentY(), 100.);
-
- // positionAtBeginnging
- listview->positionViewAtBeginning();
- QTRY_COMPARE(listview->contentY(), 0.);
-
- listview->setContentY(80);
- canvas->rootObject()->setProperty("showHeader", true);
- listview->positionViewAtBeginning();
- QTRY_COMPARE(listview->contentY(), -30.);
-
- // positionAtEnd
- listview->positionViewAtEnd();
- QTRY_COMPARE(listview->contentY(), 480.); // 40*20 - 320
-
- listview->setContentY(80);
- canvas->rootObject()->setProperty("showFooter", true);
- listview->positionViewAtEnd();
- QTRY_COMPARE(listview->contentY(), 510.);
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QDeclarative1ListView::resetModel()
-{
- QDeclarativeView *canvas = createView();
-
- QStringList strings;
- strings << "one" << "two" << "three";
- QStringListModel model(strings);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/displaylist.qml"));
- qApp->processEvents();
-
- QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QTRY_COMPARE(listview->count(), model.rowCount());
-
- for (int i = 0; i < model.rowCount(); ++i) {
- QDeclarative1Text *display = findItem<QDeclarative1Text>(contentItem, "displayText", i);
- QTRY_VERIFY(display != 0);
- QTRY_COMPARE(display->text(), strings.at(i));
- }
-
- strings.clear();
- strings << "four" << "five" << "six" << "seven";
- model.setStringList(strings);
-
- QTRY_COMPARE(listview->count(), model.rowCount());
-
- for (int i = 0; i < model.rowCount(); ++i) {
- QDeclarative1Text *display = findItem<QDeclarative1Text>(contentItem, "displayText", i);
- QTRY_VERIFY(display != 0);
- QTRY_COMPARE(display->text(), strings.at(i));
- }
-
- delete canvas;
-}
-
-void tst_QDeclarative1ListView::propertyChanges()
-{
- QDeclarativeView *canvas = createView();
- QTRY_VERIFY(canvas);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml"));
-
- QDeclarative1ListView *listView = canvas->rootObject()->findChild<QDeclarative1ListView*>("listView");
- QTRY_VERIFY(listView);
-
- QSignalSpy highlightFollowsCurrentItemSpy(listView, SIGNAL(highlightFollowsCurrentItemChanged()));
- QSignalSpy preferredHighlightBeginSpy(listView, SIGNAL(preferredHighlightBeginChanged()));
- QSignalSpy preferredHighlightEndSpy(listView, SIGNAL(preferredHighlightEndChanged()));
- QSignalSpy highlightRangeModeSpy(listView, SIGNAL(highlightRangeModeChanged()));
- QSignalSpy keyNavigationWrapsSpy(listView, SIGNAL(keyNavigationWrapsChanged()));
- QSignalSpy cacheBufferSpy(listView, SIGNAL(cacheBufferChanged()));
- QSignalSpy snapModeSpy(listView, SIGNAL(snapModeChanged()));
-
- QTRY_COMPARE(listView->highlightFollowsCurrentItem(), true);
- QTRY_COMPARE(listView->preferredHighlightBegin(), 0.0);
- QTRY_COMPARE(listView->preferredHighlightEnd(), 0.0);
- QTRY_COMPARE(listView->highlightRangeMode(), QDeclarative1ListView::ApplyRange);
- QTRY_COMPARE(listView->isWrapEnabled(), true);
- QTRY_COMPARE(listView->cacheBuffer(), 10);
- QTRY_COMPARE(listView->snapMode(), QDeclarative1ListView::SnapToItem);
-
- listView->setHighlightFollowsCurrentItem(false);
- listView->setPreferredHighlightBegin(1.0);
- listView->setPreferredHighlightEnd(1.0);
- listView->setHighlightRangeMode(QDeclarative1ListView::StrictlyEnforceRange);
- listView->setWrapEnabled(false);
- listView->setCacheBuffer(3);
- listView->setSnapMode(QDeclarative1ListView::SnapOneItem);
-
- QTRY_COMPARE(listView->highlightFollowsCurrentItem(), false);
- QTRY_COMPARE(listView->preferredHighlightBegin(), 1.0);
- QTRY_COMPARE(listView->preferredHighlightEnd(), 1.0);
- QTRY_COMPARE(listView->highlightRangeMode(), QDeclarative1ListView::StrictlyEnforceRange);
- QTRY_COMPARE(listView->isWrapEnabled(), false);
- QTRY_COMPARE(listView->cacheBuffer(), 3);
- QTRY_COMPARE(listView->snapMode(), QDeclarative1ListView::SnapOneItem);
-
- QTRY_COMPARE(highlightFollowsCurrentItemSpy.count(),1);
- QTRY_COMPARE(preferredHighlightBeginSpy.count(),1);
- QTRY_COMPARE(preferredHighlightEndSpy.count(),1);
- QTRY_COMPARE(highlightRangeModeSpy.count(),1);
- QTRY_COMPARE(keyNavigationWrapsSpy.count(),1);
- QTRY_COMPARE(cacheBufferSpy.count(),1);
- QTRY_COMPARE(snapModeSpy.count(),1);
-
- listView->setHighlightFollowsCurrentItem(false);
- listView->setPreferredHighlightBegin(1.0);
- listView->setPreferredHighlightEnd(1.0);
- listView->setHighlightRangeMode(QDeclarative1ListView::StrictlyEnforceRange);
- listView->setWrapEnabled(false);
- listView->setCacheBuffer(3);
- listView->setSnapMode(QDeclarative1ListView::SnapOneItem);
-
- QTRY_COMPARE(highlightFollowsCurrentItemSpy.count(),1);
- QTRY_COMPARE(preferredHighlightBeginSpy.count(),1);
- QTRY_COMPARE(preferredHighlightEndSpy.count(),1);
- QTRY_COMPARE(highlightRangeModeSpy.count(),1);
- QTRY_COMPARE(keyNavigationWrapsSpy.count(),1);
- QTRY_COMPARE(cacheBufferSpy.count(),1);
- QTRY_COMPARE(snapModeSpy.count(),1);
-
- delete canvas;
-}
-
-void tst_QDeclarative1ListView::componentChanges()
-{
- QDeclarativeView *canvas = createView();
- QTRY_VERIFY(canvas);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml"));
-
- QDeclarative1ListView *listView = canvas->rootObject()->findChild<QDeclarative1ListView*>("listView");
- QTRY_VERIFY(listView);
-
- QDeclarativeComponent component(canvas->engine());
- component.setData("import QtQuick 1.0; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile(""));
-
- QDeclarativeComponent delegateComponent(canvas->engine());
- delegateComponent.setData("import QtQuick 1.0; Text { text: '<b>Name:</b> ' + name }", QUrl::fromLocalFile(""));
-
- QSignalSpy highlightSpy(listView, SIGNAL(highlightChanged()));
- QSignalSpy delegateSpy(listView, SIGNAL(delegateChanged()));
- QSignalSpy headerSpy(listView, SIGNAL(headerChanged()));
- QSignalSpy footerSpy(listView, SIGNAL(footerChanged()));
-
- listView->setHighlight(&component);
- listView->setHeader(&component);
- listView->setFooter(&component);
- listView->setDelegate(&delegateComponent);
-
- QTRY_COMPARE(listView->highlight(), &component);
- QTRY_COMPARE(listView->header(), &component);
- QTRY_COMPARE(listView->footer(), &component);
- QTRY_COMPARE(listView->delegate(), &delegateComponent);
-
- QTRY_COMPARE(highlightSpy.count(),1);
- QTRY_COMPARE(delegateSpy.count(),1);
- QTRY_COMPARE(headerSpy.count(),1);
- QTRY_COMPARE(footerSpy.count(),1);
-
- listView->setHighlight(&component);
- listView->setHeader(&component);
- listView->setFooter(&component);
- listView->setDelegate(&delegateComponent);
-
- QTRY_COMPARE(highlightSpy.count(),1);
- QTRY_COMPARE(delegateSpy.count(),1);
- QTRY_COMPARE(headerSpy.count(),1);
- QTRY_COMPARE(footerSpy.count(),1);
-
- delete canvas;
-}
-
-void tst_QDeclarative1ListView::modelChanges()
-{
- QDeclarativeView *canvas = createView();
- QTRY_VERIFY(canvas);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml"));
-
- QDeclarative1ListView *listView = canvas->rootObject()->findChild<QDeclarative1ListView*>("listView");
- QTRY_VERIFY(listView);
-
- QObject *alternateModel = canvas->rootObject()->findChild<QObject*>("alternateModel");
- QTRY_VERIFY(alternateModel);
- QVariant modelVariant = QVariant::fromValue(alternateModel);
- QSignalSpy modelSpy(listView, SIGNAL(modelChanged()));
-
- listView->setModel(modelVariant);
- QTRY_COMPARE(listView->model(), modelVariant);
- QTRY_COMPARE(modelSpy.count(),1);
-
- listView->setModel(modelVariant);
- QTRY_COMPARE(modelSpy.count(),1);
-
- listView->setModel(QVariant());
- QTRY_COMPARE(modelSpy.count(),2);
-
- delete canvas;
-}
-
-void tst_QDeclarative1ListView::QTBUG_9791()
-{
- QDeclarativeView *canvas = createView();
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/strictlyenforcerange.qml"));
- qApp->processEvents();
-
- QDeclarative1ListView *listview = qobject_cast<QDeclarative1ListView*>(canvas->rootObject());
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_VERIFY(listview->delegate() != 0);
- QTRY_VERIFY(listview->model() != 0);
-
- QMetaObject::invokeMethod(listview, "fillModel");
- qApp->processEvents();
-
- // Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- QCOMPARE(itemCount, 3);
-
- for (int i = 0; i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), i*300.0);
- }
-
- // check that view is positioned correctly
- QTRY_COMPARE(listview->contentX(), 590.0);
-
- delete canvas;
-}
-
-void tst_QDeclarative1ListView::manualHighlight()
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setFixedSize(240,320);
-
- QString filename(SRCDIR "/data/manual-highlight.qml");
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- qApp->processEvents();
-
- QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QTRY_COMPARE(listview->currentIndex(), 0);
- QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 0));
- QTRY_COMPARE(listview->highlightItem()->y() - 5, listview->currentItem()->y());
-
- listview->setCurrentIndex(2);
-
- QTRY_COMPARE(listview->currentIndex(), 2);
- QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 2));
- QTRY_COMPARE(listview->highlightItem()->y() - 5, listview->currentItem()->y());
-
- // QTBUG-15972
- listview->positionViewAtIndex(3, QDeclarative1ListView::Contain);
-
- QTRY_COMPARE(listview->currentIndex(), 2);
- QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 2));
- QTRY_COMPARE(listview->highlightItem()->y() - 5, listview->currentItem()->y());
-
- delete canvas;
-}
-
-void tst_QDeclarative1ListView::QTBUG_11105()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml"));
- qApp->processEvents();
-
- QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_VERIFY(item->y() == i*20);
- }
-
- listview->positionViewAtIndex(20, QDeclarative1ListView::Beginning);
- QCOMPARE(listview->contentY(), 280.);
-
- TestModel model2;
- for (int i = 0; i < 5; i++)
- model2.addItem("Item" + QString::number(i), "");
-
- ctxt->setContextProperty("testModel", &model2);
-
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- QCOMPARE(itemCount, 5);
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QDeclarative1ListView::header()
-{
- {
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/header.qml"));
- qApp->processEvents();
-
- QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QDeclarative1Text *header = findItem<QDeclarative1Text>(contentItem, "header");
- QVERIFY(header);
- QCOMPARE(header->y(), 0.0);
- QCOMPARE(header->height(), 20.0);
-
- QCOMPARE(listview->contentY(), 0.0);
-
- model.clear();
- QTRY_COMPARE(header->y(), 0.0);
-
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QMetaObject::invokeMethod(canvas->rootObject(), "changeHeader");
-
- header = findItem<QDeclarative1Text>(contentItem, "header");
- QVERIFY(!header);
- header = findItem<QDeclarative1Text>(contentItem, "header2");
- QVERIFY(header);
-
- QCOMPARE(header->y(), 10.0);
- QCOMPARE(header->height(), 10.0);
- QCOMPARE(listview->contentY(), 10.0);
-
- delete canvas;
- }
- {
- QDeclarativeView *canvas = createView();
-
- TestModel model;
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/header1.qml"));
- qApp->processEvents();
-
- QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QDeclarative1Text *header = findItem<QDeclarative1Text>(contentItem, "header");
- QVERIFY(header);
- QCOMPARE(header->y(), 0.0);
-
- QCOMPARE(listview->contentY(), 0.0);
-
- model.clear();
- QTRY_COMPARE(header->y(), 0.0);
-
- delete canvas;
- }
- {
- // QTBUG-19844
- QDeclarativeView *canvas = createView();
-
- TestModel model;
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/header.qml"));
- qApp->processEvents();
-
- QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QDeclarative1Text *header = findItem<QDeclarative1Text>(contentItem, "header");
- QVERIFY(header);
-
- header->setHeight(500);
-
- model.addItem("Item 0", "");
-
- header->setHeight(40);
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", 0);
- QVERIFY(item);
- QTRY_VERIFY(header->y() + header->height() == item->y());
-
- delete canvas;
- }
-}
-
-void tst_QDeclarative1ListView::footer()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- for (int i = 0; i < 3; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/footer.qml"));
- qApp->processEvents();
-
- QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QDeclarative1Text *footer = findItem<QDeclarative1Text>(contentItem, "footer");
- QVERIFY(footer);
- QCOMPARE(footer->y(), 60.0);
- QCOMPARE(footer->height(), 30.0);
-
- model.removeItem(1);
- QTRY_COMPARE(footer->y(), 40.0);
-
- model.clear();
- QTRY_COMPARE(footer->y(), 0.0);
-
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QMetaObject::invokeMethod(canvas->rootObject(), "changeFooter");
-
- footer = findItem<QDeclarative1Text>(contentItem, "footer");
- QVERIFY(!footer);
- footer = findItem<QDeclarative1Text>(contentItem, "footer2");
- QVERIFY(footer);
-
- QCOMPARE(footer->y(), 600.0);
- QCOMPARE(footer->height(), 20.0);
- QCOMPARE(listview->contentY(), 0.0);
-
- delete canvas;
-}
-
-class LVAccessor : public QDeclarative1ListView
-{
-public:
- qreal minY() const { return minYExtent(); }
- qreal maxY() const { return maxYExtent(); }
- qreal minX() const { return minXExtent(); }
- qreal maxX() const { return maxXExtent(); }
-};
-
-void tst_QDeclarative1ListView::headerFooter()
-{
- {
- // Vertical
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/headerfooter.qml"));
- qApp->processEvents();
-
- QDeclarative1ListView *listview = qobject_cast<QDeclarative1ListView*>(canvas->rootObject());
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QDeclarativeItem *header = findItem<QDeclarativeItem>(contentItem, "header");
- QVERIFY(header);
- QCOMPARE(header->y(), 0.0);
-
- QDeclarativeItem *footer = findItem<QDeclarativeItem>(contentItem, "footer");
- QVERIFY(footer);
- QCOMPARE(footer->y(), 20.0);
-
- QVERIFY(static_cast<LVAccessor*>(listview)->minY() == 0);
- QVERIFY(static_cast<LVAccessor*>(listview)->maxY() == 0);
-
- delete canvas;
- }
- {
- // Horizontal
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/headerfooter.qml"));
- canvas->rootObject()->setProperty("horizontal", true);
- qApp->processEvents();
-
- QDeclarative1ListView *listview = qobject_cast<QDeclarative1ListView*>(canvas->rootObject());
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QDeclarativeItem *header = findItem<QDeclarativeItem>(contentItem, "header");
- QVERIFY(header);
- QCOMPARE(header->x(), 0.0);
-
- QDeclarativeItem *footer = findItem<QDeclarativeItem>(contentItem, "footer");
- QVERIFY(footer);
- QCOMPARE(footer->x(), 20.0);
-
- QVERIFY(static_cast<LVAccessor*>(listview)->minX() == 0);
- QVERIFY(static_cast<LVAccessor*>(listview)->maxX() == 0);
-
- delete canvas;
- }
- {
- // Horizontal RTL
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/headerfooter.qml"));
- canvas->rootObject()->setProperty("horizontal", true);
- canvas->rootObject()->setProperty("rtl", true);
- qApp->processEvents();
-
- QDeclarative1ListView *listview = qobject_cast<QDeclarative1ListView*>(canvas->rootObject());
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QDeclarativeItem *header = findItem<QDeclarativeItem>(contentItem, "header");
- QVERIFY(header);
- QCOMPARE(header->x(), -20.0);
-
- QDeclarativeItem *footer = findItem<QDeclarativeItem>(contentItem, "footer");
- QVERIFY(footer);
- QCOMPARE(footer->x(), -50.0);
-
- QCOMPARE(static_cast<LVAccessor*>(listview)->minX(), 240.);
- QCOMPARE(static_cast<LVAccessor*>(listview)->maxX(), 240.);
-
- delete canvas;
- }
-}
-
-void tst_QDeclarative1ListView::resizeView()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml"));
- qApp->processEvents();
-
- QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.);
- }
-
- QVariant heightRatio;
- QMetaObject::invokeMethod(canvas->rootObject(), "heightRatio", Q_RETURN_ARG(QVariant, heightRatio));
- QCOMPARE(heightRatio.toReal(), 0.4);
-
- listview->setHeight(200);
-
- QMetaObject::invokeMethod(canvas->rootObject(), "heightRatio", Q_RETURN_ARG(QVariant, heightRatio));
- QCOMPARE(heightRatio.toReal(), 0.25);
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QDeclarative1ListView::sizeLessThan1()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/sizelessthan1.qml"));
- qApp->processEvents();
-
- QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*0.5);
- }
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QDeclarative1ListView::QTBUG_14821()
-{
- QDeclarativeView *canvas = createView();
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/qtbug14821.qml"));
- qApp->processEvents();
-
- QDeclarative1ListView *listview = qobject_cast<QDeclarative1ListView*>(canvas->rootObject());
- QVERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- listview->decrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), 99);
-
- listview->incrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), 0);
-
- delete canvas;
-}
-
-void tst_QDeclarative1ListView::resizeDelegate()
-{
- QDeclarativeView *canvas = createView();
-
- QStringList strings;
- for (int i = 0; i < 30; ++i)
- strings << QString::number(i);
- QStringListModel model(strings);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/displaylist.qml"));
- qApp->processEvents();
-
- QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QTRY_COMPARE(listview->count(), model.rowCount());
-
- listview->setCurrentIndex(25);
- listview->setContentY(0);
-
- for (int i = 0; i < 16; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- QVERIFY(item != 0);
- QCOMPARE(item->y(), i*20.0);
- }
-
- QCOMPARE(listview->currentItem()->y(), 500.0);
- QTRY_COMPARE(listview->highlightItem()->y(), 500.0);
-
- canvas->rootObject()->setProperty("delegateHeight", 30);
- qApp->processEvents();
-
- for (int i = 0; i < 11; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- QVERIFY(item != 0);
- QTRY_COMPARE(item->y(), i*30.0);
- }
-
- QTRY_COMPARE(listview->currentItem()->y(), 750.0);
- QTRY_COMPARE(listview->highlightItem()->y(), 750.0);
-
- listview->setCurrentIndex(1);
- listview->positionViewAtIndex(25, QDeclarative1ListView::Beginning);
- listview->positionViewAtIndex(5, QDeclarative1ListView::Beginning);
-
- for (int i = 5; i < 16; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- QVERIFY(item != 0);
- QCOMPARE(item->y(), i*30.0);
- }
-
- QTRY_COMPARE(listview->currentItem()->y(), 30.0);
- QTRY_COMPARE(listview->highlightItem()->y(), 30.0);
-
- canvas->rootObject()->setProperty("delegateHeight", 20);
- qApp->processEvents();
-
- for (int i = 5; i < 11; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- QVERIFY(item != 0);
- QTRY_COMPARE(item->y(), 150 + (i-5)*20.0);
- }
-
- QTRY_COMPARE(listview->currentItem()->y(), 70.0);
- QTRY_COMPARE(listview->highlightItem()->y(), 70.0);
-
- delete canvas;
-}
-
-void tst_QDeclarative1ListView::QTBUG_16037()
-{
- QDeclarativeView *canvas = createView();
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/qtbug16037.qml"));
- qApp->processEvents();
-
- QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "listview");
- QTRY_VERIFY(listview != 0);
-
- QVERIFY(listview->contentHeight() <= 0.0);
-
- QMetaObject::invokeMethod(canvas->rootObject(), "setModel");
-
- QTRY_COMPARE(listview->contentHeight(), 80.0);
-
- delete canvas;
-}
-
-void tst_QDeclarative1ListView::indexAt()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml"));
- qApp->processEvents();
-
- QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QCOMPARE(listview->indexAt(0,0), 0);
- QCOMPARE(listview->indexAt(0,19), 0);
- QCOMPARE(listview->indexAt(239,19), 0);
- QCOMPARE(listview->indexAt(0,20), 1);
- QCOMPARE(listview->indexAt(240,20), -1);
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QDeclarative1ListView::incrementalModel()
-{
- QDeclarativeView *canvas = createView();
-
- IncrementalModel model;
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/displaylist.qml"));
- qApp->processEvents();
-
- QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QTRY_COMPARE(listview->count(), 20);
-
- listview->positionViewAtIndex(10, QDeclarative1ListView::Beginning);
-
- QTRY_COMPARE(listview->count(), 25);
-
- delete canvas;
-}
-
-void tst_QDeclarative1ListView::onAdd()
-{
- QFETCH(int, initialItemCount);
- QFETCH(int, itemsToAdd);
-
- const int delegateHeight = 10;
- TestModel2 model;
-
- // these initial items should not trigger ListView.onAdd
- for (int i=0; i<initialItemCount; i++)
- model.addItem("dummy value", "dummy value");
-
- QDeclarativeView *canvas = createView();
- canvas->setFixedSize(200, delegateHeight * (initialItemCount + itemsToAdd));
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("delegateHeight", delegateHeight);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/attachedSignals.qml"));
-
- QObject *object = canvas->rootObject();
- object->setProperty("width", canvas->width());
- object->setProperty("height", canvas->height());
- qApp->processEvents();
-
- QList<QPair<QString, QString> > items;
- for (int i=0; i<itemsToAdd; i++)
- items << qMakePair(QString("value %1").arg(i), QString::number(i));
- model.addItems(items);
-
- qApp->processEvents();
-
- QVariantList result = object->property("addedDelegates").toList();
- QCOMPARE(result.count(), items.count());
- for (int i=0; i<items.count(); i++)
- QCOMPARE(result[i].toString(), items[i].first);
-
- delete canvas;
-}
-
-void tst_QDeclarative1ListView::onAdd_data()
-{
- QTest::addColumn<int>("initialItemCount");
- QTest::addColumn<int>("itemsToAdd");
-
- QTest::newRow("0, add 1") << 0 << 1;
- QTest::newRow("0, add 2") << 0 << 2;
- QTest::newRow("0, add 10") << 0 << 10;
-
- QTest::newRow("1, add 1") << 1 << 1;
- QTest::newRow("1, add 2") << 1 << 2;
- QTest::newRow("1, add 10") << 1 << 10;
-
- QTest::newRow("5, add 1") << 5 << 1;
- QTest::newRow("5, add 2") << 5 << 2;
- QTest::newRow("5, add 10") << 5 << 10;
-}
-
-void tst_QDeclarative1ListView::onRemove()
-{
- QFETCH(int, initialItemCount);
- QFETCH(int, indexToRemove);
- QFETCH(int, removeCount);
-
- const int delegateHeight = 10;
- TestModel2 model;
- for (int i=0; i<initialItemCount; i++)
- model.addItem(QString("value %1").arg(i), "dummy value");
-
- QDeclarativeView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("delegateHeight", delegateHeight);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/attachedSignals.qml"));
- QObject *object = canvas->rootObject();
-
- qApp->processEvents();
-
- model.removeItems(indexToRemove, removeCount);
- qApp->processEvents();
- QCOMPARE(object->property("removedDelegateCount"), QVariant(removeCount));
-
- delete canvas;
-}
-
-void tst_QDeclarative1ListView::onRemove_data()
-{
- QTest::addColumn<int>("initialItemCount");
- QTest::addColumn<int>("indexToRemove");
- QTest::addColumn<int>("removeCount");
-
- QTest::newRow("remove first") << 1 << 0 << 1;
- QTest::newRow("two items, remove first") << 2 << 0 << 1;
- QTest::newRow("two items, remove last") << 2 << 1 << 1;
- QTest::newRow("two items, remove all") << 2 << 0 << 2;
-
- QTest::newRow("four items, remove first") << 4 << 0 << 1;
- QTest::newRow("four items, remove 0-2") << 4 << 0 << 2;
- QTest::newRow("four items, remove 1-3") << 4 << 1 << 2;
- QTest::newRow("four items, remove 2-4") << 4 << 2 << 2;
- QTest::newRow("four items, remove last") << 4 << 3 << 1;
- QTest::newRow("four items, remove all") << 4 << 0 << 4;
-
- QTest::newRow("ten items, remove 1-8") << 10 << 0 << 8;
- QTest::newRow("ten items, remove 2-7") << 10 << 2 << 5;
- QTest::newRow("ten items, remove 4-10") << 10 << 4 << 6;
-}
-
-void tst_QDeclarative1ListView::testQtQuick11Attributes()
-{
- QFETCH(QString, code);
- QFETCH(QString, warning);
- QFETCH(QString, error);
-
- QDeclarativeEngine engine;
- QObject *obj;
-
- QDeclarativeComponent valid(&engine);
- valid.setData("import QtQuick 1.1; ListView { " + code.toUtf8() + " }", QUrl(""));
- obj = valid.create();
- QVERIFY(obj);
- QVERIFY(valid.errorString().isEmpty());
- delete obj;
-
- QDeclarativeComponent invalid(&engine);
- invalid.setData("import QtQuick 1.0; ListView { " + code.toUtf8() + " }", QUrl(""));
- QTest::ignoreMessage(QtWarningMsg, warning.toUtf8());
- obj = invalid.create();
- QCOMPARE(invalid.errorString(), error);
- delete obj;
-}
-
-void tst_QDeclarative1ListView::testQtQuick11Attributes_data()
-{
- QTest::addColumn<QString>("code");
- QTest::addColumn<QString>("warning");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("positionViewAtBeginning") << "Component.onCompleted: positionViewAtBeginning()"
- << "<Unknown File>:1: ReferenceError: Can't find variable: positionViewAtBeginning"
- << "";
-
- QTest::newRow("positionViewAtEnd") << "Component.onCompleted: positionViewAtEnd()"
- << "<Unknown File>:1: ReferenceError: Can't find variable: positionViewAtEnd"
- << "";
-}
-
-void tst_QDeclarative1ListView::rightToLeft()
-{
- QDeclarativeView *canvas = createView();
- canvas->setFixedSize(640,320);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/rightToLeft.qml"));
- qApp->processEvents();
-
- QVERIFY(canvas->rootObject() != 0);
- QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "view");
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QDeclarative1VisualItemModel *model = canvas->rootObject()->findChild<QDeclarative1VisualItemModel*>("itemModel");
- QTRY_VERIFY(model != 0);
-
- QTRY_VERIFY(model->count() == 3);
- QTRY_COMPARE(listview->currentIndex(), 0);
-
- // initial position at first item, right edge aligned
- QCOMPARE(listview->contentX(), -640.);
-
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "item1");
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), -100.0);
- QCOMPARE(item->height(), listview->height());
-
- QDeclarative1Text *text = findItem<QDeclarative1Text>(contentItem, "text1");
- QTRY_VERIFY(text);
- QTRY_COMPARE(text->text(), QLatin1String("index: 0"));
-
- listview->setCurrentIndex(2);
-
- item = findItem<QDeclarativeItem>(contentItem, "item3");
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), -540.0);
-
- text = findItem<QDeclarative1Text>(contentItem, "text3");
- QTRY_VERIFY(text);
- QTRY_COMPARE(text->text(), QLatin1String("index: 2"));
-
- QCOMPARE(listview->contentX(), -640.);
-
- // Ensure resizing maintains position relative to right edge
- qobject_cast<QDeclarativeItem*>(canvas->rootObject())->setWidth(600);
- QTRY_COMPARE(listview->contentX(), -600.);
-
- delete canvas;
-}
-
-void tst_QDeclarative1ListView::test_mirroring()
-{
- QDeclarativeView *canvasA = createView();
- canvasA->setSource(QUrl::fromLocalFile(SRCDIR "/data/rightToLeft.qml"));
- QDeclarative1ListView *listviewA = findItem<QDeclarative1ListView>(canvasA->rootObject(), "view");
- QTRY_VERIFY(listviewA != 0);
-
- QDeclarativeView *canvasB = createView();
- canvasB->setSource(QUrl::fromLocalFile(SRCDIR "/data/rightToLeft.qml"));
- QDeclarative1ListView *listviewB = findItem<QDeclarative1ListView>(canvasB->rootObject(), "view");
- QTRY_VERIFY(listviewA != 0);
- qApp->processEvents();
-
- QList<QString> objectNames;
- objectNames << "item1" << "item2"; // << "item3"
-
- listviewA->setProperty("layoutDirection", Qt::LeftToRight);
- listviewB->setProperty("layoutDirection", Qt::RightToLeft);
- QCOMPARE(listviewA->layoutDirection(), listviewA->effectiveLayoutDirection());
-
- // LTR != RTL
- foreach(const QString objectName, objectNames)
- QVERIFY(findItem<QDeclarativeItem>(listviewA, objectName)->x() != findItem<QDeclarativeItem>(listviewB, objectName)->x());
-
- listviewA->setProperty("layoutDirection", Qt::LeftToRight);
- listviewB->setProperty("layoutDirection", Qt::LeftToRight);
-
- // LTR == LTR
- foreach(const QString objectName, objectNames)
- QCOMPARE(findItem<QDeclarativeItem>(listviewA, objectName)->x(), findItem<QDeclarativeItem>(listviewB, objectName)->x());
-
- QVERIFY(listviewB->layoutDirection() == listviewB->effectiveLayoutDirection());
- QDeclarativeItemPrivate::get(listviewB)->setLayoutMirror(true);
- QVERIFY(listviewB->layoutDirection() != listviewB->effectiveLayoutDirection());
-
- // LTR != LTR+mirror
- foreach(const QString objectName, objectNames)
- QVERIFY(findItem<QDeclarativeItem>(listviewA, objectName)->x() != findItem<QDeclarativeItem>(listviewB, objectName)->x());
-
- listviewA->setProperty("layoutDirection", Qt::RightToLeft);
-
- // RTL == LTR+mirror
- foreach(const QString objectName, objectNames)
- QCOMPARE(findItem<QDeclarativeItem>(listviewA, objectName)->x(), findItem<QDeclarativeItem>(listviewB, objectName)->x());
-
- listviewB->setProperty("layoutDirection", Qt::RightToLeft);
-
- // RTL != RTL+mirror
- foreach(const QString objectName, objectNames)
- QVERIFY(findItem<QDeclarativeItem>(listviewA, objectName)->x() != findItem<QDeclarativeItem>(listviewB, objectName)->x());
-
- listviewA->setProperty("layoutDirection", Qt::LeftToRight);
-
- // LTR == RTL+mirror
- foreach(const QString objectName, objectNames)
- QCOMPARE(findItem<QDeclarativeItem>(listviewA, objectName)->x(), findItem<QDeclarativeItem>(listviewB, objectName)->x());
-
- delete canvasA;
- delete canvasB;
-}
-
-void tst_QDeclarative1ListView::orientationChange()
-{
- QDeclarativeView *canvas = createView();
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/orientchange.qml"));
- qApp->processEvents();
-
- QDeclarative1ListView *listview = qobject_cast<QDeclarative1ListView*>(canvas->rootObject());
- QVERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- listview->positionViewAtIndex(50, QDeclarative1ListView::Beginning);
-
- // Confirm items positioned correctly
- for (int i = 50; i < 54; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- QVERIFY(item);
- QCOMPARE(item->y(), i*80.0);
- }
-
- listview->setOrientation(QDeclarative1ListView::Horizontal);
- QCOMPARE(listview->contentY(), 0.);
-
- // Confirm items positioned correctly
- for (int i = 0; i < 3; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- QVERIFY(item);
- QCOMPARE(item->x(), i*80.0);
- }
-
- listview->positionViewAtIndex(50, QDeclarative1ListView::Beginning);
- listview->setOrientation(QDeclarative1ListView::Vertical);
- QCOMPARE(listview->contentX(), 0.);
- //
- // Confirm items positioned correctly
- for (int i = 0; i < 4; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- QVERIFY(item);
- QCOMPARE(item->y(), i*80.0);
- }
-
- delete canvas;
-}
-
-void tst_QDeclarative1ListView::contentPosJump()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- for (int i = 0; i < 50; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml"));
- qApp->processEvents();
-
- QDeclarative1ListView *listview = findItem<QDeclarative1ListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_VERIFY(item->y() == i*20);
- }
-
- // Test jumping more than a page of items.
- listview->setContentY(500);
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- for (int i = 25; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_VERIFY(item->y() == i*20);
- }
-
- listview->setContentY(-100);
- itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
- QVERIFY(itemCount < 20);
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_VERIFY(item->y() == i*20);
- }
-
- delete canvas;
-}
-
-void tst_QDeclarative1ListView::qListModelInterface_items()
-{
- items<TestModel>();
-}
-
-void tst_QDeclarative1ListView::qAbstractItemModel_items()
-{
- items<TestModel2>();
-}
-
-void tst_QDeclarative1ListView::qListModelInterface_changed()
-{
- changed<TestModel>();
-}
-
-void tst_QDeclarative1ListView::qAbstractItemModel_changed()
-{
- changed<TestModel2>();
-}
-
-void tst_QDeclarative1ListView::qListModelInterface_inserted()
-{
- inserted<TestModel>();
-}
-
-void tst_QDeclarative1ListView::qAbstractItemModel_inserted()
-{
- inserted<TestModel2>();
-}
-
-void tst_QDeclarative1ListView::qListModelInterface_removed()
-{
- removed<TestModel>(false);
- removed<TestModel>(true);
-}
-
-void tst_QDeclarative1ListView::qAbstractItemModel_removed()
-{
- removed<TestModel2>(false);
- removed<TestModel2>(true);
-}
-
-void tst_QDeclarative1ListView::qListModelInterface_moved()
-{
- moved<TestModel>();
-}
-
-void tst_QDeclarative1ListView::qAbstractItemModel_moved()
-{
- moved<TestModel2>();
-}
-
-void tst_QDeclarative1ListView::qListModelInterface_clear()
-{
- clear<TestModel>();
-}
-
-void tst_QDeclarative1ListView::qAbstractItemModel_clear()
-{
- clear<TestModel2>();
-}
-
-QDeclarativeView *tst_QDeclarative1ListView::createView()
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setFixedSize(240,320);
-
- return canvas;
-}
-
-/*
- Find an item with the specified objectName. If index is supplied then the
- item must also evaluate the {index} expression equal to index
-*/
-template<typename T>
-T *tst_QDeclarative1ListView::findItem(QGraphicsObject *parent, const QString &objectName, int index)
-{
- const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->childItems().count() << "children";
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- //qDebug() << "try" << item;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
- if (index != -1) {
- QDeclarativeExpression e(qmlContext(item), item, "index");
- if (e.evaluate().toInt() == index)
- return static_cast<T*>(item);
- } else {
- return static_cast<T*>(item);
- }
- }
- item = findItem<T>(item, objectName, index);
- if (item)
- return static_cast<T*>(item);
- }
-
- return 0;
-}
-
-template<typename T>
-QList<T*> tst_QDeclarative1ListView::findItems(QGraphicsObject *parent, const QString &objectName)
-{
- QList<T*> items;
- const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->childItems().count() << "children";
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
- if(!item || !item->isVisible())
- continue;
- //qDebug() << "try" << item;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName))
- items.append(static_cast<T*>(item));
- items += findItems<T>(item, objectName);
- }
-
- return items;
-}
-
-void tst_QDeclarative1ListView::dumpTree(QDeclarativeItem *parent, int depth)
-{
- static QString padding(" ");
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- qDebug() << padding.left(depth*2) << item;
- dumpTree(item, depth+1);
- }
-}
-
-
-QTEST_MAIN(tst_QDeclarative1ListView)
-
-#include "tst_qdeclarativelistview.moc"
diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/AnchoredLoader.qml b/tests/auto/qtquick1/qdeclarativeloader/data/AnchoredLoader.qml
deleted file mode 100644
index 7654c07408..0000000000
--- a/tests/auto/qtquick1/qdeclarativeloader/data/AnchoredLoader.qml
+++ /dev/null
@@ -1,14 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 300
- height: 200
- color: "blue"
- Loader {
- objectName: "loader"
- anchors.fill: parent
- sourceComponent: Component {
- Rectangle { color: "red"; objectName: "sourceElement" }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/BlueRect.qml b/tests/auto/qtquick1/qdeclarativeloader/data/BlueRect.qml
deleted file mode 100644
index d2da64d263..0000000000
--- a/tests/auto/qtquick1/qdeclarativeloader/data/BlueRect.qml
+++ /dev/null
@@ -1,8 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- objectName: "blue"
- width: 100
- height: 100
- color: "blue"
-}
diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/CreationContextLoader.qml b/tests/auto/qtquick1/qdeclarativeloader/data/CreationContextLoader.qml
deleted file mode 100644
index bfc9a8dd8a..0000000000
--- a/tests/auto/qtquick1/qdeclarativeloader/data/CreationContextLoader.qml
+++ /dev/null
@@ -1,15 +0,0 @@
-import QtQuick 1.0
-
-Loader {
- id: myLoader
- property int testProperty: 1912
- sourceComponent: loaderComponent
- Component {
- id: loaderComponent
- Item {
- Component.onCompleted: {
- test = (myLoader.testProperty == 1912);
- }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/GraphicsWidget250x250.qml b/tests/auto/qtquick1/qdeclarativeloader/data/GraphicsWidget250x250.qml
deleted file mode 100644
index 139657bf2c..0000000000
--- a/tests/auto/qtquick1/qdeclarativeloader/data/GraphicsWidget250x250.qml
+++ /dev/null
@@ -1,5 +0,0 @@
-import QtQuick 1.0
-
-QGraphicsWidget {
- size: "250x250"
-}
diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/GreenRect.qml b/tests/auto/qtquick1/qdeclarativeloader/data/GreenRect.qml
deleted file mode 100644
index 5aeb81e918..0000000000
--- a/tests/auto/qtquick1/qdeclarativeloader/data/GreenRect.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 100; height: 100
- color: "green"
- Component.onCompleted: myLoader.source = "BlueRect.qml"
-}
diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/NoResize.qml b/tests/auto/qtquick1/qdeclarativeloader/data/NoResize.qml
deleted file mode 100644
index bb1030ef9d..0000000000
--- a/tests/auto/qtquick1/qdeclarativeloader/data/NoResize.qml
+++ /dev/null
@@ -1,8 +0,0 @@
-import QtQuick 1.0
-
-Item {
- width: 200; height: 80
- Loader {
- source: "Rect120x60.qml"
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/NoResizeGraphicsWidget.qml b/tests/auto/qtquick1/qdeclarativeloader/data/NoResizeGraphicsWidget.qml
deleted file mode 100644
index 5a31eff545..0000000000
--- a/tests/auto/qtquick1/qdeclarativeloader/data/NoResizeGraphicsWidget.qml
+++ /dev/null
@@ -1,9 +0,0 @@
-import QtQuick 1.0
-
-Item {
- width: 200
- height: 80
- Loader {
- source: "GraphicsWidget250x250.qml"
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/QTBUG_16928.qml b/tests/auto/qtquick1/qdeclarativeloader/data/QTBUG_16928.qml
deleted file mode 100644
index 9949e346f9..0000000000
--- a/tests/auto/qtquick1/qdeclarativeloader/data/QTBUG_16928.qml
+++ /dev/null
@@ -1,23 +0,0 @@
-import QtQuick 1.1
-
-Rectangle {
- color: "green"
- width: loader.implicitWidth+50
- height: loader.implicitHeight+50
-
- Loader {
- id: loader
- sourceComponent: Item {
- anchors.centerIn: parent
-
- implicitWidth: 200
- implicitHeight: 200
- Rectangle {
- color: "red"
- anchors.fill: parent
- }
- }
- anchors.fill: parent
- anchors.margins: 15
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/QTBUG_17114.qml b/tests/auto/qtquick1/qdeclarativeloader/data/QTBUG_17114.qml
deleted file mode 100644
index 8a49733a8c..0000000000
--- a/tests/auto/qtquick1/qdeclarativeloader/data/QTBUG_17114.qml
+++ /dev/null
@@ -1,18 +0,0 @@
-import QtQuick 1.1
-
-Rectangle {
- property real loaderWidth: loader.width
- property real loaderHeight: loader.height
- width: 200
- height: 200
-
- Loader {
- id: loader
- sourceComponent: Item {
- property real iwidth: 32
- property real iheight: 32
- width: iwidth
- height: iheight
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/Rect120x60.qml b/tests/auto/qtquick1/qdeclarativeloader/data/Rect120x60.qml
deleted file mode 100644
index 5a352844c3..0000000000
--- a/tests/auto/qtquick1/qdeclarativeloader/data/Rect120x60.qml
+++ /dev/null
@@ -1,6 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 120
- height:60
-}
diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/SetSourceComponent.qml b/tests/auto/qtquick1/qdeclarativeloader/data/SetSourceComponent.qml
deleted file mode 100644
index fa2d3cb325..0000000000
--- a/tests/auto/qtquick1/qdeclarativeloader/data/SetSourceComponent.qml
+++ /dev/null
@@ -1,9 +0,0 @@
-import QtQuick 1.0
-
-Item {
- function clear() {
- loader.sourceComponent = undefined
- }
- Component { id: comp; Rectangle { width: 100; height: 50 } }
- Loader { id: loader; sourceComponent: comp }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/SizeGraphicsWidgetToLoader.qml b/tests/auto/qtquick1/qdeclarativeloader/data/SizeGraphicsWidgetToLoader.qml
deleted file mode 100644
index a855947c59..0000000000
--- a/tests/auto/qtquick1/qdeclarativeloader/data/SizeGraphicsWidgetToLoader.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import QtQuick 1.0
-
-Loader {
- width: 200
- height: 80
- source: "GraphicsWidget250x250.qml"
-}
diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/SizeLoaderToGraphicsWidget.qml b/tests/auto/qtquick1/qdeclarativeloader/data/SizeLoaderToGraphicsWidget.qml
deleted file mode 100644
index b6fd57f590..0000000000
--- a/tests/auto/qtquick1/qdeclarativeloader/data/SizeLoaderToGraphicsWidget.qml
+++ /dev/null
@@ -1,5 +0,0 @@
-import QtQuick 1.0
-
-Loader {
- source: "GraphicsWidget250x250.qml"
-}
diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/SizeToItem.qml b/tests/auto/qtquick1/qdeclarativeloader/data/SizeToItem.qml
deleted file mode 100644
index 36ce9912f1..0000000000
--- a/tests/auto/qtquick1/qdeclarativeloader/data/SizeToItem.qml
+++ /dev/null
@@ -1,5 +0,0 @@
-import QtQuick 1.0
-
-Loader {
- source: "Rect120x60.qml"
-}
diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/SizeToLoader.qml b/tests/auto/qtquick1/qdeclarativeloader/data/SizeToLoader.qml
deleted file mode 100644
index 4fa945b300..0000000000
--- a/tests/auto/qtquick1/qdeclarativeloader/data/SizeToLoader.qml
+++ /dev/null
@@ -1,6 +0,0 @@
-import QtQuick 1.0
-
-Loader {
- width: 200; height: 80
- source: "Rect120x60.qml"
-}
diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/VmeError.qml b/tests/auto/qtquick1/qdeclarativeloader/data/VmeError.qml
deleted file mode 100644
index a36c246260..0000000000
--- a/tests/auto/qtquick1/qdeclarativeloader/data/VmeError.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 100; height: 100; color: "red"
- signal somethingHappened
- onSomethingHappened: QtObject {}
-}
diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/crash.qml b/tests/auto/qtquick1/qdeclarativeloader/data/crash.qml
deleted file mode 100644
index c7a4407add..0000000000
--- a/tests/auto/qtquick1/qdeclarativeloader/data/crash.qml
+++ /dev/null
@@ -1,14 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 400
- height: 400
-
- function setLoaderSource() {
- myLoader.source = "GreenRect.qml"
- }
-
- Loader {
- id: myLoader
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/creationContext.qml b/tests/auto/qtquick1/qdeclarativeloader/data/creationContext.qml
deleted file mode 100644
index 529797867f..0000000000
--- a/tests/auto/qtquick1/qdeclarativeloader/data/creationContext.qml
+++ /dev/null
@@ -1,8 +0,0 @@
-import QtQuick 1.0
-
-Item {
- property bool test: false
-
- CreationContextLoader {
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/differentorigin.qml b/tests/auto/qtquick1/qdeclarativeloader/data/differentorigin.qml
deleted file mode 100644
index 043ce5555e..0000000000
--- a/tests/auto/qtquick1/qdeclarativeloader/data/differentorigin.qml
+++ /dev/null
@@ -1,3 +0,0 @@
-import QtQuick 1.0
-
-Loader { source: "http://evil.place/evil.qml" }
diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/implicitSize.qml b/tests/auto/qtquick1/qdeclarativeloader/data/implicitSize.qml
deleted file mode 100644
index 53aad97ae1..0000000000
--- a/tests/auto/qtquick1/qdeclarativeloader/data/implicitSize.qml
+++ /dev/null
@@ -1,28 +0,0 @@
-import QtQuick 1.1
-
-Rectangle {
- property real implWidth: 0
- property real implHeight: 0
- color: "green"
- width: loader.implicitWidth+50
- height: loader.implicitHeight+50
-
- Loader {
- id: loader
- sourceComponent: Item {
- anchors.centerIn: parent
-
- implicitWidth: 100
- implicitHeight: 100
- Rectangle {
- color: "red"
- anchors.fill: parent
- }
- }
-
- anchors.fill: parent
- anchors.margins: 50
- onImplicitWidthChanged: implWidth = implicitWidth
- onImplicitHeightChanged: implHeight = loader.implicitHeight
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/nonItem.qml b/tests/auto/qtquick1/qdeclarativeloader/data/nonItem.qml
deleted file mode 100644
index 1d0ab5c10d..0000000000
--- a/tests/auto/qtquick1/qdeclarativeloader/data/nonItem.qml
+++ /dev/null
@@ -1,5 +0,0 @@
-import QtQuick 1.0
-
-Loader {
- sourceComponent: QtObject {}
-}
diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/qmldir b/tests/auto/qtquick1/qdeclarativeloader/data/qmldir
deleted file mode 100644
index bf42b507c0..0000000000
--- a/tests/auto/qtquick1/qdeclarativeloader/data/qmldir
+++ /dev/null
@@ -1 +0,0 @@
-# For tst_QDeclarativeLoader::networkRequestUrl; no types needed though.
diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/sameorigin-load.qml b/tests/auto/qtquick1/qdeclarativeloader/data/sameorigin-load.qml
deleted file mode 100644
index dbea969395..0000000000
--- a/tests/auto/qtquick1/qdeclarativeloader/data/sameorigin-load.qml
+++ /dev/null
@@ -1,3 +0,0 @@
-import QtQuick 1.0
-
-Item { }
diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/sameorigin.qml b/tests/auto/qtquick1/qdeclarativeloader/data/sameorigin.qml
deleted file mode 100644
index 8ba13a0493..0000000000
--- a/tests/auto/qtquick1/qdeclarativeloader/data/sameorigin.qml
+++ /dev/null
@@ -1,3 +0,0 @@
-import QtQuick 1.0
-
-Loader { source: "sameorigin-load.qml" }
diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/vmeErrors.qml b/tests/auto/qtquick1/qdeclarativeloader/data/vmeErrors.qml
deleted file mode 100644
index cfced31da5..0000000000
--- a/tests/auto/qtquick1/qdeclarativeloader/data/vmeErrors.qml
+++ /dev/null
@@ -1,6 +0,0 @@
-import QtQuick 1.0
-
-Loader {
- source: "VmeError.qml"
-}
-
diff --git a/tests/auto/qtquick1/qdeclarativeloader/qdeclarativeloader.pro b/tests/auto/qtquick1/qdeclarativeloader/qdeclarativeloader.pro
deleted file mode 100644
index 0e4df8d3da..0000000000
--- a/tests/auto/qtquick1/qdeclarativeloader/qdeclarativeloader.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeloader
-macx:CONFIG -= app_bundle
-
-INCLUDEPATH += ../../shared/
-HEADERS += ../../shared/testhttpserver.h
-SOURCES += tst_qdeclarativeloader.cpp \
- ../../shared/testhttpserver.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
-QT += core-private gui-private widgets-private declarative-private qtquick1-private network testlib
diff --git a/tests/auto/qtquick1/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/qtquick1/qdeclarativeloader/tst_qdeclarativeloader.cpp
deleted file mode 100644
index 6f98cf39a8..0000000000
--- a/tests/auto/qtquick1/qdeclarativeloader/tst_qdeclarativeloader.cpp
+++ /dev/null
@@ -1,631 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtWidgets/QGraphicsWidget>
-#include <QtWidgets/QGraphicsScene>
-
-#include <QSignalSpy>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick1/private/qdeclarativeloader_p.h>
-#include "testhttpserver.h"
-
-#define SERVER_PORT 14450
-
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
-}
-
-class tst_QDeclarative1Loader : public QObject
-
-{
- Q_OBJECT
-public:
- tst_QDeclarative1Loader();
-
-private slots:
- void sourceOrComponent();
- void sourceOrComponent_data();
- void clear();
- void urlToComponent();
- void componentToUrl();
- void anchoredLoader();
- void sizeLoaderToItem();
- void sizeItemToLoader();
- void noResize();
- void sizeLoaderToGraphicsWidget();
- void sizeGraphicsWidgetToLoader();
- void noResizeGraphicsWidget();
- void networkRequestUrl();
- void failNetworkRequest();
-// void networkComponent();
-
- void deleteComponentCrash();
- void nonItem();
- void vmeErrors();
- void creationContext();
- void QTBUG_16928();
- void implicitSize();
- void QTBUG_17114();
-
-private:
- QDeclarativeEngine engine;
-};
-
-
-tst_QDeclarative1Loader::tst_QDeclarative1Loader()
-{
-}
-
-void tst_QDeclarative1Loader::sourceOrComponent()
-{
- QFETCH(QString, sourceDefinition);
- QFETCH(QUrl, sourceUrl);
- QFETCH(QString, errorString);
-
- bool error = !errorString.isEmpty();
- if (error)
- QTest::ignoreMessage(QtWarningMsg, errorString.toUtf8().constData());
-
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray(
- "import QtQuick 1.0\n"
- "Loader {\n"
- " property int onItemChangedCount: 0\n"
- " property int onSourceChangedCount: 0\n"
- " property int onStatusChangedCount: 0\n"
- " property int onProgressChangedCount: 0\n"
- " property int onLoadedCount: 0\n")
- + sourceDefinition.toUtf8()
- + QByteArray(
- " onItemChanged: onItemChangedCount += 1\n"
- " onSourceChanged: onSourceChangedCount += 1\n"
- " onStatusChanged: onStatusChangedCount += 1\n"
- " onProgressChanged: onProgressChangedCount += 1\n"
- " onLoaded: onLoadedCount += 1\n"
- "}")
- , TEST_FILE(""));
-
- QDeclarative1Loader *loader = qobject_cast<QDeclarative1Loader*>(component.create());
- QVERIFY(loader != 0);
- QCOMPARE(loader->item() == 0, error);
- QCOMPARE(loader->source(), sourceUrl);
- QCOMPARE(loader->progress(), 1.0);
-
- QCOMPARE(loader->status(), error ? QDeclarative1Loader::Error : QDeclarative1Loader::Ready);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), error ? 0: 1);
-
- if (!error) {
- QDeclarativeComponent *c = qobject_cast<QDeclarativeComponent*>(loader->QGraphicsObject::children().at(0));
- QVERIFY(c);
- QCOMPARE(loader->sourceComponent(), c);
- }
-
- QCOMPARE(loader->property("onSourceChangedCount").toInt(), 1);
- QCOMPARE(loader->property("onStatusChangedCount").toInt(), 1);
- QCOMPARE(loader->property("onProgressChangedCount").toInt(), 1);
-
- QCOMPARE(loader->property("onItemChangedCount").toInt(), error ? 0 : 1);
- QCOMPARE(loader->property("onLoadedCount").toInt(), error ? 0 : 1);
-
- delete loader;
-}
-
-void tst_QDeclarative1Loader::sourceOrComponent_data()
-{
- QTest::addColumn<QString>("sourceDefinition");
- QTest::addColumn<QUrl>("sourceUrl");
- QTest::addColumn<QString>("errorString");
-
- QTest::newRow("source") << "source: 'Rect120x60.qml'\n" << QUrl::fromLocalFile(SRCDIR "/data/Rect120x60.qml") << "";
- QTest::newRow("sourceComponent") << "Component { id: comp; Rectangle { width: 100; height: 50 } }\n sourceComponent: comp\n" << QUrl() << "";
-
- QTest::newRow("invalid source") << "source: 'IDontExist.qml'\n" << QUrl::fromLocalFile(SRCDIR "/data/IDontExist.qml")
- << QString(QUrl::fromLocalFile(SRCDIR "/data/IDontExist.qml").toString() + ": File not found");
-}
-
-void tst_QDeclarative1Loader::clear()
-{
- {
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray(
- "import QtQuick 1.0\n"
- " Loader { id: loader\n"
- " source: 'Rect120x60.qml'\n"
- " Timer { interval: 200; running: true; onTriggered: loader.source = '' }\n"
- " }")
- , TEST_FILE(""));
- QDeclarative1Loader *loader = qobject_cast<QDeclarative1Loader*>(component.create());
- QVERIFY(loader != 0);
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
-
- QTRY_VERIFY(loader->item() == 0);
- QCOMPARE(loader->progress(), 0.0);
- QCOMPARE(loader->status(), QDeclarative1Loader::Null);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0);
-
- delete loader;
- }
- {
- QDeclarativeComponent component(&engine, TEST_FILE("/SetSourceComponent.qml"));
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(item);
-
- QDeclarative1Loader *loader = qobject_cast<QDeclarative1Loader*>(item->QGraphicsObject::children().at(1));
- QVERIFY(loader);
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
-
- loader->setSourceComponent(0);
-
- QVERIFY(loader->item() == 0);
- QCOMPARE(loader->progress(), 0.0);
- QCOMPARE(loader->status(), QDeclarative1Loader::Null);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0);
-
- delete item;
- }
- {
- QDeclarativeComponent component(&engine, TEST_FILE("/SetSourceComponent.qml"));
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(item);
-
- QDeclarative1Loader *loader = qobject_cast<QDeclarative1Loader*>(item->QGraphicsObject::children().at(1));
- QVERIFY(loader);
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
-
- QMetaObject::invokeMethod(item, "clear");
-
- QVERIFY(loader->item() == 0);
- QCOMPARE(loader->progress(), 0.0);
- QCOMPARE(loader->status(), QDeclarative1Loader::Null);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0);
-
- delete item;
- }
-}
-
-void tst_QDeclarative1Loader::urlToComponent()
-{
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 1.0\n"
- "Loader {\n"
- " id: loader\n"
- " Component { id: myComp; Rectangle { width: 10; height: 10 } }\n"
- " source: \"Rect120x60.qml\"\n"
- " Timer { interval: 100; running: true; onTriggered: loader.sourceComponent = myComp }\n"
- "}" )
- , TEST_FILE(""));
- QDeclarative1Loader *loader = qobject_cast<QDeclarative1Loader*>(component.create());
- QTest::qWait(200);
- QTRY_VERIFY(loader != 0);
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
- QCOMPARE(loader->width(), 10.0);
- QCOMPARE(loader->height(), 10.0);
-
- delete loader;
-}
-
-void tst_QDeclarative1Loader::componentToUrl()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("/SetSourceComponent.qml"));
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(item);
-
- QDeclarative1Loader *loader = qobject_cast<QDeclarative1Loader*>(item->QGraphicsObject::children().at(1));
- QVERIFY(loader);
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
-
- loader->setSource(TEST_FILE("/Rect120x60.qml"));
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
- QCOMPARE(loader->width(), 120.0);
- QCOMPARE(loader->height(), 60.0);
-
- delete item;
-}
-
-void tst_QDeclarative1Loader::anchoredLoader()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("/AnchoredLoader.qml"));
- QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(rootItem != 0);
- QDeclarativeItem *loader = rootItem->findChild<QDeclarativeItem*>("loader");
- QDeclarativeItem *sourceElement = rootItem->findChild<QDeclarativeItem*>("sourceElement");
-
- QVERIFY(loader != 0);
- QVERIFY(sourceElement != 0);
-
- QCOMPARE(rootItem->width(), 300.0);
- QCOMPARE(rootItem->height(), 200.0);
-
- QCOMPARE(loader->width(), 300.0);
- QCOMPARE(loader->height(), 200.0);
-
- QCOMPARE(sourceElement->width(), 300.0);
- QCOMPARE(sourceElement->height(), 200.0);
-}
-
-void tst_QDeclarative1Loader::sizeLoaderToItem()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("/SizeToItem.qml"));
- QDeclarative1Loader *loader = qobject_cast<QDeclarative1Loader*>(component.create());
- QVERIFY(loader != 0);
- QCOMPARE(loader->width(), 120.0);
- QCOMPARE(loader->height(), 60.0);
-
- // Check resize
- QDeclarativeItem *rect = qobject_cast<QDeclarativeItem*>(loader->item());
- QVERIFY(rect);
- rect->setWidth(150);
- rect->setHeight(45);
- QCOMPARE(loader->width(), 150.0);
- QCOMPARE(loader->height(), 45.0);
-
- // Check explicit width
- loader->setWidth(200.0);
- QCOMPARE(loader->width(), 200.0);
- QCOMPARE(rect->width(), 200.0);
- rect->setWidth(100.0); // when rect changes ...
- QCOMPARE(rect->width(), 100.0); // ... it changes
- QCOMPARE(loader->width(), 200.0); // ... but loader stays the same
-
- // Check explicit height
- loader->setHeight(200.0);
- QCOMPARE(loader->height(), 200.0);
- QCOMPARE(rect->height(), 200.0);
- rect->setHeight(100.0); // when rect changes ...
- QCOMPARE(rect->height(), 100.0); // ... it changes
- QCOMPARE(loader->height(), 200.0); // ... but loader stays the same
-
- // Switch mode
- loader->setWidth(180);
- loader->setHeight(30);
- QCOMPARE(rect->width(), 180.0);
- QCOMPARE(rect->height(), 30.0);
-
- delete loader;
-}
-
-void tst_QDeclarative1Loader::sizeItemToLoader()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("/SizeToLoader.qml"));
- QDeclarative1Loader *loader = qobject_cast<QDeclarative1Loader*>(component.create());
- QVERIFY(loader != 0);
- QCOMPARE(loader->width(), 200.0);
- QCOMPARE(loader->height(), 80.0);
-
- QDeclarativeItem *rect = qobject_cast<QDeclarativeItem*>(loader->item());
- QVERIFY(rect);
- QCOMPARE(rect->width(), 200.0);
- QCOMPARE(rect->height(), 80.0);
-
- // Check resize
- loader->setWidth(180);
- loader->setHeight(30);
- QCOMPARE(rect->width(), 180.0);
- QCOMPARE(rect->height(), 30.0);
-
- // Switch mode
- loader->resetWidth(); // reset explicit size
- loader->resetHeight();
- rect->setWidth(160);
- rect->setHeight(45);
- QCOMPARE(loader->width(), 160.0);
- QCOMPARE(loader->height(), 45.0);
-
- delete loader;
-}
-
-void tst_QDeclarative1Loader::noResize()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("/NoResize.qml"));
- QDeclarativeItem* item = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(item != 0);
- QCOMPARE(item->width(), 200.0);
- QCOMPARE(item->height(), 80.0);
-
- delete item;
-}
-
-void tst_QDeclarative1Loader::sizeLoaderToGraphicsWidget()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("/SizeLoaderToGraphicsWidget.qml"));
- QDeclarative1Loader *loader = qobject_cast<QDeclarative1Loader*>(component.create());
- QGraphicsScene scene;
- scene.addItem(loader);
-
- QVERIFY(loader != 0);
- QCOMPARE(loader->width(), 250.0);
- QCOMPARE(loader->height(), 250.0);
-
- // Check resize
- QGraphicsWidget *widget = qobject_cast<QGraphicsWidget*>(loader->item());
- QVERIFY(widget);
- widget->resize(QSizeF(150,45));
- QCOMPARE(loader->width(), 150.0);
- QCOMPARE(loader->height(), 45.0);
-
- // Switch mode
- loader->setWidth(180);
- loader->setHeight(30);
- QCOMPARE(widget->size().width(), 180.0);
- QCOMPARE(widget->size().height(), 30.0);
-
- delete loader;
-}
-
-void tst_QDeclarative1Loader::sizeGraphicsWidgetToLoader()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("/SizeGraphicsWidgetToLoader.qml"));
- QDeclarative1Loader *loader = qobject_cast<QDeclarative1Loader*>(component.create());
- QGraphicsScene scene;
- scene.addItem(loader);
-
- QVERIFY(loader != 0);
- QCOMPARE(loader->width(), 200.0);
- QCOMPARE(loader->height(), 80.0);
-
- QGraphicsWidget *widget = qobject_cast<QGraphicsWidget*>(loader->item());
- QVERIFY(widget);
- QCOMPARE(widget->size().width(), 200.0);
- QCOMPARE(widget->size().height(), 80.0);
-
- // Check resize
- loader->setWidth(180);
- loader->setHeight(30);
- QCOMPARE(widget->size().width(), 180.0);
- QCOMPARE(widget->size().height(), 30.0);
-
- // Switch mode
- loader->resetWidth(); // reset explicit size
- loader->resetHeight();
- widget->resize(QSizeF(160,45));
- QCOMPARE(loader->width(), 160.0);
- QCOMPARE(loader->height(), 45.0);
-
- delete loader;
-}
-
-void tst_QDeclarative1Loader::noResizeGraphicsWidget()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("/NoResizeGraphicsWidget.qml"));
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
- QGraphicsScene scene;
- scene.addItem(item);
-
- QVERIFY(item != 0);
- QCOMPARE(item->width(), 200.0);
- QCOMPARE(item->height(), 80.0);
-
- delete item;
-}
-
-void tst_QDeclarative1Loader::networkRequestUrl()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.serveDirectory(SRCDIR "/data");
-
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 1.0\nLoader { property int signalCount : 0; source: \"http://127.0.0.1:14450/Rect120x60.qml\"; onLoaded: signalCount += 1 }"), QUrl::fromLocalFile(SRCDIR "/dummy.qml"));
- if (component.isError())
- qDebug() << component.errors();
- QDeclarative1Loader *loader = qobject_cast<QDeclarative1Loader*>(component.create());
- QVERIFY(loader != 0);
-
- QTRY_VERIFY(loader->status() == QDeclarative1Loader::Ready);
-
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(loader->property("signalCount").toInt(), 1);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
-
- delete loader;
-}
-
-/* XXX Component waits until all dependencies are loaded. Is this actually possible?
-void tst_QDeclarative1Loader::networkComponent()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.serveDirectory("slowdata", TestHTTPServer::Delay);
-
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray(
- "import QtQuick 1.0\n"
- "import \"http://127.0.0.1:14450/\" as NW\n"
- "Item {\n"
- " Component { id: comp; NW.SlowRect {} }\n"
- " Loader { sourceComponent: comp } }")
- , TEST_FILE(""));
-
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(item);
-
- QDeclarative1Loader *loader = qobject_cast<QDeclarative1Loader*>(item->QGraphicsObject::children().at(1));
- QVERIFY(loader);
- QTRY_VERIFY(loader->status() == QDeclarative1Loader::Ready);
-
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(loader->status(), QDeclarative1Loader::Ready);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
-
- delete loader;
-}
-*/
-
-void tst_QDeclarative1Loader::failNetworkRequest()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.serveDirectory(SRCDIR "/data");
-
- QTest::ignoreMessage(QtWarningMsg, "http://127.0.0.1:14450/IDontExist.qml: File not found");
-
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 1.0\nLoader { property int did_load: 123; source: \"http://127.0.0.1:14450/IDontExist.qml\"; onLoaded: did_load=456 }"), QUrl::fromLocalFile("http://127.0.0.1:14450/dummy.qml"));
- QDeclarative1Loader *loader = qobject_cast<QDeclarative1Loader*>(component.create());
- QVERIFY(loader != 0);
-
- QTRY_VERIFY(loader->status() == QDeclarative1Loader::Error);
-
- QVERIFY(loader->item() == 0);
- QCOMPARE(loader->progress(), 0.0);
- QCOMPARE(loader->property("did_load").toInt(), 123);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0);
-
- delete loader;
-}
-
-// QTBUG-9241
-void tst_QDeclarative1Loader::deleteComponentCrash()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("crash.qml"));
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(item);
-
- item->metaObject()->invokeMethod(item, "setLoaderSource");
-
- QDeclarative1Loader *loader = qobject_cast<QDeclarative1Loader*>(item->QGraphicsObject::children().at(0));
- QVERIFY(loader);
- QVERIFY(loader->item());
- QCOMPARE(loader->item()->objectName(), QLatin1String("blue"));
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(loader->status(), QDeclarative1Loader::Ready);
- QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
- QVERIFY(loader->source() == QUrl::fromLocalFile(SRCDIR "/data/BlueRect.qml"));
-
- delete item;
-}
-
-void tst_QDeclarative1Loader::nonItem()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("nonItem.qml"));
- QString err = QUrl::fromLocalFile(SRCDIR).toString() + "/data/nonItem.qml:3:1: QML Loader: Loader does not support loading non-visual elements.";
-
- QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData());
- QDeclarative1Loader *loader = qobject_cast<QDeclarative1Loader*>(component.create());
- QVERIFY(loader);
- QVERIFY(loader->item() == 0);
-
- delete loader;
-}
-
-void tst_QDeclarative1Loader::vmeErrors()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("vmeErrors.qml"));
- QString err = QUrl::fromLocalFile(SRCDIR).toString() + "/data/VmeError.qml:6: Cannot assign object type QObject with no default method";
- QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData());
- QDeclarative1Loader *loader = qobject_cast<QDeclarative1Loader*>(component.create());
- QVERIFY(loader);
- QVERIFY(loader->item() == 0);
-
- delete loader;
-}
-
-// QTBUG-13481
-void tst_QDeclarative1Loader::creationContext()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("creationContext.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test").toBool(), true);
-
- delete o;
-}
-
-void tst_QDeclarative1Loader::QTBUG_16928()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("QTBUG_16928.qml"));
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(item);
-
- QCOMPARE(item->width(), 250.);
- QCOMPARE(item->height(), 250.);
-
- delete item;
-}
-
-void tst_QDeclarative1Loader::implicitSize()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("implicitSize.qml"));
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(item);
-
- QCOMPARE(item->width(), 150.);
- QCOMPARE(item->height(), 150.);
-
- QCOMPARE(item->property("implHeight").toReal(), 100.);
- QCOMPARE(item->property("implWidth").toReal(), 100.);
-
- delete item;
-}
-
-void tst_QDeclarative1Loader::QTBUG_17114()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("QTBUG_17114.qml"));
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(item);
-
- QCOMPARE(item->property("loaderWidth").toReal(), 32.);
- QCOMPARE(item->property("loaderHeight").toReal(), 32.);
-
- delete item;
-}
-
-QTEST_MAIN(tst_QDeclarative1Loader)
-
-#include "tst_qdeclarativeloader.moc"
diff --git a/tests/auto/qtquick1/qdeclarativemousearea/data/clickandhold.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/clickandhold.qml
deleted file mode 100644
index a6409e2e31..0000000000
--- a/tests/auto/qtquick1/qdeclarativemousearea/data/clickandhold.qml
+++ /dev/null
@@ -1,13 +0,0 @@
-import QtQuick 1.0
-
-Item {
- id: root
- property bool clicked: false
- property bool held: false
-
- MouseArea {
- width: 200; height: 200
- onClicked: { root.clicked = true }
- onPressAndHold: { root.held = true }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativemousearea/data/clicktwice.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/clicktwice.qml
deleted file mode 100644
index c6b1f8992a..0000000000
--- a/tests/auto/qtquick1/qdeclarativemousearea/data/clicktwice.qml
+++ /dev/null
@@ -1,16 +0,0 @@
-import QtQuick 1.0
-
-Item {
- id: root
- property int clicked: 0
- property int pressed: 0
- property int released: 0
-
- MouseArea {
- width: 200; height: 200
- onPressed: { root.pressed++ }
- onClicked: { root.clicked++ }
- onReleased: { root.released++ }
- }
-}
-
diff --git a/tests/auto/qtquick1/qdeclarativemousearea/data/doubleclick.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/doubleclick.qml
deleted file mode 100644
index 55b0812e48..0000000000
--- a/tests/auto/qtquick1/qdeclarativemousearea/data/doubleclick.qml
+++ /dev/null
@@ -1,16 +0,0 @@
-import QtQuick 1.0
-
-Item {
- id: root
- property int clicked: 0
- property int doubleClicked: 0
- property int released: 0
-
- MouseArea {
- width: 200; height: 200
- onClicked: { root.clicked++ }
- onDoubleClicked: { root.doubleClicked++ }
- onReleased: { root.released++ }
- }
-}
-
diff --git a/tests/auto/qtquick1/qdeclarativemousearea/data/dragging.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/dragging.qml
deleted file mode 100644
index dd89efb5ab..0000000000
--- a/tests/auto/qtquick1/qdeclarativemousearea/data/dragging.qml
+++ /dev/null
@@ -1,28 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- id: whiteRect
- width: 200
- height: 200
- color: "white"
- Rectangle {
- id: blackRect
- objectName: "blackrect"
- color: "black"
- y: 50
- x: 50
- width: 100
- height: 100
- opacity: (whiteRect.width-blackRect.x+whiteRect.height-blackRect.y-199)/200
- Text { text: blackRect.opacity}
- MouseArea {
- objectName: "mouseregion"
- anchors.fill: parent
- drag.target: blackRect
- drag.axis: Drag.XandYAxis
- drag.minimumX: 0
- drag.maximumX: whiteRect.width-blackRect.width
- drag.minimumY: 0
- drag.maximumY: whiteRect.height-blackRect.height
- }
- }
- }
diff --git a/tests/auto/qtquick1/qdeclarativemousearea/data/dragproperties.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/dragproperties.qml
deleted file mode 100644
index 7baefd5ded..0000000000
--- a/tests/auto/qtquick1/qdeclarativemousearea/data/dragproperties.qml
+++ /dev/null
@@ -1,28 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- id: whiteRect
- width: 200
- height: 200
- color: "white"
- Rectangle {
- id: blackRect
- objectName: "blackrect"
- color: "black"
- y: 50
- x: 50
- width: 100
- height: 100
- opacity: (whiteRect.width-blackRect.x+whiteRect.height-blackRect.y-199)/200
- Text { text: blackRect.opacity}
- MouseArea {
- objectName: "mouseregion"
- anchors.fill: parent
- drag.target: blackRect
- drag.axis: Drag.XandYAxis
- drag.minimumX: 0
- drag.maximumX: whiteRect.width-blackRect.width
- drag.minimumY: 0
- drag.maximumY: whiteRect.height-blackRect.height
- }
- }
- }
diff --git a/tests/auto/qtquick1/qdeclarativemousearea/data/dragreset.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/dragreset.qml
deleted file mode 100644
index c6d2e204b2..0000000000
--- a/tests/auto/qtquick1/qdeclarativemousearea/data/dragreset.qml
+++ /dev/null
@@ -1,28 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- id: whiteRect
- width: 200
- height: 200
- color: "white"
- Rectangle {
- id: blackRect
- objectName: "blackrect"
- color: "black"
- y: 50
- x: 50
- width: 100
- height: 100
- opacity: (whiteRect.width-blackRect.x+whiteRect.height-blackRect.y-199)/200
- Text { text: blackRect.opacity}
- MouseArea {
- objectName: "mouseregion"
- anchors.fill: parent
- drag.target: haveTarget ? blackRect : undefined
- drag.axis: Drag.XandYAxis
- drag.minimumX: 0
- drag.maximumX: whiteRect.width-blackRect.width
- drag.minimumY: 0
- drag.maximumY: whiteRect.height-blackRect.height
- }
- }
- }
diff --git a/tests/auto/qtquick1/qdeclarativemousearea/data/pressedOrdering.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/pressedOrdering.qml
deleted file mode 100644
index 4a80e83465..0000000000
--- a/tests/auto/qtquick1/qdeclarativemousearea/data/pressedOrdering.qml
+++ /dev/null
@@ -1,28 +0,0 @@
-import QtQuick 1.0
-
-Item {
- id: root
- property string value: "base"
-
- MouseArea {
- id: mouseArea
- width: 200; height: 200
- onClicked: toggleState.state = "toggled"
- }
-
- StateGroup {
- states: State {
- name: "pressed"
- when: mouseArea.pressed
- PropertyChanges { target: root; value: "pressed" }
- }
- }
-
- StateGroup {
- id: toggleState
- states: State {
- name: "toggled"
- PropertyChanges { target: root; value: "toggled" }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativemousearea/data/preventContextMenu.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/preventContextMenu.qml
deleted file mode 100644
index dcbb5d766e..0000000000
--- a/tests/auto/qtquick1/qdeclarativemousearea/data/preventContextMenu.qml
+++ /dev/null
@@ -1,22 +0,0 @@
-import QtQuick 1.1
-import Test 1.0
-
-Item {
- width: 200
- height: 200
-
- property alias mouseAreaEnabled: mouseArea.enabled
- property alias eventsReceived: receiver.eventCount
-
- ContextMenuEventReceiver {
- id: receiver
- anchors.fill: parent
- }
-
- MouseArea {
- id: mouseArea
- anchors.fill: parent
- acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
- enabled: true
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativemousearea/data/preventstealing.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/preventstealing.qml
deleted file mode 100644
index 11553fadaf..0000000000
--- a/tests/auto/qtquick1/qdeclarativemousearea/data/preventstealing.qml
+++ /dev/null
@@ -1,24 +0,0 @@
-import QtQuick 1.1
-
-Flickable {
- property bool stealing: true
- width: 200
- height: 200
- contentWidth: 400
- contentHeight: 400
- Rectangle {
- color: "black"
- width: 400
- height: 400
- Rectangle {
- x: 50; y: 50
- width: 100; height: 100
- color: "steelblue"
- MouseArea {
- objectName: "mousearea"
- anchors.fill: parent
- preventStealing: stealing
- }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativemousearea/data/rejectEvent.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/rejectEvent.qml
deleted file mode 100644
index fc8292d703..0000000000
--- a/tests/auto/qtquick1/qdeclarativemousearea/data/rejectEvent.qml
+++ /dev/null
@@ -1,28 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: root
- color: "#ffffff"
- width: 320; height: 240
- property bool mr1_pressed: false
- property bool mr1_released: false
- property bool mr1_canceled: false
- property bool mr2_pressed: false
- property bool mr2_released: false
- property bool mr2_canceled: false
-
- MouseArea {
- id: mouseRegion1
- anchors.fill: parent
- onPressed: { root.mr1_pressed = true }
- onReleased: { root.mr1_released = true }
- onCanceled: { root.mr1_canceled = true }
- }
- MouseArea {
- id: mouseRegion2
- width: 120; height: 120
- onPressed: { root.mr2_pressed = true; mouse.accepted = false }
- onReleased: { root.mr2_released = true }
- onCanceled: { root.mr2_canceled = true }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativemousearea/data/updateMousePosOnClick.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/updateMousePosOnClick.qml
deleted file mode 100644
index b77f7431c6..0000000000
--- a/tests/auto/qtquick1/qdeclarativemousearea/data/updateMousePosOnClick.qml
+++ /dev/null
@@ -1,20 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- color: "#ffffff"
- width: 320; height: 240
- MouseArea {
- id: mouseRegion
- objectName: "mouseregion"
- anchors.fill: parent
- Rectangle {
- id: ball
- objectName: "ball"
- width: 20; height: 20
- radius: 10
- color: "#0000ff"
- x: { mouseRegion.mouseX }
- y: mouseRegion.mouseY
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativemousearea/data/updateMousePosOnResize.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/updateMousePosOnResize.qml
deleted file mode 100644
index 6571d8b12d..0000000000
--- a/tests/auto/qtquick1/qdeclarativemousearea/data/updateMousePosOnResize.qml
+++ /dev/null
@@ -1,38 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- color: "#ffffff"
- width: 320; height: 240
- Rectangle {
- id: brother
- objectName: "brother"
- color: "lightgreen"
- x: 200; y: 100
- width: 120; height: 120
- }
- MouseArea {
- id: mouseRegion
- objectName: "mouseregion"
-
- property int x1
- property int y1
- property int x2
- property int y2
- property bool emitPositionChanged: false
- property bool mouseMatchesPos: true
-
- anchors.fill: brother
- onPressed: {
- if (mouse.x != mouseX || mouse.y != mouseY)
- mouseMatchesPos = false
- x1 = mouseX; y1 = mouseY
- anchors.fill = parent
- }
- onPositionChanged: { emitPositionChanged = true }
- onMousePositionChanged: {
- if (mouse.x != mouseX || mouse.y != mouseY)
- mouseMatchesPos = false
- x2 = mouseX; y2 = mouseY
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativemousearea/qdeclarativemousearea.pro b/tests/auto/qtquick1/qdeclarativemousearea/qdeclarativemousearea.pro
deleted file mode 100644
index 6f426c50c5..0000000000
--- a/tests/auto/qtquick1/qdeclarativemousearea/qdeclarativemousearea.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativemousearea
-macx:CONFIG -= app_bundle
-
-HEADERS += ../../shared/testhttpserver.h
-SOURCES += tst_qdeclarativemousearea.cpp ../../shared/testhttpserver.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
-QT += core-private gui-private widgets-private declarative-private qtquick1-private network testlib
diff --git a/tests/auto/qtquick1/qdeclarativemousearea/tst_qdeclarativemousearea.cpp b/tests/auto/qtquick1/qdeclarativemousearea/tst_qdeclarativemousearea.cpp
deleted file mode 100644
index 4715293fd4..0000000000
--- a/tests/auto/qtquick1/qdeclarativemousearea/tst_qdeclarativemousearea.cpp
+++ /dev/null
@@ -1,700 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtTest/QSignalSpy>
-#include <QtQuick1/private/qdeclarativemousearea_p.h>
-#include <QtQuick1/private/qdeclarativerectangle_p.h>
-#include <QtQuick1/private/qdeclarativeflickable_p.h>
-#include <QtQuick1/qdeclarativeview.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativeproperty.h>
-
-class tst_QDeclarative1MouseArea: public QObject
-{
- Q_OBJECT
-private slots:
- void dragProperties();
- void resetDrag();
- void dragging();
- void updateMouseAreaPosOnClick();
- void updateMouseAreaPosOnResize();
- void noOnClickedWithPressAndHold();
- void onMousePressRejected();
- void doubleClick();
- void clickTwice();
- void pressedOrdering();
- void preventStealing();
- void testQtQuick11Attributes();
- void testQtQuick11Attributes_data();
-#ifndef QT_NO_CONTEXTMENU
- void preventContextMenu();
-#endif // QT_NO_CONTEXTMENU
-
-private:
- QDeclarativeView *createView();
-};
-
-void tst_QDeclarative1MouseArea::dragProperties()
-{
- QDeclarativeView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/dragproperties.qml"));
- canvas->show();
- canvas->setFocus();
- QVERIFY(canvas->rootObject() != 0);
-
- QDeclarative1MouseArea *mouseRegion = canvas->rootObject()->findChild<QDeclarative1MouseArea*>("mouseregion");
- QDeclarative1Drag *drag = mouseRegion->drag();
- QVERIFY(mouseRegion != 0);
- QVERIFY(drag != 0);
-
- // target
- QDeclarativeItem *blackRect = canvas->rootObject()->findChild<QDeclarativeItem*>("blackrect");
- QVERIFY(blackRect != 0);
- QVERIFY(blackRect == drag->target());
- QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(canvas->rootObject());
- QVERIFY(rootItem != 0);
- QSignalSpy targetSpy(drag, SIGNAL(targetChanged()));
- drag->setTarget(rootItem);
- QCOMPARE(targetSpy.count(),1);
- drag->setTarget(rootItem);
- QCOMPARE(targetSpy.count(),1);
-
- // axis
- QCOMPARE(drag->axis(), QDeclarative1Drag::XandYAxis);
- QSignalSpy axisSpy(drag, SIGNAL(axisChanged()));
- drag->setAxis(QDeclarative1Drag::XAxis);
- QCOMPARE(drag->axis(), QDeclarative1Drag::XAxis);
- QCOMPARE(axisSpy.count(),1);
- drag->setAxis(QDeclarative1Drag::XAxis);
- QCOMPARE(axisSpy.count(),1);
-
- // minimum and maximum properties
- QSignalSpy xminSpy(drag, SIGNAL(minimumXChanged()));
- QSignalSpy xmaxSpy(drag, SIGNAL(maximumXChanged()));
- QSignalSpy yminSpy(drag, SIGNAL(minimumYChanged()));
- QSignalSpy ymaxSpy(drag, SIGNAL(maximumYChanged()));
-
- QCOMPARE(drag->xmin(), 0.0);
- QCOMPARE(drag->xmax(), rootItem->width()-blackRect->width());
- QCOMPARE(drag->ymin(), 0.0);
- QCOMPARE(drag->ymax(), rootItem->height()-blackRect->height());
-
- drag->setXmin(10);
- drag->setXmax(10);
- drag->setYmin(10);
- drag->setYmax(10);
-
- QCOMPARE(drag->xmin(), 10.0);
- QCOMPARE(drag->xmax(), 10.0);
- QCOMPARE(drag->ymin(), 10.0);
- QCOMPARE(drag->ymax(), 10.0);
-
- QCOMPARE(xminSpy.count(),1);
- QCOMPARE(xmaxSpy.count(),1);
- QCOMPARE(yminSpy.count(),1);
- QCOMPARE(ymaxSpy.count(),1);
-
- drag->setXmin(10);
- drag->setXmax(10);
- drag->setYmin(10);
- drag->setYmax(10);
-
- QCOMPARE(xminSpy.count(),1);
- QCOMPARE(xmaxSpy.count(),1);
- QCOMPARE(yminSpy.count(),1);
- QCOMPARE(ymaxSpy.count(),1);
-
- // filterChildren
- QSignalSpy filterChildrenSpy(drag, SIGNAL(filterChildrenChanged()));
-
- drag->setFilterChildren(true);
-
- QVERIFY(drag->filterChildren());
- QCOMPARE(filterChildrenSpy.count(), 1);
-
- drag->setFilterChildren(true);
- QCOMPARE(filterChildrenSpy.count(), 1);
-
- delete canvas;
-}
-
-void tst_QDeclarative1MouseArea::resetDrag()
-{
- QDeclarativeView *canvas = createView();
-
- canvas->rootContext()->setContextProperty("haveTarget", QVariant(true));
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/dragreset.qml"));
- canvas->show();
- canvas->setFocus();
- QVERIFY(canvas->rootObject() != 0);
-
- QDeclarative1MouseArea *mouseRegion = canvas->rootObject()->findChild<QDeclarative1MouseArea*>("mouseregion");
- QDeclarative1Drag *drag = mouseRegion->drag();
- QVERIFY(mouseRegion != 0);
- QVERIFY(drag != 0);
-
- // target
- QDeclarativeItem *blackRect = canvas->rootObject()->findChild<QDeclarativeItem*>("blackrect");
- QVERIFY(blackRect != 0);
- QVERIFY(blackRect == drag->target());
- QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(canvas->rootObject());
- QVERIFY(rootItem != 0);
- QSignalSpy targetSpy(drag, SIGNAL(targetChanged()));
- QVERIFY(drag->target() != 0);
- canvas->rootContext()->setContextProperty("haveTarget", QVariant(false));
- QCOMPARE(targetSpy.count(),1);
- QVERIFY(drag->target() == 0);
-
- delete canvas;
-}
-
-
-void tst_QDeclarative1MouseArea::dragging()
-{
- QDeclarativeView *canvas = createView();
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/dragging.qml"));
- canvas->show();
- canvas->setFocus();
- QVERIFY(canvas->rootObject() != 0);
-
- QDeclarative1MouseArea *mouseRegion = canvas->rootObject()->findChild<QDeclarative1MouseArea*>("mouseregion");
- QDeclarative1Drag *drag = mouseRegion->drag();
- QVERIFY(mouseRegion != 0);
- QVERIFY(drag != 0);
-
- // target
- QDeclarativeItem *blackRect = canvas->rootObject()->findChild<QDeclarativeItem*>("blackrect");
- QVERIFY(blackRect != 0);
- QVERIFY(blackRect == drag->target());
-
- QVERIFY(!drag->active());
-
- QGraphicsScene *scene = canvas->scene();
- QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress);
- pressEvent.setScenePos(QPointF(100, 100));
- pressEvent.setButton(Qt::LeftButton);
- pressEvent.setButtons(Qt::LeftButton);
- QApplication::sendEvent(scene, &pressEvent);
-
- QVERIFY(!drag->active());
- QCOMPARE(blackRect->x(), 50.0);
- QCOMPARE(blackRect->y(), 50.0);
-
- // First move event triggers drag, second is acted upon.
- // This is due to possibility of higher stacked area taking precedence.
- QGraphicsSceneMouseEvent moveEvent(QEvent::GraphicsSceneMouseMove);
- moveEvent.setScenePos(QPointF(106, 106));
- moveEvent.setButton(Qt::LeftButton);
- moveEvent.setButtons(Qt::LeftButton);
- QApplication::sendEvent(scene, &moveEvent);
-
- moveEvent.setScenePos(QPointF(110, 110));
- moveEvent.setButton(Qt::LeftButton);
- moveEvent.setButtons(Qt::LeftButton);
- QApplication::sendEvent(scene, &moveEvent);
-
- QVERIFY(drag->active());
- QCOMPARE(blackRect->x(), 60.0);
- QCOMPARE(blackRect->y(), 60.0);
-
- QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease);
- releaseEvent.setScenePos(QPointF(110, 110));
- releaseEvent.setButton(Qt::LeftButton);
- releaseEvent.setButtons(Qt::LeftButton);
- QApplication::sendEvent(scene, &releaseEvent);
-
- QVERIFY(!drag->active());
- QCOMPARE(blackRect->x(), 60.0);
- QCOMPARE(blackRect->y(), 60.0);
-
- delete canvas;
-}
-
-QDeclarativeView *tst_QDeclarative1MouseArea::createView()
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setFixedSize(240,320);
-
- return canvas;
-}
-
-void tst_QDeclarative1MouseArea::updateMouseAreaPosOnClick()
-{
- QDeclarativeView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/updateMousePosOnClick.qml"));
- canvas->show();
- canvas->setFocus();
- QVERIFY(canvas->rootObject() != 0);
-
- QDeclarative1MouseArea *mouseRegion = canvas->rootObject()->findChild<QDeclarative1MouseArea*>("mouseregion");
- QVERIFY(mouseRegion != 0);
-
- QDeclarative1Rectangle *rect = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("ball");
- QVERIFY(rect != 0);
-
- QCOMPARE(mouseRegion->mouseX(), rect->x());
- QCOMPARE(mouseRegion->mouseY(), rect->y());
-
- QGraphicsScene *scene = canvas->scene();
- QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress);
- event.setScenePos(QPointF(100, 100));
- event.setButton(Qt::LeftButton);
- event.setButtons(Qt::LeftButton);
- QApplication::sendEvent(scene, &event);
-
- QCOMPARE(mouseRegion->mouseX(), 100.0);
- QCOMPARE(mouseRegion->mouseY(), 100.0);
-
- QCOMPARE(mouseRegion->mouseX(), rect->x());
- QCOMPARE(mouseRegion->mouseY(), rect->y());
-
- delete canvas;
-}
-
-void tst_QDeclarative1MouseArea::updateMouseAreaPosOnResize()
-{
- QDeclarativeView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/updateMousePosOnResize.qml"));
- canvas->show();
- canvas->setFocus();
- QVERIFY(canvas->rootObject() != 0);
-
- QDeclarative1MouseArea *mouseRegion = canvas->rootObject()->findChild<QDeclarative1MouseArea*>("mouseregion");
- QVERIFY(mouseRegion != 0);
-
- QDeclarative1Rectangle *rect = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("brother");
- QVERIFY(rect != 0);
-
- QCOMPARE(mouseRegion->mouseX(), 0.0);
- QCOMPARE(mouseRegion->mouseY(), 0.0);
-
- QGraphicsScene *scene = canvas->scene();
- QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress);
- event.setScenePos(rect->pos());
- event.setButton(Qt::LeftButton);
- event.setButtons(Qt::LeftButton);
- QApplication::sendEvent(scene, &event);
-
- QVERIFY(!mouseRegion->property("emitPositionChanged").toBool());
- QVERIFY(mouseRegion->property("mouseMatchesPos").toBool());
-
- QCOMPARE(mouseRegion->property("x1").toInt(), 0);
- QCOMPARE(mouseRegion->property("y1").toInt(), 0);
-
- // XXX: is it on purpose that mouseX is real and mouse.x is int?
- QCOMPARE(mouseRegion->property("x2").toInt(), (int) rect->x());
- QCOMPARE(mouseRegion->property("y2").toInt(), (int) rect->y());
-
- QCOMPARE(mouseRegion->mouseX(), rect->x());
- QCOMPARE(mouseRegion->mouseY(), rect->y());
-
- delete canvas;
-}
-
-void tst_QDeclarative1MouseArea::noOnClickedWithPressAndHold()
-{
- QDeclarativeView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/clickandhold.qml"));
- canvas->show();
- canvas->setFocus();
- QVERIFY(canvas->rootObject() != 0);
-
- QGraphicsScene *scene = canvas->scene();
- QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress);
- pressEvent.setScenePos(QPointF(100, 100));
- pressEvent.setButton(Qt::LeftButton);
- pressEvent.setButtons(Qt::LeftButton);
- QApplication::sendEvent(scene, &pressEvent);
-
- QVERIFY(!canvas->rootObject()->property("clicked").toBool());
- QVERIFY(!canvas->rootObject()->property("held").toBool());
-
- QTest::qWait(1000);
-
- QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease);
- releaseEvent.setScenePos(QPointF(100, 100));
- releaseEvent.setButton(Qt::LeftButton);
- releaseEvent.setButtons(Qt::LeftButton);
- QApplication::sendEvent(scene, &releaseEvent);
-
- QVERIFY(!canvas->rootObject()->property("clicked").toBool());
- QVERIFY(canvas->rootObject()->property("held").toBool());
-
- delete canvas;
-}
-
-void tst_QDeclarative1MouseArea::onMousePressRejected()
-{
- QDeclarativeView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/rejectEvent.qml"));
- canvas->show();
- canvas->setFocus();
- QVERIFY(canvas->rootObject() != 0);
- QVERIFY(canvas->rootObject()->property("enabled").toBool());
-
- QVERIFY(!canvas->rootObject()->property("mr1_pressed").toBool());
- QVERIFY(!canvas->rootObject()->property("mr1_released").toBool());
- QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool());
- QVERIFY(!canvas->rootObject()->property("mr2_pressed").toBool());
- QVERIFY(!canvas->rootObject()->property("mr2_released").toBool());
- QVERIFY(!canvas->rootObject()->property("mr2_canceled").toBool());
-
- QGraphicsScene *scene = canvas->scene();
- QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress);
- pressEvent.setScenePos(QPointF(100, 100));
- pressEvent.setButton(Qt::LeftButton);
- pressEvent.setButtons(Qt::LeftButton);
- QApplication::sendEvent(scene, &pressEvent);
-
- QVERIFY(canvas->rootObject()->property("mr1_pressed").toBool());
- QVERIFY(!canvas->rootObject()->property("mr1_released").toBool());
- QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool());
- QVERIFY(canvas->rootObject()->property("mr2_pressed").toBool());
- QVERIFY(!canvas->rootObject()->property("mr2_released").toBool());
- QVERIFY(canvas->rootObject()->property("mr2_canceled").toBool());
-
- QTest::qWait(200);
-
- QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease);
- releaseEvent.setScenePos(QPointF(100, 100));
- releaseEvent.setButton(Qt::LeftButton);
- releaseEvent.setButtons(Qt::LeftButton);
- QApplication::sendEvent(scene, &releaseEvent);
-
- QVERIFY(canvas->rootObject()->property("mr1_released").toBool());
- QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool());
- QVERIFY(!canvas->rootObject()->property("mr2_released").toBool());
-
- delete canvas;
-}
-
-void tst_QDeclarative1MouseArea::doubleClick()
-{
- QDeclarativeView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/doubleclick.qml"));
- canvas->show();
- canvas->setFocus();
- QVERIFY(canvas->rootObject() != 0);
-
- QGraphicsScene *scene = canvas->scene();
- QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress);
- pressEvent.setScenePos(QPointF(100, 100));
- pressEvent.setButton(Qt::LeftButton);
- pressEvent.setButtons(Qt::LeftButton);
- QApplication::sendEvent(scene, &pressEvent);
-
- QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease);
- releaseEvent.setScenePos(QPointF(100, 100));
- releaseEvent.setButton(Qt::LeftButton);
- releaseEvent.setButtons(Qt::LeftButton);
- QApplication::sendEvent(scene, &releaseEvent);
-
- QCOMPARE(canvas->rootObject()->property("released").toInt(), 1);
-
- QGraphicsSceneMouseEvent dblClickEvent(QEvent::GraphicsSceneMouseDoubleClick);
- dblClickEvent.setScenePos(QPointF(100, 100));
- dblClickEvent.setButton(Qt::LeftButton);
- dblClickEvent.setButtons(Qt::LeftButton);
- QApplication::sendEvent(scene, &dblClickEvent);
-
- QApplication::sendEvent(scene, &releaseEvent);
-
- QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 1);
- QCOMPARE(canvas->rootObject()->property("doubleClicked").toInt(), 1);
- QCOMPARE(canvas->rootObject()->property("released").toInt(), 2);
-
- delete canvas;
-}
-
-// QTBUG-14832
-void tst_QDeclarative1MouseArea::clickTwice()
-{
- QDeclarativeView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/clicktwice.qml"));
- canvas->show();
- canvas->setFocus();
- QVERIFY(canvas->rootObject() != 0);
-
- QGraphicsScene *scene = canvas->scene();
- QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress);
- pressEvent.setScenePos(QPointF(100, 100));
- pressEvent.setButton(Qt::LeftButton);
- pressEvent.setButtons(Qt::LeftButton);
- QApplication::sendEvent(scene, &pressEvent);
-
- QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease);
- releaseEvent.setScenePos(QPointF(100, 100));
- releaseEvent.setButton(Qt::LeftButton);
- releaseEvent.setButtons(Qt::LeftButton);
- QApplication::sendEvent(scene, &releaseEvent);
-
- QCOMPARE(canvas->rootObject()->property("pressed").toInt(), 1);
- QCOMPARE(canvas->rootObject()->property("released").toInt(), 1);
- QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 1);
-
- QGraphicsSceneMouseEvent dblClickEvent(QEvent::GraphicsSceneMouseDoubleClick);
- dblClickEvent.setScenePos(QPointF(100, 100));
- dblClickEvent.setButton(Qt::LeftButton);
- dblClickEvent.setButtons(Qt::LeftButton);
- QApplication::sendEvent(scene, &dblClickEvent);
-
- QApplication::sendEvent(scene, &pressEvent);
- QApplication::sendEvent(scene, &releaseEvent);
-
- QCOMPARE(canvas->rootObject()->property("pressed").toInt(), 2);
- QCOMPARE(canvas->rootObject()->property("released").toInt(), 2);
- QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 2);
-
- delete canvas;
-}
-
-void tst_QDeclarative1MouseArea::pressedOrdering()
-{
- QDeclarativeView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pressedOrdering.qml"));
- canvas->show();
- canvas->setFocus();
- QVERIFY(canvas->rootObject() != 0);
-
- QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("base"));
-
- QGraphicsScene *scene = canvas->scene();
- QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress);
- pressEvent.setScenePos(QPointF(100, 100));
- pressEvent.setButton(Qt::LeftButton);
- pressEvent.setButtons(Qt::LeftButton);
- QApplication::sendEvent(scene, &pressEvent);
-
- QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("pressed"));
-
- QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease);
- releaseEvent.setScenePos(QPointF(100, 100));
- releaseEvent.setButton(Qt::LeftButton);
- releaseEvent.setButtons(Qt::LeftButton);
- QApplication::sendEvent(scene, &releaseEvent);
-
- QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("toggled"));
-
- QApplication::sendEvent(scene, &pressEvent);
-
- QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("pressed"));
-
- delete canvas;
-}
-
-void tst_QDeclarative1MouseArea::preventStealing()
-{
- QDeclarativeView *canvas = createView();
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/preventstealing.qml"));
- canvas->show();
- canvas->setFocus();
- QVERIFY(canvas->rootObject() != 0);
-
- QDeclarative1Flickable *flickable = qobject_cast<QDeclarative1Flickable*>(canvas->rootObject());
- QVERIFY(flickable != 0);
-
- QDeclarative1MouseArea *mouseArea = canvas->rootObject()->findChild<QDeclarative1MouseArea*>("mousearea");
- QVERIFY(mouseArea != 0);
-
- QSignalSpy mousePositionSpy(mouseArea, SIGNAL(positionChanged(QDeclarative1MouseEvent*)));
-
- QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(80, 80)));
-
- // Without preventStealing, mouse movement over MouseArea would
- // cause the Flickable to steal mouse and trigger content movement.
- QGraphicsScene *scene = canvas->scene();
- QGraphicsSceneMouseEvent moveEvent(QEvent::GraphicsSceneMouseMove);
- moveEvent.setScenePos(QPointF(70, 70));
- moveEvent.setButton(Qt::LeftButton);
- moveEvent.setButtons(Qt::LeftButton);
- QApplication::sendEvent(scene, &moveEvent);
-
- moveEvent.setScenePos(QPointF(60, 60));
- moveEvent.setButton(Qt::LeftButton);
- moveEvent.setButtons(Qt::LeftButton);
- QApplication::sendEvent(scene, &moveEvent);
-
- moveEvent.setScenePos(QPointF(50, 50));
- moveEvent.setButton(Qt::LeftButton);
- moveEvent.setButtons(Qt::LeftButton);
- QApplication::sendEvent(scene, &moveEvent);
-
- // We should have received all three move events
- QCOMPARE(mousePositionSpy.count(), 3);
- QVERIFY(mouseArea->pressed());
-
- // Flickable content should not have moved.
- QCOMPARE(flickable->contentX(), 0.);
- QCOMPARE(flickable->contentY(), 0.);
-
- QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(50, 50)));
-
- // Now allow stealing and confirm Flickable does its thing.
- canvas->rootObject()->setProperty("stealing", false);
-
- QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(80, 80)));
-
- // Without preventStealing, mouse movement over MouseArea would
- // cause the Flickable to steal mouse and trigger content movement.
- moveEvent.setScenePos(QPointF(70, 70));
- QApplication::sendEvent(scene, &moveEvent);
-
- moveEvent.setScenePos(QPointF(60, 60));
- QApplication::sendEvent(scene, &moveEvent);
-
- moveEvent.setScenePos(QPointF(50, 50));
- QApplication::sendEvent(scene, &moveEvent);
-
- // We should only have received the first move event
- QCOMPARE(mousePositionSpy.count(), 4);
- // Our press should be taken away
- QVERIFY(!mouseArea->pressed());
-
- // Flickable content should have moved.
- QCOMPARE(flickable->contentX(), 10.);
- QCOMPARE(flickable->contentY(), 10.);
-
- QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(50, 50)));
-
- delete canvas;
-}
-
-void tst_QDeclarative1MouseArea::testQtQuick11Attributes()
-{
- QFETCH(QString, code);
- QFETCH(QString, warning);
- QFETCH(QString, error);
-
- QDeclarativeEngine engine;
- QObject *obj;
-
- QDeclarativeComponent valid(&engine);
- valid.setData("import QtQuick 1.1; MouseArea { " + code.toUtf8() + " }", QUrl(""));
- obj = valid.create();
- QVERIFY(obj);
- QVERIFY(valid.errorString().isEmpty());
- delete obj;
-
- QDeclarativeComponent invalid(&engine);
- invalid.setData("import QtQuick 1.0; MouseArea { " + code.toUtf8() + " }", QUrl(""));
- QTest::ignoreMessage(QtWarningMsg, warning.toUtf8());
- obj = invalid.create();
- QCOMPARE(invalid.errorString(), error);
- delete obj;
-}
-
-void tst_QDeclarative1MouseArea::testQtQuick11Attributes_data()
-{
- QTest::addColumn<QString>("code");
- QTest::addColumn<QString>("warning");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("preventStealing") << "preventStealing: true"
- << "QDeclarativeComponent: Component is not ready"
- << ":1 \"MouseArea.preventStealing\" is not available in QtQuick 1.0.\n";
-}
-
-#ifndef QT_NO_CONTEXTMENU
-class ContextMenuEventReceiver : public QDeclarativeItem
-{
- Q_OBJECT
- Q_PROPERTY(int eventCount READ eventCount NOTIFY eventCountChanged);
-public:
- ContextMenuEventReceiver(QDeclarativeItem *parent = 0) : QDeclarativeItem(parent), m_eventCount(0) { }
- int eventCount() const { return m_eventCount; }
-signals:
- void eventCountChanged(int);
-protected:
- void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
- if (event->reason() == QGraphicsSceneContextMenuEvent::Mouse) {
- m_eventCount++;
- emit eventCountChanged(m_eventCount);
- }
- }
-private:
- int m_eventCount;
-};
-
-void tst_QDeclarative1MouseArea::preventContextMenu()
-{
- // A MouseArea accepting Left, Middle and Right buttons should prevent context menu
- // events with "Mouse" reason to hit the Item below.
-
- qmlRegisterType<ContextMenuEventReceiver>("Test", 1, 0, "ContextMenuEventReceiver");
-
- QDeclarativeView *view = createView();
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/preventContextMenu.qml"));
- view->show();
- QVERIFY(view->rootObject() != 0);
-
- QDeclarativeProperty mouseAreaEnabled(view->rootObject(), "mouseAreaEnabled");
- QVERIFY(mouseAreaEnabled.read().toBool());
-
- QDeclarativeProperty eventsReceived(view->rootObject(), "eventsReceived");
- QCOMPARE(eventsReceived.read().toInt(), 0);
-
- QPoint targetPoint = view->mapFromScene(QPoint(80, 80));
-
- QContextMenuEvent fakeEvent1(QContextMenuEvent::Mouse, targetPoint);
- QApplication::sendEvent(view->viewport(), &fakeEvent1);
- QCOMPARE(eventsReceived.read().toInt(), 0);
-
- mouseAreaEnabled.write(false);
- QVERIFY(!mouseAreaEnabled.read().toBool());
- QContextMenuEvent fakeEvent2(QContextMenuEvent::Mouse, targetPoint);
- QApplication::sendEvent(view->viewport(), &fakeEvent2);
- QCOMPARE(eventsReceived.read().toInt(), 1);
-
- mouseAreaEnabled.write(true);
- QVERIFY(mouseAreaEnabled.read().toBool());
- QContextMenuEvent fakeEvent3(QContextMenuEvent::Mouse, targetPoint);
- QApplication::sendEvent(view->viewport(), &fakeEvent3);
- QCOMPARE(eventsReceived.read().toInt(), 1);
-}
-#endif // QT_NO_CONTEXTMENU
-
-QTEST_MAIN(tst_QDeclarative1MouseArea)
-
-#include "tst_qdeclarativemousearea.moc"
diff --git a/tests/auto/qtquick1/qdeclarativeparticles/data/particle.png b/tests/auto/qtquick1/qdeclarativeparticles/data/particle.png
deleted file mode 100644
index defbde53ca..0000000000
--- a/tests/auto/qtquick1/qdeclarativeparticles/data/particle.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativeparticles/data/particlemotiontest.qml b/tests/auto/qtquick1/qdeclarativeparticles/data/particlemotiontest.qml
deleted file mode 100644
index dad97465b5..0000000000
--- a/tests/auto/qtquick1/qdeclarativeparticles/data/particlemotiontest.qml
+++ /dev/null
@@ -1,35 +0,0 @@
-import QtQuick 1.0
-import Qt.labs.particles 1.0
-
-Rectangle {
- width: 240
- height: 320
- color: "black"
- Particles {
- objectName: "particles"
- anchors.fill: parent
- width: 1
- height: 1
- source: "particle.png"
- lifeSpan: 5000
- count: 200
- angle: 270
- angleDeviation: 45
- velocity: 50
- velocityDeviation: 30
- ParticleMotionGravity {
- objectName: "motionGravity"
- yattractor: 1000
- xattractor: 0
- acceleration: 25
- }
- }
- resources: [
- ParticleMotionWander {
- objectName: "motionWander"
- xvariance: 30
- yvariance: 30
- pace: 100
- }
- ]
-}
diff --git a/tests/auto/qtquick1/qdeclarativeparticles/data/particlestest.qml b/tests/auto/qtquick1/qdeclarativeparticles/data/particlestest.qml
deleted file mode 100644
index c76fe9b8fc..0000000000
--- a/tests/auto/qtquick1/qdeclarativeparticles/data/particlestest.qml
+++ /dev/null
@@ -1,17 +0,0 @@
-import QtQuick 1.0
-import Qt.labs.particles 1.0
-
-Rectangle{
- width: 100
- height: 100
- color: "black"
- objectName: "rect"
- Particles { id: particles
- objectName: "particles"
- width:1; height:1; anchors.centerIn: parent; opacity: 1
- lifeSpan: 100; lifeSpanDeviation: 20; count:1000;
- fadeInDuration: 20; fadeOutDuration: 20; emissionRate: 1000
- angle: 0; angleDeviation: 360; velocity: 500; velocityDeviation:30
- source: "particle.png"
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeparticles/qdeclarativeparticles.pro b/tests/auto/qtquick1/qdeclarativeparticles/qdeclarativeparticles.pro
deleted file mode 100644
index 666fce999f..0000000000
--- a/tests/auto/qtquick1/qdeclarativeparticles/qdeclarativeparticles.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeparticles
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeparticles.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
-QT += core-private gui-private widgets-private declarative-private qtquick1 testlib
diff --git a/tests/auto/qtquick1/qdeclarativeparticles/tst_qdeclarativeparticles.cpp b/tests/auto/qtquick1/qdeclarativeparticles/tst_qdeclarativeparticles.cpp
deleted file mode 100644
index b89170385a..0000000000
--- a/tests/auto/qtquick1/qdeclarativeparticles/tst_qdeclarativeparticles.cpp
+++ /dev/null
@@ -1,222 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtTest/QtTest>
-#include <QtTest/QSignalSpy>
-#include <QtQuick1/qdeclarativeview.h>
-#include <QGraphicsObject>
-
-class tst_QDeclarativeParticles : public QObject
-{
- Q_OBJECT
-public:
- tst_QDeclarativeParticles();
-
-private slots:
- void properties();
- void motionGravity();
- void motionWander();
- void runs();
-private:
- QDeclarativeView *createView(const QString &filename);
-
-};
-
-tst_QDeclarativeParticles::tst_QDeclarativeParticles()
-{
-}
-
-void tst_QDeclarativeParticles::properties()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/particlestest.qml");
- QVERIFY(canvas->rootObject());
-
- QObject* particles = canvas->rootObject()->findChild<QObject*>("particles");
- QVERIFY(particles);
-
- particles->setProperty("source", QUrl::fromLocalFile(SRCDIR "/data/particle.png"));
- QCOMPARE(particles->property("source").toUrl(), QUrl::fromLocalFile(SRCDIR "/data/particle.png"));
-
- particles->setProperty("lifeSpanDeviation", (1000));
- QCOMPARE(particles->property("lifeSpanDeviation").toInt(), 1000);
-
- particles->setProperty("fadeInDuration", 1000);
- QCOMPARE(particles->property("fadeInDuration").toInt(), 1000);
-
- particles->setProperty("fadeOutDuration", 1000);
- QCOMPARE(particles->property("fadeOutDuration").toInt(), 1000);
-
- particles->setProperty("angle", 100.0);
- QCOMPARE(particles->property("angle").toDouble(), 100.0);
-
- particles->setProperty("angleDeviation", 100.0);
- QCOMPARE(particles->property("angleDeviation").toDouble(), 100.0);
-
- particles->setProperty("velocity", 100.0);
- QCOMPARE(particles->property("velocity").toDouble(), 100.0);
-
- particles->setProperty("velocityDeviation", 100.0);
- QCOMPARE(particles->property("velocityDeviation").toDouble(), 100.0);
-
- particles->setProperty("emissionVariance", 0.5);
- QCOMPARE(particles->property("emissionVariance").toDouble(),0.5);
-
- particles->setProperty("emissionRate", 12);
- QCOMPARE(particles->property("emissionRate").toInt(), 12);
-
- delete canvas;
-}
-
-void tst_QDeclarativeParticles::motionGravity()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/particlemotiontest.qml");
- QVERIFY(canvas->rootObject());
-
- QObject* particles = canvas->rootObject()->findChild<QObject*>("particles");
- QVERIFY(particles);
-
- QObject* motionGravity = canvas->rootObject()->findChild<QObject*>("motionGravity");
- //QCOMPARE(qvariant_cast<QObject*>(particles->property("motion")), motionGravity);
-
- QSignalSpy xattractorSpy(motionGravity, SIGNAL(xattractorChanged()));
- QSignalSpy yattractorSpy(motionGravity, SIGNAL(yattractorChanged()));
- QSignalSpy accelerationSpy(motionGravity, SIGNAL(accelerationChanged()));
-
- QCOMPARE(motionGravity->property("xattractor").toDouble(), 0.0);
- QCOMPARE(motionGravity->property("yattractor").toDouble(), 1000.0);
- QCOMPARE(motionGravity->property("acceleration").toDouble(), 25.0);
-
- motionGravity->setProperty("xattractor", 20.0);
- motionGravity->setProperty("yattractor", 10.0);
- motionGravity->setProperty("acceleration", 10.0);
-
- QCOMPARE(motionGravity->property("xattractor").toDouble(), 20.0);
- QCOMPARE(motionGravity->property("yattractor").toDouble(), 10.0);
- QCOMPARE(motionGravity->property("acceleration").toDouble(), 10.0);
-
- QCOMPARE(xattractorSpy.count(), 1);
- QCOMPARE(yattractorSpy.count(), 1);
- QCOMPARE(accelerationSpy.count(), 1);
-
- motionGravity->setProperty("xattractor", 20.0);
- motionGravity->setProperty("yattractor", 10.0);
- motionGravity->setProperty("acceleration", 10.0);
-
- QCOMPARE(xattractorSpy.count(), 1);
- QCOMPARE(yattractorSpy.count(), 1);
- QCOMPARE(accelerationSpy.count(), 1);
-
- delete canvas;
-}
-
-void tst_QDeclarativeParticles::motionWander()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/particlemotiontest.qml");
- QVERIFY(canvas->rootObject());
-
- QObject* particles = canvas->rootObject()->findChild<QObject*>("particles");
- QVERIFY(particles);
-
- QSignalSpy motionSpy(particles, SIGNAL(motionChanged()));
- QObject* motionWander = canvas->rootObject()->findChild<QObject*>("motionWander");
-
- QCOMPARE(motionSpy.count(), 0);
- particles->setProperty("motion", QVariant::fromValue(motionWander));
- //QCOMPARE(particles->property("motion"), QVariant::fromValue(motionWander));
- //QCOMPARE(motionSpy.count(), 1);
-
- particles->setProperty("motion", QVariant::fromValue(motionWander));
- //QCOMPARE(motionSpy.count(), 1);
-
- QSignalSpy xvarianceSpy(motionWander, SIGNAL(xvarianceChanged()));
- QSignalSpy yvarianceSpy(motionWander, SIGNAL(yvarianceChanged()));
- QSignalSpy paceSpy(motionWander, SIGNAL(paceChanged()));
-
- QCOMPARE(motionWander->property("xvariance").toDouble(), 30.0);
- QCOMPARE(motionWander->property("yvariance").toDouble(), 30.0);
- QCOMPARE(motionWander->property("pace").toDouble(), 100.0);
-
- motionWander->setProperty("xvariance", 20.0);
- motionWander->setProperty("yvariance", 10.0);
- motionWander->setProperty("pace", 10.0);
-
- QCOMPARE(motionWander->property("xvariance").toDouble(), 20.0);
- QCOMPARE(motionWander->property("yvariance").toDouble(), 10.0);
- QCOMPARE(motionWander->property("pace").toDouble(), 10.0);
-
- QCOMPARE(xvarianceSpy.count(), 1);
- QCOMPARE(yvarianceSpy.count(), 1);
- QCOMPARE(paceSpy.count(), 1);
-
- QCOMPARE(motionWander->property("xvariance").toDouble(), 20.0);
- QCOMPARE(motionWander->property("yvariance").toDouble(), 10.0);
- QCOMPARE(motionWander->property("pace").toDouble(), 10.0);
-
- QCOMPARE(xvarianceSpy.count(), 1);
- QCOMPARE(yvarianceSpy.count(), 1);
- QCOMPARE(paceSpy.count(), 1);
-
- delete canvas;
-}
-
-void tst_QDeclarativeParticles::runs()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/particlestest.qml");
- QVERIFY(canvas->rootObject());
-
- QObject* particles = canvas->rootObject()->findChild<QObject*>("particles");
- QVERIFY(particles);
- QTest::qWait(1000);//Run for one second. Test passes if it doesn't crash.
-
- delete canvas;
-}
-
-QDeclarativeView *tst_QDeclarativeParticles::createView(const QString &filename)
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setFixedSize(240,320);
-
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- return canvas;
-}
-QTEST_MAIN(tst_QDeclarativeParticles)
-
-#include "tst_qdeclarativeparticles.moc"
diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/closedPath.qml b/tests/auto/qtquick1/qdeclarativepathview/data/closedPath.qml
deleted file mode 100644
index 08b0d2a203..0000000000
--- a/tests/auto/qtquick1/qdeclarativepathview/data/closedPath.qml
+++ /dev/null
@@ -1,24 +0,0 @@
-import QtQuick 1.0
-
-Path {
- startY: 120
- startX: 160
- PathQuad {
- y: 120
- x: 80
- controlY: 330
- controlX: 100
- }
- PathLine {
- y: 160
- x: 20
- }
- PathCubic {
- y: 120
- x: 160
- control1Y: 0
- control1X: 100
- control2Y: 000
- control2X: 200
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/datamodel.qml b/tests/auto/qtquick1/qdeclarativepathview/data/datamodel.qml
deleted file mode 100644
index e2c4e3dd00..0000000000
--- a/tests/auto/qtquick1/qdeclarativepathview/data/datamodel.qml
+++ /dev/null
@@ -1,38 +0,0 @@
-import QtQuick 1.0
-
-PathView {
- id: pathview
- property int viewCount: count
- objectName: "pathview"
- width: 240; height: 320
- pathItemCount: testObject.pathItemCount
-
- function checkProperties() {
- testObject.error = false;
- if (testObject.useModel && pathview.model != testData) {
- console.log("model property incorrect");
- testObject.error = true;
- }
- }
-
- model: testObject.useModel ? testData : 0
-
- delegate: Component {
- id: myDelegate
- Rectangle {
- id: wrapper
- objectName: "wrapper"
- property bool onPath: PathView.onPath
- width: 20; height: 20; color: name
- Text {
- objectName: "myText"
- text: name
- }
- }
- }
-
- path: Path {
- startX: 120; startY: 20;
- PathLine { x: 120; y: 300 }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/displaypath.qml b/tests/auto/qtquick1/qdeclarativepathview/data/displaypath.qml
deleted file mode 100644
index 88dfc57b72..0000000000
--- a/tests/auto/qtquick1/qdeclarativepathview/data/displaypath.qml
+++ /dev/null
@@ -1,59 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 240
- height: 320
- color: "#ffffff"
- resources: [
- Component {
- id: delegate
- Rectangle {
- id: wrapper
- objectName: "wrapper"
- height: 20
- width: 60
- color: "white"
- border.color: "black"
- Text {
- text: index
- }
- Text {
- x: 20
- id: displayText
- objectName: "displayText"
- text: display
- }
- }
- }
- ]
- PathView {
- id: view
- objectName: "view"
- width: 240
- height: 320
- model: testModel
- delegate: delegate
- path: Path {
- startY: 120
- startX: 160
- PathQuad {
- y: 120
- x: 80
- controlY: 330
- controlX: 100
- }
- PathLine {
- y: 160
- x: 20
- }
- PathCubic {
- y: 120
- x: 160
- control1Y: 0
- control1X: 100
- control2Y: 000
- control2X: 200
- }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/dragpath.qml b/tests/auto/qtquick1/qdeclarativepathview/data/dragpath.qml
deleted file mode 100644
index 0f9484083e..0000000000
--- a/tests/auto/qtquick1/qdeclarativepathview/data/dragpath.qml
+++ /dev/null
@@ -1,19 +0,0 @@
-import QtQuick 1.0
-
-PathView {
- width: 400
- height: 200
- model: 100
- pathItemCount: 20
- path: Path {
- startX: 0; startY: 100
- PathLine { x: 400; y: 100 }
- }
- delegate: Rectangle { objectName: "wrapper"; height: 100; width: 2; color: PathView.isCurrentItem?"red" : "black" }
- dragMargin: 100
- preferredHighlightBegin: 0.5
- preferredHighlightEnd: 0.5
- Text {
- text: "current index: " + parent.currentIndex
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/emptymodel.qml b/tests/auto/qtquick1/qdeclarativepathview/data/emptymodel.qml
deleted file mode 100644
index 4deb45fdb3..0000000000
--- a/tests/auto/qtquick1/qdeclarativepathview/data/emptymodel.qml
+++ /dev/null
@@ -1,5 +0,0 @@
-import QtQuick 1.0
-
-PathView {
- model: emptyModel
-}
diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/openPath.qml b/tests/auto/qtquick1/qdeclarativepathview/data/openPath.qml
deleted file mode 100644
index 328e3cdefb..0000000000
--- a/tests/auto/qtquick1/qdeclarativepathview/data/openPath.qml
+++ /dev/null
@@ -1,10 +0,0 @@
-import QtQuick 1.0
-
-Path {
- startY: 120
- startX: 160
- PathLine {
- y: 160
- x: 20
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/pathUpdate.qml b/tests/auto/qtquick1/qdeclarativepathview/data/pathUpdate.qml
deleted file mode 100644
index 0c2ac0ce98..0000000000
--- a/tests/auto/qtquick1/qdeclarativepathview/data/pathUpdate.qml
+++ /dev/null
@@ -1,18 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 400
- height: 400
-
- PathView {
- id: view
- objectName: "pathView"
- anchors.fill: parent
- model: 10
- delegate: Rectangle { objectName: "wrapper"; color: "green"; width: 100; height: 100 }
- path: Path {
- startX: view.width/2; startY: 0
- PathLine { x: view.width/2; y: view.height }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/pathUpdateOnStartChanged.qml b/tests/auto/qtquick1/qdeclarativepathview/data/pathUpdateOnStartChanged.qml
deleted file mode 100644
index bd732ab17b..0000000000
--- a/tests/auto/qtquick1/qdeclarativepathview/data/pathUpdateOnStartChanged.qml
+++ /dev/null
@@ -1,38 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 800
- height: 480
- color: "black"
- resources: [
- ListModel {
- id: appModel
- ListElement { color: "green" }
- },
- Component {
- id: appDelegate
- Rectangle {
- id: wrapper
- objectName: "wrapper"
- color: "green"
- width: 100
- height: 100
- }
- }
- ]
- PathView {
- id: pathView
- objectName: "pathView"
- model: appModel
- anchors.fill: parent
-
- transformOrigin: "Top"
- delegate: appDelegate
- path: Path {
- objectName: "path"
- startX: pathView.width / 2 // startX: 400 <- this works as expected
- startY: 300
- PathLine { x: 400; y: 120 }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/pathtest.qml b/tests/auto/qtquick1/qdeclarativepathview/data/pathtest.qml
deleted file mode 100644
index b13c00662e..0000000000
--- a/tests/auto/qtquick1/qdeclarativepathview/data/pathtest.qml
+++ /dev/null
@@ -1,14 +0,0 @@
-import QtQuick 1.0
-
-Path {
- startX: 120; startY: 100
-
- PathAttribute { name: "scale"; value: 1.0 }
- PathQuad { x: 120; y: 25; controlX: 260; controlY: 75 }
- PathPercent { value: 0.3 }
- PathLine { x: 120; y: 100 }
- PathCubic {
- x: 180; y: 0; control1X: -10; control1Y: 90
- control2X: 210; control2Y: 90
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/pathview0.qml b/tests/auto/qtquick1/qdeclarativepathview/data/pathview0.qml
deleted file mode 100644
index 28b6fb9a72..0000000000
--- a/tests/auto/qtquick1/qdeclarativepathview/data/pathview0.qml
+++ /dev/null
@@ -1,84 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: root
- property int count: view.count
- property int currentA: -1
- property int currentB: -1
- property real delegateWidth: 60
- property real delegateHeight: 20
- property real delegateScale: 1.0
- width: 240
- height: 320
- color: "#ffffff"
- resources: [
- Component {
- id: delegate
- Rectangle {
- id: wrapper
- objectName: "wrapper"
- height: root.delegateHeight
- width: root.delegateWidth
- scale: root.delegateScale
- color: PathView.isCurrentItem ? "lightsteelblue" : "white"
- border.color: "black"
- Text {
- text: index
- }
- Text {
- x: 20
- id: textName
- objectName: "textName"
- text: name
- }
- Text {
- x: 40
- id: textNumber
- objectName: "textNumber"
- text: number
- }
- PathView.onCurrentItemChanged: {
- if (PathView.isCurrentItem) {
- root.currentA = index;
- root.currentB = wrapper.PathView.view.currentIndex;
- }
- }
- }
- }
- ]
- PathView {
- id: view
- objectName: "view"
- width: 240
- height: 320
- model: testModel
- delegate: delegate
- highlight: Rectangle {
- width: 60
- height: 20
- color: "yellow"
- }
- path: Path {
- startY: 120
- startX: 160
- PathQuad {
- y: 120
- x: 80
- controlY: 330
- controlX: 100
- }
- PathLine {
- y: 160
- x: 20
- }
- PathCubic {
- y: 120
- x: 160
- control1Y: 0
- control1X: 100
- control2Y: 000
- control2X: 200
- }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/pathview1.qml b/tests/auto/qtquick1/qdeclarativepathview/data/pathview1.qml
deleted file mode 100644
index d1ac5171db..0000000000
--- a/tests/auto/qtquick1/qdeclarativepathview/data/pathview1.qml
+++ /dev/null
@@ -1,4 +0,0 @@
-import QtQuick 1.0
-
-PathView {
-}
diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/pathview2.qml b/tests/auto/qtquick1/qdeclarativepathview/data/pathview2.qml
deleted file mode 100644
index 1e1e893a9c..0000000000
--- a/tests/auto/qtquick1/qdeclarativepathview/data/pathview2.qml
+++ /dev/null
@@ -1,57 +0,0 @@
-import QtQuick 1.0
-
-PathView {
- id: photoPathView
- y: 100; width: 800; height: 330; pathItemCount: 10; z: 1
-
- path: Path {
- startX: -50; startY: 40;
-
- PathAttribute { name: "scale"; value: 0.5 }
- PathAttribute { name: "angle"; value: -45 }
-
- PathCubic {
- x: 400; y: 220
- control1X: 140; control1Y: 40
- control2X: 210; control2Y: 220
- }
-
- PathAttribute { name: "scale"; value: 1.2 }
- PathAttribute { name: "angle"; value: 0 }
-
- PathCubic {
- x: 850; y: 40
- control2X: 660; control2Y: 40
- control1X: 590; control1Y: 220
- }
-
- PathAttribute { name: "scale"; value: 0.5 }
- PathAttribute { name: "angle"; value: 45 }
- }
-
- model: ListModel {
- id: rssModel
- ListElement { lColor: "red" }
- ListElement { lColor: "green" }
- ListElement { lColor: "yellow" }
- ListElement { lColor: "blue" }
- ListElement { lColor: "purple" }
- ListElement { lColor: "gray" }
- ListElement { lColor: "brown" }
- ListElement { lColor: "thistle" }
- }
-
- delegate: Component {
- id: photoDelegate
- Rectangle {
- id: wrapper
- width: 85; height: 85; color: lColor
- scale: wrapper.PathView.scale
-
- transform: Rotation {
- id: itemRotation; origin.x: wrapper.width/2; origin.y: wrapper.height/2
- axis.y: 1; axis.z: 0; angle: wrapper.PathView.angle
- }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/pathview3.qml b/tests/auto/qtquick1/qdeclarativepathview/data/pathview3.qml
deleted file mode 100644
index cd1ba0375d..0000000000
--- a/tests/auto/qtquick1/qdeclarativepathview/data/pathview3.qml
+++ /dev/null
@@ -1,59 +0,0 @@
-import QtQuick 1.0
-
-PathView {
- id: photoPathView
- y: 100; width: 800; height: 330; pathItemCount: 4; offset: 1
- dragMargin: 24
- preferredHighlightBegin: 0.50
- preferredHighlightEnd: 0.50
-
- path: Path {
- startX: -50; startY: 40;
-
- PathAttribute { name: "scale"; value: 0.5 }
- PathAttribute { name: "angle"; value: -45 }
-
- PathCubic {
- x: 400; y: 220
- control1X: 140; control1Y: 40
- control2X: 210; control2Y: 220
- }
-
- PathAttribute { name: "scale"; value: 1.2 }
- PathAttribute { name: "angle"; value: 0 }
-
- PathCubic {
- x: 850; y: 40
- control2X: 660; control2Y: 40
- control1X: 590; control1Y: 220
- }
-
- PathAttribute { name: "scale"; value: 0.5 }
- PathAttribute { name: "angle"; value: 45 }
- }
-
- model: ListModel {
- id: rssModel
- ListElement { lColor: "red" }
- ListElement { lColor: "green" }
- ListElement { lColor: "yellow" }
- ListElement { lColor: "blue" }
- ListElement { lColor: "purple" }
- ListElement { lColor: "gray" }
- ListElement { lColor: "brown" }
- ListElement { lColor: "thistle" }
- }
-
- delegate: Component {
- id: photoDelegate
- Rectangle {
- id: wrapper
- width: 85; height: 85; color: lColor
-
- transform: Rotation {
- id: itemRotation; origin.x: wrapper.width/2; origin.y: wrapper.height/2
- axis.y: 1; axis.z: 0
- }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/pathview_package.qml b/tests/auto/qtquick1/qdeclarativepathview/data/pathview_package.qml
deleted file mode 100644
index f9157bddeb..0000000000
--- a/tests/auto/qtquick1/qdeclarativepathview/data/pathview_package.qml
+++ /dev/null
@@ -1,88 +0,0 @@
-import QtQuick 1.0
-
-Item {
- width: 800; height: 600
- Component {
- id: photoDelegate
- Package {
- Item { id: pathItem; objectName: "pathItem"; Package.name: 'path'; width: 85; height: 85; scale: pathItem.PathView.scale }
- Item { id: linearItem; Package.name: 'linear'; width: 85; height: 85 }
- Rectangle {
- id: wrapper
- width: 85; height: 85; color: lColor
-
- transform: Rotation {
- id: itemRotation; origin.x: wrapper.width/2; origin.y: wrapper.height/2
- axis.y: 1; axis.z: 0
- }
- state: 'path'
- states: [
- State {
- name: 'path'
- ParentChange { target: wrapper; parent: pathItem; x: 0; y: 0 }
- PropertyChanges { target: wrapper; opacity: pathItem.PathView.onPath ? 1.0 : 0 }
- }
- ]
- }
- }
- }
- ListModel {
- id: rssModel
- ListElement { lColor: "red" }
- ListElement { lColor: "green" }
- ListElement { lColor: "yellow" }
- ListElement { lColor: "blue" }
- ListElement { lColor: "purple" }
- ListElement { lColor: "gray" }
- ListElement { lColor: "brown" }
- ListElement { lColor: "thistle" }
- }
- VisualDataModel { id: visualModel; model: rssModel; delegate: photoDelegate }
-
- PathView {
- id: photoPathView
- objectName: "photoPathView"
- width: 800; height: 330; pathItemCount: 4; offset: 1
- dragMargin: 24
- preferredHighlightBegin: 0.50
- preferredHighlightEnd: 0.50
-
- path: Path {
- startX: -50; startY: 40;
-
- PathAttribute { name: "scale"; value: 0.5 }
- PathAttribute { name: "angle"; value: -45 }
-
- PathCubic {
- x: 400; y: 220
- control1X: 140; control1Y: 40
- control2X: 210; control2Y: 220
- }
-
- PathAttribute { name: "scale"; value: 1.2 }
- PathAttribute { name: "angle"; value: 0 }
-
- PathCubic {
- x: 850; y: 40
- control2X: 660; control2Y: 40
- control1X: 590; control1Y: 220
- }
-
- PathAttribute { name: "scale"; value: 0.5 }
- PathAttribute { name: "angle"; value: 45 }
- }
-
- model: visualModel.parts.path
- }
-
- PathView {
- y: 400; width: 800; height: 330; pathItemCount: 8
-
- path: Path {
- startX: 0; startY: 40;
- PathLine { x: 800; y: 40 }
- }
-
- model: visualModel.parts.linear
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/propertychanges.qml b/tests/auto/qtquick1/qdeclarativepathview/data/propertychanges.qml
deleted file mode 100644
index c0cc8555e7..0000000000
--- a/tests/auto/qtquick1/qdeclarativepathview/data/propertychanges.qml
+++ /dev/null
@@ -1,116 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 350; height: 220; color: "white"
- Component {
- id: myDelegate
- Item {
- id: wrapper
- width: 180; height: 40;
- opacity: PathView.opacity
- Column {
- x: 5; y: 5
- Text { text: '<b>Name:</b> ' + name }
- Text { text: '<b>Number:</b> ' + number }
- }
- }
- }
-
- PathView {
- preferredHighlightBegin: 0.1
- preferredHighlightEnd: 0.1
- dragMargin: 5.0
- id: pathView
- objectName: "pathView"
- anchors.fill: parent
- model: listModel
- delegate: myDelegate
- focus: true
- path: Path {
- id: myPath
- objectName: "path"
- startX: 220; startY: 200
- PathAttribute { name: "opacity"; value: 1.0; objectName: "pathAttribute"; }
- PathQuad { x: 220; y: 25; controlX: 260; controlY: 75 }
- PathAttribute { name: "opacity"; value: 0.3 }
- PathQuad { x: 220; y: 200; controlX: -20; controlY: 75 }
- }
- Timer {
- interval: 2000; running: true; repeat: true
- onTriggered: {
- if (pathView.path == alternatePath)
- pathView.path = myPath;
- else
- pathView.path = alternatePath;
- }
- }
- }
-
- data:[
- ListModel {
- id: listModel
- ListElement {
- name: "Bill Smith"
- number: "555 3264"
- }
- ListElement {
- name: "John Brown"
- number: "555 8426"
- }
- ListElement {
- name: "Sam Wise"
- number: "555 0473"
- }
- ListElement {
- name: "Bill Smith"
- number: "555 3264"
- }
- ListElement {
- name: "John Brown"
- number: "555 8426"
- }
- ListElement {
- name: "Sam Wise"
- number: "555 0473"
- }
- ListElement {
- name: "Bill Smith"
- number: "555 3264"
- }
- ListElement {
- name: "John Brown"
- number: "555 8426"
- }
- ListElement {
- name: "Sam Wise"
- number: "555 0473"
- }
- },
- ListModel {
- objectName: "alternateModel"
- ListElement {
- name: "Jack"
- number: "555 8426"
- }
- ListElement {
- name: "Mary"
- number: "555 3264"
- }
- },
- Path {
- id: alternatePath
- objectName: "alternatePath"
- startX: 100; startY: 40
- PathAttribute { name: "opacity"; value: 0.0 }
- PathLine { x: 100; y: 160 }
- PathAttribute { name: "opacity"; value: 0.2 }
- PathLine { x: 300; y: 160 }
- PathAttribute { name: "opacity"; value: 0.0 }
- PathLine { x: 300; y: 40 }
- PathAttribute { name: "opacity"; value: 0.2 }
- PathLine { x: 100; y: 40 }
- }
- ]
-}
-
-
diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/treemodel.qml b/tests/auto/qtquick1/qdeclarativepathview/data/treemodel.qml
deleted file mode 100644
index 56f7ae46da..0000000000
--- a/tests/auto/qtquick1/qdeclarativepathview/data/treemodel.qml
+++ /dev/null
@@ -1,19 +0,0 @@
-import QtQuick 1.0
-
-PathView {
- width: 320
- height: 240
- function setRoot(index) {
- vdm.rootIndex = vdm.modelIndex(index);
- }
- model: VisualDataModel {
- id: vdm
- model: myModel
- delegate: Text { objectName: "wrapper"; text: display }
- }
-
- path: Path {
- startX: 0; startY: 120
- PathLine { x: 320; y: 120 }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/undefinedpath.qml b/tests/auto/qtquick1/qdeclarativepathview/data/undefinedpath.qml
deleted file mode 100644
index 5a647cb079..0000000000
--- a/tests/auto/qtquick1/qdeclarativepathview/data/undefinedpath.qml
+++ /dev/null
@@ -1,17 +0,0 @@
-import QtQuick 1.0
-
-PathView {
- id: pathView
- width: 240; height: 200
- path: Path {
- startX: pathView.undef/2.0; startY: 0
- PathLine { x: pathView.undef/2.0; y: 0 }
- }
-
- delegate: Text { text: value }
- model: ListModel {
- ListElement { value: "one" }
- ListElement { value: "two" }
- ListElement { value: "three" }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/vdm.qml b/tests/auto/qtquick1/qdeclarativepathview/data/vdm.qml
deleted file mode 100644
index 012db3fb57..0000000000
--- a/tests/auto/qtquick1/qdeclarativepathview/data/vdm.qml
+++ /dev/null
@@ -1,28 +0,0 @@
-import QtQuick 1.0
-
-PathView {
- id: pathView
- width: 240; height: 320
-
- pathItemCount: 4
- preferredHighlightBegin : 0.5
- preferredHighlightEnd : 0.5
-
- path: Path {
- startX: 120; startY: 20;
- PathLine { x: 120; y: 300 }
- }
-
- ListModel {
- id: mo
- ListElement { value: "one" }
- ListElement { value: "two" }
- ListElement { value: "three" }
- }
-
- model: VisualDataModel {
- delegate: Text { text: model.value }
- model : mo
- }
-}
-
diff --git a/tests/auto/qtquick1/qdeclarativepathview/qdeclarativepathview.pro b/tests/auto/qtquick1/qdeclarativepathview/qdeclarativepathview.pro
deleted file mode 100644
index cf5cf64d01..0000000000
--- a/tests/auto/qtquick1/qdeclarativepathview/qdeclarativepathview.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativepathview
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativepathview.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
-QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib
diff --git a/tests/auto/qtquick1/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/qtquick1/qdeclarativepathview/tst_qdeclarativepathview.cpp
deleted file mode 100644
index 470ceca5fe..0000000000
--- a/tests/auto/qtquick1/qdeclarativepathview/tst_qdeclarativepathview.cpp
+++ /dev/null
@@ -1,1061 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtQuick1/qdeclarativeview.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtQuick1/private/qdeclarativepathview_p.h>
-#include <QtQuick1/private/qdeclarativepath_p.h>
-#include <QtQuick1/private/qdeclarativetext_p.h>
-#include <QtQuick1/private/qdeclarativerectangle_p.h>
-#include <QtDeclarative/private/qdeclarativevaluetype_p.h>
-#include <QAbstractListModel>
-#include <QStringListModel>
-#include <QStandardItemModel>
-#include <QFile>
-
-static void initStandardTreeModel(QStandardItemModel *model)
-{
- QStandardItem *item;
- item = new QStandardItem(QLatin1String("Row 1 Item"));
- model->insertRow(0, item);
-
- item = new QStandardItem(QLatin1String("Row 2 Item"));
- item->setCheckable(true);
- model->insertRow(1, item);
-
- QStandardItem *childItem = new QStandardItem(QLatin1String("Row 2 Child Item"));
- item->setChild(0, childItem);
-
- item = new QStandardItem(QLatin1String("Row 3 Item"));
- item->setIcon(QIcon());
- model->insertRow(2, item);
-}
-
-
-class tst_QDeclarative1PathView : public QObject
-{
- Q_OBJECT
-public:
- tst_QDeclarative1PathView();
-
-private slots:
- void initValues();
- void items();
- void dataModel();
- void pathview2();
- void pathview3();
- void path();
- void pathMoved();
- void setCurrentIndex();
- void resetModel();
- void propertyChanges();
- void pathChanges();
- void componentChanges();
- void modelChanges();
- void pathUpdateOnStartChanged();
- void package();
- void emptyModel();
- void closed();
- void pathUpdate();
- void visualDataModel();
- void undefinedPath();
- void mouseDrag();
- void treeModel();
- void changePreferredHighlight();
-
-private:
- QDeclarativeView *createView();
- template<typename T>
- T *findItem(QGraphicsObject *parent, const QString &objectName, int index=-1);
- template<typename T>
- QList<T*> findItems(QGraphicsObject *parent, const QString &objectName);
-};
-
-class TestObject : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(bool error READ error WRITE setError)
- Q_PROPERTY(bool useModel READ useModel NOTIFY useModelChanged)
- Q_PROPERTY(int pathItemCount READ pathItemCount NOTIFY pathItemCountChanged)
-
-public:
- TestObject() : QObject(), mError(true), mUseModel(true), mPathItemCount(-1) {}
-
- bool error() const { return mError; }
- void setError(bool err) { mError = err; }
-
- bool useModel() const { return mUseModel; }
- void setUseModel(bool use) { mUseModel = use; emit useModelChanged(); }
-
- int pathItemCount() const { return mPathItemCount; }
- void setPathItemCount(int count) { mPathItemCount = count; emit pathItemCountChanged(); }
-
-signals:
- void useModelChanged();
- void pathItemCountChanged();
-
-private:
- bool mError;
- bool mUseModel;
- int mPathItemCount;
-};
-
-class TestModel : public QAbstractListModel
-{
-public:
- enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 };
-
- TestModel(QObject *parent=0) : QAbstractListModel(parent) {
- QHash<int, QByteArray> roles;
- roles[Name] = "name";
- roles[Number] = "number";
- setRoleNames(roles);
- }
-
- int rowCount(const QModelIndex &parent=QModelIndex()) const { Q_UNUSED(parent); return list.count(); }
- QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const {
- QVariant rv;
- if (role == Name)
- rv = list.at(index.row()).first;
- else if (role == Number)
- rv = list.at(index.row()).second;
-
- return rv;
- }
-
- int count() const { return rowCount(); }
- QString name(int index) const { return list.at(index).first; }
- QString number(int index) const { return list.at(index).second; }
-
- void addItem(const QString &name, const QString &number) {
- beginInsertRows(QModelIndex(), list.count(), list.count());
- list.append(QPair<QString,QString>(name, number));
- endInsertRows();
- }
-
- void insertItem(int index, const QString &name, const QString &number) {
- beginInsertRows(QModelIndex(), index, index);
- list.insert(index, QPair<QString,QString>(name, number));
- endInsertRows();
- }
-
- void removeItem(int index) {
- beginRemoveRows(QModelIndex(), index, index);
- list.removeAt(index);
- endRemoveRows();
- }
-
- void moveItem(int from, int to) {
- beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
- list.move(from, to);
- endMoveRows();
- }
-
- void modifyItem(int idx, const QString &name, const QString &number) {
- list[idx] = QPair<QString,QString>(name, number);
- emit dataChanged(index(idx,0), index(idx,0));
- }
-
-private:
- QList<QPair<QString,QString> > list;
-};
-
-
-tst_QDeclarative1PathView::tst_QDeclarative1PathView()
-{
-}
-
-void tst_QDeclarative1PathView::initValues()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/pathview1.qml"));
- QDeclarative1PathView *obj = qobject_cast<QDeclarative1PathView*>(c.create());
-
- QVERIFY(obj != 0);
- QVERIFY(obj->path() == 0);
- QVERIFY(obj->delegate() == 0);
- QCOMPARE(obj->model(), QVariant());
- QCOMPARE(obj->currentIndex(), 0);
- QCOMPARE(obj->offset(), 0.);
- QCOMPARE(obj->preferredHighlightBegin(), 0.);
- QCOMPARE(obj->dragMargin(), 0.);
- QCOMPARE(obj->count(), 0);
- QCOMPARE(obj->pathItemCount(), -1);
-}
-
-void tst_QDeclarative1PathView::items()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
- model.addItem("Bill", "4321");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview0.qml"));
- qApp->processEvents();
-
- QDeclarative1PathView *pathview = findItem<QDeclarative1PathView>(canvas->rootObject(), "view");
- QVERIFY(pathview != 0);
-
- QCOMPARE(pathview->count(), model.count());
- QCOMPARE(canvas->rootObject()->property("count").toInt(), model.count());
- QCOMPARE(pathview->childItems().count(), model.count()+1); // assumes all are visible, including highlight
-
- for (int i = 0; i < model.count(); ++i) {
- QDeclarative1Text *name = findItem<QDeclarative1Text>(pathview, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
- QDeclarative1Text *number = findItem<QDeclarative1Text>(pathview, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
- }
-
- QDeclarative1Path *path = qobject_cast<QDeclarative1Path*>(pathview->path());
- QVERIFY(path);
-
- QVERIFY(pathview->highlightItem());
- QPointF start = path->pointAt(0.0);
- QPointF offset;
- offset.setX(pathview->highlightItem()->width()/2);
- offset.setY(pathview->highlightItem()->height()/2);
- QCOMPARE(pathview->highlightItem()->pos() + offset, start);
-
- delete canvas;
-}
-
-void tst_QDeclarative1PathView::pathview2()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/pathview2.qml"));
- QDeclarative1PathView *obj = qobject_cast<QDeclarative1PathView*>(c.create());
-
- QVERIFY(obj != 0);
- QVERIFY(obj->path() != 0);
- QVERIFY(obj->delegate() != 0);
- QVERIFY(obj->model() != QVariant());
- QCOMPARE(obj->currentIndex(), 0);
- QCOMPARE(obj->offset(), 0.);
- QCOMPARE(obj->preferredHighlightBegin(), 0.);
- QCOMPARE(obj->dragMargin(), 0.);
- QCOMPARE(obj->count(), 8);
- QCOMPARE(obj->pathItemCount(), 10);
-}
-
-void tst_QDeclarative1PathView::pathview3()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/pathview3.qml"));
- QDeclarative1PathView *obj = qobject_cast<QDeclarative1PathView*>(c.create());
-
- QVERIFY(obj != 0);
- QVERIFY(obj->path() != 0);
- QVERIFY(obj->delegate() != 0);
- QVERIFY(obj->model() != QVariant());
- QCOMPARE(obj->currentIndex(), 0);
- QCOMPARE(obj->offset(), 1.0);
- QCOMPARE(obj->preferredHighlightBegin(), 0.5);
- QCOMPARE(obj->dragMargin(), 24.);
- QCOMPARE(obj->count(), 8);
- QCOMPARE(obj->pathItemCount(), 4);
-}
-
-void tst_QDeclarative1PathView::path()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/pathtest.qml"));
- QDeclarative1Path *obj = qobject_cast<QDeclarative1Path*>(c.create());
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->startX(), 120.);
- QCOMPARE(obj->startY(), 100.);
- QVERIFY(obj->path() != QPainterPath());
-
- QDeclarativeListReference list(obj, "pathElements");
- QCOMPARE(list.count(), 5);
-
- QDeclarative1PathAttribute* attr = qobject_cast<QDeclarative1PathAttribute*>(list.at(0));
- QVERIFY(attr != 0);
- QCOMPARE(attr->name(), QString("scale"));
- QCOMPARE(attr->value(), 1.0);
-
- QDeclarative1PathQuad* quad = qobject_cast<QDeclarative1PathQuad*>(list.at(1));
- QVERIFY(quad != 0);
- QCOMPARE(quad->x(), 120.);
- QCOMPARE(quad->y(), 25.);
- QCOMPARE(quad->controlX(), 260.);
- QCOMPARE(quad->controlY(), 75.);
-
- QDeclarative1PathPercent* perc = qobject_cast<QDeclarative1PathPercent*>(list.at(2));
- QVERIFY(perc != 0);
- QCOMPARE(perc->value(), 0.3);
-
- QDeclarative1PathLine* line = qobject_cast<QDeclarative1PathLine*>(list.at(3));
- QVERIFY(line != 0);
- QCOMPARE(line->x(), 120.);
- QCOMPARE(line->y(), 100.);
-
- QDeclarative1PathCubic* cubic = qobject_cast<QDeclarative1PathCubic*>(list.at(4));
- QVERIFY(cubic != 0);
- QCOMPARE(cubic->x(), 180.);
- QCOMPARE(cubic->y(), 0.);
- QCOMPARE(cubic->control1X(), -10.);
- QCOMPARE(cubic->control1Y(), 90.);
- QCOMPARE(cubic->control2X(), 210.);
- QCOMPARE(cubic->control2Y(), 90.);
-}
-
-void tst_QDeclarative1PathView::dataModel()
-{
- QDeclarativeView *canvas = createView();
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- TestModel model;
- model.addItem("red", "1");
- model.addItem("green", "2");
- model.addItem("blue", "3");
- model.addItem("purple", "4");
- model.addItem("gray", "5");
- model.addItem("brown", "6");
- model.addItem("yellow", "7");
- model.addItem("thistle", "8");
- model.addItem("cyan", "9");
- model.addItem("peachpuff", "10");
- model.addItem("powderblue", "11");
- model.addItem("gold", "12");
- model.addItem("sandybrown", "13");
-
- ctxt->setContextProperty("testData", &model);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/datamodel.qml"));
- qApp->processEvents();
-
- QDeclarative1PathView *pathview = qobject_cast<QDeclarative1PathView*>(canvas->rootObject());
- QVERIFY(pathview != 0);
-
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
-
- QDeclarativeItem *item = findItem<QDeclarativeItem>(pathview, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->x(), 110.0);
- QCOMPARE(item->y(), 10.0);
-
- model.insertItem(4, "orange", "10");
- QTest::qWait(100);
-
- QCOMPARE(canvas->rootObject()->property("viewCount").toInt(), model.count());
- QTRY_COMPARE(findItems<QDeclarativeItem>(pathview, "wrapper").count(), 14);
-
- QVERIFY(pathview->currentIndex() == 0);
-
- QDeclarative1Text *text = findItem<QDeclarative1Text>(pathview, "myText", 4);
- QVERIFY(text);
- QCOMPARE(text->text(), model.name(4));
-
- model.removeItem(2);
- QCOMPARE(canvas->rootObject()->property("viewCount").toInt(), model.count());
- text = findItem<QDeclarative1Text>(pathview, "myText", 2);
- QVERIFY(text);
- QCOMPARE(text->text(), model.name(2));
-
- testObject->setPathItemCount(5);
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
-
- QTRY_COMPARE(findItems<QDeclarativeItem>(pathview, "wrapper").count(), 5);
-
- QDeclarative1Rectangle *testItem = findItem<QDeclarative1Rectangle>(pathview, "wrapper", 4);
- QVERIFY(testItem != 0);
- testItem = findItem<QDeclarative1Rectangle>(pathview, "wrapper", 5);
- QVERIFY(testItem == 0);
-
- pathview->setCurrentIndex(1);
-
- model.insertItem(2, "pink", "2");
- QTest::qWait(100);
-
- QTRY_COMPARE(findItems<QDeclarativeItem>(pathview, "wrapper").count(), 5);
- QVERIFY(pathview->currentIndex() == 1);
-
- text = findItem<QDeclarative1Text>(pathview, "myText", 2);
- QVERIFY(text);
- QCOMPARE(text->text(), model.name(2));
-
- model.removeItem(3);
- QTRY_COMPARE(findItems<QDeclarativeItem>(pathview, "wrapper").count(), 5);
- text = findItem<QDeclarative1Text>(pathview, "myText", 3);
- QVERIFY(text);
- QCOMPARE(text->text(), model.name(3));
-
- model.moveItem(3, 5);
- QTRY_COMPARE(findItems<QDeclarativeItem>(pathview, "wrapper").count(), 5);
- QList<QDeclarativeItem*> items = findItems<QDeclarativeItem>(pathview, "wrapper");
- foreach (QDeclarativeItem *item, items) {
- QVERIFY(item->property("onPath").toBool());
- }
-
- // QTBUG-14199
- pathview->setOffset(7);
- pathview->setOffset(0);
- QCOMPARE(findItems<QDeclarativeItem>(pathview, "wrapper").count(), 5);
-
- pathview->setCurrentIndex(model.count()-1);
- model.removeItem(model.count()-1);
- QCOMPARE(pathview->currentIndex(), model.count()-1);
-
- // QTBUG-18825
- // Confirm that the target offset is adjusted when removing items
- pathview->setCurrentIndex(model.count()-1);
- QTRY_COMPARE(pathview->offset(), 1.);
- pathview->setCurrentIndex(model.count()-5);
- model.removeItem(model.count()-1);
- model.removeItem(model.count()-1);
- model.removeItem(model.count()-1);
- QTRY_COMPARE(pathview->offset(), 2.);
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QDeclarative1PathView::pathMoved()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- model.addItem("Ben", "12345");
- model.addItem("Bohn", "2345");
- model.addItem("Bob", "54321");
- model.addItem("Bill", "4321");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview0.qml"));
- qApp->processEvents();
-
- QDeclarative1PathView *pathview = findItem<QDeclarative1PathView>(canvas->rootObject(), "view");
- QVERIFY(pathview != 0);
-
- QDeclarative1Rectangle *firstItem = findItem<QDeclarative1Rectangle>(pathview, "wrapper", 0);
- QVERIFY(firstItem);
- QDeclarative1Path *path = qobject_cast<QDeclarative1Path*>(pathview->path());
- QVERIFY(path);
- QPointF start = path->pointAt(0.0);
- QPointF offset;//Center of item is at point, but pos is from corner
- offset.setX(firstItem->width()/2);
- offset.setY(firstItem->height()/2);
- QCOMPARE(firstItem->pos() + offset, start);
- pathview->setOffset(1.0);
-
- for(int i=0; i<model.count(); i++){
- QDeclarative1Rectangle *curItem = findItem<QDeclarative1Rectangle>(pathview, "wrapper", i);
- QPointF itemPos(path->pointAt(0.25 + i*0.25));
- QCOMPARE(curItem->pos() + offset, QPointF(qRound(itemPos.x()), qRound(itemPos.y())));
- }
-
- pathview->setOffset(0.0);
- QCOMPARE(firstItem->pos() + offset, start);
-
- // Change delegate size
- pathview->setOffset(0.1);
- pathview->setOffset(0.0);
- canvas->rootObject()->setProperty("delegateWidth", 30);
- QCOMPARE(firstItem->width(), 30.0);
- offset.setX(firstItem->width()/2);
- QTRY_COMPARE(firstItem->pos() + offset, start);
-
- // Change delegate scale
- pathview->setOffset(0.1);
- pathview->setOffset(0.0);
- canvas->rootObject()->setProperty("delegateScale", 1.2);
- QTRY_COMPARE(firstItem->pos() + offset, start);
-
- delete canvas;
-}
-
-void tst_QDeclarative1PathView::setCurrentIndex()
-{
- QDeclarativeView *canvas = createView();
-
- TestModel model;
- model.addItem("Ben", "12345");
- model.addItem("Bohn", "2345");
- model.addItem("Bob", "54321");
- model.addItem("Bill", "4321");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview0.qml"));
- qApp->processEvents();
-
- QDeclarative1PathView *pathview = findItem<QDeclarative1PathView>(canvas->rootObject(), "view");
- QVERIFY(pathview != 0);
-
- QDeclarative1Rectangle *firstItem = findItem<QDeclarative1Rectangle>(pathview, "wrapper", 0);
- QVERIFY(firstItem);
- QDeclarative1Path *path = qobject_cast<QDeclarative1Path*>(pathview->path());
- QVERIFY(path);
- QPointF start = path->pointAt(0.0);
- QPointF offset;//Center of item is at point, but pos is from corner
- offset.setX(firstItem->width()/2);
- offset.setY(firstItem->height()/2);
- QCOMPARE(firstItem->pos() + offset, start);
- QCOMPARE(canvas->rootObject()->property("currentA").toInt(), 0);
- QCOMPARE(canvas->rootObject()->property("currentB").toInt(), 0);
-
- pathview->setCurrentIndex(2);
-
- firstItem = findItem<QDeclarative1Rectangle>(pathview, "wrapper", 2);
- QTRY_COMPARE(firstItem->pos() + offset, start);
- QCOMPARE(canvas->rootObject()->property("currentA").toInt(), 2);
- QCOMPARE(canvas->rootObject()->property("currentB").toInt(), 2);
-
- pathview->decrementCurrentIndex();
- QTRY_COMPARE(pathview->currentIndex(), 1);
- firstItem = findItem<QDeclarative1Rectangle>(pathview, "wrapper", 1);
- QVERIFY(firstItem);
- QTRY_COMPARE(firstItem->pos() + offset, start);
-
- pathview->decrementCurrentIndex();
- QTRY_COMPARE(pathview->currentIndex(), 0);
- firstItem = findItem<QDeclarative1Rectangle>(pathview, "wrapper", 0);
- QVERIFY(firstItem);
- QTRY_COMPARE(firstItem->pos() + offset, start);
-
- pathview->decrementCurrentIndex();
- QTRY_COMPARE(pathview->currentIndex(), 3);
- firstItem = findItem<QDeclarative1Rectangle>(pathview, "wrapper", 3);
- QVERIFY(firstItem);
- QTRY_COMPARE(firstItem->pos() + offset, start);
-
- pathview->incrementCurrentIndex();
- QTRY_COMPARE(pathview->currentIndex(), 0);
- firstItem = findItem<QDeclarative1Rectangle>(pathview, "wrapper", 0);
- QVERIFY(firstItem);
- QTRY_COMPARE(firstItem->pos() + offset, start);
-
- delete canvas;
-}
-
-void tst_QDeclarative1PathView::resetModel()
-{
- QDeclarativeView *canvas = createView();
-
- QStringList strings;
- strings << "one" << "two" << "three";
- QStringListModel model(strings);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/displaypath.qml"));
- qApp->processEvents();
-
- QDeclarative1PathView *pathview = findItem<QDeclarative1PathView>(canvas->rootObject(), "view");
- QVERIFY(pathview != 0);
-
- QCOMPARE(pathview->count(), model.rowCount());
-
- for (int i = 0; i < model.rowCount(); ++i) {
- QDeclarative1Text *display = findItem<QDeclarative1Text>(pathview, "displayText", i);
- QVERIFY(display != 0);
- QCOMPARE(display->text(), strings.at(i));
- }
-
- strings.clear();
- strings << "four" << "five" << "six" << "seven";
- model.setStringList(strings);
-
- QCOMPARE(pathview->count(), model.rowCount());
-
- for (int i = 0; i < model.rowCount(); ++i) {
- QDeclarative1Text *display = findItem<QDeclarative1Text>(pathview, "displayText", i);
- QVERIFY(display != 0);
- QCOMPARE(display->text(), strings.at(i));
- }
-
- delete canvas;
-}
-
-void tst_QDeclarative1PathView::propertyChanges()
-{
- QDeclarativeView *canvas = createView();
- QVERIFY(canvas);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
-
- QDeclarative1PathView *pathView = canvas->rootObject()->findChild<QDeclarative1PathView*>("pathView");
- QVERIFY(pathView);
-
- QSignalSpy snapPositionSpy(pathView, SIGNAL(preferredHighlightBeginChanged()));
- QSignalSpy dragMarginSpy(pathView, SIGNAL(dragMarginChanged()));
-
- QCOMPARE(pathView->preferredHighlightBegin(), 0.1);
- QCOMPARE(pathView->dragMargin(), 5.0);
-
- pathView->setPreferredHighlightBegin(0.4);
- pathView->setPreferredHighlightEnd(0.4);
- pathView->setDragMargin(20.0);
-
- QCOMPARE(pathView->preferredHighlightBegin(), 0.4);
- QCOMPARE(pathView->preferredHighlightEnd(), 0.4);
- QCOMPARE(pathView->dragMargin(), 20.0);
-
- QCOMPARE(snapPositionSpy.count(), 1);
- QCOMPARE(dragMarginSpy.count(), 1);
-
- pathView->setPreferredHighlightBegin(0.4);
- pathView->setPreferredHighlightEnd(0.4);
- pathView->setDragMargin(20.0);
-
- QCOMPARE(snapPositionSpy.count(), 1);
- QCOMPARE(dragMarginSpy.count(), 1);
- delete canvas;
-}
-
-void tst_QDeclarative1PathView::pathChanges()
-{
- QDeclarativeView *canvas = createView();
- QVERIFY(canvas);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
-
- QDeclarative1PathView *pathView = canvas->rootObject()->findChild<QDeclarative1PathView*>("pathView");
- QVERIFY(pathView);
-
- QDeclarative1Path *path = canvas->rootObject()->findChild<QDeclarative1Path*>("path");
- QVERIFY(path);
-
- QSignalSpy startXSpy(path, SIGNAL(startXChanged()));
- QSignalSpy startYSpy(path, SIGNAL(startYChanged()));
-
- QCOMPARE(path->startX(), 220.0);
- QCOMPARE(path->startY(), 200.0);
-
- path->setStartX(240.0);
- path->setStartY(220.0);
-
- QCOMPARE(path->startX(), 240.0);
- QCOMPARE(path->startY(), 220.0);
-
- QCOMPARE(startXSpy.count(),1);
- QCOMPARE(startYSpy.count(),1);
-
- path->setStartX(240);
- path->setStartY(220);
-
- QCOMPARE(startXSpy.count(),1);
- QCOMPARE(startYSpy.count(),1);
-
- QDeclarative1Path *alternatePath = canvas->rootObject()->findChild<QDeclarative1Path*>("alternatePath");
- QVERIFY(alternatePath);
-
- QSignalSpy pathSpy(pathView, SIGNAL(pathChanged()));
-
- QCOMPARE(pathView->path(), path);
-
- pathView->setPath(alternatePath);
- QCOMPARE(pathView->path(), alternatePath);
- QCOMPARE(pathSpy.count(),1);
-
- pathView->setPath(alternatePath);
- QCOMPARE(pathSpy.count(),1);
-
- QDeclarative1PathAttribute *pathAttribute = canvas->rootObject()->findChild<QDeclarative1PathAttribute*>("pathAttribute");
- QVERIFY(pathAttribute);
-
- QSignalSpy nameSpy(pathAttribute, SIGNAL(nameChanged()));
- QCOMPARE(pathAttribute->name(), QString("opacity"));
-
- pathAttribute->setName("scale");
- QCOMPARE(pathAttribute->name(), QString("scale"));
- QCOMPARE(nameSpy.count(),1);
-
- pathAttribute->setName("scale");
- QCOMPARE(nameSpy.count(),1);
- delete canvas;
-}
-
-void tst_QDeclarative1PathView::componentChanges()
-{
- QDeclarativeView *canvas = createView();
- QVERIFY(canvas);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
-
- QDeclarative1PathView *pathView = canvas->rootObject()->findChild<QDeclarative1PathView*>("pathView");
- QVERIFY(pathView);
-
- QDeclarativeComponent delegateComponent(canvas->engine());
- delegateComponent.setData("import QtQuick 1.0; Text { text: '<b>Name:</b> ' + name }", QUrl::fromLocalFile(""));
-
- QSignalSpy delegateSpy(pathView, SIGNAL(delegateChanged()));
-
- pathView->setDelegate(&delegateComponent);
- QCOMPARE(pathView->delegate(), &delegateComponent);
- QCOMPARE(delegateSpy.count(),1);
-
- pathView->setDelegate(&delegateComponent);
- QCOMPARE(delegateSpy.count(),1);
- delete canvas;
-}
-
-void tst_QDeclarative1PathView::modelChanges()
-{
- QDeclarativeView *canvas = createView();
- QVERIFY(canvas);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
-
- QDeclarative1PathView *pathView = canvas->rootObject()->findChild<QDeclarative1PathView*>("pathView");
- QVERIFY(pathView);
-
-// QDeclarative1ListModel *alternateModel = canvas->rootObject()->findChild<QDeclarative1ListModel*>("alternateModel");
- QObject *alternateModel = canvas->rootObject()->findChild<QObject*>("alternateModel");
- QVERIFY(alternateModel);
- QVariant modelVariant = QVariant::fromValue(alternateModel);
- QSignalSpy modelSpy(pathView, SIGNAL(modelChanged()));
-
- pathView->setModel(modelVariant);
- QCOMPARE(pathView->model(), modelVariant);
- QCOMPARE(modelSpy.count(),1);
-
- pathView->setModel(modelVariant);
- QCOMPARE(modelSpy.count(),1);
-
- pathView->setModel(QVariant());
- QCOMPARE(modelSpy.count(),2);
-
- delete canvas;
-}
-
-void tst_QDeclarative1PathView::pathUpdateOnStartChanged()
-{
- QDeclarativeView *canvas = createView();
- QVERIFY(canvas);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathUpdateOnStartChanged.qml"));
-
- QDeclarative1PathView *pathView = canvas->rootObject()->findChild<QDeclarative1PathView*>("pathView");
- QVERIFY(pathView);
-
- QDeclarative1Path *path = canvas->rootObject()->findChild<QDeclarative1Path*>("path");
- QVERIFY(path);
- QCOMPARE(path->startX(), 400.0);
- QCOMPARE(path->startY(), 300.0);
-
- QDeclarativeItem *item = findItem<QDeclarativeItem>(pathView, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->x(), path->startX() - item->width() / 2.0);
- QCOMPARE(item->y(), path->startY() - item->height() / 2.0);
-
- delete canvas;
-}
-
-void tst_QDeclarative1PathView::package()
-{
- QDeclarativeView *canvas = createView();
- QVERIFY(canvas);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview_package.qml"));
-
- QDeclarative1PathView *pathView = canvas->rootObject()->findChild<QDeclarative1PathView*>("photoPathView");
- QVERIFY(pathView);
-
- QDeclarativeItem *item = findItem<QDeclarativeItem>(pathView, "pathItem");
- QVERIFY(item);
- QVERIFY(item->scale() != 1.0);
-
- delete canvas;
-}
-
-//QTBUG-13017
-void tst_QDeclarative1PathView::emptyModel()
-{
- QDeclarativeView *canvas = createView();
-
- QStringListModel model;
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("emptyModel", &model);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/emptymodel.qml"));
- qApp->processEvents();
-
- QDeclarative1PathView *pathview = qobject_cast<QDeclarative1PathView*>(canvas->rootObject());
- QVERIFY(pathview != 0);
-
- QCOMPARE(pathview->offset(), qreal(0.0));
-
- delete canvas;
-}
-
-void tst_QDeclarative1PathView::closed()
-{
- QDeclarativeEngine engine;
-
- {
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/openPath.qml"));
- QDeclarative1Path *obj = qobject_cast<QDeclarative1Path*>(c.create());
- QVERIFY(obj);
- QCOMPARE(obj->isClosed(), false);
- delete obj;
- }
-
- {
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/closedPath.qml"));
- QDeclarative1Path *obj = qobject_cast<QDeclarative1Path*>(c.create());
- QVERIFY(obj);
- QCOMPARE(obj->isClosed(), true);
- delete obj;
- }
-}
-
-// QTBUG-14239
-void tst_QDeclarative1PathView::pathUpdate()
-{
- QDeclarativeView *canvas = createView();
- QVERIFY(canvas);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathUpdate.qml"));
-
- QDeclarative1PathView *pathView = canvas->rootObject()->findChild<QDeclarative1PathView*>("pathView");
- QVERIFY(pathView);
-
- QDeclarativeItem *item = findItem<QDeclarativeItem>(pathView, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->x(), 150.0);
-
- delete canvas;
-}
-
-void tst_QDeclarative1PathView::visualDataModel()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/vdm.qml"));
-
- QDeclarative1PathView *obj = qobject_cast<QDeclarative1PathView*>(c.create());
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->count(), 3);
-
- delete obj;
-}
-
-void tst_QDeclarative1PathView::undefinedPath()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/undefinedpath.qml"));
-
- QDeclarative1PathView *obj = qobject_cast<QDeclarative1PathView*>(c.create());
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->count(), 3);
-
- delete obj;
-}
-
-void tst_QDeclarative1PathView::mouseDrag()
-{
- QDeclarativeView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/dragpath.qml"));
- canvas->show();
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
-
- QDeclarative1PathView *pathview = qobject_cast<QDeclarative1PathView*>(canvas->rootObject());
- QVERIFY(pathview != 0);
-
- int current = pathview->currentIndex();
-
- QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(10,100)));
-
- {
- QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(30,100)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(canvas->viewport(), &mv);
- }
- {
- QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(90,100)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(canvas->viewport(), &mv);
- }
-
- QVERIFY(pathview->currentIndex() != current);
-
- QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(40,100)));
-
- delete canvas;
-}
-
-void tst_QDeclarative1PathView::treeModel()
-{
- QDeclarativeView *canvas = createView();
-
- QStandardItemModel model;
- initStandardTreeModel(&model);
- canvas->engine()->rootContext()->setContextProperty("myModel", &model);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/treemodel.qml"));
-
- QDeclarative1PathView *pathview = qobject_cast<QDeclarative1PathView*>(canvas->rootObject());
- QVERIFY(pathview != 0);
- QCOMPARE(pathview->count(), 3);
-
- QDeclarative1Text *item = findItem<QDeclarative1Text>(pathview, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->text(), QLatin1String("Row 1 Item"));
-
- QVERIFY(QMetaObject::invokeMethod(pathview, "setRoot", Q_ARG(QVariant, 1)));
- QCOMPARE(pathview->count(), 1);
-
- QTRY_VERIFY(item = findItem<QDeclarative1Text>(pathview, "wrapper", 0));
- QTRY_COMPARE(item->text(), QLatin1String("Row 2 Child Item"));
-
- delete canvas;
-}
-
-void tst_QDeclarative1PathView::changePreferredHighlight()
-{
- QDeclarativeView *canvas = createView();
- canvas->setFixedSize(400,200);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/dragpath.qml"));
- canvas->show();
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
-
- QDeclarative1PathView *pathview = qobject_cast<QDeclarative1PathView*>(canvas->rootObject());
- QVERIFY(pathview != 0);
-
- int current = pathview->currentIndex();
- QCOMPARE(current, 0);
-
- QDeclarative1Rectangle *firstItem = findItem<QDeclarative1Rectangle>(pathview, "wrapper", 0);
- QVERIFY(firstItem);
- QDeclarative1Path *path = qobject_cast<QDeclarative1Path*>(pathview->path());
- QVERIFY(path);
- QPointF start = path->pointAt(0.5);
- start.setX(qRound(start.x()));
- start.setY(qRound(start.y()));
- QPointF offset;//Center of item is at point, but pos is from corner
- offset.setX(firstItem->width()/2);
- offset.setY(firstItem->height()/2);
- QTRY_COMPARE(firstItem->pos() + offset, start);
-
- pathview->setPreferredHighlightBegin(0.8);
- pathview->setPreferredHighlightEnd(0.8);
- start = path->pointAt(0.8);
- start.setX(qRound(start.x()));
- start.setY(qRound(start.y()));
- QTRY_COMPARE(firstItem->pos() + offset, start);
- QCOMPARE(pathview->currentIndex(), 0);
-
- delete canvas;
-}
-
-QDeclarativeView *tst_QDeclarative1PathView::createView()
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setFixedSize(240,320);
-
- return canvas;
-}
-
-/*
- Find an item with the specified objectName. If index is supplied then the
- item must also evaluate the {index} expression equal to index
- */
-template<typename T>
-T *tst_QDeclarative1PathView::findItem(QGraphicsObject *parent, const QString &objectName, int index)
-{
- const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->childItems().count() << "children";
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- //qDebug() << "try" << item;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
- if (index != -1) {
- QDeclarativeExpression e(qmlContext(item), item, "index");
- if (e.evaluate().toInt() == index)
- return static_cast<T*>(item);
- } else {
- return static_cast<T*>(item);
- }
- }
- item = findItem<T>(item, objectName, index);
- if (item)
- return static_cast<T*>(item);
- }
-
- return 0;
-}
-
-template<typename T>
-QList<T*> tst_QDeclarative1PathView::findItems(QGraphicsObject *parent, const QString &objectName)
-{
- QList<T*> items;
- const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->QGraphicsObject::children().count() << "children";
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- //qDebug() << "try" << item;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName))
- items.append(static_cast<T*>(item));
- items += findItems<T>(item, objectName);
- }
-
- return items;
-}
-
-QTEST_MAIN(tst_QDeclarative1PathView)
-
-#include "tst_qdeclarativepathview.moc"
diff --git a/tests/auto/qtquick1/qdeclarativepincharea/data/flickresize.qml b/tests/auto/qtquick1/qdeclarativepincharea/data/flickresize.qml
deleted file mode 100644
index 2da58fce3a..0000000000
--- a/tests/auto/qtquick1/qdeclarativepincharea/data/flickresize.qml
+++ /dev/null
@@ -1,50 +0,0 @@
-import QtQuick 1.1
-
-Flickable {
- id: flick
- property real scale: 1.0
- width: 640
- height: 360
- contentWidth: 500
- contentHeight: 500
-
- PinchArea {
- objectName: "pincharea"
- width: Math.max(flick.contentWidth, flick.width)
- height: Math.max(flick.contentHeight, flick.height)
-
- property real initialWidth
- property real initialHeight
- onPinchStarted: {
- initialWidth = flick.contentWidth
- initialHeight = flick.contentHeight
- }
-
- onPinchUpdated: {
- // adjust content pos due to drag
- flick.contentX += pinch.previousCenter.x - pinch.center.x
- flick.contentY += pinch.previousCenter.y - pinch.center.y
-
- // resize content
- flick.resizeContent(initialWidth * pinch.scale, initialHeight * pinch.scale, pinch.center)
- flick.scale = pinch.scale
- }
-
- onPinchFinished: {
- // Move its content within bounds.
- flick.returnToBounds()
- }
-
- Rectangle {
- width: flick.contentWidth
- height: flick.contentHeight
- color: "white"
- Rectangle {
- anchors.centerIn: parent
- width: parent.width-40
- height: parent.height-40
- color: "blue"
- }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepincharea/data/pinchproperties.qml b/tests/auto/qtquick1/qdeclarativepincharea/data/pinchproperties.qml
deleted file mode 100644
index 0b59d9dc15..0000000000
--- a/tests/auto/qtquick1/qdeclarativepincharea/data/pinchproperties.qml
+++ /dev/null
@@ -1,46 +0,0 @@
-import QtQuick 1.1
-Rectangle {
- id: whiteRect
- property variant center
- property real scale
- width: 240; height: 320
- color: "white"
- Rectangle {
- id: blackRect
- objectName: "blackrect"
- color: "black"
- y: 50
- x: 50
- width: 100
- height: 100
- opacity: (whiteRect.width-blackRect.x+whiteRect.height-blackRect.y-199)/200
- Text { text: blackRect.opacity}
- PinchArea {
- id: pincharea
- objectName: "pincharea"
- anchors.fill: parent
- pinch.target: blackRect
- pinch.dragAxis: Drag.XandYAxis
- pinch.minimumX: 0
- pinch.maximumX: whiteRect.width-blackRect.width
- pinch.minimumY: 0
- pinch.maximumY: whiteRect.height-blackRect.height
- pinch.minimumScale: 1.0
- pinch.maximumScale: 2.0
- pinch.minimumRotation: 0.0
- pinch.maximumRotation: 90.0
- onPinchStarted: {
- whiteRect.center = pinch.center
- whiteRect.scale = pinch.scale
- }
- onPinchUpdated: {
- whiteRect.center = pinch.center
- whiteRect.scale = pinch.scale
- }
- onPinchFinished: {
- whiteRect.center = pinch.center
- whiteRect.scale = pinch.scale
- }
- }
- }
- }
diff --git a/tests/auto/qtquick1/qdeclarativepincharea/qdeclarativepincharea.pro b/tests/auto/qtquick1/qdeclarativepincharea/qdeclarativepincharea.pro
deleted file mode 100644
index 4a8ef9bc5d..0000000000
--- a/tests/auto/qtquick1/qdeclarativepincharea/qdeclarativepincharea.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativepincharea
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativepincharea.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
-QT += core-private gui-private widgets-private declarative-private qtquick1-private testlib
diff --git a/tests/auto/qtquick1/qdeclarativepincharea/tst_qdeclarativepincharea.cpp b/tests/auto/qtquick1/qdeclarativepincharea/tst_qdeclarativepincharea.cpp
deleted file mode 100644
index f5cb60ea78..0000000000
--- a/tests/auto/qtquick1/qdeclarativepincharea/tst_qdeclarativepincharea.cpp
+++ /dev/null
@@ -1,393 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtTest/QSignalSpy>
-#include <QtQuick1/private/qdeclarativepincharea_p.h>
-#include <QtQuick1/private/qdeclarativerectangle_p.h>
-#include <QtQuick1/private/qdeclarativeflickable_p.h>
-#include <QtQuick1/qdeclarativeview.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-
-class tst_QDeclarative1PinchArea: public QObject
-{
- Q_OBJECT
-public:
- tst_QDeclarative1PinchArea() : device(0) { }
-private slots:
- void initTestCase() {
- if (!device) {
- device = new QTouchDevice;
- device->setType(QTouchDevice::TouchScreen);
- QWindowSystemInterface::registerTouchDevice(device);
- }
- }
- void pinchProperties();
- void scale();
- void pan();
- void flickable();
-
-private:
- QDeclarativeView *createView();
- QTouchDevice *device;
-};
-
-void tst_QDeclarative1PinchArea::pinchProperties()
-{
- QDeclarativeView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pinchproperties.qml"));
- canvas->show();
- canvas->setFocus();
- QVERIFY(canvas->rootObject() != 0);
-
- QDeclarative1PinchArea *pinchArea = canvas->rootObject()->findChild<QDeclarative1PinchArea*>("pincharea");
- QDeclarative1Pinch *pinch = pinchArea->pinch();
- QVERIFY(pinchArea != 0);
- QVERIFY(pinch != 0);
-
- // target
- QDeclarativeItem *blackRect = canvas->rootObject()->findChild<QDeclarativeItem*>("blackrect");
- QVERIFY(blackRect != 0);
- QVERIFY(blackRect == pinch->target());
- QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(canvas->rootObject());
- QVERIFY(rootItem != 0);
- QSignalSpy targetSpy(pinch, SIGNAL(targetChanged()));
- pinch->setTarget(rootItem);
- QCOMPARE(targetSpy.count(),1);
- pinch->setTarget(rootItem);
- QCOMPARE(targetSpy.count(),1);
-
- // axis
- QCOMPARE(pinch->axis(), QDeclarative1Pinch::XandYAxis);
- QSignalSpy axisSpy(pinch, SIGNAL(dragAxisChanged()));
- pinch->setAxis(QDeclarative1Pinch::XAxis);
- QCOMPARE(pinch->axis(), QDeclarative1Pinch::XAxis);
- QCOMPARE(axisSpy.count(),1);
- pinch->setAxis(QDeclarative1Pinch::XAxis);
- QCOMPARE(axisSpy.count(),1);
-
- // minimum and maximum drag properties
- QSignalSpy xminSpy(pinch, SIGNAL(minimumXChanged()));
- QSignalSpy xmaxSpy(pinch, SIGNAL(maximumXChanged()));
- QSignalSpy yminSpy(pinch, SIGNAL(minimumYChanged()));
- QSignalSpy ymaxSpy(pinch, SIGNAL(maximumYChanged()));
-
- QCOMPARE(pinch->xmin(), 0.0);
- QCOMPARE(pinch->xmax(), rootItem->width()-blackRect->width());
- QCOMPARE(pinch->ymin(), 0.0);
- QCOMPARE(pinch->ymax(), rootItem->height()-blackRect->height());
-
- pinch->setXmin(10);
- pinch->setXmax(10);
- pinch->setYmin(10);
- pinch->setYmax(10);
-
- QCOMPARE(pinch->xmin(), 10.0);
- QCOMPARE(pinch->xmax(), 10.0);
- QCOMPARE(pinch->ymin(), 10.0);
- QCOMPARE(pinch->ymax(), 10.0);
-
- QCOMPARE(xminSpy.count(),1);
- QCOMPARE(xmaxSpy.count(),1);
- QCOMPARE(yminSpy.count(),1);
- QCOMPARE(ymaxSpy.count(),1);
-
- pinch->setXmin(10);
- pinch->setXmax(10);
- pinch->setYmin(10);
- pinch->setYmax(10);
-
- QCOMPARE(xminSpy.count(),1);
- QCOMPARE(xmaxSpy.count(),1);
- QCOMPARE(yminSpy.count(),1);
- QCOMPARE(ymaxSpy.count(),1);
-
- // minimum and maximum scale properties
- QSignalSpy scaleMinSpy(pinch, SIGNAL(minimumScaleChanged()));
- QSignalSpy scaleMaxSpy(pinch, SIGNAL(maximumScaleChanged()));
-
- QCOMPARE(pinch->minimumScale(), 1.0);
- QCOMPARE(pinch->maximumScale(), 2.0);
-
- pinch->setMinimumScale(0.5);
- pinch->setMaximumScale(1.5);
-
- QCOMPARE(pinch->minimumScale(), 0.5);
- QCOMPARE(pinch->maximumScale(), 1.5);
-
- QCOMPARE(scaleMinSpy.count(),1);
- QCOMPARE(scaleMaxSpy.count(),1);
-
- pinch->setMinimumScale(0.5);
- pinch->setMaximumScale(1.5);
-
- QCOMPARE(scaleMinSpy.count(),1);
- QCOMPARE(scaleMaxSpy.count(),1);
-
- // minimum and maximum rotation properties
- QSignalSpy rotMinSpy(pinch, SIGNAL(minimumRotationChanged()));
- QSignalSpy rotMaxSpy(pinch, SIGNAL(maximumRotationChanged()));
-
- QCOMPARE(pinch->minimumRotation(), 0.0);
- QCOMPARE(pinch->maximumRotation(), 90.0);
-
- pinch->setMinimumRotation(-90.0);
- pinch->setMaximumRotation(45.0);
-
- QCOMPARE(pinch->minimumRotation(), -90.0);
- QCOMPARE(pinch->maximumRotation(), 45.0);
-
- QCOMPARE(rotMinSpy.count(),1);
- QCOMPARE(rotMaxSpy.count(),1);
-
- pinch->setMinimumRotation(-90.0);
- pinch->setMaximumRotation(45.0);
-
- QCOMPARE(rotMinSpy.count(),1);
- QCOMPARE(rotMaxSpy.count(),1);
-
- delete canvas;
-}
-
-QTouchEvent::TouchPoint makeTouchPoint(int id, QPoint p, QGraphicsView *v, QGraphicsItem *i)
-{
- QTouchEvent::TouchPoint touchPoint(id);
- touchPoint.setPos(i->mapFromScene(p));
- touchPoint.setScreenPos(v->mapToGlobal(p));
- touchPoint.setScenePos(p);
- return touchPoint;
-}
-
-void tst_QDeclarative1PinchArea::scale()
-{
- QDeclarativeView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pinchproperties.qml"));
- canvas->show();
- canvas->setFocus();
- QTest::qWaitForWindowShown(canvas);
- QVERIFY(canvas->rootObject() != 0);
- qApp->processEvents();
-
- QDeclarative1PinchArea *pinchArea = canvas->rootObject()->findChild<QDeclarative1PinchArea*>("pincharea");
- QDeclarative1Pinch *pinch = pinchArea->pinch();
- QVERIFY(pinchArea != 0);
- QVERIFY(pinch != 0);
-
- QDeclarativeItem *root = qobject_cast<QDeclarativeItem*>(canvas->rootObject());
- QVERIFY(root != 0);
-
- // target
- QDeclarativeItem *blackRect = canvas->rootObject()->findChild<QDeclarativeItem*>("blackrect");
- QVERIFY(blackRect != 0);
-
- QWidget *vp = canvas->viewport();
-
- QPoint p1(80, 80);
- QPoint p2(100, 100);
-
- QTest::touchEvent(vp, device).press(0, p1, canvas);
- QTest::touchEvent(vp, device).stationary(0).press(1, p2, canvas);
- p1 -= QPoint(10,10);
- p2 += QPoint(10,10);
- QTest::touchEvent(vp, device).move(0, p1, canvas).move(1, p2, canvas);
-
- QCOMPARE(root->property("scale").toReal(), 1.0);
-
- p1 -= QPoint(10,10);
- p2 += QPoint(10,10);
- QTest::touchEvent(vp, device).move(0, p1, canvas).move(1, p2, canvas);
-
- QCOMPARE(root->property("scale").toReal(), 1.5);
- QCOMPARE(root->property("center").toPointF(), QPointF(40, 40)); // blackrect is at 50,50
- QCOMPARE(blackRect->scale(), 1.5);
-
- // scale beyond bound
- p1 -= QPoint(50,50);
- p2 += QPoint(50,50);
- QTest::touchEvent(vp, device).move(0, p1, canvas).move(1, p2, canvas);
-
- QCOMPARE(blackRect->scale(), 2.0);
-
- QTest::touchEvent(vp, device).release(0, p1, canvas).release(1, p2, canvas);
-
- delete canvas;
-}
-
-void tst_QDeclarative1PinchArea::pan()
-{
- QDeclarativeView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pinchproperties.qml"));
- canvas->show();
- canvas->setFocus();
- QTest::qWaitForWindowShown(canvas);
- QVERIFY(canvas->rootObject() != 0);
- qApp->processEvents();
-
- QDeclarative1PinchArea *pinchArea = canvas->rootObject()->findChild<QDeclarative1PinchArea*>("pincharea");
- QDeclarative1Pinch *pinch = pinchArea->pinch();
- QVERIFY(pinchArea != 0);
- QVERIFY(pinch != 0);
-
- QDeclarativeItem *root = qobject_cast<QDeclarativeItem*>(canvas->rootObject());
- QVERIFY(root != 0);
-
- // target
- QDeclarativeItem *blackRect = canvas->rootObject()->findChild<QDeclarativeItem*>("blackrect");
- QVERIFY(blackRect != 0);
-
- QWidget *vp = canvas->viewport();
-
- QPoint p1(80, 80);
- QPoint p2(100, 100);
-
- QTest::touchEvent(vp, device).press(0, p1, canvas);
- QTest::touchEvent(vp, device).stationary(0).press(1, p2, canvas);
- p1 += QPoint(10,10);
- p2 += QPoint(10,10);
- QTest::touchEvent(vp, device).move(0, p1, canvas).move(1, p2, canvas);
-
- QCOMPARE(root->property("scale").toReal(), 1.0);
-
- p1 += QPoint(10,10);
- p2 += QPoint(10,10);
- QTest::touchEvent(vp, device).move(0, p1, canvas).move(1, p2, canvas);
-
- QCOMPARE(root->property("center").toPointF(), QPointF(60, 60)); // blackrect is at 50,50
-
- QCOMPARE(blackRect->x(), 60.0);
- QCOMPARE(blackRect->y(), 60.0);
-
- // pan x beyond bound
- p1 += QPoint(100,100);
- p2 += QPoint(100,100);
- QTest::touchEvent(vp, device).move(0, p1, canvas).move(1, p2, canvas);
-
- QCOMPARE(blackRect->x(), 140.0);
- QCOMPARE(blackRect->y(), 160.0);
-
- QTest::touchEvent(vp, device).release(0, p1, canvas).release(1, p2, canvas);
-
- delete canvas;
-}
-
-void tst_QDeclarative1PinchArea::flickable()
-{
- QDeclarativeView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/flickresize.qml"));
- canvas->show();
- canvas->setFocus();
- QTest::qWaitForWindowShown(canvas);
- QVERIFY(canvas->rootObject() != 0);
- qApp->processEvents();
-
- QDeclarative1PinchArea *pinchArea = canvas->rootObject()->findChild<QDeclarative1PinchArea*>("pincharea");
- QDeclarative1Pinch *pinch = pinchArea->pinch();
- QVERIFY(pinchArea != 0);
- QVERIFY(pinch != 0);
-
- QDeclarative1Flickable *root = qobject_cast<QDeclarative1Flickable*>(canvas->rootObject());
- QVERIFY(root != 0);
-
- QWidget *vp = canvas->viewport();
-
- QPoint p1(110, 80);
- QPoint p2(100, 100);
-
- // begin by moving one touch point (mouse)
- QTest::mousePress(vp, Qt::LeftButton, 0, canvas->mapFromScene(p1));
- QTest::touchEvent(vp, device).press(0, p1, canvas);
- {
- p1 -= QPoint(10,10);
- QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(p1), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(canvas->viewport(), &mv);
- QTest::touchEvent(vp, device).move(0, p1, canvas);
- }
- {
- p1 -= QPoint(10,10);
- QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(p1), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(vp, &mv);
- QTest::touchEvent(vp, device).move(0, p1, canvas);
- }
- {
- p1 -= QPoint(10,10);
- QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(p1), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(vp, &mv);
- QTest::touchEvent(vp, device).move(0, p1, canvas);
- }
-
- // Flickable has reacted to the gesture
- QVERIFY(root->isMoving());
- QVERIFY(root->property("scale").toReal() == 1.0);
-
- // add another touch point and continue moving
- QTest::touchEvent(vp, device).stationary(0).press(1, p2, canvas);
- p1 -= QPoint(10,10);
- p2 += QPoint(10,10);
- QTest::touchEvent(vp, device).move(0, p1, canvas).move(1, p2, canvas);
-
- QCOMPARE(root->property("scale").toReal(), 1.0);
-
- p1 -= QPoint(10,10);
- p2 += QPoint(10,10);
- QTest::touchEvent(vp, device).move(0, p1, canvas).move(1, p2, canvas);
-
- // PinchArea has stolen the gesture.
- QVERIFY(!root->isMoving());
- QVERIFY(root->property("scale").toReal() > 1.0);
-
- QTest::mouseRelease(vp, Qt::LeftButton, 0, canvas->mapFromScene(p1));
- QTest::touchEvent(vp, device).release(0, p1, canvas).release(1, p2, canvas);
-
- delete canvas;
-}
-
-QDeclarativeView *tst_QDeclarative1PinchArea::createView()
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->viewport()->setAttribute(Qt::WA_AcceptTouchEvents);
- canvas->setFixedSize(240,320);
-
- return canvas;
-}
-
-QTEST_MAIN(tst_QDeclarative1PinchArea)
-
-#include "tst_qdeclarativepincharea.moc"
diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/flow-testimplicitsize.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/flow-testimplicitsize.qml
deleted file mode 100644
index ee4e1048a2..0000000000
--- a/tests/auto/qtquick1/qdeclarativepositioners/data/flow-testimplicitsize.qml
+++ /dev/null
@@ -1,19 +0,0 @@
-import QtQuick 1.1
-
-Rectangle {
- width: 300; height: 200;
-
- property int flowLayout: 1
-
- Flow {
- objectName: "flow"
- layoutDirection: (flowLayout == 2) ? Qt.RightToLeft : Qt.LeftToRight
- flow: (flowLayout == 1) ? Flow.TopToBottom : Flow.LeftToRight;
-
- spacing: 20
- anchors.horizontalCenter: parent.horizontalCenter
- Rectangle { color: "red"; width: 100; height: 50 }
- Rectangle { color: "blue"; width: 100; height: 50 }
- }
-}
-
diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/flowtest-toptobottom.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/flowtest-toptobottom.qml
deleted file mode 100644
index ec1d6660c3..0000000000
--- a/tests/auto/qtquick1/qdeclarativepositioners/data/flowtest-toptobottom.qml
+++ /dev/null
@@ -1,44 +0,0 @@
-import QtQuick 1.1
-
-Item {
- height: 90
- width: 480
- property bool testRightToLeft: false
-
- Flow {
- objectName: "flow"
- height: parent.height
- layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight
- flow: Flow.TopToBottom
- Rectangle {
- objectName: "one"
- color: "red"
- width: 50
- height: 50
- }
- Rectangle {
- objectName: "two"
- color: "green"
- width: 20
- height: 50
- }
- Rectangle {
- objectName: "three"
- color: "blue"
- width: 50
- height: 20
- }
- Rectangle {
- objectName: "four"
- color: "cyan"
- width: 50
- height: 50
- }
- Rectangle {
- objectName: "five"
- color: "magenta"
- width: 10
- height: 10
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/flowtest.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/flowtest.qml
deleted file mode 100644
index 7c124a3d44..0000000000
--- a/tests/auto/qtquick1/qdeclarativepositioners/data/flowtest.qml
+++ /dev/null
@@ -1,43 +0,0 @@
-import QtQuick 1.1
-
-Item {
- width: 90
- height: 480
- property bool testRightToLeft: false
-
- Flow {
- objectName: "flow"
- width: parent.width
- layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight
- Rectangle {
- objectName: "one"
- color: "red"
- width: 50
- height: 50
- }
- Rectangle {
- objectName: "two"
- color: "green"
- width: 20
- height: 50
- }
- Rectangle {
- objectName: "three"
- color: "blue"
- width: 50
- height: 20
- }
- Rectangle {
- objectName: "four"
- color: "cyan"
- width: 50
- height: 50
- }
- Rectangle {
- objectName: "five"
- color: "magenta"
- width: 10
- height: 10
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/grid-animated.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/grid-animated.qml
deleted file mode 100644
index 3dcbed1103..0000000000
--- a/tests/auto/qtquick1/qdeclarativepositioners/data/grid-animated.qml
+++ /dev/null
@@ -1,64 +0,0 @@
-import QtQuick 1.1
-
-Item {
- width: 640
- height: 480
- property bool testRightToLeft: true
-
- Grid {
- objectName: "grid"
- columns: 3
- layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight
- add: Transition {
- NumberAnimation {
- properties: "x,y";
- }
- }
- move: Transition {
- NumberAnimation {
- properties: "x,y";
- }
- }
- Rectangle {
- objectName: "one"
- color: "red"
- x: -100
- y: -100
- width: 50
- height: 50
- }
- Rectangle {
- objectName: "two"
- x: -100
- y: -100
- opacity: 0
- color: "green"
- width: 50
- height: 50
- }
- Rectangle {
- objectName: "three"
- color: "blue"
- x: -100
- y: -100
- width: 50
- height: 50
- }
- Rectangle {
- objectName: "four"
- color: "cyan"
- x: -100
- y: -100
- width: 50
- height: 50
- }
- Rectangle {
- objectName: "five"
- color: "magenta"
- x: -100
- y: -100
- width: 50
- height: 50
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/grid-spacing.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/grid-spacing.qml
deleted file mode 100644
index f03733001b..0000000000
--- a/tests/auto/qtquick1/qdeclarativepositioners/data/grid-spacing.qml
+++ /dev/null
@@ -1,41 +0,0 @@
-import QtQuick 1.0
-
-Item {
- width: 640
- height: 480
- Grid {
- objectName: "grid"
- columns: 3
- spacing: 4
- Rectangle {
- objectName: "one"
- color: "red"
- width: 50
- height: 50
- }
- Rectangle {
- objectName: "two"
- color: "green"
- width: 20
- height: 50
- }
- Rectangle {
- objectName: "three"
- color: "blue"
- width: 50
- height: 20
- }
- Rectangle {
- objectName: "four"
- color: "cyan"
- width: 50
- height: 50
- }
- Rectangle {
- objectName: "five"
- color: "magenta"
- width: 10
- height: 10
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/grid-toptobottom.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/grid-toptobottom.qml
deleted file mode 100644
index 5d4c3373e5..0000000000
--- a/tests/auto/qtquick1/qdeclarativepositioners/data/grid-toptobottom.qml
+++ /dev/null
@@ -1,41 +0,0 @@
-import QtQuick 1.0
-
-Item {
- width: 640
- height: 480
- Grid {
- objectName: "grid"
- rows: 3
- flow: Grid.TopToBottom
- Rectangle {
- objectName: "one"
- color: "red"
- width: 50
- height: 50
- }
- Rectangle {
- objectName: "two"
- color: "green"
- width: 20
- height: 50
- }
- Rectangle {
- objectName: "three"
- color: "blue"
- width: 50
- height: 20
- }
- Rectangle {
- objectName: "four"
- color: "cyan"
- width: 50
- height: 50
- }
- Rectangle {
- objectName: "five"
- color: "magenta"
- width: 10
- height: 10
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/gridtest.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/gridtest.qml
deleted file mode 100644
index 929b7267cf..0000000000
--- a/tests/auto/qtquick1/qdeclarativepositioners/data/gridtest.qml
+++ /dev/null
@@ -1,42 +0,0 @@
-import QtQuick 1.1
-
-Item {
- width: 640
- height: 480
- property bool testRightToLeft: false
- Grid {
- layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight
- objectName: "grid"
- columns: 3
- Rectangle {
- objectName: "one"
- color: "red"
- width: 50
- height: 50
- }
- Rectangle {
- objectName: "two"
- color: "green"
- width: 20
- height: 50
- }
- Rectangle {
- objectName: "three"
- color: "blue"
- width: 30
- height: 20
- }
- Rectangle {
- objectName: "four"
- color: "cyan"
- width: 50
- height: 50
- }
- Rectangle {
- objectName: "five"
- color: "magenta"
- width: 10
- height: 10
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/gridzerocolumns.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/gridzerocolumns.qml
deleted file mode 100644
index 169f974477..0000000000
--- a/tests/auto/qtquick1/qdeclarativepositioners/data/gridzerocolumns.qml
+++ /dev/null
@@ -1,40 +0,0 @@
-import QtQuick 1.0
-
-Item {
- width: 640
- height: 480
- Grid {
- objectName: "grid"
- columns: 0
- Rectangle {
- objectName: "one"
- color: "red"
- width: 50
- height: 50
- }
- Rectangle {
- objectName: "two"
- color: "green"
- width: 20
- height: 50
- }
- Rectangle {
- objectName: "three"
- color: "blue"
- width: 50
- height: 20
- }
- Rectangle {
- objectName: "four"
- color: "cyan"
- width: 50
- height: 50
- }
- Rectangle {
- objectName: "five"
- color: "magenta"
- width: 10
- height: 10
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/horizontal-animated.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/horizontal-animated.qml
deleted file mode 100644
index 3c95f53fe7..0000000000
--- a/tests/auto/qtquick1/qdeclarativepositioners/data/horizontal-animated.qml
+++ /dev/null
@@ -1,44 +0,0 @@
-import QtQuick 1.1
-
-Item {
- width: 640
- height: 480
- property bool testRightToLeft: false
-
- Row {
- objectName: "row"
- layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight
- add: Transition {
- NumberAnimation {
- properties: "x";
- }
- }
- move: Transition {
- NumberAnimation {
- properties: "x";
- }
- }
- Rectangle {
- objectName: "one"
- color: "red"
- x: -100;
- width: 50
- height: 50
- }
- Rectangle {
- objectName: "two"
- color: "blue"
- x: -100;
- opacity: 0
- width: 50
- height: 50
- }
- Rectangle {
- objectName: "three"
- x: -100;
- color: "green"
- width: 50
- height: 50
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/horizontal-spacing.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/horizontal-spacing.qml
deleted file mode 100644
index 64bedb02d3..0000000000
--- a/tests/auto/qtquick1/qdeclarativepositioners/data/horizontal-spacing.qml
+++ /dev/null
@@ -1,31 +0,0 @@
-import QtQuick 1.1
-
-Item {
- width: 640
- height: 480
- property bool testRightToLeft: false
-
- Row {
- objectName: "row"
- spacing: 10
- layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight
- Rectangle {
- objectName: "one"
- color: "red"
- width: 50
- height: 50
- }
- Rectangle {
- objectName: "two"
- color: "red"
- width: 20
- height: 10
- }
- Rectangle {
- objectName: "three"
- color: "red"
- width: 40
- height: 20
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/horizontal.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/horizontal.qml
deleted file mode 100644
index d35c02d538..0000000000
--- a/tests/auto/qtquick1/qdeclarativepositioners/data/horizontal.qml
+++ /dev/null
@@ -1,29 +0,0 @@
-import QtQuick 1.1
-
-Item {
- width: 640
- height: 480
- property bool testRightToLeft: false
- Row {
- objectName: "row"
- layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight
- Rectangle {
- objectName: "one"
- color: "red"
- width: 50
- height: 50
- }
- Rectangle {
- objectName: "two"
- color: "red"
- width: 20
- height: 10
- }
- Rectangle {
- objectName: "three"
- color: "red"
- width: 40
- height: 20
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/propertychangestest.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/propertychangestest.qml
deleted file mode 100644
index 3c95c4c279..0000000000
--- a/tests/auto/qtquick1/qdeclarativepositioners/data/propertychangestest.qml
+++ /dev/null
@@ -1,39 +0,0 @@
-import QtQuick 1.0
-
-Grid {
- id: myGrid
-
- width: 270
- height: 270
- x: 3
- y: 3
- columns: 4
- spacing: 3
-
- add: columnTransition
- move: columnTransition
-
- Repeater {
- model: 20
- Rectangle { color: "black"; width: 50; height: 50 }
- }
-
- data: [
- Transition {
- id: rowTransition
- objectName: "rowTransition"
- NumberAnimation {
- properties: "x,y";
- easing.type: "OutInCubic"
- }
- },
- Transition {
- id: columnTransition
- objectName: "columnTransition"
- NumberAnimation {
- properties: "x,y";
- easing.type: "OutInCubic"
- }
- }
- ]
-}
diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/repeatertest.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/repeatertest.qml
deleted file mode 100644
index f93ce67da3..0000000000
--- a/tests/auto/qtquick1/qdeclarativepositioners/data/repeatertest.qml
+++ /dev/null
@@ -1,38 +0,0 @@
-import QtQuick 1.0
-
-Item {
- width: 640
- height: 480
- Row {
- Repeater{ model: 3;
- delegate: Component {
- Rectangle {
- color: "red"
- width: 50
- height: 50
- z: {if(index == 0){2;}else if(index == 1){1;} else{3;}}
- objectName: {if(index == 0){"one";}else if(index == 1){"two";} else{"three";}}
- }
- }
- }
- }
-
- //This crashed once (QTBUG-16959) because the repeater ended up on the end of the list
- //If this grid just instantiates without crashing, then it has not regressed.
- Grid {
- id: grid
- rows: 2
- flow: Grid.TopToBottom
-
- Repeater {
- model: 13
- Rectangle {
- color: "goldenrod"
- width: 100
- height: 100
- radius: 10
- border.width: 1
- }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/vertical-animated.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/vertical-animated.qml
deleted file mode 100644
index 8899ac83cc..0000000000
--- a/tests/auto/qtquick1/qdeclarativepositioners/data/vertical-animated.qml
+++ /dev/null
@@ -1,41 +0,0 @@
-import QtQuick 1.0
-
-Item {
- width: 640
- height: 480
- Column {
- objectName: "column"
- add: Transition {
- NumberAnimation {
- properties: "y";
- }
- }
- move: Transition {
- NumberAnimation {
- properties: "y";
- }
- }
- Rectangle {
- objectName: "one"
- color: "red"
- y: -100
- width: 50
- height: 50
- }
- Rectangle {
- objectName: "two"
- color: "blue"
- y: -100
- opacity: 0
- width: 50
- height: 50
- }
- Rectangle {
- objectName: "three"
- color: "red"
- y: -100
- width: 50
- height: 50
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/vertical-spacing.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/vertical-spacing.qml
deleted file mode 100644
index 557896115d..0000000000
--- a/tests/auto/qtquick1/qdeclarativepositioners/data/vertical-spacing.qml
+++ /dev/null
@@ -1,28 +0,0 @@
-import QtQuick 1.0
-
-Item {
- width: 640
- height: 480
- Column {
- objectName: "column"
- spacing: 10
- Rectangle {
- objectName: "one"
- color: "red"
- width: 50
- height: 50
- }
- Rectangle {
- objectName: "two"
- color: "red"
- width: 20
- height: 10
- }
- Rectangle {
- objectName: "three"
- color: "red"
- width: 40
- height: 20
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/vertical.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/vertical.qml
deleted file mode 100644
index 310d791d55..0000000000
--- a/tests/auto/qtquick1/qdeclarativepositioners/data/vertical.qml
+++ /dev/null
@@ -1,27 +0,0 @@
-import QtQuick 1.0
-
-Item {
- width: 640
- height: 480
- Column {
- objectName: "column"
- Rectangle {
- objectName: "one"
- color: "red"
- width: 50
- height: 50
- }
- Rectangle {
- objectName: "two"
- color: "red"
- width: 20
- height: 10
- }
- Rectangle {
- objectName: "three"
- color: "red"
- width: 40
- height: 20
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/verticalqgraphicswidget.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/verticalqgraphicswidget.qml
deleted file mode 100644
index c320714f15..0000000000
--- a/tests/auto/qtquick1/qdeclarativepositioners/data/verticalqgraphicswidget.qml
+++ /dev/null
@@ -1,24 +0,0 @@
-import QtQuick 1.0
-
-Item {
- width: 640
- height: 480
- Column {
- objectName: "column"
- QGraphicsWidget {
- objectName: "one"
- width: 50
- height: 50
- }
- QGraphicsWidget {
- objectName: "two"
- width: 20
- height: 10
- }
- QGraphicsWidget {
- objectName: "three"
- width: 40
- height: 20
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativepositioners/qdeclarativepositioners.pro b/tests/auto/qtquick1/qdeclarativepositioners/qdeclarativepositioners.pro
deleted file mode 100644
index 2844c51232..0000000000
--- a/tests/auto/qtquick1/qdeclarativepositioners/qdeclarativepositioners.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativepositioners
-SOURCES += tst_qdeclarativepositioners.cpp
-macx:CONFIG -= app_bundle
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
-QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib
diff --git a/tests/auto/qtquick1/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/qtquick1/qdeclarativepositioners/tst_qdeclarativepositioners.cpp
deleted file mode 100644
index 97859f82fc..0000000000
--- a/tests/auto/qtquick1/qdeclarativepositioners/tst_qdeclarativepositioners.cpp
+++ /dev/null
@@ -1,1349 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtTest/QtTest>
-#include <QtQuick1/qdeclarativeview.h>
-#include <qdeclarativeengine.h>
-#include <QtQuick1/private/qdeclarativerectangle_p.h>
-#include <QtQuick1/private/qdeclarativepositioners_p.h>
-#include <QtQuick1/private/qdeclarativetransition_p.h>
-#include <QtQuick1/private/qdeclarativeitem_p.h>
-#include <qdeclarativeexpression.h>
-#include <QtWidgets/qgraphicswidget.h>
-
-class tst_QDeclarativePositioners : public QObject
-{
- Q_OBJECT
-public:
- tst_QDeclarativePositioners();
-
-private slots:
- void test_horizontal();
- void test_horizontal_rtl();
- void test_horizontal_spacing();
- void test_horizontal_spacing_rightToLeft();
- void test_horizontal_animated();
- void test_horizontal_animated_rightToLeft();
- void test_vertical();
- void test_vertical_spacing();
- void test_vertical_animated();
- void test_grid();
- void test_grid_topToBottom();
- void test_grid_rightToLeft();
- void test_grid_spacing();
- void test_grid_animated();
- void test_grid_animated_rightToLeft();
- void test_grid_zero_columns();
- void test_propertychanges();
- void test_repeater();
- void test_flow();
- void test_flow_rightToLeft();
- void test_flow_topToBottom();
- void test_flow_resize();
- void test_flow_resize_rightToLeft();
- void test_flow_implicit_resize();
- void test_conflictinganchors();
- void test_vertical_qgraphicswidget();
- void test_mirroring();
- void testQtQuick11Attributes();
- void testQtQuick11Attributes_data();
-private:
- QDeclarativeView *createView(const QString &filename);
-};
-
-tst_QDeclarativePositioners::tst_QDeclarativePositioners()
-{
-}
-
-void tst_QDeclarativePositioners::test_horizontal()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/horizontal.qml");
-
- canvas->rootObject()->setProperty("testRightToLeft", false);
-
- QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
- QVERIFY(one != 0);
-
- QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
- QVERIFY(two != 0);
-
- QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
- QVERIFY(three != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 70.0);
- QCOMPARE(three->y(), 0.0);
-
- QDeclarativeItem *row = canvas->rootObject()->findChild<QDeclarativeItem*>("row");
- QCOMPARE(row->width(), 110.0);
- QCOMPARE(row->height(), 50.0);
-
- delete canvas;
-}
-
-void tst_QDeclarativePositioners::test_horizontal_rtl()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/horizontal.qml");
-
- canvas->rootObject()->setProperty("testRightToLeft", true);
-
- QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
- QVERIFY(one != 0);
-
- QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
- QVERIFY(two != 0);
-
- QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
- QVERIFY(three != 0);
-
- QCOMPARE(one->x(), 60.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 40.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 0.0);
- QCOMPARE(three->y(), 0.0);
-
- QDeclarativeItem *row = canvas->rootObject()->findChild<QDeclarativeItem*>("row");
- QCOMPARE(row->width(), 110.0);
- QCOMPARE(row->height(), 50.0);
-
- // Change the width of the row and check that items stay to the right
- row->setWidth(200);
- QCOMPARE(one->x(), 150.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 130.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 90.0);
- QCOMPARE(three->y(), 0.0);
-
- delete canvas;
-}
-
-void tst_QDeclarativePositioners::test_horizontal_spacing()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/horizontal-spacing.qml");
-
- canvas->rootObject()->setProperty("testRightToLeft", false);
-
- QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
- QVERIFY(one != 0);
-
- QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
- QVERIFY(two != 0);
-
- QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
- QVERIFY(three != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 60.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 90.0);
- QCOMPARE(three->y(), 0.0);
-
- QDeclarativeItem *row = canvas->rootObject()->findChild<QDeclarativeItem*>("row");
- QCOMPARE(row->width(), 130.0);
- QCOMPARE(row->height(), 50.0);
-
- delete canvas;
-}
-
-void tst_QDeclarativePositioners::test_horizontal_spacing_rightToLeft()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/horizontal-spacing.qml");
-
- canvas->rootObject()->setProperty("testRightToLeft", true);
-
- QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
- QVERIFY(one != 0);
-
- QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
- QVERIFY(two != 0);
-
- QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
- QVERIFY(three != 0);
-
- QCOMPARE(one->x(), 80.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 00.0);
- QCOMPARE(three->y(), 0.0);
-
- QDeclarativeItem *row = canvas->rootObject()->findChild<QDeclarativeItem*>("row");
- QCOMPARE(row->width(), 130.0);
- QCOMPARE(row->height(), 50.0);
-
- delete canvas;
-}
-
-void tst_QDeclarativePositioners::test_horizontal_animated()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/horizontal-animated.qml");
-
- canvas->rootObject()->setProperty("testRightToLeft", false);
-
- QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
- QVERIFY(one != 0);
-
- QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
- QVERIFY(two != 0);
-
- QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
- QVERIFY(three != 0);
-
- //Note that they animate in
- QCOMPARE(one->x(), -100.0);
- QCOMPARE(two->x(), -100.0);
- QCOMPARE(three->x(), -100.0);
-
- QDeclarativeItem *row = canvas->rootObject()->findChild<QDeclarativeItem*>("row");
- QVERIFY(row);
- QCOMPARE(row->width(), 100.0);
- QCOMPARE(row->height(), 50.0);
-
- //QTRY_COMPARE used instead of waiting for the expected time of animation completion
- //Note that this means the duration of the animation is NOT tested
-
- QTRY_COMPARE(one->x(), 0.0);
- QTRY_COMPARE(one->y(), 0.0);
- QTRY_COMPARE(two->opacity(), 0.0);
- QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet
- QTRY_COMPARE(two->y(), 0.0);
- QTRY_COMPARE(three->x(), 50.0);
- QTRY_COMPARE(three->y(), 0.0);
-
- //Add 'two'
- two->setOpacity(1.0);
- QCOMPARE(two->opacity(), 1.0);
-
- // New size should be immediate
- QCOMPARE(row->width(), 150.0);
- QCOMPARE(row->height(), 50.0);
-
- QTest::qWait(0);//Let the animation start
- QCOMPARE(two->x(), -100.0);
- QCOMPARE(three->x(), 50.0);
-
- QTRY_COMPARE(two->x(), 50.0);
- QTRY_COMPARE(three->x(), 100.0);
-
- delete canvas;
-}
-
-void tst_QDeclarativePositioners::test_horizontal_animated_rightToLeft()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/horizontal-animated.qml");
-
- canvas->rootObject()->setProperty("testRightToLeft", true);
-
- QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
- QVERIFY(one != 0);
-
- QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
- QVERIFY(two != 0);
-
- QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
- QVERIFY(three != 0);
-
- //Note that they animate in
- QCOMPARE(one->x(), -100.0);
- QCOMPARE(two->x(), -100.0);
- QCOMPARE(three->x(), -100.0);
-
- QDeclarativeItem *row = canvas->rootObject()->findChild<QDeclarativeItem*>("row");
- QVERIFY(row);
- QCOMPARE(row->width(), 100.0);
- QCOMPARE(row->height(), 50.0);
-
- //QTRY_COMPARE used instead of waiting for the expected time of animation completion
- //Note that this means the duration of the animation is NOT tested
-
- QTRY_COMPARE(one->x(), 50.0);
- QTRY_COMPARE(one->y(), 0.0);
- QTRY_COMPARE(two->opacity(), 0.0);
- QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet
- QTRY_COMPARE(two->y(), 0.0);
- QTRY_COMPARE(three->x(), 0.0);
- QTRY_COMPARE(three->y(), 0.0);
-
- //Add 'two'
- two->setOpacity(1.0);
- QCOMPARE(two->opacity(), 1.0);
-
- // New size should be immediate
- QCOMPARE(row->width(), 150.0);
- QCOMPARE(row->height(), 50.0);
-
- QTest::qWait(0);//Let the animation start
- QCOMPARE(one->x(), 50.0);
- QCOMPARE(two->x(), -100.0);
-
- QTRY_COMPARE(one->x(), 100.0);
- QTRY_COMPARE(two->x(), 50.0);
-
- delete canvas;
-}
-
-void tst_QDeclarativePositioners::test_vertical()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/vertical.qml");
-
- QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
- QVERIFY(one != 0);
-
- QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
- QVERIFY(two != 0);
-
- QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
- QVERIFY(three != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 0.0);
- QCOMPARE(two->y(), 50.0);
- QCOMPARE(three->x(), 0.0);
- QCOMPARE(three->y(), 60.0);
-
- QDeclarativeItem *column = canvas->rootObject()->findChild<QDeclarativeItem*>("column");
- QVERIFY(column);
- QCOMPARE(column->height(), 80.0);
- QCOMPARE(column->width(), 50.0);
-
- delete canvas;
-}
-
-void tst_QDeclarativePositioners::test_vertical_spacing()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/vertical-spacing.qml");
-
- QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
- QVERIFY(one != 0);
-
- QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
- QVERIFY(two != 0);
-
- QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
- QVERIFY(three != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 0.0);
- QCOMPARE(two->y(), 60.0);
- QCOMPARE(three->x(), 0.0);
- QCOMPARE(three->y(), 80.0);
-
- QDeclarativeItem *column = canvas->rootObject()->findChild<QDeclarativeItem*>("column");
- QCOMPARE(column->height(), 100.0);
- QCOMPARE(column->width(), 50.0);
-
- delete canvas;
-}
-
-void tst_QDeclarativePositioners::test_vertical_animated()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/vertical-animated.qml");
-
- //Note that they animate in
- QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
- QVERIFY(one != 0);
- QCOMPARE(one->y(), -100.0);
-
- QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
- QVERIFY(two != 0);
- QCOMPARE(two->y(), -100.0);
-
- QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
- QVERIFY(three != 0);
- QCOMPARE(three->y(), -100.0);
-
- QDeclarativeItem *column = canvas->rootObject()->findChild<QDeclarativeItem*>("column");
- QVERIFY(column);
- QCOMPARE(column->height(), 100.0);
- QCOMPARE(column->width(), 50.0);
-
- //QTRY_COMPARE used instead of waiting for the expected time of animation completion
- //Note that this means the duration of the animation is NOT tested
-
- QTRY_COMPARE(one->y(), 0.0);
- QTRY_COMPARE(one->x(), 0.0);
- QTRY_COMPARE(two->opacity(), 0.0);
- QTRY_COMPARE(two->y(), -100.0);//Not 'in' yet
- QTRY_COMPARE(two->x(), 0.0);
- QTRY_COMPARE(three->y(), 50.0);
- QTRY_COMPARE(three->x(), 0.0);
-
- //Add 'two'
- two->setOpacity(1.0);
- QTRY_COMPARE(two->opacity(), 1.0);
- QCOMPARE(column->height(), 150.0);
- QCOMPARE(column->width(), 50.0);
- QTest::qWait(0);//Let the animation start
- QCOMPARE(two->y(), -100.0);
- QCOMPARE(three->y(), 50.0);
-
- QTRY_COMPARE(two->y(), 50.0);
- QTRY_COMPARE(three->y(), 100.0);
-
- delete canvas;
-}
-
-void tst_QDeclarativePositioners::test_grid()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/gridtest.qml");
-
- QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
- QVERIFY(one != 0);
- QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
- QVERIFY(two != 0);
- QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
- QVERIFY(three != 0);
- QDeclarative1Rectangle *four = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("four");
- QVERIFY(four != 0);
- QDeclarative1Rectangle *five = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 70.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 0.0);
- QCOMPARE(four->y(), 50.0);
- QCOMPARE(five->x(), 50.0);
- QCOMPARE(five->y(), 50.0);
-
- QDeclarative1Grid *grid = canvas->rootObject()->findChild<QDeclarative1Grid*>("grid");
- QCOMPARE(grid->flow(), QDeclarative1Grid::LeftToRight);
- QCOMPARE(grid->width(), 100.0);
- QCOMPARE(grid->height(), 100.0);
-
- delete canvas;
-}
-
-void tst_QDeclarativePositioners::test_grid_topToBottom()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/grid-toptobottom.qml");
-
- QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
- QVERIFY(one != 0);
- QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
- QVERIFY(two != 0);
- QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
- QVERIFY(three != 0);
- QDeclarative1Rectangle *four = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("four");
- QVERIFY(four != 0);
- QDeclarative1Rectangle *five = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 0.0);
- QCOMPARE(two->y(), 50.0);
- QCOMPARE(three->x(), 0.0);
- QCOMPARE(three->y(), 100.0);
- QCOMPARE(four->x(), 50.0);
- QCOMPARE(four->y(), 0.0);
- QCOMPARE(five->x(), 50.0);
- QCOMPARE(five->y(), 50.0);
-
- QDeclarative1Grid *grid = canvas->rootObject()->findChild<QDeclarative1Grid*>("grid");
- QCOMPARE(grid->flow(), QDeclarative1Grid::TopToBottom);
- QCOMPARE(grid->width(), 100.0);
- QCOMPARE(grid->height(), 120.0);
-
- delete canvas;
-}
-
-void tst_QDeclarativePositioners::test_grid_rightToLeft()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/gridtest.qml");
-
- canvas->rootObject()->setProperty("testRightToLeft", true);
-
- QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
- QVERIFY(one != 0);
- QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
- QVERIFY(two != 0);
- QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
- QVERIFY(three != 0);
- QDeclarative1Rectangle *four = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("four");
- QVERIFY(four != 0);
- QDeclarative1Rectangle *five = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 50.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 30.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 0.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 50.0);
- QCOMPARE(four->y(), 50.0);
- QCOMPARE(five->x(), 40.0);
- QCOMPARE(five->y(), 50.0);
-
- QDeclarative1Grid *grid = canvas->rootObject()->findChild<QDeclarative1Grid*>("grid");
- QCOMPARE(grid->layoutDirection(), Qt::RightToLeft);
- QCOMPARE(grid->width(), 100.0);
- QCOMPARE(grid->height(), 100.0);
-
- // Change the width of the grid and check that items stay to the right
- grid->setWidth(200);
- QCOMPARE(one->x(), 150.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 130.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 100.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 150.0);
- QCOMPARE(four->y(), 50.0);
- QCOMPARE(five->x(), 140.0);
- QCOMPARE(five->y(), 50.0);
-
- delete canvas;
-}
-
-void tst_QDeclarativePositioners::test_grid_spacing()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/grid-spacing.qml");
-
- QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
- QVERIFY(one != 0);
- QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
- QVERIFY(two != 0);
- QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
- QVERIFY(three != 0);
- QDeclarative1Rectangle *four = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("four");
- QVERIFY(four != 0);
- QDeclarative1Rectangle *five = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 54.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 78.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 0.0);
- QCOMPARE(four->y(), 54.0);
- QCOMPARE(five->x(), 54.0);
- QCOMPARE(five->y(), 54.0);
-
- QDeclarativeItem *grid = canvas->rootObject()->findChild<QDeclarativeItem*>("grid");
- QCOMPARE(grid->width(), 128.0);
- QCOMPARE(grid->height(), 104.0);
-
- delete canvas;
-}
-
-void tst_QDeclarativePositioners::test_grid_animated()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/grid-animated.qml");
-
- canvas->rootObject()->setProperty("testRightToLeft", false);
-
- //Note that all animate in
- QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
- QVERIFY(one != 0);
- QCOMPARE(one->x(), -100.0);
- QCOMPARE(one->y(), -100.0);
-
- QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
- QVERIFY(two != 0);
- QCOMPARE(two->x(), -100.0);
- QCOMPARE(two->y(), -100.0);
-
- QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
- QVERIFY(three != 0);
- QCOMPARE(three->x(), -100.0);
- QCOMPARE(three->y(), -100.0);
-
- QDeclarative1Rectangle *four = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("four");
- QVERIFY(four != 0);
- QCOMPARE(four->x(), -100.0);
- QCOMPARE(four->y(), -100.0);
-
- QDeclarative1Rectangle *five = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("five");
- QVERIFY(five != 0);
- QCOMPARE(five->x(), -100.0);
- QCOMPARE(five->y(), -100.0);
-
- QDeclarativeItem *grid = canvas->rootObject()->findChild<QDeclarativeItem*>("grid");
- QVERIFY(grid);
- QCOMPARE(grid->width(), 150.0);
- QCOMPARE(grid->height(), 100.0);
-
- //QTRY_COMPARE used instead of waiting for the expected time of animation completion
- //Note that this means the duration of the animation is NOT tested
-
- QTRY_COMPARE(one->y(), 0.0);
- QTRY_COMPARE(one->x(), 0.0);
- QTRY_COMPARE(two->opacity(), 0.0);
- QTRY_COMPARE(two->y(), -100.0);
- QTRY_COMPARE(two->x(), -100.0);
- QTRY_COMPARE(three->y(), 0.0);
- QTRY_COMPARE(three->x(), 50.0);
- QTRY_COMPARE(four->y(), 0.0);
- QTRY_COMPARE(four->x(), 100.0);
- QTRY_COMPARE(five->y(), 50.0);
- QTRY_COMPARE(five->x(), 0.0);
-
- //Add 'two'
- two->setOpacity(1.0);
- QCOMPARE(two->opacity(), 1.0);
- QCOMPARE(grid->width(), 150.0);
- QCOMPARE(grid->height(), 100.0);
- QTest::qWait(0);//Let the animation start
- QCOMPARE(two->x(), -100.0);
- QCOMPARE(two->y(), -100.0);
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(three->x(), 50.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 100.0);
- QCOMPARE(four->y(), 0.0);
- QCOMPARE(five->x(), 0.0);
- QCOMPARE(five->y(), 50.0);
- //Let the animation complete
- QTRY_COMPARE(two->x(), 50.0);
- QTRY_COMPARE(two->y(), 0.0);
- QTRY_COMPARE(one->x(), 0.0);
- QTRY_COMPARE(one->y(), 0.0);
- QTRY_COMPARE(three->x(), 100.0);
- QTRY_COMPARE(three->y(), 0.0);
- QTRY_COMPARE(four->x(), 0.0);
- QTRY_COMPARE(four->y(), 50.0);
- QTRY_COMPARE(five->x(), 50.0);
- QTRY_COMPARE(five->y(), 50.0);
-
- delete canvas;
-}
-
-void tst_QDeclarativePositioners::test_grid_animated_rightToLeft()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/grid-animated.qml");
-
- canvas->rootObject()->setProperty("testRightToLeft", true);
-
- //Note that all animate in
- QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
- QVERIFY(one != 0);
- QCOMPARE(one->x(), -100.0);
- QCOMPARE(one->y(), -100.0);
-
- QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
- QVERIFY(two != 0);
- QCOMPARE(two->x(), -100.0);
- QCOMPARE(two->y(), -100.0);
-
- QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
- QVERIFY(three != 0);
- QCOMPARE(three->x(), -100.0);
- QCOMPARE(three->y(), -100.0);
-
- QDeclarative1Rectangle *four = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("four");
- QVERIFY(four != 0);
- QCOMPARE(four->x(), -100.0);
- QCOMPARE(four->y(), -100.0);
-
- QDeclarative1Rectangle *five = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("five");
- QVERIFY(five != 0);
- QCOMPARE(five->x(), -100.0);
- QCOMPARE(five->y(), -100.0);
-
- QDeclarativeItem *grid = canvas->rootObject()->findChild<QDeclarativeItem*>("grid");
- QVERIFY(grid);
- QCOMPARE(grid->width(), 150.0);
- QCOMPARE(grid->height(), 100.0);
-
- //QTRY_COMPARE used instead of waiting for the expected time of animation completion
- //Note that this means the duration of the animation is NOT tested
-
- QTRY_COMPARE(one->y(), 0.0);
- QTRY_COMPARE(one->x(), 100.0);
- QTRY_COMPARE(two->opacity(), 0.0);
- QTRY_COMPARE(two->y(), -100.0);
- QTRY_COMPARE(two->x(), -100.0);
- QTRY_COMPARE(three->y(), 0.0);
- QTRY_COMPARE(three->x(), 50.0);
- QTRY_COMPARE(four->y(), 0.0);
- QTRY_COMPARE(four->x(), 0.0);
- QTRY_COMPARE(five->y(), 50.0);
- QTRY_COMPARE(five->x(), 100.0);
-
- //Add 'two'
- two->setOpacity(1.0);
- QCOMPARE(two->opacity(), 1.0);
- QCOMPARE(grid->width(), 150.0);
- QCOMPARE(grid->height(), 100.0);
- QTest::qWait(0);//Let the animation start
- QCOMPARE(two->x(), -100.0);
- QCOMPARE(two->y(), -100.0);
- QCOMPARE(one->x(), 100.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(three->x(), 50.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 0.0);
- QCOMPARE(four->y(), 0.0);
- QCOMPARE(five->x(), 100.0);
- QCOMPARE(five->y(), 50.0);
- //Let the animation complete
- QTRY_COMPARE(two->x(), 50.0);
- QTRY_COMPARE(two->y(), 0.0);
- QTRY_COMPARE(one->x(), 100.0);
- QTRY_COMPARE(one->y(), 0.0);
- QTRY_COMPARE(three->x(), 0.0);
- QTRY_COMPARE(three->y(), 0.0);
- QTRY_COMPARE(four->x(), 100.0);
- QTRY_COMPARE(four->y(), 50.0);
- QTRY_COMPARE(five->x(), 50.0);
- QTRY_COMPARE(five->y(), 50.0);
-
- delete canvas;
-}
-
-void tst_QDeclarativePositioners::test_grid_zero_columns()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/gridzerocolumns.qml");
-
- QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
- QVERIFY(one != 0);
- QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
- QVERIFY(two != 0);
- QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
- QVERIFY(three != 0);
- QDeclarative1Rectangle *four = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("four");
- QVERIFY(four != 0);
- QDeclarative1Rectangle *five = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 70.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 120.0);
- QCOMPARE(four->y(), 0.0);
- QCOMPARE(five->x(), 0.0);
- QCOMPARE(five->y(), 50.0);
-
- QDeclarativeItem *grid = canvas->rootObject()->findChild<QDeclarativeItem*>("grid");
- QCOMPARE(grid->width(), 170.0);
- QCOMPARE(grid->height(), 60.0);
-
- delete canvas;
-}
-
-void tst_QDeclarativePositioners::test_propertychanges()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/propertychangestest.qml");
-
- QDeclarative1Grid *grid = qobject_cast<QDeclarative1Grid*>(canvas->rootObject());
- QVERIFY(grid != 0);
- QDeclarative1Transition *rowTransition = canvas->rootObject()->findChild<QDeclarative1Transition*>("rowTransition");
- QDeclarative1Transition *columnTransition = canvas->rootObject()->findChild<QDeclarative1Transition*>("columnTransition");
-
- QSignalSpy addSpy(grid, SIGNAL(addChanged()));
- QSignalSpy moveSpy(grid, SIGNAL(moveChanged()));
- QSignalSpy columnsSpy(grid, SIGNAL(columnsChanged()));
- QSignalSpy rowsSpy(grid, SIGNAL(rowsChanged()));
-
- QVERIFY(grid);
- QVERIFY(rowTransition);
- QVERIFY(columnTransition);
- QCOMPARE(grid->add(), columnTransition);
- QCOMPARE(grid->move(), columnTransition);
- QCOMPARE(grid->columns(), 4);
- QCOMPARE(grid->rows(), -1);
-
- grid->setAdd(rowTransition);
- grid->setMove(rowTransition);
- QCOMPARE(grid->add(), rowTransition);
- QCOMPARE(grid->move(), rowTransition);
- QCOMPARE(addSpy.count(),1);
- QCOMPARE(moveSpy.count(),1);
-
- grid->setAdd(rowTransition);
- grid->setMove(rowTransition);
- QCOMPARE(addSpy.count(),1);
- QCOMPARE(moveSpy.count(),1);
-
- grid->setAdd(0);
- grid->setMove(0);
- QCOMPARE(addSpy.count(),2);
- QCOMPARE(moveSpy.count(),2);
-
- grid->setColumns(-1);
- grid->setRows(3);
- QCOMPARE(grid->columns(), -1);
- QCOMPARE(grid->rows(), 3);
- QCOMPARE(columnsSpy.count(),1);
- QCOMPARE(rowsSpy.count(),1);
-
- grid->setColumns(-1);
- grid->setRows(3);
- QCOMPARE(columnsSpy.count(),1);
- QCOMPARE(rowsSpy.count(),1);
-
- grid->setColumns(2);
- grid->setRows(2);
- QCOMPARE(columnsSpy.count(),2);
- QCOMPARE(rowsSpy.count(),2);
-
- delete canvas;
-}
-
-void tst_QDeclarativePositioners::test_repeater()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/repeatertest.qml");
-
- QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
- QVERIFY(one != 0);
-
- QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
- QVERIFY(two != 0);
-
- QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
- QVERIFY(three != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 100.0);
- QCOMPARE(three->y(), 0.0);
-
- delete canvas;
-}
-
-void tst_QDeclarativePositioners::test_flow()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/flowtest.qml");
-
- canvas->rootObject()->setProperty("testRightToLeft", false);
-
- QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
- QVERIFY(one != 0);
- QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
- QVERIFY(two != 0);
- QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
- QVERIFY(three != 0);
- QDeclarative1Rectangle *four = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("four");
- QVERIFY(four != 0);
- QDeclarative1Rectangle *five = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 0.0);
- QCOMPARE(three->y(), 50.0);
- QCOMPARE(four->x(), 0.0);
- QCOMPARE(four->y(), 70.0);
- QCOMPARE(five->x(), 50.0);
- QCOMPARE(five->y(), 70.0);
-
- QDeclarativeItem *flow = canvas->rootObject()->findChild<QDeclarativeItem*>("flow");
- QVERIFY(flow);
- QCOMPARE(flow->width(), 90.0);
- QCOMPARE(flow->height(), 120.0);
-
- delete canvas;
-}
-
-void tst_QDeclarativePositioners::test_flow_rightToLeft()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/flowtest.qml");
-
- canvas->rootObject()->setProperty("testRightToLeft", true);
-
- QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
- QVERIFY(one != 0);
- QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
- QVERIFY(two != 0);
- QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
- QVERIFY(three != 0);
- QDeclarative1Rectangle *four = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("four");
- QVERIFY(four != 0);
- QDeclarative1Rectangle *five = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 40.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 20.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 40.0);
- QCOMPARE(three->y(), 50.0);
- QCOMPARE(four->x(), 40.0);
- QCOMPARE(four->y(), 70.0);
- QCOMPARE(five->x(), 30.0);
- QCOMPARE(five->y(), 70.0);
-
- QDeclarativeItem *flow = canvas->rootObject()->findChild<QDeclarativeItem*>("flow");
- QVERIFY(flow);
- QCOMPARE(flow->width(), 90.0);
- QCOMPARE(flow->height(), 120.0);
-
- delete canvas;
-}
-
-void tst_QDeclarativePositioners::test_flow_topToBottom()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/flowtest-toptobottom.qml");
-
- canvas->rootObject()->setProperty("testRightToLeft", false);
-
- QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
- QVERIFY(one != 0);
- QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
- QVERIFY(two != 0);
- QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
- QVERIFY(three != 0);
- QDeclarative1Rectangle *four = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("four");
- QVERIFY(four != 0);
- QDeclarative1Rectangle *five = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 50.0);
- QCOMPARE(three->y(), 50.0);
- QCOMPARE(four->x(), 100.0);
- QCOMPARE(four->y(), 00.0);
- QCOMPARE(five->x(), 100.0);
- QCOMPARE(five->y(), 50.0);
-
- QDeclarativeItem *flow = canvas->rootObject()->findChild<QDeclarativeItem*>("flow");
- QVERIFY(flow);
- QCOMPARE(flow->height(), 90.0);
- QCOMPARE(flow->width(), 150.0);
-
- canvas->rootObject()->setProperty("testRightToLeft", true);
-
- QVERIFY(flow);
- QCOMPARE(flow->height(), 90.0);
- QCOMPARE(flow->width(), 150.0);
-
- QCOMPARE(one->x(), 100.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 80.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 50.0);
- QCOMPARE(three->y(), 50.0);
- QCOMPARE(four->x(), 0.0);
- QCOMPARE(four->y(), 0.0);
- QCOMPARE(five->x(), 40.0);
- QCOMPARE(five->y(), 50.0);
-
- delete canvas;
-}
-
-void tst_QDeclarativePositioners::test_flow_resize()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/flowtest.qml");
-
- QDeclarativeItem *root = qobject_cast<QDeclarativeItem*>(canvas->rootObject());
- QVERIFY(root);
- root->setWidth(125);
- root->setProperty("testRightToLeft", false);
-
- QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
- QVERIFY(one != 0);
- QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
- QVERIFY(two != 0);
- QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
- QVERIFY(three != 0);
- QDeclarative1Rectangle *four = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("four");
- QVERIFY(four != 0);
- QDeclarative1Rectangle *five = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 70.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 0.0);
- QCOMPARE(four->y(), 50.0);
- QCOMPARE(five->x(), 50.0);
- QCOMPARE(five->y(), 50.0);
-
- delete canvas;
-}
-
-void tst_QDeclarativePositioners::test_flow_resize_rightToLeft()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/flowtest.qml");
-
- QDeclarativeItem *root = qobject_cast<QDeclarativeItem*>(canvas->rootObject());
- QVERIFY(root);
- root->setWidth(125);
- root->setProperty("testRightToLeft", true);
-
- QDeclarative1Rectangle *one = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("one");
- QVERIFY(one != 0);
- QDeclarative1Rectangle *two = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("two");
- QVERIFY(two != 0);
- QDeclarative1Rectangle *three = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("three");
- QVERIFY(three != 0);
- QDeclarative1Rectangle *four = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("four");
- QVERIFY(four != 0);
- QDeclarative1Rectangle *five = canvas->rootObject()->findChild<QDeclarative1Rectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 75.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 55.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 5.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 75.0);
- QCOMPARE(four->y(), 50.0);
- QCOMPARE(five->x(), 65.0);
- QCOMPARE(five->y(), 50.0);
-
- delete canvas;
-}
-
-void tst_QDeclarativePositioners::test_flow_implicit_resize()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/flow-testimplicitsize.qml");
- QVERIFY(canvas->rootObject() != 0);
-
- QDeclarative1Flow *flow = canvas->rootObject()->findChild<QDeclarative1Flow*>("flow");
- QVERIFY(flow != 0);
-
- QCOMPARE(flow->width(), 100.0);
- QCOMPARE(flow->height(), 120.0);
-
- canvas->rootObject()->setProperty("flowLayout", 0);
- QCOMPARE(flow->flow(), QDeclarative1Flow::LeftToRight);
- QCOMPARE(flow->width(), 220.0);
- QCOMPARE(flow->height(), 50.0);
-
- canvas->rootObject()->setProperty("flowLayout", 1);
- QCOMPARE(flow->flow(), QDeclarative1Flow::TopToBottom);
- QCOMPARE(flow->width(), 100.0);
- QCOMPARE(flow->height(), 120.0);
-
- canvas->rootObject()->setProperty("flowLayout", 2);
- QCOMPARE(flow->layoutDirection(), Qt::RightToLeft);
- QCOMPARE(flow->width(), 220.0);
- QCOMPARE(flow->height(), 50.0);
-
- delete canvas;
-}
-
-QString warningMessage;
-
-void interceptWarnings(QtMsgType type, const char *msg)
-{
- Q_UNUSED( type );
- warningMessage = msg;
-}
-
-void tst_QDeclarativePositioners::test_conflictinganchors()
-{
- QtMsgHandler oldMsgHandler = qInstallMsgHandler(interceptWarnings);
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
-
- component.setData("import QtQuick 1.0\nColumn { Item {} }", QUrl::fromLocalFile(""));
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(item);
- QVERIFY(warningMessage.isEmpty());
- delete item;
-
- component.setData("import QtQuick 1.0\nRow { Item {} }", QUrl::fromLocalFile(""));
- item = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(item);
- QVERIFY(warningMessage.isEmpty());
- delete item;
-
- component.setData("import QtQuick 1.0\nGrid { Item {} }", QUrl::fromLocalFile(""));
- item = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(item);
- QVERIFY(warningMessage.isEmpty());
- delete item;
-
- component.setData("import QtQuick 1.0\nFlow { Item {} }", QUrl::fromLocalFile(""));
- item = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(item);
- QVERIFY(warningMessage.isEmpty());
- delete item;
-
- component.setData("import QtQuick 1.0\nColumn { Item { anchors.top: parent.top } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(item);
- QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column"));
- warningMessage.clear();
- delete item;
-
- component.setData("import QtQuick 1.0\nColumn { Item { anchors.centerIn: parent } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(item);
- QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column"));
- warningMessage.clear();
- delete item;
-
- component.setData("import QtQuick 1.0\nColumn { Item { anchors.left: parent.left } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(item);
- QVERIFY(warningMessage.isEmpty());
- warningMessage.clear();
- delete item;
-
- component.setData("import QtQuick 1.0\nRow { Item { anchors.left: parent.left } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(item);
- QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row"));
- warningMessage.clear();
- delete item;
-
- component.setData("import QtQuick 1.0\nRow { Item { anchors.fill: parent } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(item);
- QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row"));
- warningMessage.clear();
- delete item;
-
- component.setData("import QtQuick 1.0\nRow { Item { anchors.top: parent.top } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(item);
- QVERIFY(warningMessage.isEmpty());
- warningMessage.clear();
- delete item;
-
- component.setData("import QtQuick 1.0\nGrid { Item { anchors.horizontalCenter: parent.horizontalCenter } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(item);
- QCOMPARE(warningMessage, QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid"));
- warningMessage.clear();
- delete item;
-
- component.setData("import QtQuick 1.0\nGrid { Item { anchors.centerIn: parent } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(item);
- QCOMPARE(warningMessage, QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid"));
- warningMessage.clear();
- delete item;
-
- component.setData("import QtQuick 1.0\nFlow { Item { anchors.verticalCenter: parent.verticalCenter } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(item);
- QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow"));
- delete item;
-
- component.setData("import QtQuick 1.0\nFlow { Item { anchors.fill: parent } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(item);
- QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow"));
- qInstallMsgHandler(oldMsgHandler);
- delete item;
-}
-
-void tst_QDeclarativePositioners::test_vertical_qgraphicswidget()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/verticalqgraphicswidget.qml");
-
- QGraphicsWidget *one = canvas->rootObject()->findChild<QGraphicsWidget*>("one");
- QVERIFY(one != 0);
-
- QGraphicsWidget *two = canvas->rootObject()->findChild<QGraphicsWidget*>("two");
- QVERIFY(two != 0);
-
- QGraphicsWidget *three = canvas->rootObject()->findChild<QGraphicsWidget*>("three");
- QVERIFY(three != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 0.0);
- QCOMPARE(two->y(), 50.0);
- QCOMPARE(three->x(), 0.0);
- QCOMPARE(three->y(), 60.0);
-
- QDeclarativeItem *column = canvas->rootObject()->findChild<QDeclarativeItem*>("column");
- QVERIFY(column);
- QCOMPARE(column->height(), 80.0);
- QCOMPARE(column->width(), 50.0);
-
- two->resize(QSizeF(two->size().width(), 20.0));
- QCOMPARE(three->x(), 0.0);
- QCOMPARE(three->y(), 70.0);
-
- two->setOpacity(0.0);
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(three->x(), 0.0);
- QCOMPARE(three->y(), 50.0);
-
- one->setVisible(false);
- QCOMPARE(three->x(), 0.0);
- QCOMPARE(three->y(), 0.0);
-
- delete canvas;
-}
-
-void tst_QDeclarativePositioners::test_mirroring()
-{
- QList<QString> qmlFiles;
- qmlFiles << "horizontal.qml" << "gridtest.qml" << "flowtest.qml";
- QList<QString> objectNames;
- objectNames << "one" << "two" << "three" << "four" << "five";
-
- foreach(const QString qmlFile, qmlFiles) {
- QDeclarativeView *canvasA = createView(QString(SRCDIR) + "/data/" + qmlFile);
- QDeclarativeItem *rootA = qobject_cast<QDeclarativeItem*>(canvasA->rootObject());
-
- QDeclarativeView *canvasB = createView(QString(SRCDIR) + "/data/" + qmlFile);
- QDeclarativeItem *rootB = qobject_cast<QDeclarativeItem*>(canvasB->rootObject());
-
- rootA->setProperty("testRightToLeft", true); // layoutDirection: Qt.RightToLeft
-
- // LTR != RTL
- foreach(const QString objectName, objectNames) {
- // horizontal.qml only has three items
- if (qmlFile == QString("horizontal.qml") && objectName == QString("four"))
- break;
- QDeclarativeItem *itemA = rootA->findChild<QDeclarativeItem*>(objectName);
- QDeclarativeItem *itemB = rootB->findChild<QDeclarativeItem*>(objectName);
- QVERIFY(itemA->x() != itemB->x());
- }
-
- QDeclarativeItemPrivate* rootPrivateB = QDeclarativeItemPrivate::get(rootB);
-
- rootPrivateB->effectiveLayoutMirror = true; // LayoutMirroring.enabled: true
- rootPrivateB->isMirrorImplicit = false;
- rootPrivateB->inheritMirrorFromItem = true; // LayoutMirroring.childrenInherit: true
- rootPrivateB->resolveLayoutMirror();
-
- // RTL == mirror
- foreach(const QString objectName, objectNames) {
- // horizontal.qml only has three items
- if (qmlFile == QString("horizontal.qml") && objectName == QString("four"))
- break;
- QDeclarativeItem *itemA = rootA->findChild<QDeclarativeItem*>(objectName);
- QDeclarativeItem *itemB = rootB->findChild<QDeclarativeItem*>(objectName);
- QCOMPARE(itemA->x(), itemB->x());
- }
-
- rootA->setProperty("testRightToLeft", false); // layoutDirection: Qt.LeftToRight
- rootB->setProperty("testRightToLeft", true); // layoutDirection: Qt.RightToLeft
-
- // LTR == RTL + mirror
- foreach(const QString objectName, objectNames) {
- // horizontal.qml only has three items
- if (qmlFile == QString("horizontal.qml") && objectName == QString("four"))
- break;
- QDeclarativeItem *itemA = rootA->findChild<QDeclarativeItem*>(objectName);
- QDeclarativeItem *itemB = rootB->findChild<QDeclarativeItem*>(objectName);
- QCOMPARE(itemA->x(), itemB->x());
- }
- delete canvasA;
- delete canvasB;
- }
-}
-
-void tst_QDeclarativePositioners::testQtQuick11Attributes()
-{
- QFETCH(QString, code);
- QFETCH(QString, warning);
- QFETCH(QString, error);
-
- QDeclarativeEngine engine;
- QObject *obj;
-
- QDeclarativeComponent valid(&engine);
- valid.setData("import QtQuick 1.1; " + code.toUtf8(), QUrl(""));
- obj = valid.create();
- QVERIFY(obj);
- QVERIFY(valid.errorString().isEmpty());
- delete obj;
-
- QDeclarativeComponent invalid(&engine);
- invalid.setData("import QtQuick 1.0; " + code.toUtf8(), QUrl(""));
- QTest::ignoreMessage(QtWarningMsg, warning.toUtf8());
- obj = invalid.create();
- QCOMPARE(invalid.errorString(), error);
- delete obj;
-}
-
-void tst_QDeclarativePositioners::testQtQuick11Attributes_data()
-{
- QTest::addColumn<QString>("code");
- QTest::addColumn<QString>("warning");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("Flow.layoutDirection") << "Flow { layoutDirection: Qt.LeftToRight }"
- << "QDeclarativeComponent: Component is not ready"
- << ":1 \"Flow.layoutDirection\" is not available in QtQuick 1.0.\n";
-
- QTest::newRow("Row.layoutDirection") << "Row { layoutDirection: Qt.LeftToRight }"
- << "QDeclarativeComponent: Component is not ready"
- << ":1 \"Row.layoutDirection\" is not available in QtQuick 1.0.\n";
-
- QTest::newRow("Grid.layoutDirection") << "Grid { layoutDirection: Qt.LeftToRight }"
- << "QDeclarativeComponent: Component is not ready"
- << ":1 \"Grid.layoutDirection\" is not available in QtQuick 1.0.\n";
-}
-
-QDeclarativeView *tst_QDeclarativePositioners::createView(const QString &filename)
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
-
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- return canvas;
-}
-
-
-QTEST_MAIN(tst_QDeclarativePositioners)
-
-#include "tst_qdeclarativepositioners.moc"
diff --git a/tests/auto/qtquick1/qdeclarativerepeater/data/intmodel.qml b/tests/auto/qtquick1/qdeclarativerepeater/data/intmodel.qml
deleted file mode 100644
index 85e1608bbf..0000000000
--- a/tests/auto/qtquick1/qdeclarativerepeater/data/intmodel.qml
+++ /dev/null
@@ -1,29 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: container
- objectName: "container"
- width: 240
- height: 320
- color: "white"
-
- function checkProperties() {
- testObject.error = false;
- if (repeater.delegate != comp) {
- console.log("delegate property incorrect");
- testObject.error = true;
- }
- }
-
- Component {
- id: comp
- Item{}
- }
-
- Repeater {
- id: repeater
- objectName: "repeater"
- model: testData
- delegate: comp
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativerepeater/data/itemlist.qml b/tests/auto/qtquick1/qdeclarativerepeater/data/itemlist.qml
deleted file mode 100644
index 590a9cd194..0000000000
--- a/tests/auto/qtquick1/qdeclarativerepeater/data/itemlist.qml
+++ /dev/null
@@ -1,68 +0,0 @@
-// This example demonstrates placing items in a view using
-// a VisualItemModel
-
-import QtQuick 1.0
-
-Rectangle {
- id: root
- color: "lightgray"
- width: 240
- height: 320
- property variant itemModel: itemModel1
-
- function checkProperties() {
- testObject.error = false;
- if (testObject.useModel && view.model != root.itemModel) {
- console.log("model property incorrect");
- testObject.error = true;
- }
- }
-
- function switchModel() {
- root.itemModel = itemModel2
- }
-
- VisualItemModel {
- id: itemModel1
- objectName: "itemModel1"
- Rectangle {
- objectName: "item1"
- height: 50; width: 100; color: "#FFFEF0"
- Text { objectName: "text1"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent }
- }
- Rectangle {
- objectName: "item2"
- height: 50; width: 100; color: "#F0FFF7"
- Text { objectName: "text2"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent }
- }
- Rectangle {
- objectName: "item3"
- height: 50; width: 100; color: "#F4F0FF"
- Text { objectName: "text3"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent }
- }
- }
-
- VisualItemModel {
- id: itemModel2
- objectName: "itemModel2"
- Rectangle {
- objectName: "item4"
- height: 50; width: 100; color: "#FFFEF0"
- Text { objectName: "text4"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent }
- }
- Rectangle {
- objectName: "item5"
- height: 50; width: 100; color: "#F0FFF7"
- Text { objectName: "text5"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent }
- }
- }
-
- Column {
- objectName: "container"
- Repeater {
- id: view
- objectName: "repeater"
- model: testObject.useModel ? root.itemModel : 0
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativerepeater/data/modelChanged.qml b/tests/auto/qtquick1/qdeclarativerepeater/data/modelChanged.qml
deleted file mode 100644
index 0b57d50b6f..0000000000
--- a/tests/auto/qtquick1/qdeclarativerepeater/data/modelChanged.qml
+++ /dev/null
@@ -1,26 +0,0 @@
-import QtQuick 1.1
-
-Column {
- Repeater {
- id: repeater
- objectName: "repeater"
-
- property int itemsCount
- property variant itemsFound: []
-
- delegate: Rectangle {
- color: "red"
- width: (index+1)*50
- height: 50
- }
-
- onModelChanged: {
- repeater.itemsCount = repeater.count
- var items = []
- for (var i=0; i<repeater.count; i++)
- items.push(repeater.itemAt(i))
- repeater.itemsFound = items
- }
- }
-}
-
diff --git a/tests/auto/qtquick1/qdeclarativerepeater/data/objlist.qml b/tests/auto/qtquick1/qdeclarativerepeater/data/objlist.qml
deleted file mode 100644
index b47b04237c..0000000000
--- a/tests/auto/qtquick1/qdeclarativerepeater/data/objlist.qml
+++ /dev/null
@@ -1,21 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: container
- objectName: "container"
- width: 240
- height: 320
- color: "white"
- Repeater {
- id: repeater
- objectName: "repeater"
- model: testData
- property int errors: 0
- property int instantiated: 0
- Component {
- Item{
- Component.onCompleted: {if(index!=modelData.idx) repeater.errors += 1; repeater.instantiated++}
- }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativerepeater/data/properties.qml b/tests/auto/qtquick1/qdeclarativerepeater/data/properties.qml
deleted file mode 100644
index 689a103082..0000000000
--- a/tests/auto/qtquick1/qdeclarativerepeater/data/properties.qml
+++ /dev/null
@@ -1,11 +0,0 @@
-import QtQuick 1.0
-
-Row {
- Repeater {
- objectName: "repeater"
- model: 5
- Text {
- text: "I'm item " + index
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativerepeater/data/repeater1.qml b/tests/auto/qtquick1/qdeclarativerepeater/data/repeater1.qml
deleted file mode 100644
index 2456b6d75d..0000000000
--- a/tests/auto/qtquick1/qdeclarativerepeater/data/repeater1.qml
+++ /dev/null
@@ -1,28 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: container
- objectName: "container"
- width: 240
- height: 320
- color: "white"
- Text {
- text: "Zero"
- }
- Repeater {
- id: repeater
- objectName: "repeater"
- width: 240
- height: 320
- model: testData
- Component {
- Text {
- y: index*20
- text: modelData
- }
- }
- }
- Text {
- text: "Last"
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativerepeater/data/repeater2.qml b/tests/auto/qtquick1/qdeclarativerepeater/data/repeater2.qml
deleted file mode 100644
index 02ef81033c..0000000000
--- a/tests/auto/qtquick1/qdeclarativerepeater/data/repeater2.qml
+++ /dev/null
@@ -1,36 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 240
- height: 320
- color: "white"
- Component {
- id: myDelegate
- Item {
- objectName: "myDelegate"
- height: 20
- width: 240
- Text {
- objectName: "myName"
- text: name
- }
- Text {
- objectName: "myNumber"
- x: 100
- text: number
- }
- }
- }
- Column {
- id: container
- objectName: "container"
- Repeater {
- id: repeater
- objectName: "repeater"
- width: 240
- height: 320
- delegate: myDelegate
- model: testData
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativerepeater/qdeclarativerepeater.pro b/tests/auto/qtquick1/qdeclarativerepeater/qdeclarativerepeater.pro
deleted file mode 100644
index 0fc556c10a..0000000000
--- a/tests/auto/qtquick1/qdeclarativerepeater/qdeclarativerepeater.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativerepeater
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativerepeater.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-QT += core-private gui-private widgets-private declarative-private qtquick1-private testlib
diff --git a/tests/auto/qtquick1/qdeclarativerepeater/tst_qdeclarativerepeater.cpp b/tests/auto/qtquick1/qdeclarativerepeater/tst_qdeclarativerepeater.cpp
deleted file mode 100644
index ab423f452b..0000000000
--- a/tests/auto/qtquick1/qdeclarativerepeater/tst_qdeclarativerepeater.cpp
+++ /dev/null
@@ -1,730 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtTest/QSignalSpy>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtQuick1/qdeclarativeview.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtQuick1/private/qdeclarativerepeater_p.h>
-#include <QtQuick1/private/qdeclarativetext_p.h>
-
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename);
-}
-
-class tst_QDeclarative1Repeater : public QObject
-{
- Q_OBJECT
-public:
- tst_QDeclarative1Repeater();
-
-private slots:
- void numberModel();
- void objectList();
- void stringList();
- void dataModel_adding();
- void dataModel_removing();
- void dataModel_changes();
- void itemModel();
- void resetModel();
- void modelChanged();
- void properties();
- void testQtQuick11Attributes();
- void testQtQuick11Attributes_data();
-
-private:
- QDeclarativeView *createView();
- template<typename T>
- T *findItem(QGraphicsObject *parent, const QString &objectName, int index);
- template<typename T>
- T *findItem(QGraphicsObject *parent, const QString &id);
-};
-
-class TestObject : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(bool error READ error WRITE setError)
- Q_PROPERTY(bool useModel READ useModel NOTIFY useModelChanged)
-
-public:
- TestObject() : QObject(), mError(true), mUseModel(false) {}
-
- bool error() const { return mError; }
- void setError(bool err) { mError = err; }
-
- bool useModel() const { return mUseModel; }
- void setUseModel(bool use) { mUseModel = use; emit useModelChanged(); }
-
-signals:
- void useModelChanged();
-
-private:
- bool mError;
- bool mUseModel;
-};
-
-class TestModel : public QAbstractListModel
-{
-public:
- enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 };
-
- TestModel(QObject *parent=0) : QAbstractListModel(parent) {
- QHash<int, QByteArray> roles;
- roles[Name] = "name";
- roles[Number] = "number";
- setRoleNames(roles);
- }
-
- int rowCount(const QModelIndex &parent=QModelIndex()) const { Q_UNUSED(parent); return list.count(); }
- QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const {
- QVariant rv;
- if (role == Name)
- rv = list.at(index.row()).first;
- else if (role == Number)
- rv = list.at(index.row()).second;
-
- return rv;
- }
-
- int count() const { return rowCount(); }
- QString name(int index) const { return list.at(index).first; }
- QString number(int index) const { return list.at(index).second; }
-
- void addItem(const QString &name, const QString &number) {
- emit beginInsertRows(QModelIndex(), list.count(), list.count());
- list.append(QPair<QString,QString>(name, number));
- emit endInsertRows();
- }
-
- void insertItem(int index, const QString &name, const QString &number) {
- emit beginInsertRows(QModelIndex(), index, index);
- list.insert(index, QPair<QString,QString>(name, number));
- emit endInsertRows();
- }
-
- void removeItem(int index) {
- emit beginRemoveRows(QModelIndex(), index, index);
- list.removeAt(index);
- emit endRemoveRows();
- }
-
- void moveItem(int from, int to) {
- emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
- list.move(from, to);
- emit endMoveRows();
- }
-
- void modifyItem(int idx, const QString &name, const QString &number) {
- list[idx] = QPair<QString,QString>(name, number);
- emit dataChanged(index(idx,0), index(idx,0));
- }
-
-private:
- QList<QPair<QString,QString> > list;
-};
-
-
-tst_QDeclarative1Repeater::tst_QDeclarative1Repeater()
-{
-}
-
-void tst_QDeclarative1Repeater::numberModel()
-{
- QDeclarativeView *canvas = createView();
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testData", 5);
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/intmodel.qml"));
- qApp->processEvents();
-
- QDeclarative1Repeater *repeater = findItem<QDeclarative1Repeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
- QCOMPARE(repeater->parentItem()->childItems().count(), 5+1);
-
- QVERIFY(!repeater->itemAt(-1));
- for (int i=0; i<repeater->count(); i++)
- QCOMPARE(repeater->itemAt(i), repeater->parentItem()->childItems().at(i));
- QVERIFY(!repeater->itemAt(repeater->count()));
-
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
-
- delete testObject;
- delete canvas;
-}
-
-class MyObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int idx READ idx CONSTANT)
-public:
- MyObject(int i) : QObject(), m_idx(i) {}
-
- int idx() const { return m_idx; }
-
- int m_idx;
-};
-
-void tst_QDeclarative1Repeater::objectList()
-{
- QDeclarativeView *canvas = createView();
- QObjectList data;
- for(int i=0; i<100; i++)
- data << new MyObject(i);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testData", QVariant::fromValue(data));
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/objlist.qml"));
- qApp->processEvents();
-
- QDeclarative1Repeater *repeater = findItem<QDeclarative1Repeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
- QCOMPARE(repeater->property("errors").toInt(), 0);//If this fails either they are out of order or can't find the object's data
- QCOMPARE(repeater->property("instantiated").toInt(), 100);
-
- QVERIFY(!repeater->itemAt(-1));
- for (int i=0; i<data.count(); i++)
- QCOMPARE(repeater->itemAt(i), repeater->parentItem()->childItems().at(i));
- QVERIFY(!repeater->itemAt(data.count()));
-
- QSignalSpy addedSpy(repeater, SIGNAL(itemAdded(int,QDeclarativeItem*)));
- QSignalSpy removedSpy(repeater, SIGNAL(itemRemoved(int,QDeclarativeItem*)));
- ctxt->setContextProperty("testData", QVariant::fromValue(data));
- QCOMPARE(addedSpy.count(), data.count());
- QCOMPARE(removedSpy.count(), data.count());
-
- qDeleteAll(data);
- delete canvas;
-}
-
-/*
-The Repeater element creates children at its own position in its parent's
-stacking order. In this test we insert a repeater between two other Text
-elements to test this.
-*/
-void tst_QDeclarative1Repeater::stringList()
-{
- QDeclarativeView *canvas = createView();
-
- QStringList data;
- data << "One";
- data << "Two";
- data << "Three";
- data << "Four";
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testData", data);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/repeater1.qml"));
- qApp->processEvents();
-
- QDeclarative1Repeater *repeater = findItem<QDeclarative1Repeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
-
- QDeclarativeItem *container = findItem<QDeclarativeItem>(canvas->rootObject(), "container");
- QVERIFY(container != 0);
-
- QCOMPARE(container->childItems().count(), data.count() + 3);
-
- bool saw_repeater = false;
- for (int i = 0; i < container->childItems().count(); ++i) {
-
- if (i == 0) {
- QDeclarative1Text *name = qobject_cast<QDeclarative1Text*>(container->childItems().at(i));
- QVERIFY(name != 0);
- QCOMPARE(name->text(), QLatin1String("Zero"));
- } else if (i == container->childItems().count() - 2) {
- // The repeater itself
- QDeclarative1Repeater *rep = qobject_cast<QDeclarative1Repeater*>(container->childItems().at(i));
- QCOMPARE(rep, repeater);
- saw_repeater = true;
- continue;
- } else if (i == container->childItems().count() - 1) {
- QDeclarative1Text *name = qobject_cast<QDeclarative1Text*>(container->childItems().at(i));
- QVERIFY(name != 0);
- QCOMPARE(name->text(), QLatin1String("Last"));
- } else {
- QDeclarative1Text *name = qobject_cast<QDeclarative1Text*>(container->childItems().at(i));
- QVERIFY(name != 0);
- QCOMPARE(name->text(), data.at(i-1));
- }
- }
- QVERIFY(saw_repeater);
-
- delete canvas;
-}
-
-void tst_QDeclarative1Repeater::dataModel_adding()
-{
- QDeclarativeView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- TestModel testModel;
- ctxt->setContextProperty("testData", &testModel);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/repeater2.qml"));
- qApp->processEvents();
-
- QDeclarative1Repeater *repeater = findItem<QDeclarative1Repeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
- QDeclarativeItem *container = findItem<QDeclarativeItem>(canvas->rootObject(), "container");
- QVERIFY(container != 0);
-
- QVERIFY(!repeater->itemAt(0));
-
- QSignalSpy countSpy(repeater, SIGNAL(countChanged()));
- QSignalSpy addedSpy(repeater, SIGNAL(itemAdded(int,QDeclarativeItem*)));
-
- // add to empty model
- testModel.addItem("two", "2");
- QCOMPARE(repeater->itemAt(0), container->childItems().at(0));
- QCOMPARE(countSpy.count(), 1); countSpy.clear();
- QCOMPARE(addedSpy.count(), 1);
- QCOMPARE(addedSpy.at(0).at(0).toInt(), 0);
- QCOMPARE(addedSpy.at(0).at(1).value<QDeclarativeItem*>(), container->childItems().at(0));
- addedSpy.clear();
-
- // insert at start
- testModel.insertItem(0, "one", "1");
- QCOMPARE(repeater->itemAt(0), container->childItems().at(0));
- QCOMPARE(countSpy.count(), 1); countSpy.clear();
- QCOMPARE(addedSpy.count(), 1);
- QCOMPARE(addedSpy.at(0).at(0).toInt(), 0);
- QCOMPARE(addedSpy.at(0).at(1).value<QDeclarativeItem*>(), container->childItems().at(0));
- addedSpy.clear();
-
- // insert at end
- testModel.insertItem(2, "four", "4");
- QCOMPARE(repeater->itemAt(2), container->childItems().at(2));
- QCOMPARE(countSpy.count(), 1); countSpy.clear();
- QCOMPARE(addedSpy.count(), 1);
- QCOMPARE(addedSpy.at(0).at(0).toInt(), 2);
- QCOMPARE(addedSpy.at(0).at(1).value<QDeclarativeItem*>(), container->childItems().at(2));
- addedSpy.clear();
-
- // insert in middle
- testModel.insertItem(2, "three", "3");
- QCOMPARE(repeater->itemAt(2), container->childItems().at(2));
- QCOMPARE(countSpy.count(), 1); countSpy.clear();
- QCOMPARE(addedSpy.count(), 1);
- QCOMPARE(addedSpy.at(0).at(0).toInt(), 2);
- QCOMPARE(addedSpy.at(0).at(1).value<QDeclarativeItem*>(), container->childItems().at(2));
- addedSpy.clear();
-
- delete testObject;
- delete canvas;
-}
-
-void tst_QDeclarative1Repeater::dataModel_removing()
-{
- QDeclarativeView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- TestModel testModel;
- testModel.addItem("one", "1");
- testModel.addItem("two", "2");
- testModel.addItem("three", "3");
- testModel.addItem("four", "4");
- testModel.addItem("five", "5");
-
- ctxt->setContextProperty("testData", &testModel);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/repeater2.qml"));
- qApp->processEvents();
-
- QDeclarative1Repeater *repeater = findItem<QDeclarative1Repeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
- QDeclarativeItem *container = findItem<QDeclarativeItem>(canvas->rootObject(), "container");
- QVERIFY(container != 0);
- QCOMPARE(container->childItems().count(), repeater->count()+1);
-
- QSignalSpy countSpy(repeater, SIGNAL(countChanged()));
- QSignalSpy removedSpy(repeater, SIGNAL(itemRemoved(int,QDeclarativeItem*)));
-
- // remove at start
- QDeclarativeItem *item = repeater->itemAt(0);
- QCOMPARE(item, container->childItems().at(0));
-
- testModel.removeItem(0);
- QVERIFY(repeater->itemAt(0) != item);
- QCOMPARE(countSpy.count(), 1); countSpy.clear();
- QCOMPARE(removedSpy.count(), 1);
- QCOMPARE(removedSpy.at(0).at(0).toInt(), 0);
- QCOMPARE(removedSpy.at(0).at(1).value<QDeclarativeItem*>(), item);
- removedSpy.clear();
-
- // remove at end
- int lastIndex = testModel.count()-1;
- item = repeater->itemAt(lastIndex);
- QCOMPARE(item, container->childItems().at(lastIndex));
-
- testModel.removeItem(lastIndex);
- QVERIFY(repeater->itemAt(lastIndex) != item);
- QCOMPARE(countSpy.count(), 1); countSpy.clear();
- QCOMPARE(removedSpy.count(), 1);
- QCOMPARE(removedSpy.at(0).at(0).toInt(), lastIndex);
- QCOMPARE(removedSpy.at(0).at(1).value<QDeclarativeItem*>(), item);
- removedSpy.clear();
-
- // remove from middle
- item = repeater->itemAt(1);
- QCOMPARE(item, container->childItems().at(1));
-
- testModel.removeItem(1);
- QVERIFY(repeater->itemAt(lastIndex) != item);
- QCOMPARE(countSpy.count(), 1); countSpy.clear();
- QCOMPARE(removedSpy.count(), 1);
- QCOMPARE(removedSpy.at(0).at(0).toInt(), 1);
- QCOMPARE(removedSpy.at(0).at(1).value<QDeclarativeItem*>(), item);
- removedSpy.clear();
-
- delete testObject;
- delete canvas;
-}
-
-void tst_QDeclarative1Repeater::dataModel_changes()
-{
- QDeclarativeView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- TestModel testModel;
- testModel.addItem("one", "1");
- testModel.addItem("two", "2");
- testModel.addItem("three", "3");
-
- ctxt->setContextProperty("testData", &testModel);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/repeater2.qml"));
- qApp->processEvents();
-
- QDeclarative1Repeater *repeater = findItem<QDeclarative1Repeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
- QDeclarativeItem *container = findItem<QDeclarativeItem>(canvas->rootObject(), "container");
- QVERIFY(container != 0);
- QCOMPARE(container->childItems().count(), repeater->count()+1);
-
- // Check that model changes are propagated
- QDeclarative1Text *text = findItem<QDeclarative1Text>(canvas->rootObject(), "myName", 1);
- QVERIFY(text);
- QCOMPARE(text->text(), QString("two"));
-
- testModel.modifyItem(1, "Item two", "_2");
- text = findItem<QDeclarative1Text>(canvas->rootObject(), "myName", 1);
- QVERIFY(text);
- QCOMPARE(text->text(), QString("Item two"));
-
- text = findItem<QDeclarative1Text>(canvas->rootObject(), "myNumber", 1);
- QVERIFY(text);
- QCOMPARE(text->text(), QString("_2"));
-
- delete testObject;
- delete canvas;
-}
-
-void tst_QDeclarative1Repeater::itemModel()
-{
- QDeclarativeView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/itemlist.qml"));
- qApp->processEvents();
-
- QDeclarative1Repeater *repeater = findItem<QDeclarative1Repeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
-
- QDeclarativeItem *container = findItem<QDeclarativeItem>(canvas->rootObject(), "container");
- QVERIFY(container != 0);
-
- QCOMPARE(container->childItems().count(), 1);
-
- testObject->setUseModel(true);
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
-
- QCOMPARE(container->childItems().count(), 4);
- QVERIFY(qobject_cast<QObject*>(container->childItems().at(0))->objectName() == "item1");
- QVERIFY(qobject_cast<QObject*>(container->childItems().at(1))->objectName() == "item2");
- QVERIFY(qobject_cast<QObject*>(container->childItems().at(2))->objectName() == "item3");
- QVERIFY(container->childItems().at(3) == repeater);
-
- QMetaObject::invokeMethod(canvas->rootObject(), "switchModel");
- QCOMPARE(container->childItems().count(), 3);
- QVERIFY(qobject_cast<QObject*>(container->childItems().at(0))->objectName() == "item4");
- QVERIFY(qobject_cast<QObject*>(container->childItems().at(1))->objectName() == "item5");
- QVERIFY(container->childItems().at(2) == repeater);
-
- testObject->setUseModel(false);
- QCOMPARE(container->childItems().count(), 1);
-
- delete testObject;
- delete canvas;
-}
-
-void tst_QDeclarative1Repeater::resetModel()
-{
- QDeclarativeView *canvas = createView();
-
- QStringList dataA;
- for (int i=0; i<10; i++)
- dataA << QString::number(i);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testData", dataA);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/repeater1.qml"));
- qApp->processEvents();
- QDeclarative1Repeater *repeater = findItem<QDeclarative1Repeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
- QDeclarativeItem *container = findItem<QDeclarativeItem>(canvas->rootObject(), "container");
- QVERIFY(container != 0);
-
- QCOMPARE(repeater->count(), dataA.count());
- for (int i=0; i<repeater->count(); i++)
- QCOMPARE(repeater->itemAt(i), container->childItems().at(i+1)); // +1 to skip first Text object
-
- QSignalSpy modelChangedSpy(repeater, SIGNAL(modelChanged()));
- QSignalSpy countSpy(repeater, SIGNAL(countChanged()));
- QSignalSpy addedSpy(repeater, SIGNAL(itemAdded(int,QDeclarativeItem*)));
- QSignalSpy removedSpy(repeater, SIGNAL(itemRemoved(int,QDeclarativeItem*)));
-
- QStringList dataB;
- for (int i=0; i<20; i++)
- dataB << QString::number(i);
-
- // reset context property
- ctxt->setContextProperty("testData", dataB);
- QCOMPARE(repeater->count(), dataB.count());
-
- QCOMPARE(modelChangedSpy.count(), 1);
- QCOMPARE(countSpy.count(), 1);
- QCOMPARE(removedSpy.count(), dataA.count());
- QCOMPARE(addedSpy.count(), dataB.count());
- for (int i=0; i<dataB.count(); i++) {
- QCOMPARE(addedSpy.at(i).at(0).toInt(), i);
- QCOMPARE(addedSpy.at(i).at(1).value<QDeclarativeItem*>(), repeater->itemAt(i));
- }
- modelChangedSpy.clear();
- countSpy.clear();
- removedSpy.clear();
- addedSpy.clear();
-
- // reset via setModel()
- repeater->setModel(dataA);
- QCOMPARE(repeater->count(), dataA.count());
-
- QCOMPARE(modelChangedSpy.count(), 1);
- QCOMPARE(countSpy.count(), 1);
- QCOMPARE(removedSpy.count(), dataB.count());
- QCOMPARE(addedSpy.count(), dataA.count());
- for (int i=0; i<dataA.count(); i++) {
- QCOMPARE(addedSpy.at(i).at(0).toInt(), i);
- QCOMPARE(addedSpy.at(i).at(1).value<QDeclarativeItem*>(), repeater->itemAt(i));
- }
-
- delete canvas;
-}
-
-// QTBUG-17156
-void tst_QDeclarative1Repeater::modelChanged()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TEST_FILE("/modelChanged.qml"));
-
- QDeclarativeItem *rootObject = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(rootObject);
- QDeclarative1Repeater *repeater = findItem<QDeclarative1Repeater>(rootObject, "repeater");
- QVERIFY(repeater);
-
- repeater->setModel(4);
- QCOMPARE(repeater->count(), 4);
- QCOMPARE(repeater->property("itemsCount").toInt(), 4);
- QCOMPARE(repeater->property("itemsFound").toList().count(), 4);
-
- repeater->setModel(10);
- QCOMPARE(repeater->count(), 10);
- QCOMPARE(repeater->property("itemsCount").toInt(), 10);
- QCOMPARE(repeater->property("itemsFound").toList().count(), 10);
-
- delete rootObject;
-}
-
-void tst_QDeclarative1Repeater::properties()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TEST_FILE("/properties.qml"));
-
- QDeclarativeItem *rootObject = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(rootObject);
-
- QDeclarative1Repeater *repeater = findItem<QDeclarative1Repeater>(rootObject, "repeater");
- QVERIFY(repeater);
-
- QSignalSpy modelSpy(repeater, SIGNAL(modelChanged()));
- repeater->setModel(3);
- QCOMPARE(modelSpy.count(),1);
- repeater->setModel(3);
- QCOMPARE(modelSpy.count(),1);
-
- QSignalSpy delegateSpy(repeater, SIGNAL(delegateChanged()));
-
- QDeclarativeComponent rectComponent(&engine);
- rectComponent.setData("import QtQuick 1.0; Rectangle {}", QUrl::fromLocalFile(""));
-
- repeater->setDelegate(&rectComponent);
- QCOMPARE(delegateSpy.count(),1);
- repeater->setDelegate(&rectComponent);
- QCOMPARE(delegateSpy.count(),1);
-
- delete rootObject;
-}
-
-void tst_QDeclarative1Repeater::testQtQuick11Attributes()
-{
- QFETCH(QString, code);
- QFETCH(QString, warning);
- QFETCH(QString, error);
-
- QDeclarativeEngine engine;
- QObject *obj;
-
- QDeclarativeComponent invalid(&engine);
- invalid.setData("import QtQuick 1.0; Repeater { " + code.toUtf8() + " }", QUrl(""));
- QTest::ignoreMessage(QtWarningMsg, warning.toUtf8());
- obj = invalid.create();
- QCOMPARE(invalid.errorString(), error);
- delete obj;
-
- QDeclarativeComponent valid(&engine);
- valid.setData("import QtQuick 1.1; Repeater { " + code.toUtf8() + " }", QUrl(""));
- obj = valid.create();
- QVERIFY(obj);
- QVERIFY(valid.errorString().isEmpty());
- delete obj;
-}
-
-void tst_QDeclarative1Repeater::testQtQuick11Attributes_data()
-{
- QTest::addColumn<QString>("code");
- QTest::addColumn<QString>("warning");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("itemAdded") << "onItemAdded: count"
- << "QDeclarativeComponent: Component is not ready"
- << ":1 \"Repeater.onItemAdded\" is not available in QtQuick 1.0.\n";
-
- QTest::newRow("itemRemoved") << "onItemRemoved: count"
- << "QDeclarativeComponent: Component is not ready"
- << ":1 \"Repeater.onItemRemoved\" is not available in QtQuick 1.0.\n";
-
- QTest::newRow("itemAt") << "Component.onCompleted: itemAt(0)"
- << "<Unknown File>:1: ReferenceError: Can't find variable: itemAt"
- << "";
-}
-
-
-QDeclarativeView *tst_QDeclarative1Repeater::createView()
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setFixedSize(240,320);
-
- return canvas;
-}
-
-template<typename T>
-T *tst_QDeclarative1Repeater::findItem(QGraphicsObject *parent, const QString &objectName, int index)
-{
- const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->childItems().count() << "children";
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- //qDebug() << "try" << item;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
- if (index != -1) {
- QDeclarativeExpression e(qmlContext(item), item, "index");
- if (e.evaluate().toInt() == index)
- return static_cast<T*>(item);
- } else {
- return static_cast<T*>(item);
- }
- }
- item = findItem<T>(item, objectName, index);
- if (item)
- return static_cast<T*>(item);
- }
-
- return 0;
-}
-
-template<typename T>
-T *tst_QDeclarative1Repeater::findItem(QGraphicsObject *parent, const QString &objectName)
-{
- const QMetaObject &mo = T::staticMetaObject;
- if (mo.cast(parent) && (objectName.isEmpty() || parent->objectName() == objectName))
- return static_cast<T*>(parent);
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QDeclarativeItem *child = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
- if (!child)
- continue;
- QDeclarativeItem *item = findItem<T>(child, objectName);
- if (item)
- return static_cast<T*>(item);
- }
-
- return 0;
-}
-
-QTEST_MAIN(tst_QDeclarative1Repeater)
-
-#include "tst_qdeclarativerepeater.moc"
diff --git a/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation1.qml b/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation1.qml
deleted file mode 100644
index 3a2c4e386b..0000000000
--- a/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation1.qml
+++ /dev/null
@@ -1,3 +0,0 @@
-import QtQuick 1.0
-
-SmoothedAnimation {}
diff --git a/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation2.qml b/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation2.qml
deleted file mode 100644
index 47935d48f0..0000000000
--- a/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation2.qml
+++ /dev/null
@@ -1,5 +0,0 @@
-import QtQuick 1.0
-
-SmoothedAnimation {
- to: 10; duration: 300; reversingMode: SmoothedAnimation.Immediate
-}
diff --git a/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation3.qml b/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation3.qml
deleted file mode 100644
index fe44cce14b..0000000000
--- a/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation3.qml
+++ /dev/null
@@ -1,6 +0,0 @@
-import QtQuick 1.0
-
-SmoothedAnimation {
- to: 10; velocity: 250; reversingMode: SmoothedAnimation.Sync
- maximumEasingTime: 150
-}
diff --git a/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimationBehavior.qml b/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimationBehavior.qml
deleted file mode 100644
index 65611227d0..0000000000
--- a/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimationBehavior.qml
+++ /dev/null
@@ -1,24 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 400; height: 400; color: "blue"
-
- Rectangle {
- id: rect1
- color: "red"
- width: 60; height: 60;
- x: 100; y: 100;
- SmoothedAnimation on x { to: 200; velocity: 500 }
- SmoothedAnimation on y { to: 200; velocity: 500 }
- }
-
- Rectangle {
- objectName: "theRect"
- color: "green"
- width: 60; height: 60;
- x: rect1.x; y: rect1.y;
- // id are needed for SmoothedAnimation in order to avoid deferred creation
- Behavior on x { SmoothedAnimation { id: anim1; objectName: "easeX"; velocity: 400 } }
- Behavior on y { SmoothedAnimation { id: anim2; objectName: "easeY"; velocity: 400 } }
- }
- }
diff --git a/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimationValueSource.qml b/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimationValueSource.qml
deleted file mode 100644
index 5036d5f225..0000000000
--- a/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimationValueSource.qml
+++ /dev/null
@@ -1,13 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 300; height: 300;
- Rectangle {
- objectName: "theRect"
- color: "red"
- width: 60; height: 60;
- x: 100; y: 100;
- SmoothedAnimation on x { objectName: "easeX"; to: 200; velocity: 500 }
- SmoothedAnimation on y { objectName: "easeY"; to: 200; duration: 250; velocity: 500 }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro b/tests/auto/qtquick1/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro
deleted file mode 100644
index 3044072c7c..0000000000
--- a/tests/auto/qtquick1/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativesmoothedanimation
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativesmoothedanimation.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
-QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib
diff --git a/tests/auto/qtquick1/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp b/tests/auto/qtquick1/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp
deleted file mode 100644
index 1aa931ee50..0000000000
--- a/tests/auto/qtquick1/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp
+++ /dev/null
@@ -1,210 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick1/private/qdeclarativesmoothedanimation_p.h>
-#include <QtQuick1/private/qdeclarativerectangle_p.h>
-#include <private/qdeclarativevaluetype_p.h>
-
-class tst_qdeclarativesmoothedanimation : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativesmoothedanimation();
-
-private slots:
- void defaultValues();
- void values();
- void disabled();
- void simpleAnimation();
- void valueSource();
- void behavior();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_qdeclarativesmoothedanimation::tst_qdeclarativesmoothedanimation()
-{
-}
-
-void tst_qdeclarativesmoothedanimation::defaultValues()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/smoothedanimation1.qml"));
- QDeclarative1SmoothedAnimation *obj = qobject_cast<QDeclarative1SmoothedAnimation*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->to(), 0.);
- QCOMPARE(obj->velocity(), 200.);
- QCOMPARE(obj->duration(), -1);
- QCOMPARE(obj->maximumEasingTime(), -1);
- QCOMPARE(obj->reversingMode(), QDeclarative1SmoothedAnimation::Eased);
-
- delete obj;
-}
-
-void tst_qdeclarativesmoothedanimation::values()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/smoothedanimation2.qml"));
- QDeclarative1SmoothedAnimation *obj = qobject_cast<QDeclarative1SmoothedAnimation*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->to(), 10.);
- QCOMPARE(obj->velocity(), 200.);
- QCOMPARE(obj->duration(), 300);
- QCOMPARE(obj->maximumEasingTime(), -1);
- QCOMPARE(obj->reversingMode(), QDeclarative1SmoothedAnimation::Immediate);
-
- delete obj;
-}
-
-void tst_qdeclarativesmoothedanimation::disabled()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/smoothedanimation3.qml"));
- QDeclarative1SmoothedAnimation *obj = qobject_cast<QDeclarative1SmoothedAnimation*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->to(), 10.);
- QCOMPARE(obj->velocity(), 250.);
- QCOMPARE(obj->maximumEasingTime(), 150);
- QCOMPARE(obj->reversingMode(), QDeclarative1SmoothedAnimation::Sync);
-
- delete obj;
-}
-
-void tst_qdeclarativesmoothedanimation::simpleAnimation()
-{
- QDeclarative1Rectangle rect;
- QDeclarative1SmoothedAnimation animation;
- animation.setTarget(&rect);
- animation.setProperty("x");
- animation.setTo(200);
- animation.setDuration(250);
- QVERIFY(animation.target() == &rect);
- QVERIFY(animation.property() == "x");
- QVERIFY(animation.to() == 200);
- animation.start();
- QVERIFY(animation.isRunning());
- QTest::qWait(animation.duration());
- QTRY_COMPARE(rect.x(), qreal(200));
-
- rect.setX(0);
- animation.start();
- animation.pause();
- QVERIFY(animation.isRunning());
- QVERIFY(animation.isPaused());
- animation.setCurrentTime(125);
- QVERIFY(animation.currentTime() == 125);
- QCOMPARE(rect.x(), qreal(100));
-}
-
-void tst_qdeclarativesmoothedanimation::valueSource()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/smoothedanimationValueSource.qml"));
-
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarative1Rectangle *theRect = rect->findChild<QDeclarative1Rectangle*>("theRect");
- QVERIFY(theRect);
-
- QDeclarative1SmoothedAnimation *easeX = rect->findChild<QDeclarative1SmoothedAnimation*>("easeX");
- QVERIFY(easeX);
- QVERIFY(easeX->isRunning());
-
- QDeclarative1SmoothedAnimation *easeY = rect->findChild<QDeclarative1SmoothedAnimation*>("easeY");
- QVERIFY(easeY);
- QVERIFY(easeY->isRunning());
-
- // XXX get the proper duration
- QTest::qWait(100);
-
- QTRY_VERIFY(!easeX->isRunning());
- QTRY_VERIFY(!easeY->isRunning());
-
- QTRY_COMPARE(theRect->x(), qreal(200));
- QTRY_COMPARE(theRect->y(), qreal(200));
-
- delete rect;
-}
-
-void tst_qdeclarativesmoothedanimation::behavior()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/smoothedanimationBehavior.qml"));
-
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarative1Rectangle *theRect = rect->findChild<QDeclarative1Rectangle*>("theRect");
- QVERIFY(theRect);
-
- QDeclarative1SmoothedAnimation *easeX = rect->findChild<QDeclarative1SmoothedAnimation*>("easeX");
- QVERIFY(easeX);
-
- QDeclarative1SmoothedAnimation *easeY = rect->findChild<QDeclarative1SmoothedAnimation*>("easeY");
- QVERIFY(easeY);
-
- // XXX get the proper duration
- QTest::qWait(400);
-
- QTRY_VERIFY(!easeX->isRunning());
- QTRY_VERIFY(!easeY->isRunning());
-
- QTRY_COMPARE(theRect->x(), qreal(200));
- QTRY_COMPARE(theRect->y(), qreal(200));
-
- delete rect;
-}
-
-QTEST_MAIN(tst_qdeclarativesmoothedanimation)
-
-#include "tst_qdeclarativesmoothedanimation.moc"
diff --git a/tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation1.qml b/tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation1.qml
deleted file mode 100644
index 8890a78fdb..0000000000
--- a/tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation1.qml
+++ /dev/null
@@ -1,4 +0,0 @@
-import QtQuick 1.0
-
-SpringAnimation {
-}
diff --git a/tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation2.qml b/tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation2.qml
deleted file mode 100644
index de75bb06cb..0000000000
--- a/tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation2.qml
+++ /dev/null
@@ -1,9 +0,0 @@
-import QtQuick 1.0
-
-SpringAnimation {
- to: 1.44; velocity: 0.9
- spring: 1.0; damping: 0.5
- epsilon: 0.25; modulus: 360.0
- mass: 2.0;
- running: true;
-}
diff --git a/tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation3.qml b/tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation3.qml
deleted file mode 100644
index b68d769f01..0000000000
--- a/tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation3.qml
+++ /dev/null
@@ -1,8 +0,0 @@
-import QtQuick 1.0
-
-SpringAnimation {
- to: 1.44; velocity: 0.9
- spring: 1.0; damping: 0.5
- epsilon: 0.25; modulus: 360.0
- mass: 2.0; running: false
-}
diff --git a/tests/auto/qtquick1/qdeclarativespringanimation/qdeclarativespringanimation.pro b/tests/auto/qtquick1/qdeclarativespringanimation/qdeclarativespringanimation.pro
deleted file mode 100644
index 14b5fb3ec0..0000000000
--- a/tests/auto/qtquick1/qdeclarativespringanimation/qdeclarativespringanimation.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativespringanimation
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativespringanimation.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
-QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib
diff --git a/tests/auto/qtquick1/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp b/tests/auto/qtquick1/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp
deleted file mode 100644
index 235ec68ada..0000000000
--- a/tests/auto/qtquick1/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick1/private/qdeclarativespringanimation_p.h>
-#include <private/qdeclarativevaluetype_p.h>
-
-class tst_qdeclarativespringanimation : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativespringanimation();
-
-private slots:
- void defaultValues();
- void values();
- void disabled();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_qdeclarativespringanimation::tst_qdeclarativespringanimation()
-{
-}
-
-void tst_qdeclarativespringanimation::defaultValues()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springanimation1.qml"));
- QDeclarative1SpringAnimation *obj = qobject_cast<QDeclarative1SpringAnimation*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->to(), 0.);
- QCOMPARE(obj->velocity(), 0.);
- QCOMPARE(obj->spring(), 0.);
- QCOMPARE(obj->damping(), 0.);
- QCOMPARE(obj->epsilon(), 0.01);
- QCOMPARE(obj->modulus(), 0.);
- QCOMPARE(obj->mass(), 1.);
- QCOMPARE(obj->isRunning(), false);
-
- delete obj;
-}
-
-void tst_qdeclarativespringanimation::values()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springanimation2.qml"));
- QDeclarative1SpringAnimation *obj = qobject_cast<QDeclarative1SpringAnimation*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->to(), 1.44);
- QCOMPARE(obj->velocity(), 0.9);
- QCOMPARE(obj->spring(), 1.0);
- QCOMPARE(obj->damping(), 0.5);
- QCOMPARE(obj->epsilon(), 0.25);
- QCOMPARE(obj->modulus(), 360.0);
- QCOMPARE(obj->mass(), 2.0);
- QCOMPARE(obj->isRunning(), true);
-
- QTRY_COMPARE(obj->isRunning(), false);
-
- delete obj;
-}
-
-void tst_qdeclarativespringanimation::disabled()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springanimation3.qml"));
- QDeclarative1SpringAnimation *obj = qobject_cast<QDeclarative1SpringAnimation*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->to(), 1.44);
- QCOMPARE(obj->velocity(), 0.9);
- QCOMPARE(obj->spring(), 1.0);
- QCOMPARE(obj->damping(), 0.5);
- QCOMPARE(obj->epsilon(), 0.25);
- QCOMPARE(obj->modulus(), 360.0);
- QCOMPARE(obj->mass(), 2.0);
- QCOMPARE(obj->isRunning(), false);
-
- delete obj;
-}
-
-QTEST_MAIN(tst_qdeclarativespringanimation)
-
-#include "tst_qdeclarativespringanimation.moc"
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/ExtendedRectangle.qml b/tests/auto/qtquick1/qdeclarativestates/data/ExtendedRectangle.qml
deleted file mode 100644
index d91f504455..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/ExtendedRectangle.qml
+++ /dev/null
@@ -1,19 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- id: extendedRect
- objectName: "extendedRect"
- property color extendedColor: "orange"
-
- width: 100; height: 100
- color: "red"
- states: State {
- name: "green"
- PropertyChanges {
- target: rect
- onDidSomething: {
- extendedRect.color = "green"
- extendedColor = "green"
- }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/Implementation/MyType.qml b/tests/auto/qtquick1/qdeclarativestates/data/Implementation/MyType.qml
deleted file mode 100644
index 6ad3b4a6ba..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/Implementation/MyType.qml
+++ /dev/null
@@ -1,32 +0,0 @@
-import QtQuick 1.0
-
-Item {
- Column {
- anchors.centerIn: parent
- Image { id: image1; objectName: "image1" }
- Image { id: image2; objectName: "image2" }
- Image { id: image3; objectName: "image3" }
- }
-
- states: State {
- name: "SetImageState"
- PropertyChanges {
- target: image1
- source: "images/qt-logo.png"
- }
- PropertyChanges {
- target: image2
- source: "images/" + "qt-logo.png"
- }
- PropertyChanges {
- target: image3
- source: "images/" + (true ? "qt-logo.png" : "")
- }
- }
-
- MouseArea {
- anchors.fill: parent
- onClicked: parent.state = "SetImageState"
- }
-
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/Implementation/images/qt-logo.png b/tests/auto/qtquick1/qdeclarativestates/data/Implementation/images/qt-logo.png
deleted file mode 100644
index 14ddf2a028..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/Implementation/images/qt-logo.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/QTBUG-14830.qml b/tests/auto/qtquick1/qdeclarativestates/data/QTBUG-14830.qml
deleted file mode 100644
index 7f9ddbfa2d..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/QTBUG-14830.qml
+++ /dev/null
@@ -1,29 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 1024
- height: 768
-
- Item {
- id: area
- objectName: "area"
- property int numx: 6
- property int cellwidth: 1024/numx
-
- onWidthChanged: {
- width = width>1024?1024:width;
- }
-
- state: 'minimal'
- states: [
- State {
- name: 'minimal'
- PropertyChanges {
- target: area
- width: cellwidth
- }
- }
- ]
-
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges1.qml b/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges1.qml
deleted file mode 100644
index fad27080fe..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges1.qml
+++ /dev/null
@@ -1,23 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: container
- width: 200; height: 200
- Rectangle {
- id: myRect
- objectName: "MyRect"
- width: 50; height: 50
- color: "green";
- anchors.left: parent.left
- anchors.leftMargin: 5
- }
- states: State {
- name: "right"
- AnchorChanges {
- id: ancCh
- target: myRect;
- anchors.left: undefined
- anchors.right: container.right
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges2.qml b/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges2.qml
deleted file mode 100644
index e1d4d66abd..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges2.qml
+++ /dev/null
@@ -1,21 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 200; height: 200
- Rectangle {
- id: myRect
- objectName: "MyRect"
- width: 50; height: 50
- color: "green";
- anchors.left: parent.left
- anchors.leftMargin: 5
- }
- states: State {
- name: "right"
- AnchorChanges {
- target: myRect;
- anchors.left: undefined
- anchors.right: parent.right
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges3.qml b/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges3.qml
deleted file mode 100644
index 116b844489..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges3.qml
+++ /dev/null
@@ -1,29 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: container
- width: 200; height: 200
- Rectangle {
- id: myRect
- objectName: "MyRect"
- color: "green";
- anchors.left: parent.left
- anchors.right: rightGuideline.left
- anchors.top: topGuideline.top
- anchors.bottom: container.bottom
- }
- Item { objectName: "LeftGuideline"; id: leftGuideline; x: 10 }
- Item { id: rightGuideline; x: 150 }
- Item { id: topGuideline; y: 10 }
- Item { objectName: "BottomGuideline"; id: bottomGuideline; y: 150 }
- states: State {
- name: "reanchored"
- AnchorChanges {
- target: myRect;
- anchors.left: leftGuideline.left
- anchors.right: container.right
- anchors.top: container.top
- anchors.bottom: bottomGuideline.bottom
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges4.qml b/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges4.qml
deleted file mode 100644
index eaff37345b..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges4.qml
+++ /dev/null
@@ -1,22 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 200; height: 200
- Rectangle {
- id: myRect
- objectName: "MyRect"
- color: "green";
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.verticalCenter: parent.verticalCenter
- }
- Item { objectName: "LeftGuideline"; id: leftGuideline; x: 10 }
- Item { objectName: "BottomGuideline"; id: bottomGuideline; y: 150 }
- states: State {
- name: "reanchored"
- AnchorChanges {
- target: myRect;
- anchors.horizontalCenter: bottomGuideline.horizontalCenter
- anchors.verticalCenter: leftGuideline.verticalCenter
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges5.qml b/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges5.qml
deleted file mode 100644
index ea7b251151..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges5.qml
+++ /dev/null
@@ -1,22 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 200; height: 200
- Rectangle {
- id: myRect
- objectName: "MyRect"
- color: "green";
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.baseline: parent.baseline
- }
- Item { objectName: "LeftGuideline"; id: leftGuideline; x: 10 }
- Item { objectName: "BottomGuideline"; id: bottomGuideline; y: 150 }
- states: State {
- name: "reanchored"
- AnchorChanges {
- target: myRect;
- anchors.horizontalCenter: bottomGuideline.horizontalCenter
- anchors.baseline: leftGuideline.baseline
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/anchorChangesCrash.qml b/tests/auto/qtquick1/qdeclarativestates/data/anchorChangesCrash.qml
deleted file mode 100644
index ca96da8855..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/anchorChangesCrash.qml
+++ /dev/null
@@ -1,14 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: container
- width: 400
- height: 400
-
- states: State {
- name: "reanchored"
- AnchorChanges {
- anchors.top: container.top
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/anchorRewindBug.qml b/tests/auto/qtquick1/qdeclarativestates/data/anchorRewindBug.qml
deleted file mode 100644
index 6277111e68..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/anchorRewindBug.qml
+++ /dev/null
@@ -1,37 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- id: container
- color: "red"
- height: 200
- width: 200
- Column {
- id: column
- objectName: "column"
- anchors.left: container.right
- anchors.bottom: container.bottom
-
- Rectangle {
- id: rectangle
- color: "blue"
- height: 100
- width: 200
- }
- Rectangle {
- color: "blue"
- height: 100
- width: 200
- }
- }
- states: State {
- name: "reanchored"
- AnchorChanges {
- target: column
- anchors.left: undefined
- anchors.right: container.right
- }
- PropertyChanges {
- target: rectangle
- opacity: 0
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/anchorRewindBug2.qml b/tests/auto/qtquick1/qdeclarativestates/data/anchorRewindBug2.qml
deleted file mode 100644
index d8b02e9b32..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/anchorRewindBug2.qml
+++ /dev/null
@@ -1,25 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: root
- width:200; height:300
-
- Rectangle {
- id: rectangle
- objectName: "mover"
- color: "green"
- width:50; height:50
- }
-
- states: [
- State {
- name: "anchored"
- AnchorChanges {
- target: rectangle
- anchors.left: root.left
- anchors.right: root.right
- anchors.bottom: root.bottom
- }
- }
- ]
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/attachedPropertyChanges.qml b/tests/auto/qtquick1/qdeclarativestates/data/attachedPropertyChanges.qml
deleted file mode 100644
index 2cad0504b2..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/attachedPropertyChanges.qml
+++ /dev/null
@@ -1,20 +0,0 @@
-import Qt.test 1.0
-import QtQuick 1.0
-
-Item {
- id: item
- width: 100; height: 100
- MyRectangle.foo: 0
-
- states: State {
- name: "foo1"
- PropertyChanges {
- target: item
- MyRectangle.foo: 1
- width: 50
- }
- }
-
- Component.onCompleted: item.state = "foo1"
-}
-
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml b/tests/auto/qtquick1/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml
deleted file mode 100644
index ccd126f6a7..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml
+++ /dev/null
@@ -1,18 +0,0 @@
-import QtQuick 1.0
-
-Item {
- id: root
- property int input: 1
- property int test: 9
-
- states: [
- State {
- name: "portrait"
- when: root.input == 1
- PropertyChanges {
- target: root
- test: 3
- }
- }
- ]
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/basicBinding.qml b/tests/auto/qtquick1/qdeclarativestates/data/basicBinding.qml
deleted file mode 100644
index 2060f03009..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/basicBinding.qml
+++ /dev/null
@@ -1,12 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- id: myRectangle
-
- property color sourceColor: "blue"
- width: 100; height: 100
- color: "red"
- states: State {
- name: "blue"
- PropertyChanges { target: myRectangle; color: sourceColor }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/basicBinding2.qml b/tests/auto/qtquick1/qdeclarativestates/data/basicBinding2.qml
deleted file mode 100644
index a329da33dd..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/basicBinding2.qml
+++ /dev/null
@@ -1,12 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- id: myRectangle
-
- property color sourceColor: "red"
- width: 100; height: 100
- color: sourceColor
- states: State {
- name: "blue"
- PropertyChanges { target: myRectangle; color: "blue" }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/basicBinding3.qml b/tests/auto/qtquick1/qdeclarativestates/data/basicBinding3.qml
deleted file mode 100644
index cb054d214d..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/basicBinding3.qml
+++ /dev/null
@@ -1,13 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- id: myRectangle
-
- property color sourceColor: "red"
- property color sourceColor2: "blue"
- width: 100; height: 100
- color: sourceColor
- states: State {
- name: "blue"
- PropertyChanges { target: myRectangle; color: sourceColor2 }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/basicBinding4.qml b/tests/auto/qtquick1/qdeclarativestates/data/basicBinding4.qml
deleted file mode 100644
index 7a740e570c..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/basicBinding4.qml
+++ /dev/null
@@ -1,17 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- id: myRectangle
-
- property color sourceColor: "blue"
- width: 100; height: 100
- color: "red"
- states: [
- State {
- name: "blue"
- PropertyChanges { target: myRectangle; color: sourceColor }
- },
- State {
- name: "green"
- PropertyChanges { target: myRectangle; color: "green" }
- }]
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/basicChanges.qml b/tests/auto/qtquick1/qdeclarativestates/data/basicChanges.qml
deleted file mode 100644
index 08ce7875f0..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/basicChanges.qml
+++ /dev/null
@@ -1,10 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- id: myRectangle
- width: 100; height: 100
- color: "red"
- states: State {
- name: "blue"
- PropertyChanges { target: myRectangle; color: "blue" }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/basicChanges2.qml b/tests/auto/qtquick1/qdeclarativestates/data/basicChanges2.qml
deleted file mode 100644
index ab97ba18b5..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/basicChanges2.qml
+++ /dev/null
@@ -1,15 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- id: myRectangle
- width: 100; height: 100
- color: "red"
- states: [
- State {
- name: "blue"
- PropertyChanges { target: myRectangle; color: "blue" }
- },
- State {
- name: "green"
- PropertyChanges { target: myRectangle; color: "green" }
- }]
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/basicChanges3.qml b/tests/auto/qtquick1/qdeclarativestates/data/basicChanges3.qml
deleted file mode 100644
index 73ac34d7ff..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/basicChanges3.qml
+++ /dev/null
@@ -1,15 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- id: myRectangle
- width: 100; height: 100
- color: "red"
- states: [
- State {
- name: "blue"
- PropertyChanges { target: myRectangle; color: "blue" }
- },
- State {
- name: "bordered"
- PropertyChanges { target: myRectangle; border.width: 2 }
- }]
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/basicChanges4.qml b/tests/auto/qtquick1/qdeclarativestates/data/basicChanges4.qml
deleted file mode 100644
index b5df922190..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/basicChanges4.qml
+++ /dev/null
@@ -1,19 +0,0 @@
-import Qt.test 1.0
-import QtQuick 1.0
-
-MyRectangle {
- id: rect
- width: 100; height: 100
- color: "red"
-
- states: State {
- name: "aBlueDay"
- PropertyChanges {
- target: rect
- onPropertyWithNotifyChanged: { rect.color = "blue"; }
- }
- }
-
- Component.onCompleted: rect.state = "aBlueDay"
-}
-
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/basicExtension.qml b/tests/auto/qtquick1/qdeclarativestates/data/basicExtension.qml
deleted file mode 100644
index 58c9fbe231..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/basicExtension.qml
+++ /dev/null
@@ -1,16 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- id: myRectangle
- width: 100; height: 100
- color: "red"
- states: [
- State {
- name: "blue"
- PropertyChanges { target: myRectangle; color: "blue" }
- },
- State {
- name: "bordered"
- extend: "blue"
- PropertyChanges { target: myRectangle; border.width: 2 }
- }]
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/deleting.qml b/tests/auto/qtquick1/qdeclarativestates/data/deleting.qml
deleted file mode 100644
index d1b3fd3a10..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/deleting.qml
+++ /dev/null
@@ -1,11 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- id: myRectangle
- width: 100; height: 100
- color: "red"
- states: State {
- name: "blue"
- PropertyChanges { target: myRectangle; color: "blue"; objectName: "pc1" }
- PropertyChanges { target: myRectangle; radius: 5; objectName: "pc2" }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/deletingState.qml b/tests/auto/qtquick1/qdeclarativestates/data/deletingState.qml
deleted file mode 100644
index 654e09cb2e..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/deletingState.qml
+++ /dev/null
@@ -1,13 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- id: myRectangle
- width: 100; height: 100
- color: "red"
- StateGroup {
- id: stateGroup
- states: State {
- name: "blue"
- PropertyChanges { target: myRectangle; color: "blue" }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/editProperties.qml b/tests/auto/qtquick1/qdeclarativestates/data/editProperties.qml
deleted file mode 100644
index 08d0209615..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/editProperties.qml
+++ /dev/null
@@ -1,34 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- id: myRectangle
-
- property color sourceColor: "blue"
- width: 400; height: 400
- color: "red"
-
- Rectangle {
- id: rect2
- objectName: "rect2"
- width: parent.width + 2
- height: 200
- color: "yellow"
- }
-
- states: [
- State {
- name: "blue"
- PropertyChanges {
- target: rect2
- width:50
- height: 40
- }
- },
- State {
- name: "green"
- PropertyChanges {
- target: rect2
- width: myRectangle.width / 2
- height: myRectangle.width / 4
- }
- }]
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/explicit.qml b/tests/auto/qtquick1/qdeclarativestates/data/explicit.qml
deleted file mode 100644
index 426731914f..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/explicit.qml
+++ /dev/null
@@ -1,15 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- id: myRectangle
- property color sourceColor: "blue"
- width: 100; height: 100
- color: "red"
- states: State {
- name: "blue"
- PropertyChanges {
- objectName: "changes"
- target: myRectangle; explicit: true
- color: sourceColor
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/extendsBug.qml b/tests/auto/qtquick1/qdeclarativestates/data/extendsBug.qml
deleted file mode 100644
index a4b77b122e..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/extendsBug.qml
+++ /dev/null
@@ -1,26 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 200
- height: 200
-
- Rectangle {
- id: rect
- objectName: "greenRect"
- width: 100
- height: 100
- color: "green"
- }
-
- states:[
- State {
- name: "a"
- PropertyChanges { target: rect; x: 100 }
- },
- State {
- name: "b"
- extend:"a"
- PropertyChanges { target: rect; y: 100 }
- }
- ]
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/fakeExtension.qml b/tests/auto/qtquick1/qdeclarativestates/data/fakeExtension.qml
deleted file mode 100644
index a98c96bedc..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/fakeExtension.qml
+++ /dev/null
@@ -1,16 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- id: myRectangle
- width: 100; height: 100
- color: "red"
- states: [
- State {
- name: "blue"
- PropertyChanges { target: myRectangle; color: "blue" }
- },
- State {
- name: "green"
- extend: "blue"
- PropertyChanges { target: myRectangle; color: "green" }
- }]
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/illegalObj.qml b/tests/auto/qtquick1/qdeclarativestates/data/illegalObj.qml
deleted file mode 100644
index e6444325a3..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/illegalObj.qml
+++ /dev/null
@@ -1,12 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: myItem
-
- states : State {
- PropertyChanges {
- target: myItem
- children: Item { id: newItem }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/illegalTempState.qml b/tests/auto/qtquick1/qdeclarativestates/data/illegalTempState.qml
deleted file mode 100644
index c04b03c94b..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/illegalTempState.qml
+++ /dev/null
@@ -1,21 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: card
- width: 100; height: 100
-
- states: [
- State {
- name: "placed"
- PropertyChanges { target: card; state: "idle" }
- },
- State {
- name: "idle"
- }
- ]
-
- MouseArea {
- anchors.fill: parent
- onClicked: card.state = "placed"
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/image.png b/tests/auto/qtquick1/qdeclarativestates/data/image.png
deleted file mode 100644
index ed1833c95b..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/image.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/legalTempState.qml b/tests/auto/qtquick1/qdeclarativestates/data/legalTempState.qml
deleted file mode 100644
index 4d500d9e05..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/legalTempState.qml
+++ /dev/null
@@ -1,23 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: card
- width: 100; height: 100
-
- states: [
- State {
- name: "placed"
- onCompleted: card.state = "idle"
- StateChangeScript { script: console.log("entering placed") }
- },
- State {
- name: "idle"
- StateChangeScript { script: console.log("entering idle") }
- }
- ]
-
- MouseArea {
- anchors.fill: parent
- onClicked: card.state = "placed"
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/nonExistantProp.qml b/tests/auto/qtquick1/qdeclarativestates/data/nonExistantProp.qml
deleted file mode 100644
index 4973b82c3f..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/nonExistantProp.qml
+++ /dev/null
@@ -1,11 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- id: myRectangle
-
- width: 100; height: 100
- color: "red"
- states: State {
- name: "blue"
- PropertyChanges { target: myRectangle; colr: "blue" }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/parentChange1.qml b/tests/auto/qtquick1/qdeclarativestates/data/parentChange1.qml
deleted file mode 100644
index 2f7e80eb08..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/parentChange1.qml
+++ /dev/null
@@ -1,37 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 400; height: 400
- Item {
- x: 10; y: 10
- Rectangle {
- id: myRect
- objectName: "MyRect"
- x: 5
- width: 100; height: 100
- color: "red"
- }
- }
- MouseArea {
- id: clickable
- anchors.fill: parent
- }
-
- Item {
- x: -100; y: -50
- Item {
- id: newParent
- objectName: "NewParent"
- x: 248; y: 360
- }
- }
-
- states: State {
- name: "reparented"
- when: clickable.pressed
- ParentChange {
- target: myRect
- parent: newParent
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/parentChange2.qml b/tests/auto/qtquick1/qdeclarativestates/data/parentChange2.qml
deleted file mode 100644
index bdd0c6c282..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/parentChange2.qml
+++ /dev/null
@@ -1,31 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: newParent
- width: 400; height: 400
- Item {
- scale: .5
- rotation: 15
- x: 10; y: 10
- Rectangle {
- id: myRect
- objectName: "MyRect"
- x: 5
- width: 100; height: 100
- color: "red"
- }
- }
- MouseArea {
- id: clickable
- anchors.fill: parent
- }
-
- states: State {
- name: "reparented"
- when: clickable.pressed
- ParentChange {
- target: myRect
- parent: newParent
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/parentChange3.qml b/tests/auto/qtquick1/qdeclarativestates/data/parentChange3.qml
deleted file mode 100644
index 55f3ead7c6..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/parentChange3.qml
+++ /dev/null
@@ -1,42 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 400; height: 400
- Item {
- scale: .5
- rotation: 15
- transformOrigin: "Center"
- x: 10; y: 10
- Rectangle {
- id: myRect
- objectName: "MyRect"
- x: 5
- width: 100; height: 100
- transformOrigin: "BottomLeft"
- color: "red"
- }
- }
- MouseArea {
- id: clickable
- anchors.fill: parent
- }
-
- Item {
- x: 200; y: 200
- rotation: 52;
- scale: 2
- Item {
- id: newParent
- x: 100; y: 100
- }
- }
-
- states: State {
- name: "reparented"
- when: clickable.pressed
- ParentChange {
- target: myRect
- parent: newParent
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/parentChange4.qml b/tests/auto/qtquick1/qdeclarativestates/data/parentChange4.qml
deleted file mode 100644
index ae05b05072..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/parentChange4.qml
+++ /dev/null
@@ -1,30 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 400; height: 400
- Rectangle {
- id: myRect
- objectName: "MyRect"
- x: 5; y: 5
- width: 100; height: 100
- color: "red"
- }
- MouseArea {
- id: clickable
- anchors.fill: parent
- }
-
- Item {
- id: newParent
- transform: Scale { xScale: .5; yScale: .7}
- }
-
- states: State {
- name: "reparented"
- when: clickable.pressed
- ParentChange {
- target: myRect
- parent: newParent
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/parentChange5.qml b/tests/auto/qtquick1/qdeclarativestates/data/parentChange5.qml
deleted file mode 100644
index 32a0b91cd9..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/parentChange5.qml
+++ /dev/null
@@ -1,30 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 400; height: 400
- Rectangle {
- id: myRect
- objectName: "MyRect"
- x: 5; y: 5
- width: 100; height: 100
- color: "red"
- }
- MouseArea {
- id: clickable
- anchors.fill: parent
- }
-
- Item {
- id: newParent
- transform: Rotation { angle: 30; axis { x: 0; y: 1; z: 0 } }
- }
-
- states: State {
- name: "reparented"
- when: clickable.pressed
- ParentChange {
- target: myRect
- parent: newParent
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/parentChange6.qml b/tests/auto/qtquick1/qdeclarativestates/data/parentChange6.qml
deleted file mode 100644
index 70ad894ffc..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/parentChange6.qml
+++ /dev/null
@@ -1,30 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 400; height: 400
- Rectangle {
- id: myRect
- objectName: "MyRect"
- x: 5; y: 5
- width: 100; height: 100
- color: "red"
- }
- MouseArea {
- id: clickable
- anchors.fill: parent
- }
-
- Item {
- id: newParent
- rotation: 180
- }
-
- states: State {
- name: "reparented"
- when: clickable.pressed
- ParentChange {
- target: myRect
- parent: newParent
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/propertyErrors.qml b/tests/auto/qtquick1/qdeclarativestates/data/propertyErrors.qml
deleted file mode 100644
index 3ab3c3252e..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/propertyErrors.qml
+++ /dev/null
@@ -1,10 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- id: myRectangle
- width: 100; height: 100
- color: "red"
- states: State {
- name: "blue"
- PropertyChanges { target: myRectangle; colr: "blue"; activeFocus: true }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/reset.qml b/tests/auto/qtquick1/qdeclarativestates/data/reset.qml
deleted file mode 100644
index a140ffab4d..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/reset.qml
+++ /dev/null
@@ -1,19 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 640
- height: 480
- Image {
- id: image
- width: 40
- source: "image.png"
- }
-
- states: State {
- name: "state1"
- PropertyChanges {
- target: image
- width: undefined
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/restoreEntryValues.qml b/tests/auto/qtquick1/qdeclarativestates/data/restoreEntryValues.qml
deleted file mode 100644
index dfd7c1794a..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/restoreEntryValues.qml
+++ /dev/null
@@ -1,14 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- id: myRectangle
- width: 100; height: 100
- color: "red"
- states: State {
- name: "blue"
- PropertyChanges {
- target: myRectangle
- restoreEntryValues: false
- color: "blue"
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/returnToBase.qml b/tests/auto/qtquick1/qdeclarativestates/data/returnToBase.qml
deleted file mode 100644
index a0d053cf03..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/returnToBase.qml
+++ /dev/null
@@ -1,21 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: theRect
- property bool triggerState: false
- property string stateString: ""
- states: [ State {
- when: triggerState
- PropertyChanges {
- target: theRect
- stateString: "inState"
- }
- },
- State {
- name: ""
- PropertyChanges {
- target: theRect
- stateString: "originalState"
- }
- }]
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/script.qml b/tests/auto/qtquick1/qdeclarativestates/data/script.qml
deleted file mode 100644
index 630aaf0ffa..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/script.qml
+++ /dev/null
@@ -1,10 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- id: myRectangle
- width: 100; height: 100
- color: "red"
- states: State {
- name: "blue"
- StateChangeScript { script: myRectangle.color = "blue"; }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/signalOverride.qml b/tests/auto/qtquick1/qdeclarativestates/data/signalOverride.qml
deleted file mode 100644
index 0eaf547644..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/signalOverride.qml
+++ /dev/null
@@ -1,18 +0,0 @@
-import QtQuick 1.0
-import Qt.test 1.0
-
-MyRectangle {
- id: rect
-
- onDidSomething: color = "blue"
-
- width: 100; height: 100
- color: "red"
- states: State {
- name: "green"
- PropertyChanges {
- target: rect
- onDidSomething: color = "green"
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/signalOverride2.qml b/tests/auto/qtquick1/qdeclarativestates/data/signalOverride2.qml
deleted file mode 100644
index ef26ff14e7..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/signalOverride2.qml
+++ /dev/null
@@ -1,9 +0,0 @@
-import QtQuick 1.0
-import Qt.test 1.0
-
-MyRectangle {
- id: rect
- onDidSomething: color = "blue"
- width: 100; height: 100
- ExtendedRectangle {}
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/signalOverrideCrash.qml b/tests/auto/qtquick1/qdeclarativestates/data/signalOverrideCrash.qml
deleted file mode 100644
index 8e9b698383..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/signalOverrideCrash.qml
+++ /dev/null
@@ -1,15 +0,0 @@
-import QtQuick 1.0
-import Qt.test 1.0
-
-MyRectangle {
- id: rect
-
- width: 100; height: 100
- states: State {
- name: "overridden"
- PropertyChanges {
- target: rect
- onDidSomething: rect.state = ""
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/signalOverrideCrash2.qml b/tests/auto/qtquick1/qdeclarativestates/data/signalOverrideCrash2.qml
deleted file mode 100644
index 74df9430c3..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/signalOverrideCrash2.qml
+++ /dev/null
@@ -1,24 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: myRect
- width: 400
- height: 400
-
- states: [
- State {
- name: "state1"
- PropertyChanges {
- target: myRect
- onHeightChanged: console.log("Hello World")
- color: "green"
- }
- },
- State {
- name: "state2"; extend: "state1"
- PropertyChanges {
- target: myRect
- color: "red"
- }
- }]
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/signalOverrideCrash3.qml b/tests/auto/qtquick1/qdeclarativestates/data/signalOverrideCrash3.qml
deleted file mode 100644
index ed1f22f39a..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/signalOverrideCrash3.qml
+++ /dev/null
@@ -1,27 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: myRect
- width: 400
- height: 400
-
- onHeightChanged: console.log("base state")
-
- states: [
- State {
- name: "state1"
- PropertyChanges {
- target: myRect
- onHeightChanged: console.log("state1")
- color: "green"
- }
- },
- State {
- name: "state2";
- PropertyChanges {
- target: myRect
- onHeightChanged: console.log("state2")
- color: "red"
- }
- }]
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/unnamedWhen.qml b/tests/auto/qtquick1/qdeclarativestates/data/unnamedWhen.qml
deleted file mode 100644
index 4425b4dd49..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/unnamedWhen.qml
+++ /dev/null
@@ -1,14 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: theRect
- property bool triggerState: false
- property string stateString: ""
- states: State {
- when: triggerState
- PropertyChanges {
- target: theRect
- stateString: "inState"
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/urlResolution.qml b/tests/auto/qtquick1/qdeclarativestates/data/urlResolution.qml
deleted file mode 100644
index 743f5404b0..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/urlResolution.qml
+++ /dev/null
@@ -1,12 +0,0 @@
-import QtQuick 1.0
-import "Implementation"
-
-Rectangle {
- width: 100
- height: 200
-
- MyType {
- objectName: "MyType"
- anchors.fill: parent
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/data/whenOrdering.qml b/tests/auto/qtquick1/qdeclarativestates/data/whenOrdering.qml
deleted file mode 100644
index 48aef5a6ce..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/data/whenOrdering.qml
+++ /dev/null
@@ -1,11 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- property bool condition1: false
- property bool condition2: false
-
- states: [
- State { name: "state1"; when: condition1 },
- State { name: "state2"; when: condition2 }
- ]
-}
diff --git a/tests/auto/qtquick1/qdeclarativestates/qdeclarativestates.pro b/tests/auto/qtquick1/qdeclarativestates/qdeclarativestates.pro
deleted file mode 100644
index 1c9a58647f..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/qdeclarativestates.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativestates
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativestates.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib
diff --git a/tests/auto/qtquick1/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/qtquick1/qdeclarativestates/tst_qdeclarativestates.cpp
deleted file mode 100644
index 2d5731bc8e..0000000000
--- a/tests/auto/qtquick1/qdeclarativestates/tst_qdeclarativestates.cpp
+++ /dev/null
@@ -1,1526 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick1/private/qdeclarativeanchors_p_p.h>
-#include <QtQuick1/private/qdeclarativerectangle_p.h>
-#include <QtQuick1/private/qdeclarativeimage_p.h>
-#include <QtQuick1/private/qdeclarativepropertychanges_p.h>
-#include <QtQuick1/private/qdeclarativestategroup_p.h>
-#include <QtQuick1/private/qdeclarativeitem_p.h>
-#include <private/qdeclarativeproperty_p.h>
-
-class MyAttached : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int foo READ foo WRITE setFoo)
-public:
- MyAttached(QObject *parent) : QObject(parent), m_foo(13) {}
-
- int foo() const { return m_foo; }
- void setFoo(int f) { m_foo = f; }
-
-private:
- int m_foo;
-};
-
-class MyRect : public QDeclarative1Rectangle
-{
- Q_OBJECT
- Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal)
-public:
- MyRect() {}
-
- void doSomething() { emit didSomething(); }
-
- int propertyWithNotify() const { return m_prop; }
- void setPropertyWithNotify(int i) { m_prop = i; emit oddlyNamedNotifySignal(); }
-
- static MyAttached *qmlAttachedProperties(QObject *o) {
- return new MyAttached(o);
- }
-Q_SIGNALS:
- void didSomething();
- void oddlyNamedNotifySignal();
-
-private:
- int m_prop;
-};
-
-QML_DECLARE_TYPE(MyRect)
-QML_DECLARE_TYPEINFO(MyRect, QML_HAS_ATTACHED_PROPERTIES)
-
-class tst_qdeclarativestates : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativestates() {}
-
-private:
- static QByteArray fullDataPath(const QString &path);
-
-private slots:
- void initTestCase();
-
- void basicChanges();
- void attachedPropertyChanges();
- void basicExtension();
- void basicBinding();
- void signalOverride();
- void signalOverrideCrash();
- void signalOverrideCrash2();
- void signalOverrideCrash3();
- void parentChange();
- void parentChangeErrors();
- void anchorChanges();
- void anchorChanges2();
- void anchorChanges3();
- void anchorChanges4();
- void anchorChanges5();
- void anchorChangesRTL();
- void anchorChangesRTL2();
- void anchorChangesRTL3();
- void anchorChangesCrash();
- void anchorRewindBug();
- void anchorRewindBug2();
- void script();
- void restoreEntryValues();
- void explicitChanges();
- void propertyErrors();
- void incorrectRestoreBug();
- void autoStateAtStartupRestoreBug();
- void deletingChange();
- void deletingState();
- void tempState();
- void illegalTempState();
- void nonExistantProperty();
- void reset();
- void illegalObjectCreation();
- void whenOrdering();
- void urlResolution();
- void unnamedWhen();
- void returnToBase();
- void extendsBug();
- void editProperties();
- void QTBUG_14830();
-};
-
-void tst_qdeclarativestates::initTestCase()
-{
- qmlRegisterType<MyRect>("Qt.test", 1, 0, "MyRectangle");
-}
-
-QByteArray tst_qdeclarativestates::fullDataPath(const QString &path)
-{
- return QUrl::fromLocalFile(SRCDIR + path).toString().toUtf8();
-}
-
-void tst_qdeclarativestates::basicChanges()
-{
- QDeclarativeEngine engine;
-
- {
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges2.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges3.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),1);
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),1);
-
- rectPrivate->setState("bordered");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),2);
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),1);
- //### we should be checking that this is an implicit rather than explicit 1 (which currently fails)
-
- rectPrivate->setState("bordered");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),2);
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),1);
-
- }
-
- {
- // Test basicChanges4.qml can magically connect to propertyWithNotify's notify
- // signal using 'onPropertyWithNotifyChanged' even though the signal name is
- // actually 'oddlyNamedNotifySignal'
-
- QDeclarativeComponent component(&engine, SRCDIR "/data/basicChanges4.qml");
- QVERIFY(component.isReady());
-
- MyRect *rect = qobject_cast<MyRect*>(component.create());
- QVERIFY(rect != 0);
-
- QMetaProperty prop = rect->metaObject()->property(rect->metaObject()->indexOfProperty("propertyWithNotify"));
- QVERIFY(prop.hasNotifySignal());
- QString notifySignal = QByteArray(prop.notifySignal().signature());
- QVERIFY(!notifySignal.startsWith("propertyWithNotifyChanged("));
-
- QCOMPARE(rect->color(), QColor(Qt::red));
-
- rect->setPropertyWithNotify(100);
- QCOMPARE(rect->color(), QColor(Qt::blue));
- }
-}
-
-void tst_qdeclarativestates::attachedPropertyChanges()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent component(&engine, SRCDIR "/data/attachedPropertyChanges.qml");
- QVERIFY(component.isReady());
-
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(item != 0);
- QCOMPARE(item->width(), 50.0);
-
- // Ensure attached property has been changed
- QObject *attObj = qmlAttachedPropertiesObject<MyRect>(item, false);
- QVERIFY(attObj);
-
- MyAttached *att = qobject_cast<MyAttached*>(attObj);
- QVERIFY(att);
-
- QCOMPARE(att->foo(), 1);
-}
-
-void tst_qdeclarativestates::basicExtension()
-{
- QDeclarativeEngine engine;
-
- {
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicExtension.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),1);
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),1);
-
- rectPrivate->setState("bordered");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),2);
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),1);
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),1);
-
- rectPrivate->setState("bordered");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),2);
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),1);
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/fakeExtension.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
- }
-}
-
-void tst_qdeclarativestates::basicBinding()
-{
- QDeclarativeEngine engine;
-
- {
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- rect->setProperty("sourceColor", QColor("green"));
- QCOMPARE(rect->color(),QColor("green"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- rect->setProperty("sourceColor", QColor("yellow"));
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("yellow"));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding2.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- rect->setProperty("sourceColor", QColor("green"));
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("green"));
- rect->setProperty("sourceColor", QColor("yellow"));
- QCOMPARE(rect->color(),QColor("yellow"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("yellow"));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding3.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
- rect->setProperty("sourceColor", QColor("green"));
- QCOMPARE(rect->color(),QColor("green"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- rect->setProperty("sourceColor", QColor("red"));
- QCOMPARE(rect->color(),QColor("blue"));
- rect->setProperty("sourceColor2", QColor("yellow"));
- QCOMPARE(rect->color(),QColor("yellow"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- rect->setProperty("sourceColor2", QColor("green"));
- QCOMPARE(rect->color(),QColor("red"));
- rect->setProperty("sourceColor", QColor("yellow"));
- QCOMPARE(rect->color(),QColor("yellow"));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding4.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- rect->setProperty("sourceColor", QColor("yellow"));
- QCOMPARE(rect->color(),QColor("yellow"));
-
- rectPrivate->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
- rect->setProperty("sourceColor", QColor("purple"));
- QCOMPARE(rect->color(),QColor("green"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("purple"));
-
- rectPrivate->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- }
-}
-
-void tst_qdeclarativestates::signalOverride()
-{
- QDeclarativeEngine engine;
-
- {
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/signalOverride.qml");
- MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
- rect->doSomething();
- QCOMPARE(rect->color(),QColor("blue"));
-
- QDeclarativeItemPrivate::get(rect)->setState("green");
- rect->doSomething();
- QCOMPARE(rect->color(),QColor("green"));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/signalOverride2.qml");
- MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("white"));
- rect->doSomething();
- QCOMPARE(rect->color(),QColor("blue"));
-
- QDeclarative1Rectangle *innerRect = qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("extendedRect"));
- QDeclarativeItemPrivate::get(innerRect)->setState("green");
- rect->doSomething();
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(innerRect->color(),QColor("green"));
- QCOMPARE(innerRect->property("extendedColor").value<QColor>(),QColor("green"));
- }
-}
-
-void tst_qdeclarativestates::signalOverrideCrash()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/signalOverrideCrash.qml");
- MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QDeclarativeItemPrivate::get(rect)->setState("overridden");
- rect->doSomething();
-}
-
-void tst_qdeclarativestates::signalOverrideCrash2()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/signalOverrideCrash2.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QDeclarativeItemPrivate::get(rect)->setState("state1");
- QDeclarativeItemPrivate::get(rect)->setState("state2");
- QDeclarativeItemPrivate::get(rect)->setState("state1");
-
- delete rect;
-}
-
-void tst_qdeclarativestates::signalOverrideCrash3()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/signalOverrideCrash3.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QDeclarativeItemPrivate::get(rect)->setState("state1");
- QDeclarativeItemPrivate::get(rect)->setState("");
- QDeclarativeItemPrivate::get(rect)->setState("state2");
- QDeclarativeItemPrivate::get(rect)->setState("");
-
- delete rect;
-}
-
-void tst_qdeclarativestates::parentChange()
-{
- QDeclarativeEngine engine;
-
- {
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange1.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QDeclarative1Rectangle *innerRect = qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QDeclarativeListReference list(rect, "states");
- QDeclarative1State *state = qobject_cast<QDeclarative1State*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QDeclarative1ParentChange *pChange = qobject_cast<QDeclarative1ParentChange*>(state->operationAt(0));
- QVERIFY(pChange != 0);
- QDeclarativeItem *nParent = qobject_cast<QDeclarativeItem*>(rect->findChild<QDeclarativeItem*>("NewParent"));
- QVERIFY(nParent != 0);
-
- QCOMPARE(pChange->parent(), nParent);
-
- QDeclarativeItemPrivate::get(rect)->setState("reparented");
- QCOMPARE(innerRect->rotation(), qreal(0));
- QCOMPARE(innerRect->scale(), qreal(1));
- QCOMPARE(innerRect->x(), qreal(-133));
- QCOMPARE(innerRect->y(), qreal(-300));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange2.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
- QDeclarative1Rectangle *innerRect = qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- rectPrivate->setState("reparented");
- QCOMPARE(innerRect->rotation(), qreal(15));
- QCOMPARE(innerRect->scale(), qreal(.5));
- QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(-19.9075));
- QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(-8.73433));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange3.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
- QDeclarative1Rectangle *innerRect = qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- rectPrivate->setState("reparented");
- QCOMPARE(innerRect->rotation(), qreal(-37));
- QCOMPARE(innerRect->scale(), qreal(.25));
- QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(-217.305));
- QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(-164.413));
-
- rectPrivate->setState("");
- QCOMPARE(innerRect->rotation(), qreal(0));
- QCOMPARE(innerRect->scale(), qreal(1));
- QCOMPARE(innerRect->x(), qreal(5));
- //do a non-qFuzzyCompare fuzzy compare
- QVERIFY(innerRect->y() < qreal(0.00001) && innerRect->y() > qreal(-0.00001));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange6.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QDeclarative1Rectangle *innerRect = qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QDeclarativeItemPrivate::get(rect)->setState("reparented");
- QCOMPARE(innerRect->rotation(), qreal(180));
- QCOMPARE(innerRect->scale(), qreal(1));
- QCOMPARE(innerRect->x(), qreal(-105));
- QCOMPARE(innerRect->y(), qreal(-105));
- }
-}
-
-void tst_qdeclarativestates::parentChangeErrors()
-{
- QDeclarativeEngine engine;
-
- {
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange4.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QDeclarative1Rectangle *innerRect = qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/parentChange4.qml") + ":25:9: QML ParentChange: Unable to preserve appearance under non-uniform scale");
- QDeclarativeItemPrivate::get(rect)->setState("reparented");
- QCOMPARE(innerRect->rotation(), qreal(0));
- QCOMPARE(innerRect->scale(), qreal(1));
- QCOMPARE(innerRect->x(), qreal(5));
- QCOMPARE(innerRect->y(), qreal(5));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange5.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QDeclarative1Rectangle *innerRect = qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/parentChange5.qml") + ":25:9: QML ParentChange: Unable to preserve appearance under complex transform");
- QDeclarativeItemPrivate::get(rect)->setState("reparented");
- QCOMPARE(innerRect->rotation(), qreal(0));
- QCOMPARE(innerRect->scale(), qreal(1));
- QCOMPARE(innerRect->x(), qreal(5));
- QCOMPARE(innerRect->y(), qreal(5));
- }
-}
-
-void tst_qdeclarativestates::anchorChanges()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges1.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
-
- QDeclarative1Rectangle *innerRect = qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QDeclarativeListReference list(rect, "states");
- QDeclarative1State *state = qobject_cast<QDeclarative1State*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QDeclarative1AnchorChanges *aChanges = qobject_cast<QDeclarative1AnchorChanges*>(state->operationAt(0));
- QVERIFY(aChanges != 0);
-
- rectPrivate->setState("right");
- QCOMPARE(innerRect->x(), qreal(150));
- QCOMPARE(aChanges->object(), qobject_cast<QDeclarativeItem*>(innerRect));
- QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QDeclarative1AnchorLine::Invalid); //### was reset (how do we distinguish from not set at all)
- QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item);
- QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine);
-
- rectPrivate->setState("");
- QCOMPARE(innerRect->x(), qreal(5));
-
- delete rect;
-}
-
-void tst_qdeclarativestates::anchorChanges2()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges2.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
-
- QDeclarative1Rectangle *innerRect = qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- rectPrivate->setState("right");
- QCOMPARE(innerRect->x(), qreal(150));
-
- rectPrivate->setState("");
- QCOMPARE(innerRect->x(), qreal(5));
-
- delete rect;
-}
-
-void tst_qdeclarativestates::anchorChanges3()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges3.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
-
- QDeclarative1Rectangle *innerRect = qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QDeclarativeItem *leftGuideline = qobject_cast<QDeclarativeItem*>(rect->findChild<QDeclarativeItem*>("LeftGuideline"));
- QVERIFY(leftGuideline != 0);
-
- QDeclarativeItem *bottomGuideline = qobject_cast<QDeclarativeItem*>(rect->findChild<QDeclarativeItem*>("BottomGuideline"));
- QVERIFY(bottomGuideline != 0);
-
- QDeclarativeListReference list(rect, "states");
- QDeclarative1State *state = qobject_cast<QDeclarative1State*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QDeclarative1AnchorChanges *aChanges = qobject_cast<QDeclarative1AnchorChanges*>(state->operationAt(0));
- QVERIFY(aChanges != 0);
-
- rectPrivate->setState("reanchored");
- QCOMPARE(aChanges->object(), qobject_cast<QDeclarativeItem*>(innerRect));
- QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().item, QDeclarativeItemPrivate::get(leftGuideline)->left().item);
- QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QDeclarativeItemPrivate::get(leftGuideline)->left().anchorLine);
- QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item);
- QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine);
- QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->top().item, rectPrivate->top().item);
- QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->top().anchorLine, rectPrivate->top().anchorLine);
- QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->bottom().item, QDeclarativeItemPrivate::get(bottomGuideline)->bottom().item);
- QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->bottom().anchorLine, QDeclarativeItemPrivate::get(bottomGuideline)->bottom().anchorLine);
-
- QCOMPARE(innerRect->x(), qreal(10));
- QCOMPARE(innerRect->y(), qreal(0));
- QCOMPARE(innerRect->width(), qreal(190));
- QCOMPARE(innerRect->height(), qreal(150));
-
- rectPrivate->setState("");
- QCOMPARE(innerRect->x(), qreal(0));
- QCOMPARE(innerRect->y(), qreal(10));
- QCOMPARE(innerRect->width(), qreal(150));
- QCOMPARE(innerRect->height(), qreal(190));
-
- delete rect;
-}
-
-void tst_qdeclarativestates::anchorChanges4()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges4.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QDeclarative1Rectangle *innerRect = qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QDeclarativeItem *leftGuideline = qobject_cast<QDeclarativeItem*>(rect->findChild<QDeclarativeItem*>("LeftGuideline"));
- QVERIFY(leftGuideline != 0);
-
- QDeclarativeItem *bottomGuideline = qobject_cast<QDeclarativeItem*>(rect->findChild<QDeclarativeItem*>("BottomGuideline"));
- QVERIFY(bottomGuideline != 0);
-
- QDeclarativeListReference list(rect, "states");
- QDeclarative1State *state = qobject_cast<QDeclarative1State*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QDeclarative1AnchorChanges *aChanges = qobject_cast<QDeclarative1AnchorChanges*>(state->operationAt(0));
- QVERIFY(aChanges != 0);
-
- QDeclarativeItemPrivate::get(rect)->setState("reanchored");
- QCOMPARE(aChanges->object(), qobject_cast<QDeclarativeItem*>(innerRect));
- QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().item, QDeclarativeItemPrivate::get(bottomGuideline)->horizontalCenter().item);
- QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().anchorLine, QDeclarativeItemPrivate::get(bottomGuideline)->horizontalCenter().anchorLine);
- QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->verticalCenter().item, QDeclarativeItemPrivate::get(leftGuideline)->verticalCenter().item);
- QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->verticalCenter().anchorLine, QDeclarativeItemPrivate::get(leftGuideline)->verticalCenter().anchorLine);
-
- delete rect;
-}
-
-void tst_qdeclarativestates::anchorChanges5()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges5.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QDeclarative1Rectangle *innerRect = qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QDeclarativeItem *leftGuideline = qobject_cast<QDeclarativeItem*>(rect->findChild<QDeclarativeItem*>("LeftGuideline"));
- QVERIFY(leftGuideline != 0);
-
- QDeclarativeItem *bottomGuideline = qobject_cast<QDeclarativeItem*>(rect->findChild<QDeclarativeItem*>("BottomGuideline"));
- QVERIFY(bottomGuideline != 0);
-
- QDeclarativeListReference list(rect, "states");
- QDeclarative1State *state = qobject_cast<QDeclarative1State*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QDeclarative1AnchorChanges *aChanges = qobject_cast<QDeclarative1AnchorChanges*>(state->operationAt(0));
- QVERIFY(aChanges != 0);
-
- QDeclarativeItemPrivate::get(rect)->setState("reanchored");
- QCOMPARE(aChanges->object(), qobject_cast<QDeclarativeItem*>(innerRect));
- //QCOMPARE(aChanges->anchors()->horizontalCenter().item, bottomGuideline->horizontalCenter().item);
- //QCOMPARE(aChanges->anchors()->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine);
- //QCOMPARE(aChanges->anchors()->baseline().item, leftGuideline->baseline().item);
- //QCOMPARE(aChanges->anchors()->baseline().anchorLine, leftGuideline->baseline().anchorLine);
-
- delete rect;
-}
-
-void mirrorAnchors(QDeclarativeItem *item) {
- QDeclarativeItemPrivate *itemPrivate = QDeclarativeItemPrivate::get(item);
- itemPrivate->setLayoutMirror(true);
-}
-
-qreal offsetRTL(QDeclarativeItem *anchorItem, QDeclarativeItem *item) {
- return anchorItem->width()+2*anchorItem->x()-item->width();
-}
-
-void tst_qdeclarativestates::anchorChangesRTL()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges1.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
-
- QDeclarative1Rectangle *innerRect = qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
- mirrorAnchors(innerRect);
-
- QDeclarativeListReference list(rect, "states");
- QDeclarative1State *state = qobject_cast<QDeclarative1State*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QDeclarative1AnchorChanges *aChanges = qobject_cast<QDeclarative1AnchorChanges*>(state->operationAt(0));
- QVERIFY(aChanges != 0);
-
- rectPrivate->setState("right");
- QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(150));
- QCOMPARE(aChanges->object(), qobject_cast<QDeclarativeItem*>(innerRect));
- QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QDeclarative1AnchorLine::Invalid); //### was reset (how do we distinguish from not set at all)
- QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item);
- QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine);
-
- rectPrivate->setState("");
- QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) -qreal(5));
-
- delete rect;
-}
-
-void tst_qdeclarativestates::anchorChangesRTL2()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges2.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
-
- QDeclarative1Rectangle *innerRect = qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
- mirrorAnchors(innerRect);
-
- rectPrivate->setState("right");
- QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(150));
-
- rectPrivate->setState("");
- QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(5));
-
- delete rect;
-}
-
-void tst_qdeclarativestates::anchorChangesRTL3()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges3.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
-
- QDeclarative1Rectangle *innerRect = qobject_cast<QDeclarative1Rectangle*>(rect->findChild<QDeclarative1Rectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
- mirrorAnchors(innerRect);
-
- QDeclarativeItem *leftGuideline = qobject_cast<QDeclarativeItem*>(rect->findChild<QDeclarativeItem*>("LeftGuideline"));
- QVERIFY(leftGuideline != 0);
-
- QDeclarativeItem *bottomGuideline = qobject_cast<QDeclarativeItem*>(rect->findChild<QDeclarativeItem*>("BottomGuideline"));
- QVERIFY(bottomGuideline != 0);
-
- QDeclarativeListReference list(rect, "states");
- QDeclarative1State *state = qobject_cast<QDeclarative1State*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QDeclarative1AnchorChanges *aChanges = qobject_cast<QDeclarative1AnchorChanges*>(state->operationAt(0));
- QVERIFY(aChanges != 0);
-
- rectPrivate->setState("reanchored");
- QCOMPARE(aChanges->object(), qobject_cast<QDeclarativeItem*>(innerRect));
- QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().item, QDeclarativeItemPrivate::get(leftGuideline)->left().item);
- QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QDeclarativeItemPrivate::get(leftGuideline)->left().anchorLine);
- QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item);
- QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine);
- QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->top().item, rectPrivate->top().item);
- QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->top().anchorLine, rectPrivate->top().anchorLine);
- QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->bottom().item, QDeclarativeItemPrivate::get(bottomGuideline)->bottom().item);
- QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->bottom().anchorLine, QDeclarativeItemPrivate::get(bottomGuideline)->bottom().anchorLine);
-
- QCOMPARE(innerRect->x(), offsetRTL(leftGuideline, innerRect) - qreal(10));
- QCOMPARE(innerRect->y(), qreal(0));
- // between left side of parent and leftGuideline.x: 10, which has width 0
- QCOMPARE(innerRect->width(), qreal(10));
- QCOMPARE(innerRect->height(), qreal(150));
-
- rectPrivate->setState("");
- QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(0));
- QCOMPARE(innerRect->y(), qreal(10));
- // between right side of parent and left side of rightGuideline.x: 150, which has width 0
- QCOMPARE(innerRect->width(), qreal(50));
- QCOMPARE(innerRect->height(), qreal(190));
-
- delete rect;
-}
-
-//QTBUG-9609
-void tst_qdeclarativestates::anchorChangesCrash()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChangesCrash.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QDeclarativeItemPrivate::get(rect)->setState("reanchored");
-
- delete rect;
-}
-
-// QTBUG-12273
-void tst_qdeclarativestates::anchorRewindBug()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorRewindBug.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QDeclarativeItem * column = rect->findChild<QDeclarativeItem*>("column");
-
- QVERIFY(column != 0);
- QVERIFY(!QDeclarativeItemPrivate::get(column)->heightValid);
- QVERIFY(!QDeclarativeItemPrivate::get(column)->widthValid);
- QCOMPARE(column->height(), 200.0);
- QDeclarativeItemPrivate::get(rect)->setState("reanchored");
-
- // column height and width should stay implicit
- // and column's implicit resizing should still work
- QVERIFY(!QDeclarativeItemPrivate::get(column)->heightValid);
- QVERIFY(!QDeclarativeItemPrivate::get(column)->widthValid);
- QCOMPARE(column->height(), 100.0);
-
- QDeclarativeItemPrivate::get(rect)->setState("");
-
- // column height and width should stay implicit
- // and column's implicit resizing should still work
- QVERIFY(!QDeclarativeItemPrivate::get(column)->heightValid);
- QVERIFY(!QDeclarativeItemPrivate::get(column)->widthValid);
- QCOMPARE(column->height(), 200.0);
-
- delete rect;
-}
-
-// QTBUG-11834
-void tst_qdeclarativestates::anchorRewindBug2()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorRewindBug2.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QDeclarative1Rectangle *mover = rect->findChild<QDeclarative1Rectangle*>("mover");
-
- QVERIFY(mover != 0);
- QCOMPARE(mover->y(), qreal(0.0));
- QCOMPARE(mover->width(), qreal(50.0));
-
- QDeclarativeItemPrivate::get(rect)->setState("anchored");
- QCOMPARE(mover->y(), qreal(250.0));
- QCOMPARE(mover->width(), qreal(200.0));
-
- QDeclarativeItemPrivate::get(rect)->setState("");
- QCOMPARE(mover->y(), qreal(0.0));
- QCOMPARE(mover->width(), qreal(50.0));
-
- delete rect;
-}
-
-void tst_qdeclarativestates::script()
-{
- QDeclarativeEngine engine;
-
- {
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/script.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("blue")); // a script isn't reverted
- }
-}
-
-void tst_qdeclarativestates::restoreEntryValues()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/restoreEntryValues.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("blue"));
-}
-
-void tst_qdeclarativestates::explicitChanges()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/explicit.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
- QDeclarativeListReference list(rect, "states");
- QDeclarative1State *state = qobject_cast<QDeclarative1State*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QDeclarative1PropertyChanges *changes = qobject_cast<QDeclarative1PropertyChanges*>(rect->findChild<QDeclarative1PropertyChanges*>("changes"));
- QVERIFY(changes != 0);
- QVERIFY(changes->isExplicit());
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setProperty("sourceColor", QColor("green"));
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- rect->setProperty("sourceColor", QColor("yellow"));
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("yellow"));
-}
-
-void tst_qdeclarativestates::propertyErrors()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/propertyErrors.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\"");
- QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to read-only property \"activeFocus\"");
- QDeclarativeItemPrivate::get(rect)->setState("blue");
-}
-
-void tst_qdeclarativestates::incorrectRestoreBug()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
-
- // make sure if we change the base state value, we then restore to it correctly
- rect->setColor(QColor("green"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("green"));
-}
-
-void tst_qdeclarativestates::autoStateAtStartupRestoreBug()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent component(&engine, SRCDIR "/data/autoStateAtStartupRestoreBug.qml");
- QObject *obj = component.create();
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->property("test").toInt(), 3);
-
- obj->setProperty("input", 2);
-
- QCOMPARE(obj->property("test").toInt(), 9);
-
- delete obj;
-}
-
-void tst_qdeclarativestates::deletingChange()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/deleting.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->radius(),qreal(5));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->radius(),qreal(0));
-
- QDeclarative1PropertyChanges *pc = rect->findChild<QDeclarative1PropertyChanges*>("pc1");
- QVERIFY(pc != 0);
- delete pc;
-
- QDeclarative1State *state = rect->findChild<QDeclarative1State*>();
- QVERIFY(state != 0);
- qmlExecuteDeferred(state);
- QCOMPARE(state->operationCount(), 1);
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->radius(),qreal(5));
-
- delete rect;
-}
-
-void tst_qdeclarativestates::deletingState()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/deletingState.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QDeclarative1StateGroup *sg = rect->findChild<QDeclarative1StateGroup*>();
- QVERIFY(sg != 0);
- QVERIFY(sg->findState("blue") != 0);
-
- sg->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- sg->setState("");
- QCOMPARE(rect->color(),QColor("red"));
-
- QDeclarative1State *state = rect->findChild<QDeclarative1State*>();
- QVERIFY(state != 0);
- delete state;
-
- QVERIFY(sg->findState("blue") == 0);
-
- //### should we warn that state doesn't exist
- sg->setState("blue");
- QCOMPARE(rect->color(),QColor("red"));
-
- delete rect;
-}
-
-void tst_qdeclarativestates::tempState()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/legalTempState.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
- QTest::ignoreMessage(QtDebugMsg, "entering placed");
- QTest::ignoreMessage(QtDebugMsg, "entering idle");
- rectPrivate->setState("placed");
- QCOMPARE(rectPrivate->state(), QLatin1String("idle"));
-}
-
-void tst_qdeclarativestates::illegalTempState()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/illegalTempState.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML StateGroup: Can't apply a state change as part of a state definition.");
- rectPrivate->setState("placed");
- QCOMPARE(rectPrivate->state(), QLatin1String("placed"));
-}
-
-void tst_qdeclarativestates::nonExistantProperty()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/nonExistantProp.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
- QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/nonExistantProp.qml") + ":9:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\"");
- rectPrivate->setState("blue");
- QCOMPARE(rectPrivate->state(), QLatin1String("blue"));
-}
-
-void tst_qdeclarativestates::reset()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, SRCDIR "/data/reset.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QDeclarative1Image *image = rect->findChild<QDeclarative1Image*>();
- QVERIFY(image != 0);
- QCOMPARE(image->width(), qreal(40.));
- QCOMPARE(image->height(), qreal(20.));
-
- QDeclarativeItemPrivate::get(rect)->setState("state1");
-
- QCOMPARE(image->width(), 20.0);
- QCOMPARE(image->height(), qreal(20.));
-}
-
-void tst_qdeclarativestates::illegalObjectCreation()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent component(&engine, SRCDIR "/data/illegalObj.qml");
- QList<QDeclarativeError> errors = component.errors();
- QVERIFY(errors.count() == 1);
- const QDeclarativeError &error = errors.at(0);
- QCOMPARE(error.line(), 9);
- QCOMPARE(error.column(), 23);
- QCOMPARE(error.description().toUtf8().constData(), "PropertyChanges does not support creating state-specific objects.");
-}
-
-void tst_qdeclarativestates::whenOrdering()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, SRCDIR "/data/whenOrdering.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect != 0);
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
-
- QCOMPARE(rectPrivate->state(), QLatin1String(""));
- rect->setProperty("condition2", true);
- QCOMPARE(rectPrivate->state(), QLatin1String("state2"));
- rect->setProperty("condition1", true);
- QCOMPARE(rectPrivate->state(), QLatin1String("state1"));
- rect->setProperty("condition2", false);
- QCOMPARE(rectPrivate->state(), QLatin1String("state1"));
- rect->setProperty("condition2", true);
- QCOMPARE(rectPrivate->state(), QLatin1String("state1"));
- rect->setProperty("condition1", false);
- rect->setProperty("condition2", false);
- QCOMPARE(rectPrivate->state(), QLatin1String(""));
-}
-
-void tst_qdeclarativestates::urlResolution()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, SRCDIR "/data/urlResolution.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QDeclarativeItem *myType = rect->findChild<QDeclarativeItem*>("MyType");
- QDeclarative1Image *image1 = rect->findChild<QDeclarative1Image*>("image1");
- QDeclarative1Image *image2 = rect->findChild<QDeclarative1Image*>("image2");
- QDeclarative1Image *image3 = rect->findChild<QDeclarative1Image*>("image3");
- QVERIFY(myType != 0 && image1 != 0 && image2 != 0 && image3 != 0);
-
- QDeclarativeItemPrivate::get(myType)->setState("SetImageState");
- QUrl resolved = QUrl::fromLocalFile(SRCDIR "/data/Implementation/images/qt-logo.png");
- QCOMPARE(image1->source(), resolved);
- QCOMPARE(image2->source(), resolved);
- QCOMPARE(image3->source(), resolved);
-}
-
-void tst_qdeclarativestates::unnamedWhen()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, SRCDIR "/data/unnamedWhen.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect != 0);
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
-
- QCOMPARE(rectPrivate->state(), QLatin1String(""));
- QCOMPARE(rect->property("stateString").toString(), QLatin1String(""));
- rect->setProperty("triggerState", true);
- QCOMPARE(rectPrivate->state(), QLatin1String("anonymousState1"));
- QCOMPARE(rect->property("stateString").toString(), QLatin1String("inState"));
- rect->setProperty("triggerState", false);
- QCOMPARE(rectPrivate->state(), QLatin1String(""));
- QCOMPARE(rect->property("stateString").toString(), QLatin1String(""));
-}
-
-void tst_qdeclarativestates::returnToBase()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, SRCDIR "/data/returnToBase.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect != 0);
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
-
- QCOMPARE(rectPrivate->state(), QLatin1String(""));
- QCOMPARE(rect->property("stateString").toString(), QLatin1String(""));
- rect->setProperty("triggerState", true);
- QCOMPARE(rectPrivate->state(), QLatin1String("anonymousState1"));
- QCOMPARE(rect->property("stateString").toString(), QLatin1String("inState"));
- rect->setProperty("triggerState", false);
- QCOMPARE(rectPrivate->state(), QLatin1String(""));
- QCOMPARE(rect->property("stateString").toString(), QLatin1String("originalState"));
-}
-
-//QTBUG-12559
-void tst_qdeclarativestates::extendsBug()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, SRCDIR "/data/extendsBug.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect != 0);
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
- QDeclarative1Rectangle *greenRect = rect->findChild<QDeclarative1Rectangle*>("greenRect");
-
- rectPrivate->setState("b");
- QCOMPARE(greenRect->x(), qreal(100));
- QCOMPARE(greenRect->y(), qreal(100));
-}
-
-void tst_qdeclarativestates::editProperties()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, SRCDIR "/data/editProperties.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
-
- QDeclarative1StateGroup *stateGroup = rectPrivate->_states();
- QVERIFY(stateGroup != 0);
- qmlExecuteDeferred(stateGroup);
-
- QDeclarative1State *blueState = stateGroup->findState("blue");
- QVERIFY(blueState != 0);
- qmlExecuteDeferred(blueState);
-
- QDeclarative1PropertyChanges *propertyChangesBlue = qobject_cast<QDeclarative1PropertyChanges*>(blueState->operationAt(0));
- QVERIFY(propertyChangesBlue != 0);
-
- QDeclarative1State *greenState = stateGroup->findState("green");
- QVERIFY(greenState != 0);
- qmlExecuteDeferred(greenState);
-
- QDeclarative1PropertyChanges *propertyChangesGreen = qobject_cast<QDeclarative1PropertyChanges*>(greenState->operationAt(0));
- QVERIFY(propertyChangesGreen != 0);
-
- QDeclarative1Rectangle *childRect = rect->findChild<QDeclarative1Rectangle*>("rect2");
- QVERIFY(childRect != 0);
- QCOMPARE(childRect->width(), qreal(402));
- QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
- QCOMPARE(childRect->height(), qreal(200));
-
- rectPrivate->setState("blue");
- QCOMPARE(childRect->width(), qreal(50));
- QCOMPARE(childRect->height(), qreal(40));
- QVERIFY(!QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
- QVERIFY(blueState->bindingInRevertList(childRect, "width"));
-
-
- rectPrivate->setState("green");
- QCOMPARE(childRect->width(), qreal(200));
- QCOMPARE(childRect->height(), qreal(100));
- QVERIFY(greenState->bindingInRevertList(childRect, "width"));
-
-
- rectPrivate->setState("");
-
-
- QCOMPARE(propertyChangesBlue->actions().length(), 2);
- QVERIFY(propertyChangesBlue->containsValue("width"));
- QVERIFY(!propertyChangesBlue->containsProperty("x"));
- QCOMPARE(propertyChangesBlue->value("width").toInt(), 50);
- QVERIFY(!propertyChangesBlue->value("x").isValid());
-
- propertyChangesBlue->changeValue("width", 60);
- QCOMPARE(propertyChangesBlue->value("width").toInt(), 60);
- QCOMPARE(propertyChangesBlue->actions().length(), 2);
-
-
- propertyChangesBlue->changeExpression("width", "myRectangle.width / 2");
- QVERIFY(!propertyChangesBlue->containsValue("width"));
- QVERIFY(propertyChangesBlue->containsExpression("width"));
- QCOMPARE(propertyChangesBlue->value("width").toInt(), 0);
- QCOMPARE(propertyChangesBlue->actions().length(), 2);
-
- propertyChangesBlue->changeValue("width", 50);
- QVERIFY(propertyChangesBlue->containsValue("width"));
- QVERIFY(!propertyChangesBlue->containsExpression("width"));
- QCOMPARE(propertyChangesBlue->value("width").toInt(), 50);
- QCOMPARE(propertyChangesBlue->actions().length(), 2);
-
- QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
- rectPrivate->setState("blue");
- QCOMPARE(childRect->width(), qreal(50));
- QCOMPARE(childRect->height(), qreal(40));
-
- propertyChangesBlue->changeValue("width", 60);
- QCOMPARE(propertyChangesBlue->value("width").toInt(), 60);
- QCOMPARE(propertyChangesBlue->actions().length(), 2);
- QCOMPARE(childRect->width(), qreal(60));
- QVERIFY(!QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
-
- propertyChangesBlue->changeExpression("width", "myRectangle.width / 2");
- QVERIFY(!propertyChangesBlue->containsValue("width"));
- QVERIFY(propertyChangesBlue->containsExpression("width"));
- QCOMPARE(propertyChangesBlue->value("width").toInt(), 0);
- QCOMPARE(propertyChangesBlue->actions().length(), 2);
- QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
- QCOMPARE(childRect->width(), qreal(200));
-
- propertyChangesBlue->changeValue("width", 50);
- QCOMPARE(childRect->width(), qreal(50));
-
- rectPrivate->setState("");
- QCOMPARE(childRect->width(), qreal(402));
- QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
-
- QCOMPARE(propertyChangesGreen->actions().length(), 2);
- rectPrivate->setState("green");
- QCOMPARE(childRect->width(), qreal(200));
- QCOMPARE(childRect->height(), qreal(100));
- QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
- QVERIFY(greenState->bindingInRevertList(childRect, "width"));
- QCOMPARE(propertyChangesGreen->actions().length(), 2);
-
-
- propertyChangesGreen->removeProperty("height");
- QVERIFY(!QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "height")));
- QCOMPARE(childRect->height(), qreal(200));
-
- QVERIFY(greenState->bindingInRevertList(childRect, "width"));
- QVERIFY(greenState->containsPropertyInRevertList(childRect, "width"));
- propertyChangesGreen->removeProperty("width");
- QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width")));
- QCOMPARE(childRect->width(), qreal(402));
- QVERIFY(!greenState->bindingInRevertList(childRect, "width"));
- QVERIFY(!greenState->containsPropertyInRevertList(childRect, "width"));
-
- propertyChangesBlue->removeProperty("width");
- QCOMPARE(childRect->width(), qreal(402));
-
- rectPrivate->setState("blue");
- QCOMPARE(childRect->width(), qreal(402));
- QCOMPARE(childRect->height(), qreal(40));
-}
-
-void tst_qdeclarativestates::QTBUG_14830()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, SRCDIR "/data/QTBUG-14830.qml");
- QDeclarative1Rectangle *rect = qobject_cast<QDeclarative1Rectangle*>(c.create());
- QVERIFY(rect != 0);
- QDeclarativeItem *item = rect->findChild<QDeclarativeItem*>("area");
-
- QCOMPARE(item->width(), qreal(171));
-}
-
-QTEST_MAIN(tst_qdeclarativestates)
-
-#include "tst_qdeclarativestates.moc"
diff --git a/tests/auto/qtquick1/qdeclarativesystempalette/qdeclarativesystempalette.pro b/tests/auto/qtquick1/qdeclarativesystempalette/qdeclarativesystempalette.pro
deleted file mode 100644
index 3efa477a33..0000000000
--- a/tests/auto/qtquick1/qdeclarativesystempalette/qdeclarativesystempalette.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativesystempalette
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativesystempalette.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
-QT += core-private gui-private widgets-private declarative-private qtquick1-private testlib
diff --git a/tests/auto/qtquick1/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp b/tests/auto/qtquick1/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp
deleted file mode 100644
index 64c13fd48a..0000000000
--- a/tests/auto/qtquick1/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDebug>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick1/private/qdeclarativesystempalette_p.h>
-#include <qpalette.h>
-
-class tst_qdeclarativesystempalette : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativesystempalette();
-
-private slots:
- void activePalette();
- void inactivePalette();
- void disabledPalette();
- void paletteChanged();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_qdeclarativesystempalette::tst_qdeclarativesystempalette()
-{
-}
-
-void tst_qdeclarativesystempalette::activePalette()
-{
- QString componentStr = "import QtQuick 1.0\nSystemPalette { }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1SystemPalette *object = qobject_cast<QDeclarative1SystemPalette*>(component.create());
-
- QVERIFY(object != 0);
-
- QPalette palette;
- palette.setCurrentColorGroup(QPalette::Active);
- QCOMPARE(palette.window().color(), object->window());
- QCOMPARE(palette.windowText().color(), object->windowText());
- QCOMPARE(palette.base().color(), object->base());
- QCOMPARE(palette.text().color(), object->text());
- QCOMPARE(palette.alternateBase().color(), object->alternateBase());
- QCOMPARE(palette.button().color(), object->button());
- QCOMPARE(palette.buttonText().color(), object->buttonText());
- QCOMPARE(palette.light().color(), object->light());
- QCOMPARE(palette.midlight().color(), object->midlight());
- QCOMPARE(palette.dark().color(), object->dark());
- QCOMPARE(palette.mid().color(), object->mid());
- QCOMPARE(palette.shadow().color(), object->shadow());
- QCOMPARE(palette.highlight().color(), object->highlight());
- QCOMPARE(palette.highlightedText().color(), object->highlightedText());
-
- delete object;
-}
-
-void tst_qdeclarativesystempalette::inactivePalette()
-{
- QString componentStr = "import QtQuick 1.0\nSystemPalette { colorGroup: SystemPalette.Inactive }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1SystemPalette *object = qobject_cast<QDeclarative1SystemPalette*>(component.create());
-
- QVERIFY(object != 0);
- QVERIFY(object->colorGroup() == QDeclarative1SystemPalette::Inactive);
-
- QPalette palette;
- palette.setCurrentColorGroup(QPalette::Inactive);
- QCOMPARE(palette.window().color(), object->window());
- QCOMPARE(palette.windowText().color(), object->windowText());
- QCOMPARE(palette.base().color(), object->base());
- QCOMPARE(palette.text().color(), object->text());
- QCOMPARE(palette.alternateBase().color(), object->alternateBase());
- QCOMPARE(palette.button().color(), object->button());
- QCOMPARE(palette.buttonText().color(), object->buttonText());
- QCOMPARE(palette.light().color(), object->light());
- QCOMPARE(palette.midlight().color(), object->midlight());
- QCOMPARE(palette.dark().color(), object->dark());
- QCOMPARE(palette.mid().color(), object->mid());
- QCOMPARE(palette.shadow().color(), object->shadow());
- QCOMPARE(palette.highlight().color(), object->highlight());
- QCOMPARE(palette.highlightedText().color(), object->highlightedText());
-
- delete object;
-}
-
-void tst_qdeclarativesystempalette::disabledPalette()
-{
- QString componentStr = "import QtQuick 1.0\nSystemPalette { colorGroup: SystemPalette.Disabled }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1SystemPalette *object = qobject_cast<QDeclarative1SystemPalette*>(component.create());
-
- QVERIFY(object != 0);
- QVERIFY(object->colorGroup() == QDeclarative1SystemPalette::Disabled);
-
- QPalette palette;
- palette.setCurrentColorGroup(QPalette::Disabled);
- QCOMPARE(palette.window().color(), object->window());
- QCOMPARE(palette.windowText().color(), object->windowText());
- QCOMPARE(palette.base().color(), object->base());
- QCOMPARE(palette.text().color(), object->text());
- QCOMPARE(palette.alternateBase().color(), object->alternateBase());
- QCOMPARE(palette.button().color(), object->button());
- QCOMPARE(palette.buttonText().color(), object->buttonText());
- QCOMPARE(palette.light().color(), object->light());
- QCOMPARE(palette.midlight().color(), object->midlight());
- QCOMPARE(palette.dark().color(), object->dark());
- QCOMPARE(palette.mid().color(), object->mid());
- QCOMPARE(palette.shadow().color(), object->shadow());
- QCOMPARE(palette.highlight().color(), object->highlight());
- QCOMPARE(palette.highlightedText().color(), object->highlightedText());
-
- delete object;
-}
-
-void tst_qdeclarativesystempalette::paletteChanged()
-{
- QString componentStr = "import QtQuick 1.0\nSystemPalette { }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1SystemPalette *object = qobject_cast<QDeclarative1SystemPalette*>(component.create());
-
- QVERIFY(object != 0);
-
- QPalette p;
- p.setCurrentColorGroup(QPalette::Active);
- p.setColor(QPalette::Active, QPalette::Text, QColor("red"));
- p.setColor(QPalette::Active, QPalette::ButtonText, QColor("green"));
- p.setColor(QPalette::Active, QPalette::WindowText, QColor("blue"));
-
- qApp->setPalette(p);
-
- object->setColorGroup(QDeclarative1SystemPalette::Active);
- QTRY_COMPARE(QColor("red"), object->text());
- QTRY_COMPARE(QColor("green"), object->buttonText());
- QTRY_COMPARE(QColor("blue"), object->windowText());
-
- delete object;
-}
-
-QTEST_MAIN(tst_qdeclarativesystempalette)
-
-#include "tst_qdeclarativesystempalette.moc"
diff --git a/tests/auto/qtquick1/qdeclarativetext/data/alignments.qml b/tests/auto/qtquick1/qdeclarativetext/data/alignments.qml
deleted file mode 100644
index 25105f6789..0000000000
--- a/tests/auto/qtquick1/qdeclarativetext/data/alignments.qml
+++ /dev/null
@@ -1,41 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: top
- width: 70; height: 70;
-
- property alias horizontalAlignment: t.horizontalAlignment
- property alias verticalAlignment: t.verticalAlignment
- property alias wrapMode: t.wrapMode
- property alias running: timer.running
- property string txt: "Test"
-
- Rectangle {
- anchors.centerIn: parent
- width: 40
- height: 40
- color: "green"
-
- Text {
- id: t
-
- anchors.fill: parent
- horizontalAlignment: Text.AlignRight
- verticalAlignment: Text.AlignBottom
- wrapMode: Text.WordWrap
- text: top.txt
- }
- Timer {
- id: timer
-
- interval: 1
- running: true
- repeat: true
- onTriggered: {
- top.txt = top.txt + "<br>more " + top.txt.length;
- if (top.txt.length > 50)
- running = false
- }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativetext/data/alignments_cb.png b/tests/auto/qtquick1/qdeclarativetext/data/alignments_cb.png
deleted file mode 100644
index cf6199a418..0000000000
--- a/tests/auto/qtquick1/qdeclarativetext/data/alignments_cb.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativetext/data/alignments_cc.png b/tests/auto/qtquick1/qdeclarativetext/data/alignments_cc.png
deleted file mode 100644
index f81ccb4238..0000000000
--- a/tests/auto/qtquick1/qdeclarativetext/data/alignments_cc.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativetext/data/alignments_ct.png b/tests/auto/qtquick1/qdeclarativetext/data/alignments_ct.png
deleted file mode 100644
index 9ba64125d5..0000000000
--- a/tests/auto/qtquick1/qdeclarativetext/data/alignments_ct.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativetext/data/alignments_lb.png b/tests/auto/qtquick1/qdeclarativetext/data/alignments_lb.png
deleted file mode 100644
index 1b50a81f3d..0000000000
--- a/tests/auto/qtquick1/qdeclarativetext/data/alignments_lb.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativetext/data/alignments_lc.png b/tests/auto/qtquick1/qdeclarativetext/data/alignments_lc.png
deleted file mode 100644
index f041b868f8..0000000000
--- a/tests/auto/qtquick1/qdeclarativetext/data/alignments_lc.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativetext/data/alignments_lt.png b/tests/auto/qtquick1/qdeclarativetext/data/alignments_lt.png
deleted file mode 100644
index c75e0d158e..0000000000
--- a/tests/auto/qtquick1/qdeclarativetext/data/alignments_lt.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativetext/data/alignments_rb.png b/tests/auto/qtquick1/qdeclarativetext/data/alignments_rb.png
deleted file mode 100644
index b06a5da715..0000000000
--- a/tests/auto/qtquick1/qdeclarativetext/data/alignments_rb.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativetext/data/alignments_rc.png b/tests/auto/qtquick1/qdeclarativetext/data/alignments_rc.png
deleted file mode 100644
index e468857cd0..0000000000
--- a/tests/auto/qtquick1/qdeclarativetext/data/alignments_rc.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativetext/data/alignments_rt.png b/tests/auto/qtquick1/qdeclarativetext/data/alignments_rt.png
deleted file mode 100644
index 576715ffce..0000000000
--- a/tests/auto/qtquick1/qdeclarativetext/data/alignments_rt.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativetext/data/elideimplicitwidth.qml b/tests/auto/qtquick1/qdeclarativetext/data/elideimplicitwidth.qml
deleted file mode 100644
index 60ae15c4e1..0000000000
--- a/tests/auto/qtquick1/qdeclarativetext/data/elideimplicitwidth.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import QtQuick 1.1
-
-Text {
- text: "Hello World"
- elide: Text.ElideRight
- width: 30
-}
diff --git a/tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesLocal.qml b/tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesLocal.qml
deleted file mode 100644
index ee9b95a2a7..0000000000
--- a/tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesLocal.qml
+++ /dev/null
@@ -1,5 +0,0 @@
-import QtQuick 1.0
-
-Text {
- text: "<img src='http/exists.png'>"
-}
diff --git a/tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesLocalError.qml b/tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesLocalError.qml
deleted file mode 100644
index 4dc0d3e16f..0000000000
--- a/tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesLocalError.qml
+++ /dev/null
@@ -1,5 +0,0 @@
-import QtQuick 1.0
-
-Text {
- text: "<img src='http/notexists.png'>"
-}
diff --git a/tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesRemote.qml b/tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesRemote.qml
deleted file mode 100644
index 438f4a06d3..0000000000
--- a/tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesRemote.qml
+++ /dev/null
@@ -1,5 +0,0 @@
-import QtQuick 1.0
-
-Text {
- text: "<img src='http://127.0.0.1:14453/exists.png'>"
-}
diff --git a/tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesRemoteError.qml b/tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesRemoteError.qml
deleted file mode 100644
index c24bf24f9c..0000000000
--- a/tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesRemoteError.qml
+++ /dev/null
@@ -1,5 +0,0 @@
-import QtQuick 1.0
-
-Text {
- text: "<img src='http://127.0.0.1:14453/notexists.png'>"
-}
diff --git a/tests/auto/qtquick1/qdeclarativetext/data/horizontalAlignment_RightToLeft.qml b/tests/auto/qtquick1/qdeclarativetext/data/horizontalAlignment_RightToLeft.qml
deleted file mode 100644
index 4f58944672..0000000000
--- a/tests/auto/qtquick1/qdeclarativetext/data/horizontalAlignment_RightToLeft.qml
+++ /dev/null
@@ -1,23 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: top
- width: 200; height: 70;
-
- property alias horizontalAlignment: text.horizontalAlignment
- property string text: "اختبا"
-
- Rectangle {
- anchors.centerIn: parent
- width: 180
- height: 20
- color: "green"
-
- Text {
- id: text
- objectName: "text"
- anchors.fill: parent
- text: top.text
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativetext/data/http/exists.png b/tests/auto/qtquick1/qdeclarativetext/data/http/exists.png
deleted file mode 100644
index 399bd0b1d9..0000000000
--- a/tests/auto/qtquick1/qdeclarativetext/data/http/exists.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativetext/data/lineCount.qml b/tests/auto/qtquick1/qdeclarativetext/data/lineCount.qml
deleted file mode 100644
index 63817f6f2a..0000000000
--- a/tests/auto/qtquick1/qdeclarativetext/data/lineCount.qml
+++ /dev/null
@@ -1,15 +0,0 @@
-import QtQuick 1.1
-
-Item {
- width: 200
- height: 200
-
- Text {
- id: myText
- objectName: "myText"
- width: 200
- wrapMode: Text.WordWrap
- maximumLineCount: undefined
- text: "Testing that maximumLines, visibleLines, and totalLines works properly in the autotests. The quick brown fox jumped over the lazy anything with the letter 'g'."
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativetext/data/lineHeight.qml b/tests/auto/qtquick1/qdeclarativetext/data/lineHeight.qml
deleted file mode 100644
index 851d871192..0000000000
--- a/tests/auto/qtquick1/qdeclarativetext/data/lineHeight.qml
+++ /dev/null
@@ -1,15 +0,0 @@
-import QtQuick 1.1
-
-Item {
- width: 200
- height: 200
-
- Text {
- id: myText
- objectName: "myText"
- width: 200
- wrapMode: Text.WordWrap
- font.pixelSize: 13
- text: "Lorem ipsum sit amet, consectetur adipiscing elit. Integer felis nisl, varius in pretium nec, venenatis non erat. Proin lobortis interdum dictum."
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativetext/data/qtbug_14734.qml b/tests/auto/qtquick1/qdeclarativetext/data/qtbug_14734.qml
deleted file mode 100644
index bd07d66727..0000000000
--- a/tests/auto/qtquick1/qdeclarativetext/data/qtbug_14734.qml
+++ /dev/null
@@ -1,10 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width: 640
- height: 480
-
- Text {
- text: "í "
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativetext/data/rotated.qml b/tests/auto/qtquick1/qdeclarativetext/data/rotated.qml
deleted file mode 100644
index 1e893b93fc..0000000000
--- a/tests/auto/qtquick1/qdeclarativetext/data/rotated.qml
+++ /dev/null
@@ -1,18 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- width : 200
- height : 100
-
- Text {
- objectName: "text"
- x: 20
- y: 20
- height : 20
- width : 80
- text : "Something"
- rotation : 30
- transformOrigin : Item.TopLeft
- }
-}
-
diff --git a/tests/auto/qtquick1/qdeclarativetext/qdeclarativetext.pro b/tests/auto/qtquick1/qdeclarativetext/qdeclarativetext.pro
deleted file mode 100644
index 1957bdd9fd..0000000000
--- a/tests/auto/qtquick1/qdeclarativetext/qdeclarativetext.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativetext
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativetext.cpp
-
-INCLUDEPATH += ../../shared/
-HEADERS += ../../shared/testhttpserver.h
-SOURCES += ../../shared/testhttpserver.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
-QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private network testlib
diff --git a/tests/auto/qtquick1/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/qtquick1/qdeclarativetext/tst_qdeclarativetext.cpp
deleted file mode 100644
index 2145d77d6e..0000000000
--- a/tests/auto/qtquick1/qdeclarativetext/tst_qdeclarativetext.cpp
+++ /dev/null
@@ -1,1444 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QTextDocument>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick1/private/qdeclarativetext_p.h>
-#include <QtQuick1/private/qdeclarativetext_p_p.h>
-#include <private/qdeclarativevaluetype_p.h>
-#include <QFontMetrics>
-#include <QGraphicsSceneMouseEvent>
-#include <qmath.h>
-#include <QtQuick1/QDeclarativeView>
-#include <private/qapplication_p.h>
-#include <limits.h>
-
-#include "testhttpserver.h"
-
-class tst_qdeclarativetext : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativetext();
-
-private slots:
- void text();
- void width();
- void wrap();
- void elide();
- void textFormat();
-
- void alignments_data();
- void alignments();
-
- void embeddedImages_data();
- void embeddedImages();
-
- void lineCount();
- void lineHeight();
-
- // ### these tests may be trivial
- void horizontalAlignment();
- void horizontalAlignment_RightToLeft();
- void verticalAlignment();
- void font();
- void style();
- void color();
- void smooth();
-
- // QDeclarativeFontValueType
- void weight();
- void underline();
- void overline();
- void strikeout();
- void capitalization();
- void letterSpacing();
- void wordSpacing();
-
- void clickLink();
-
- void QTBUG_12291();
- void implicitSize_data();
- void implicitSize();
- void testQtQuick11Attributes();
- void testQtQuick11Attributes_data();
-
- void qtbug_14734();
-private:
- QStringList standard;
- QStringList richText;
-
- QStringList horizontalAlignmentmentStrings;
- QStringList verticalAlignmentmentStrings;
-
- QList<Qt::Alignment> verticalAlignmentments;
- QList<Qt::Alignment> horizontalAlignmentments;
-
- QStringList styleStrings;
- QList<QDeclarative1Text::TextStyle> styles;
-
- QStringList colorStrings;
-
- QDeclarativeEngine engine;
-
- QDeclarativeView *createView(const QString &filename);
-};
-
-tst_qdeclarativetext::tst_qdeclarativetext()
-{
- standard << "the quick brown fox jumped over the lazy dog"
- << "the quick brown fox\n jumped over the lazy dog";
-
- richText << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a> jumped over the <b>lazy</b> dog</i>"
- << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a><br>jumped over the <b>lazy</b> dog</i>";
-
- horizontalAlignmentmentStrings << "AlignLeft"
- << "AlignRight"
- << "AlignHCenter";
-
- verticalAlignmentmentStrings << "AlignTop"
- << "AlignBottom"
- << "AlignVCenter";
-
- horizontalAlignmentments << Qt::AlignLeft
- << Qt::AlignRight
- << Qt::AlignHCenter;
-
- verticalAlignmentments << Qt::AlignTop
- << Qt::AlignBottom
- << Qt::AlignVCenter;
-
- styleStrings << "Normal"
- << "Outline"
- << "Raised"
- << "Sunken";
-
- styles << QDeclarative1Text::Normal
- << QDeclarative1Text::Outline
- << QDeclarative1Text::Raised
- << QDeclarative1Text::Sunken;
-
- colorStrings << "aliceblue"
- << "antiquewhite"
- << "aqua"
- << "darkkhaki"
- << "darkolivegreen"
- << "dimgray"
- << "palevioletred"
- << "lightsteelblue"
- << "#000000"
- << "#AAAAAA"
- << "#FFFFFF"
- << "#2AC05F";
- //
- // need a different test to do alpha channel test
- // << "#AA0011DD"
- // << "#00F16B11";
- //
-}
-
-QDeclarativeView *tst_qdeclarativetext::createView(const QString &filename)
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
-
- canvas->setSource(QUrl::fromLocalFile(filename));
- return canvas;
-}
-
-void tst_qdeclarativetext::text()
-{
- {
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData("import QtQuick 1.0\nText { text: \"\" }", QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->text(), QString(""));
- QVERIFY(textObject->width() == 0);
-
- delete textObject;
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import QtQuick 1.0\nText { text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
-
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->text(), standard.at(i));
- QVERIFY(textObject->width() > 0);
-
- delete textObject;
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import QtQuick 1.0\nText { text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QString expected = richText.at(i);
- QCOMPARE(textObject->text(), expected.replace("\\\"", "\""));
- QVERIFY(textObject->width() > 0);
-
- delete textObject;
- }
-}
-
-void tst_qdeclarativetext::width()
-{
- // uses Font metrics to find the width for standard and document to find the width for rich
- {
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData("import QtQuick 1.0\nText { text: \"\" }", QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->width(), 0.);
-
- delete textObject;
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QVERIFY(!Qt::mightBeRichText(standard.at(i))); // self-test
-
- QFont f;
- QFontMetricsF fm(f);
- qreal metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
- metricWidth = qCeil(metricWidth);
-
- QString componentStr = "import QtQuick 1.0\nText { text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->boundingRect().width() > 0);
- QCOMPARE(textObject->width(), qreal(metricWidth));
- QVERIFY(textObject->textFormat() == QDeclarative1Text::AutoText); // setting text doesn't change format
-
- delete textObject;
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QVERIFY(Qt::mightBeRichText(richText.at(i))); // self-test
-
- QTextDocument document;
- document.setHtml(richText.at(i));
- document.setDocumentMargin(0);
-
- int documentWidth = document.idealWidth();
-
- QString componentStr = "import QtQuick 1.0\nText { text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->width(), qreal(documentWidth));
- QVERIFY(textObject->textFormat() == QDeclarative1Text::AutoText); // setting text doesn't change format
-
- delete textObject;
- }
-}
-
-void tst_qdeclarativetext::wrap()
-{
- int textHeight = 0;
- // for specified width and wrap set true
- {
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData("import QtQuick 1.0\nText { text: \"Hello\"; wrapMode: Text.WordWrap; width: 300 }", QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
- textHeight = textObject->height();
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->wrapMode() == QDeclarative1Text::WordWrap);
- QCOMPARE(textObject->width(), 300.);
-
- delete textObject;
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import QtQuick 1.0\nText { wrapMode: Text.WordWrap; width: 30; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->width(), 30.);
- QVERIFY(textObject->height() > textHeight);
-
- int oldHeight = textObject->height();
- textObject->setWidth(100);
- QVERIFY(textObject->height() < oldHeight);
-
- delete textObject;
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import QtQuick 1.0\nText { wrapMode: Text.WordWrap; width: 30; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->width(), 30.);
- QVERIFY(textObject->height() > textHeight);
-
- qreal oldHeight = textObject->height();
- textObject->setWidth(100);
- QVERIFY(textObject->height() < oldHeight);
-
- delete textObject;
- }
-
- // richtext again with a fixed height
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import QtQuick 1.0\nText { wrapMode: Text.WordWrap; width: 30; height: 50; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->width(), 30.);
- QVERIFY(textObject->implicitHeight() > textHeight);
-
- qreal oldHeight = textObject->implicitHeight();
- textObject->setWidth(100);
- QVERIFY(textObject->implicitHeight() < oldHeight);
-
- delete textObject;
- }
-}
-
-void tst_qdeclarativetext::elide()
-{
- for (QDeclarative1Text::TextElideMode m = QDeclarative1Text::ElideLeft; m<=QDeclarative1Text::ElideNone; m=QDeclarative1Text::TextElideMode(int(m)+1)) {
- const char* elidename[]={"ElideLeft", "ElideRight", "ElideMiddle", "ElideNone"};
- QString elide = "elide: Text." + QString(elidename[int(m)]) + ";";
-
- // XXX Poor coverage.
-
- {
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(("import QtQuick 1.0\nText { text: \"\"; "+elide+" width: 100 }").toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QCOMPARE(textObject->elideMode(), m);
- QCOMPARE(textObject->width(), 100.);
-
- delete textObject;
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import QtQuick 1.0\nText { "+elide+" width: 100; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QCOMPARE(textObject->elideMode(), m);
- QCOMPARE(textObject->width(), 100.);
-
- delete textObject;
- }
-
- // richtext - does nothing
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import QtQuick 1.0\nText { "+elide+" width: 100; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QCOMPARE(textObject->elideMode(), m);
- QCOMPARE(textObject->width(), 100.);
-
- delete textObject;
- }
- }
-
- // QTBUG-18627
- QUrl qmlfile = QUrl::fromLocalFile(SRCDIR "/data/elideimplicitwidth.qml");
- QDeclarativeComponent textComponent(&engine, qmlfile);
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(textComponent.create());
- QVERIFY(item != 0);
- QVERIFY(item->implicitWidth() > item->width());
-}
-
-void tst_qdeclarativetext::textFormat()
-{
- {
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData("import QtQuick 1.0\nText { text: \"Hello\"; textFormat: Text.RichText }", QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->textFormat() == QDeclarative1Text::RichText);
-
- delete textObject;
- }
- {
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData("import QtQuick 1.0\nText { text: \"<b>Hello</b>\"; textFormat: Text.PlainText }", QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->textFormat() == QDeclarative1Text::PlainText);
-
- delete textObject;
- }
-}
-
-
-void tst_qdeclarativetext::alignments_data()
-{
- QTest::addColumn<int>("hAlign");
- QTest::addColumn<int>("vAlign");
- QTest::addColumn<QString>("expectfile");
-
- QTest::newRow("LT") << int(Qt::AlignLeft) << int(Qt::AlignTop) << SRCDIR "/data/alignments_lt.png";
- QTest::newRow("RT") << int(Qt::AlignRight) << int(Qt::AlignTop) << SRCDIR "/data/alignments_rt.png";
- QTest::newRow("CT") << int(Qt::AlignHCenter) << int(Qt::AlignTop) << SRCDIR "/data/alignments_ct.png";
-
- QTest::newRow("LB") << int(Qt::AlignLeft) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_lb.png";
- QTest::newRow("RB") << int(Qt::AlignRight) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_rb.png";
- QTest::newRow("CB") << int(Qt::AlignHCenter) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_cb.png";
-
- QTest::newRow("LC") << int(Qt::AlignLeft) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_lc.png";
- QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_rc.png";
- QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_cc.png";
-}
-
-
-void tst_qdeclarativetext::alignments()
-{
- QFETCH(int, hAlign);
- QFETCH(int, vAlign);
- QFETCH(QString, expectfile);
-
-#ifdef Q_WS_X11
- // Font-specific, but not likely platform-specific, so only test on one platform
- QFont fn;
- fn.setRawName("-misc-fixed-medium-r-*-*-8-*-*-*-*-*-*-*");
- QApplication::setFont(fn);
-#endif
-
- QDeclarativeView *canvas = createView(SRCDIR "/data/alignments.qml");
-
- canvas->show();
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
-
- QObject *ob = canvas->rootObject();
- QVERIFY(ob != 0);
- ob->setProperty("horizontalAlignment",hAlign);
- ob->setProperty("verticalAlignment",vAlign);
- QTRY_COMPARE(ob->property("running").toBool(),false);
- QImage actual(canvas->width(), canvas->height(), QImage::Format_RGB32);
- actual.fill(qRgb(255,255,255));
- QPainter p(&actual);
- canvas->render(&p);
-
- QImage expect(expectfile);
-
-#ifdef Q_WS_X11
- // Font-specific, but not likely platform-specific, so only test on one platform
- if (QApplicationPrivate::graphics_system_name == "raster" || QApplicationPrivate::graphics_system_name == "") {
- QCOMPARE(actual,expect);
- }
-#endif
-
- delete canvas;
-}
-
-//the alignment tests may be trivial o.oa
-void tst_qdeclarativetext::horizontalAlignment()
-{
- //test one align each, and then test if two align fails.
-
- for (int i = 0; i < standard.size(); i++)
- {
- for (int j=0; j < horizontalAlignmentmentStrings.size(); j++)
- {
- QString componentStr = "import QtQuick 1.0\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j));
-
- delete textObject;
- }
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- for (int j=0; j < horizontalAlignmentmentStrings.size(); j++)
- {
- QString componentStr = "import QtQuick 1.0\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j));
-
- delete textObject;
- }
- }
-
-}
-
-void tst_qdeclarativetext::horizontalAlignment_RightToLeft()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/horizontalAlignment_RightToLeft.qml");
- QDeclarative1Text *text = canvas->rootObject()->findChild<QDeclarative1Text*>("text");
- QVERIFY(text != 0);
- canvas->show();
-
- QDeclarative1TextPrivate *textPrivate = QDeclarative1TextPrivate::get(text);
- QVERIFY(textPrivate != 0);
-
- // implicit alignment should follow the reading direction of RTL text
- QCOMPARE(text->hAlign(), QDeclarative1Text::AlignRight);
- QCOMPARE(text->effectiveHAlign(), text->hAlign());
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2);
-
- // explicitly left aligned text
- text->setHAlign(QDeclarative1Text::AlignLeft);
- QCOMPARE(text->hAlign(), QDeclarative1Text::AlignLeft);
- QCOMPARE(text->effectiveHAlign(), text->hAlign());
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2);
-
- // explicitly right aligned text
- text->setHAlign(QDeclarative1Text::AlignRight);
- QCOMPARE(text->hAlign(), QDeclarative1Text::AlignRight);
- QCOMPARE(text->effectiveHAlign(), text->hAlign());
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2);
-
- // change to rich text
- QString textString = text->text();
- text->setText(QString("<i>") + textString + QString("</i>"));
- text->setTextFormat(QDeclarative1Text::RichText);
- text->resetHAlign();
-
- // implicitly aligned rich text should follow the reading direction of text
- QCOMPARE(text->hAlign(), QDeclarative1Text::AlignRight);
- QCOMPARE(text->effectiveHAlign(), text->hAlign());
- QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignLeft);
-
- // explicitly left aligned rich text
- text->setHAlign(QDeclarative1Text::AlignLeft);
- QCOMPARE(text->hAlign(), QDeclarative1Text::AlignLeft);
- QCOMPARE(text->effectiveHAlign(), text->hAlign());
- QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignRight);
-
- // explicitly right aligned rich text
- text->setHAlign(QDeclarative1Text::AlignRight);
- QCOMPARE(text->hAlign(), QDeclarative1Text::AlignRight);
- QCOMPARE(text->effectiveHAlign(), text->hAlign());
- QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignLeft);
-
- text->setText(textString);
- text->setTextFormat(QDeclarative1Text::PlainText);
-
- // explicitly center aligned
- text->setHAlign(QDeclarative1Text::AlignHCenter);
- QCOMPARE(text->hAlign(), QDeclarative1Text::AlignHCenter);
- QCOMPARE(text->effectiveHAlign(), text->hAlign());
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2);
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().right() > canvas->width()/2);
-
- // reseted alignment should go back to following the text reading direction
- text->resetHAlign();
- QCOMPARE(text->hAlign(), QDeclarative1Text::AlignRight);
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2);
-
- // mirror the text item
- QDeclarativeItemPrivate::get(text)->setLayoutMirror(true);
-
- // mirrored implicit alignment should continue to follow the reading direction of the text
- QCOMPARE(text->hAlign(), QDeclarative1Text::AlignRight);
- QCOMPARE(text->effectiveHAlign(), QDeclarative1Text::AlignRight);
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2);
-
- // mirrored explicitly right aligned behaves as left aligned
- text->setHAlign(QDeclarative1Text::AlignRight);
- QCOMPARE(text->hAlign(), QDeclarative1Text::AlignRight);
- QCOMPARE(text->effectiveHAlign(), QDeclarative1Text::AlignLeft);
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2);
-
- // mirrored explicitly left aligned behaves as right aligned
- text->setHAlign(QDeclarative1Text::AlignLeft);
- QCOMPARE(text->hAlign(), QDeclarative1Text::AlignLeft);
- QCOMPARE(text->effectiveHAlign(), QDeclarative1Text::AlignRight);
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2);
-
- // disable mirroring
- QDeclarativeItemPrivate::get(text)->setLayoutMirror(false);
- text->resetHAlign();
-
- // English text should be implicitly left aligned
- text->setText("Hello world!");
- QCOMPARE(text->hAlign(), QDeclarative1Text::AlignLeft);
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2);
-
-#ifndef Q_OS_MAC // QTBUG-18040
- // empty text with implicit alignment follows the system locale-based
- // keyboard input direction from QInputpanel::inputDirection
- text->setText("");
- QCOMPARE(text->hAlign(), qApp->inputPanel()->inputDirection() == Qt::LeftToRight ?
- QDeclarative1Text::AlignLeft : QDeclarative1Text::AlignRight);
- text->setHAlign(QDeclarative1Text::AlignRight);
- QCOMPARE(text->hAlign(), QDeclarative1Text::AlignRight);
-#endif
-
- delete canvas;
-
-#ifndef Q_OS_MAC // QTBUG-18040
- // alignment of Text with no text set to it
- QString componentStr = "import QtQuick 1.0\nText {}";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
- QCOMPARE(textObject->hAlign(), qApp->inputPanel()->inputDirection() == Qt::LeftToRight ?
- QDeclarative1Text::AlignLeft : QDeclarative1Text::AlignRight);
- delete textObject;
-#endif
-}
-
-void tst_qdeclarativetext::verticalAlignment()
-{
- //test one align each, and then test if two align fails.
-
- for (int i = 0; i < standard.size(); i++)
- {
- for (int j=0; j < verticalAlignmentmentStrings.size(); j++)
- {
- QString componentStr = "import QtQuick 1.0\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j));
-
- delete textObject;
- }
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- for (int j=0; j < verticalAlignmentmentStrings.size(); j++)
- {
- QString componentStr = "import QtQuick 1.0\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j));
-
- delete textObject;
- }
- }
-
- //confirm that bounding rect is correctly positioned.
- QString componentStr = "import QtQuick 1.0\nText { height: 80; text: \"Hello\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
- QVERIFY(textObject != 0);
- QRectF br = textObject->boundingRect();
- QVERIFY(br.y() == 0);
-
- textObject->setVAlign(QDeclarative1Text::AlignVCenter);
- br = textObject->boundingRect();
- QCOMPARE(qFloor(br.y()), qFloor((80.0 - br.height())/2));
-
- textObject->setVAlign(QDeclarative1Text::AlignBottom);
- br = textObject->boundingRect();
- QCOMPARE(qFloor(br.y()), qFloor(80.0 - br.height()));
-
- delete textObject;
-}
-
-void tst_qdeclarativetext::font()
-{
- //test size, then bold, then italic, then family
- {
- QString componentStr = "import QtQuick 1.0\nText { font.pointSize: 40; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QCOMPARE(textObject->font().pointSize(), 40);
- QCOMPARE(textObject->font().bold(), false);
- QCOMPARE(textObject->font().italic(), false);
-
- delete textObject;
- }
-
- {
- QString componentStr = "import QtQuick 1.0\nText { font.pixelSize: 40; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QCOMPARE(textObject->font().pixelSize(), 40);
- QCOMPARE(textObject->font().bold(), false);
- QCOMPARE(textObject->font().italic(), false);
-
- delete textObject;
- }
-
- {
- QString componentStr = "import QtQuick 1.0\nText { font.bold: true; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QCOMPARE(textObject->font().bold(), true);
- QCOMPARE(textObject->font().italic(), false);
-
- delete textObject;
- }
-
- {
- QString componentStr = "import QtQuick 1.0\nText { font.italic: true; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QCOMPARE(textObject->font().italic(), true);
- QCOMPARE(textObject->font().bold(), false);
-
- delete textObject;
- }
-
- {
- QString componentStr = "import QtQuick 1.0\nText { font.family: \"Helvetica\"; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QCOMPARE(textObject->font().family(), QString("Helvetica"));
- QCOMPARE(textObject->font().bold(), false);
- QCOMPARE(textObject->font().italic(), false);
-
- delete textObject;
- }
-
- {
- QString componentStr = "import QtQuick 1.0\nText { font.family: \"\"; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QCOMPARE(textObject->font().family(), QString(""));
-
- delete textObject;
- }
-}
-
-void tst_qdeclarativetext::style()
-{
- //test style
- for (int i = 0; i < styles.size(); i++)
- {
- QString componentStr = "import QtQuick 1.0\nText { style: \"" + styleStrings.at(i) + "\"; styleColor: \"white\"; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QCOMPARE((int)textObject->style(), (int)styles.at(i));
- QCOMPARE(textObject->styleColor(), QColor("white"));
-
- delete textObject;
- }
- QString componentStr = "import QtQuick 1.0\nText { text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QRectF brPre = textObject->boundingRect();
- textObject->setStyle(QDeclarative1Text::Outline);
- QRectF brPost = textObject->boundingRect();
-
- QVERIFY(brPre.width() < brPost.width());
- QVERIFY(brPre.height() < brPost.height());
-
- delete textObject;
-}
-
-void tst_qdeclarativetext::color()
-{
- //test style
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import QtQuick 1.0\nText { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QCOMPARE(textObject->color(), QColor(colorStrings.at(i)));
- QCOMPARE(textObject->styleColor(), QColor());
-
- delete textObject;
- }
-
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import QtQuick 1.0\nText { styleColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(i)));
- // default color to black?
- QCOMPARE(textObject->color(), QColor("black"));
-
- delete textObject;
- }
-
- for (int i = 0; i < colorStrings.size(); i++)
- {
- for (int j = 0; j < colorStrings.size(); j++)
- {
- QString componentStr = "import QtQuick 1.0\nText { color: \"" + colorStrings.at(i) + "\"; styleColor: \"" + colorStrings.at(j) + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QCOMPARE(textObject->color(), QColor(colorStrings.at(i)));
- QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(j)));
-
- delete textObject;
- }
- }
- {
- QString colorStr = "#AA001234";
- QColor testColor("#001234");
- testColor.setAlpha(170);
-
- QString componentStr = "import QtQuick 1.0\nText { color: \"" + colorStr + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QCOMPARE(textObject->color(), testColor);
-
- delete textObject;
- }
-}
-
-void tst_qdeclarativetext::smooth()
-{
- for (int i = 0; i < standard.size(); i++)
- {
- {
- QString componentStr = "import QtQuick 1.0\nText { smooth: true; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
- QCOMPARE(textObject->smooth(), true);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 1.0\nText { text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
- QCOMPARE(textObject->smooth(), false);
-
- delete textObject;
- }
- }
- for (int i = 0; i < richText.size(); i++)
- {
- {
- QString componentStr = "import QtQuick 1.0\nText { smooth: true; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
- QCOMPARE(textObject->smooth(), true);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 1.0\nText { text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
- QCOMPARE(textObject->smooth(), false);
-
- delete textObject;
- }
- }
-}
-
-void tst_qdeclarativetext::weight()
-{
- {
- QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().weight(), (int)QDeclarativeFontValueType::Normal);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 1.0\nText { font.weight: \"Bold\"; text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().weight(), (int)QDeclarativeFontValueType::Bold);
-
- delete textObject;
- }
-}
-
-void tst_qdeclarativetext::underline()
-{
- {
- QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().underline(), false);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 1.0\nText { font.underline: true; text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().underline(), true);
-
- delete textObject;
- }
-}
-
-void tst_qdeclarativetext::overline()
-{
- {
- QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().overline(), false);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 1.0\nText { font.overline: true; text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().overline(), true);
-
- delete textObject;
- }
-}
-
-void tst_qdeclarativetext::strikeout()
-{
- {
- QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().strikeOut(), false);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 1.0\nText { font.strikeout: true; text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().strikeOut(), true);
-
- delete textObject;
- }
-}
-
-void tst_qdeclarativetext::capitalization()
-{
- {
- QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::MixedCase);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\"; font.capitalization: \"AllUppercase\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::AllUppercase);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\"; font.capitalization: \"AllLowercase\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::AllLowercase);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\"; font.capitalization: \"SmallCaps\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::SmallCaps);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\"; font.capitalization: \"Capitalize\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::Capitalize);
-
- delete textObject;
- }
-}
-
-void tst_qdeclarativetext::letterSpacing()
-{
- {
- QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().letterSpacing(), 0.0);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\"; font.letterSpacing: -2 }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().letterSpacing(), -2.);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\"; font.letterSpacing: 3 }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().letterSpacing(), 3.);
-
- delete textObject;
- }
-}
-
-void tst_qdeclarativetext::wordSpacing()
-{
- {
- QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().wordSpacing(), 0.0);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\"; font.wordSpacing: -50 }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().wordSpacing(), -50.);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\"; font.wordSpacing: 200 }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().wordSpacing(), 200.);
-
- delete textObject;
- }
-}
-
-void tst_qdeclarativetext::QTBUG_12291()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/rotated.qml");
-
- canvas->show();
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
-
- QObject *ob = canvas->rootObject();
- QVERIFY(ob != 0);
-
- QDeclarative1Text *text = ob->findChild<QDeclarative1Text*>("text");
- QVERIFY(text);
- QVERIFY(text->boundingRect().isValid());
-
- delete canvas;
-}
-
-class EventSender : public QGraphicsItem
-{
-public:
- void sendEvent(QEvent *event) { sceneEvent(event); }
-};
-
-class LinkTest : public QObject
-{
- Q_OBJECT
-public:
- LinkTest() {}
-
- QString link;
-
-public slots:
- void linkClicked(QString l) { link = l; }
-};
-
-void tst_qdeclarativetext::clickLink()
-{
- {
- QString componentStr = "import QtQuick 1.0\nText { text: \"<a href=\\\"http://qt.nokia.com\\\">Hello world!</a>\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
-
- LinkTest test;
- QObject::connect(textObject, SIGNAL(linkActivated(QString)), &test, SLOT(linkClicked(QString)));
-
- {
- QGraphicsSceneMouseEvent me(QEvent::GraphicsSceneMousePress);
- me.setPos(QPointF(textObject->x()/2, textObject->y()/2));
- me.setButton(Qt::LeftButton);
- static_cast<EventSender*>(static_cast<QGraphicsItem*>(textObject))->sendEvent(&me);
- }
-
- {
- QGraphicsSceneMouseEvent me(QEvent::GraphicsSceneMouseRelease);
- me.setPos(QPointF(textObject->x()/2, textObject->y()/2));
- me.setButton(Qt::LeftButton);
- static_cast<EventSender*>(static_cast<QGraphicsItem*>(textObject))->sendEvent(&me);
- }
-
- QCOMPARE(test.link, QLatin1String("http://qt.nokia.com"));
-
- delete textObject;
- }
-}
-
-void tst_qdeclarativetext::embeddedImages_data()
-{
- QTest::addColumn<QUrl>("qmlfile");
- QTest::addColumn<QString>("error");
- QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesLocal.qml") << "";
- QTest::newRow("local-error") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesLocalError.qml")
- << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesLocalError.qml").toString()+":3:1: QML Text: Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/http/notexists.png").toString();
- QTest::newRow("remote") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesRemote.qml") << "";
- QTest::newRow("remote-error") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesRemoteError.qml")
- << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesRemoteError.qml").toString()+":3:1: QML Text: Error downloading http://127.0.0.1:14453/notexists.png - server replied: Not found";
-}
-
-void tst_qdeclarativetext::embeddedImages()
-{
- // Tests QTBUG-9900
-
- QFETCH(QUrl, qmlfile);
- QFETCH(QString, error);
-
- TestHTTPServer server(14453);
- server.serveDirectory(SRCDIR "/data/http");
-
- if (!error.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, error.toLatin1());
-
- QDeclarativeComponent textComponent(&engine, qmlfile);
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject != 0);
-
- QTRY_COMPARE(textObject->resourcesLoading(), 0);
-
- QPixmap pm(SRCDIR "/data/http/exists.png");
- if (error.isEmpty()) {
- QCOMPARE(textObject->width(), double(pm.width()));
- QCOMPARE(textObject->height(), double(pm.height()));
- } else {
- QVERIFY(16 != pm.width()); // check test is effective
- QCOMPARE(textObject->width(), 16.0); // default size of QTextDocument broken image icon
- QCOMPARE(textObject->height(), 16.0);
- }
-
- delete textObject;
-}
-
-void tst_qdeclarativetext::lineCount()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/lineCount.qml");
-
- QDeclarative1Text *myText = canvas->rootObject()->findChild<QDeclarative1Text*>("myText");
- QVERIFY(myText != 0);
-
- QVERIFY(myText->lineCount() > 1);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->maximumLineCount(), INT_MAX);
-
- myText->setMaximumLineCount(2);
- QCOMPARE(myText->lineCount(), 2);
- QCOMPARE(myText->truncated(), true);
- QCOMPARE(myText->maximumLineCount(), 2);
-
- myText->resetMaximumLineCount();
- QCOMPARE(myText->maximumLineCount(), INT_MAX);
- QCOMPARE(myText->truncated(), false);
-
- myText->setElideMode(QDeclarative1Text::ElideRight);
- myText->setMaximumLineCount(2);
- QCOMPARE(myText->lineCount(), 2);
- QCOMPARE(myText->truncated(), true);
- QCOMPARE(myText->maximumLineCount(), 2);
-
- delete canvas;
-}
-
-void tst_qdeclarativetext::lineHeight()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/lineHeight.qml");
-
- QDeclarative1Text *myText = canvas->rootObject()->findChild<QDeclarative1Text*>("myText");
- QVERIFY(myText != 0);
-
- QVERIFY(myText->lineHeight() == 1);
- QVERIFY(myText->lineHeightMode() == QDeclarative1Text::ProportionalHeight);
-
- qreal h = myText->height();
- myText->setLineHeight(1.5);
- QEXPECT_FAIL("", "QTBUG-21015 fails", Continue);
- QVERIFY(myText->height() == h * 1.5);
-
- myText->setLineHeightMode(QDeclarative1Text::FixedHeight);
- myText->setLineHeight(20);
- QCOMPARE(myText->height(), myText->lineCount() * 20.0);
-
- myText->setText("Lorem ipsum sit <b>amet</b>, consectetur adipiscing elit. Integer felis nisl, varius in pretium nec, venenatis non erat. Proin lobortis interdum dictum.");
- myText->setLineHeightMode(QDeclarative1Text::ProportionalHeight);
- myText->setLineHeight(1.0);
-
- qreal h2 = myText->height();
- myText->setLineHeight(2.0);
- QEXPECT_FAIL("", "QTBUG-17325", Continue);
- QVERIFY(myText->height() == h2 * 2.0);
-
- myText->setLineHeightMode(QDeclarative1Text::FixedHeight);
- myText->setLineHeight(10);
- QEXPECT_FAIL("", "QTBUG-17325", Continue);
- QCOMPARE(myText->height(), myText->lineCount() * 10.0);
-
- delete canvas;
-}
-
-void tst_qdeclarativetext::implicitSize_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<QString>("wrap");
- QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog" << "Text.NoWrap";
- QTest::newRow("richtext") << "<b>The quick red fox jumped over the lazy brown dog</b>" << "Text.NoWrap";
- QTest::newRow("plain_wrap") << "The quick red fox jumped over the lazy brown dog" << "Text.Wrap";
- QTest::newRow("richtext_wrap") << "<b>The quick red fox jumped over the lazy brown dog</b>" << "Text.Wrap";
-}
-
-void tst_qdeclarativetext::implicitSize()
-{
- QFETCH(QString, text);
- QFETCH(QString, wrap);
- QString componentStr = "import QtQuick 1.1\nText { text: \"" + text + "\"; width: 50; wrapMode: " + wrap + " }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1Text *textObject = qobject_cast<QDeclarative1Text*>(textComponent.create());
-
- QVERIFY(textObject->width() < textObject->implicitWidth());
- QVERIFY(textObject->height() == textObject->implicitHeight());
-
- textObject->resetWidth();
- QVERIFY(textObject->width() == textObject->implicitWidth());
- QVERIFY(textObject->height() == textObject->implicitHeight());
-
- delete textObject;
-}
-
-void tst_qdeclarativetext::testQtQuick11Attributes()
-{
- QFETCH(QString, code);
- QFETCH(QString, warning);
- QFETCH(QString, error);
-
- QDeclarativeEngine engine;
- QObject *obj;
-
- QDeclarativeComponent valid(&engine);
- valid.setData("import QtQuick 1.1; Text { " + code.toUtf8() + " }", QUrl(""));
- obj = valid.create();
- QVERIFY(obj);
- QVERIFY(valid.errorString().isEmpty());
- delete obj;
-
- QDeclarativeComponent invalid(&engine);
- invalid.setData("import QtQuick 1.0; Text { " + code.toUtf8() + " }", QUrl(""));
- QTest::ignoreMessage(QtWarningMsg, warning.toUtf8());
- obj = invalid.create();
- QCOMPARE(invalid.errorString(), error);
- delete obj;
-}
-
-void tst_qdeclarativetext::testQtQuick11Attributes_data()
-{
- QTest::addColumn<QString>("code");
- QTest::addColumn<QString>("warning");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("maximumLineCount") << "maximumLineCount: 4"
- << "QDeclarativeComponent: Component is not ready"
- << ":1 \"Text.maximumLineCount\" is not available in QtQuick 1.0.\n";
-
- QTest::newRow("lineHeight") << "lineHeight: 2"
- << "QDeclarativeComponent: Component is not ready"
- << ":1 \"Text.lineHeight\" is not available in QtQuick 1.0.\n";
-
- QTest::newRow("lineHeightMode") << "lineHeightMode: Text.ProportionalHeight"
- << "QDeclarativeComponent: Component is not ready"
- << ":1 \"Text.lineHeightMode\" is not available in QtQuick 1.0.\n";
-
- QTest::newRow("lineCount") << "property int foo: lineCount"
- << "<Unknown File>:1: ReferenceError: Can't find variable: lineCount"
- << "";
-
- QTest::newRow("truncated") << "property bool foo: truncated"
- << "<Unknown File>:1: ReferenceError: Can't find variable: truncated"
- << "";
-}
-
-void tst_qdeclarativetext::qtbug_14734()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/qtbug_14734.qml");
- QVERIFY(canvas);
-
- canvas->show();
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
-
- delete canvas;
-}
-
-QTEST_MAIN(tst_qdeclarativetext)
-
-#include "tst_qdeclarativetext.moc"
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/CursorRect.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/CursorRect.qml
deleted file mode 100644
index 3af0313692..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/CursorRect.qml
+++ /dev/null
@@ -1,8 +0,0 @@
-import QtQuick 1.0
-
-TextEdit {
- focus: true
- objectName: "myEdit"
- width: 50
- text: "This is a long piece of text"
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments.qml
deleted file mode 100644
index bc977fc6de..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments.qml
+++ /dev/null
@@ -1,41 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: top
- width: 70; height: 70;
-
- property alias horizontalAlignment: t.horizontalAlignment
- property alias verticalAlignment: t.verticalAlignment
- property alias wrapMode: t.wrapMode
- property alias running: timer.running
- property string txt: "Test"
-
- Rectangle {
- anchors.centerIn: parent
- width: 40
- height: 40
- color: "green"
-
- TextEdit {
- id: t
-
- anchors.fill: parent
- horizontalAlignment: TextEdit.AlignRight
- verticalAlignment: TextEdit.AlignBottom
- wrapMode: TextEdit.WordWrap
- text: top.txt
- }
- Timer {
- id: timer
-
- interval: 1
- running: true
- repeat: true
- onTriggered: {
- top.txt = top.txt + "<br>more " + top.txt.length;
- if (top.txt.length > 50)
- running = false
- }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_cb.png b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_cb.png
deleted file mode 100644
index 99de2192de..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_cb.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_cc.png b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_cc.png
deleted file mode 100644
index cb85251180..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_cc.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_ct.png b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_ct.png
deleted file mode 100644
index ddca549c82..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_ct.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_lb.png b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_lb.png
deleted file mode 100644
index 1b50a81f3d..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_lb.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_lc.png b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_lc.png
deleted file mode 100644
index f041b868f8..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_lc.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_lt.png b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_lt.png
deleted file mode 100644
index c75e0d158e..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_lt.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_rb.png b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_rb.png
deleted file mode 100644
index b06a5da715..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_rb.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_rc.png b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_rc.png
deleted file mode 100644
index e468857cd0..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_rc.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_rt.png b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_rt.png
deleted file mode 100644
index 576715ffce..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_rt.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/cursorTest.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/cursorTest.qml
deleted file mode 100644
index f7fb3e7ced..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/cursorTest.qml
+++ /dev/null
@@ -1,9 +0,0 @@
-import QtQuick 1.0
-
-Rectangle { width: 300; height: 300; color: "white"
- TextEdit { text: "Hello world!"; id: textEditObject; objectName: "textEditObject"
- anchors.fill: parent
- resources: [ Component { id:cursor; Item { id:cursorInstance; objectName: "cursorInstance" } } ]
- cursorDelegate: cursor
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/geometrySignals.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/geometrySignals.qml
deleted file mode 100644
index fe2ae12246..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/geometrySignals.qml
+++ /dev/null
@@ -1,12 +0,0 @@
-import QtQuick 1.0
-
-Item {
- width: 400; height: 500;
- property int bindingWidth: text.width
- property int bindingHeight: text.height
-
- TextInput {
- id: text
- anchors.fill: parent
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/horizontalAlignment_RightToLeft.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/horizontalAlignment_RightToLeft.qml
deleted file mode 100644
index 6e739bf2bb..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/horizontalAlignment_RightToLeft.qml
+++ /dev/null
@@ -1,24 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: top
- width: 200; height: 70;
-
- property alias horizontalAlignment: text.horizontalAlignment
- property string text: "اختبا"
-
- Rectangle {
- anchors.centerIn: parent
- width: 200
- height: 20
- color: "green"
-
- TextEdit {
- id: text
- objectName: "text"
- anchors.fill: parent
- text: top.text
- focus: true
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/http/ErrItem.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/http/ErrItem.qml
deleted file mode 100644
index fa7dbd107f..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/http/ErrItem.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import QtQuick 1.0
-
-Item{
- Fungus{
- palatable: false;
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/http/NormItem.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/http/NormItem.qml
deleted file mode 100644
index 4989193527..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/http/NormItem.qml
+++ /dev/null
@@ -1,6 +0,0 @@
-import QtQuick 1.0
-
-Item {
- objectName: "delegateOkay"
- Rectangle { }
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTest.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTest.qml
deleted file mode 100644
index 724c058de5..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTest.qml
+++ /dev/null
@@ -1,22 +0,0 @@
-import QtQuick 1.0
-
-Rectangle { width: 300; height: 300; color: "white"
- resources: [
- Component { id:cursorFail; FailItem { objectName: "delegateFail" } },
- Component { id:cursorWait; WaitItem { objectName: "delegateSlow" } },
- Component { id:cursorNorm; NormItem { objectName: "delegateOkay" } },
- Component { id:cursorErr; ErrItem { objectName: "delegateErrorA" } }
- ]
- TextEdit {
- cursorDelegate: cursorFail
- }
- TextEdit {
- cursorDelegate: cursorWait
- }
- TextEdit {
- cursorDelegate: cursorNorm
- }
- TextEdit {
- cursorDelegate: cursorErr
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTestFail1.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTestFail1.qml
deleted file mode 100644
index 6dcf7855f4..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTestFail1.qml
+++ /dev/null
@@ -1,18 +0,0 @@
-import QtQuick 1.0
-
-Rectangle { width: 300; height: 300; color: "white"
- resources: [
- Component { id:cursorFail; FailItem { objectName: "delegateFail" } },
- Component { id:cursorWait; WaitItem { objectName: "delegateSlow" } },
- Component { id:cursorNorm; NormItem { objectName: "delegateOkay" } }
- ]
- TextEdit {
- cursorDelegate: cursorFail
- }
- TextEdit {
- cursorDelegate: cursorWait
- }
- TextEdit {
- cursorDelegate: cursorNorm
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTestFail2.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTestFail2.qml
deleted file mode 100644
index 5f441d0db6..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTestFail2.qml
+++ /dev/null
@@ -1,18 +0,0 @@
-import QtQuick 1.0
-
-Rectangle { width: 300; height: 300; color: "white"
- resources: [
- Component { id:cursorWait; WaitItem { objectName: "delegateSlow" } },
- Component { id:cursorNorm; NormItem { objectName: "delegateOkay" } },
- Component { id:cursorErr; ErrItem { objectName: "delegateErrorA" } }
- ]
- TextEdit {
- cursorDelegate: cursorWait
- }
- TextEdit {
- cursorDelegate: cursorNorm
- }
- TextEdit {
- cursorDelegate: cursorErr
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTestPass.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTestPass.qml
deleted file mode 100644
index 95f5d87eb7..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTestPass.qml
+++ /dev/null
@@ -1,18 +0,0 @@
-import QtQuick 1.0
-
-Rectangle { width: 300; height: 300; color: "white"
- resources: [
- Component { id:cursorWait; WaitItem { objectName: "delegateSlow" } },
- Component { id:cursorNorm; NormItem { objectName: "delegateOkay" } }
- ]
- TextEdit {
- cursorDelegate: cursorWait
- text: "Hello"
- }
- TextEdit {
- objectName: "textEditObject"
- cursorDelegate: cursorNorm
- focus: true;
- text: "Hello"
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/http/qmldir b/tests/auto/qtquick1/qdeclarativetextedit/data/http/qmldir
deleted file mode 100644
index 886e6ffec0..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/http/qmldir
+++ /dev/null
@@ -1,4 +0,0 @@
-ErrItem ErrItem.qml
-NormItem NormItem.qml
-FailItem FailItem.qml
-WaitItem WaitItem.qml
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/httpfail/FailItem.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/httpfail/FailItem.qml
deleted file mode 100644
index 466eb9d2f1..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/httpfail/FailItem.qml
+++ /dev/null
@@ -1,5 +0,0 @@
-import QtQuick 1.0
-
-Item {
- Rectangle { }
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/httpslow/WaitItem.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/httpslow/WaitItem.qml
deleted file mode 100644
index 466eb9d2f1..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/httpslow/WaitItem.qml
+++ /dev/null
@@ -1,5 +0,0 @@
-import QtQuick 1.0
-
-Item {
- Rectangle { }
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/inputmethodhints.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/inputmethodhints.qml
deleted file mode 100644
index 7df17f2158..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/inputmethodhints.qml
+++ /dev/null
@@ -1,6 +0,0 @@
-import QtQuick 1.0
-
-TextEdit {
- text: "Hello world!"
- inputMethodHints: Qt.ImhNoPredictiveText
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_default.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_default.qml
deleted file mode 100644
index 22a9871306..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_default.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import QtQuick 1.0
-
-TextEdit {
- focus: true
- text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- selectByMouse: false
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_false.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_false.qml
deleted file mode 100644
index 22a9871306..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_false.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import QtQuick 1.0
-
-TextEdit {
- focus: true
- text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- selectByMouse: false
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_false_readonly.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_false_readonly.qml
deleted file mode 100644
index 4aea61160f..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_false_readonly.qml
+++ /dev/null
@@ -1,8 +0,0 @@
-import QtQuick 1.0
-
-TextEdit {
- focus: true
- text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- selectByMouse: false
- readOnly: true
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_false_words.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_false_words.qml
deleted file mode 100644
index f8d2e4e2f2..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_false_words.qml
+++ /dev/null
@@ -1,8 +0,0 @@
-import QtQuick 1.1
-
-TextEdit {
- focus: true
- text: "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- selectByMouse: false
- mouseSelectionMode: TextEdit.SelectWords
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_multiline.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_multiline.qml
deleted file mode 100644
index af23f6d91c..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_multiline.qml
+++ /dev/null
@@ -1,8 +0,0 @@
-import QtQuick 1.1
-
-TextEdit {
- focus: true
- text: "0123456789ABCDEFGHIJKLMNOPQRS\nTUVWXYZ"
- selectByMouse: true
- mouseSelectionMode: TextInput.SelectWords
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_true.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_true.qml
deleted file mode 100644
index d61da46f48..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_true.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import QtQuick 1.0
-
-TextEdit {
- focus: true
- text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- selectByMouse: true
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_true_readonly.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_true_readonly.qml
deleted file mode 100644
index 959e683721..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_true_readonly.qml
+++ /dev/null
@@ -1,8 +0,0 @@
-import QtQuick 1.0
-
-TextEdit {
- focus: true
- text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- selectByMouse: true
- readOnly: true
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_true_words.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_true_words.qml
deleted file mode 100644
index f58fd45837..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_true_words.qml
+++ /dev/null
@@ -1,8 +0,0 @@
-import QtQuick 1.1
-
-TextEdit {
- focus: true
- text: "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- selectByMouse: true
- mouseSelectionMode: TextEdit.SelectWords
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselectionmode_characters.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselectionmode_characters.qml
deleted file mode 100644
index 5784e1960b..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselectionmode_characters.qml
+++ /dev/null
@@ -1,8 +0,0 @@
-import QtQuick 1.1
-
-TextEdit {
- focus: true
- text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- selectByMouse: true
- mouseSelectionMode: TextEdit.SelectCharacters
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselectionmode_default.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselectionmode_default.qml
deleted file mode 100644
index 1e5f4aac88..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselectionmode_default.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import QtQuick 1.1
-
-TextEdit {
- focus: true
- text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- selectByMouse: true
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselectionmode_words.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselectionmode_words.qml
deleted file mode 100644
index 4b25f2f890..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselectionmode_words.qml
+++ /dev/null
@@ -1,8 +0,0 @@
-import QtQuick 1.1
-
-TextEdit {
- focus: true
- text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- selectByMouse: true
- mouseSelectionMode: TextEdit.SelectWords
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/navigation.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/navigation.qml
deleted file mode 100644
index 0e1caf6e23..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/navigation.qml
+++ /dev/null
@@ -1,24 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- property variant myInput: input
-
- width: 800; height: 600; color: "blue"
-
- Item {
- id: firstItem;
- KeyNavigation.right: input
- }
-
- TextEdit { id: input; focus: true
- KeyNavigation.left: firstItem
- KeyNavigation.right: lastItem
- KeyNavigation.up: firstItem
- KeyNavigation.down: lastItem
- text: "a"
- }
- Item {
- id: lastItem
- KeyNavigation.left: input
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/positionAt.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/positionAt.qml
deleted file mode 100644
index e01013560b..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/positionAt.qml
+++ /dev/null
@@ -1,9 +0,0 @@
-import QtQuick 1.0
-
-TextEdit {
- focus: true
- objectName: "myInput"
- width: 50
- height: 25
- text: "This is\n a long piece of text"
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/readOnly.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/readOnly.qml
deleted file mode 100644
index 36177d3be8..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/data/readOnly.qml
+++ /dev/null
@@ -1,12 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- property variant myInput: input
-
- width: 800; height: 600; color: "blue"
-
- TextEdit { id: input; focus: true
- readOnly: true
- text: "I am the very model of a modern major general.\n"
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/qdeclarativetextedit.pro b/tests/auto/qtquick1/qdeclarativetextedit/qdeclarativetextedit.pro
deleted file mode 100644
index 5c86e111e8..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/qdeclarativetextedit.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativetextedit
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativetextedit.cpp ../../shared/testhttpserver.cpp
-HEADERS += ../../shared/testhttpserver.h
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private network testlib
diff --git a/tests/auto/qtquick1/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/qtquick1/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
deleted file mode 100644
index 4ad3efd414..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
+++ /dev/null
@@ -1,2549 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QSignalSpy>
-#include "../../shared/testhttpserver.h"
-#include <math.h>
-#include <QFile>
-#include <QTextDocument>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick1/private/qdeclarativetextedit_p.h>
-#include <QtQuick1/private/qdeclarativetextedit_p_p.h>
-#include <QFontMetrics>
-#include <QtQuick1/QDeclarativeView>
-#include <QDir>
-#include <QStyle>
-#include <QClipboard>
-#include <QMimeData>
-#include <private/qapplication_p.h>
-#include <private/qwidgettextcontrol_p.h>
-#include <private/qinputpanel_p.h>
-#include "../../shared/platforminputcontext.h"
-
-
-Q_DECLARE_METATYPE(QDeclarative1TextEdit::SelectionMode)
-
-QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual)
-{
- // XXX This will be replaced by some clever persistent platform image store.
- QString persistent_dir = SRCDIR "/data";
- QString arch = "unknown-architecture"; // QTest needs to help with this.
-
- QString expectfile = persistent_dir + QDir::separator() + filebasename + "-" + arch + ".png";
-
- if (!QFile::exists(expectfile)) {
- actual.save(expectfile);
- qWarning() << "created" << expectfile;
- }
-
- return expectfile;
-}
-
-void sendPreeditText(const QString &text, int cursor)
-{
- QList<QInputMethodEvent::Attribute> attributes;
- attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, cursor,
- text.length(), QVariant()));
- QInputMethodEvent event(text, attributes);
- QApplication::sendEvent(qApp->focusObject(), &event);
-}
-
-
-class tst_qdeclarativetextedit : public QObject
-
-{
- Q_OBJECT
-public:
- tst_qdeclarativetextedit();
-
-private slots:
- void cleanup();
-
- void text();
- void width();
- void wrap();
- void textFormat();
- void alignments();
- void alignments_data();
-
- // ### these tests may be trivial
- void hAlign();
- void hAlign_RightToLeft();
- void vAlign();
- void font();
- void color();
- void textMargin();
- void persistentSelection();
- void focusOnPress();
- void selection();
- void isRightToLeft_data();
- void isRightToLeft();
- void keySelection();
- void moveCursorSelection_data();
- void moveCursorSelection();
- void moveCursorSelectionSequence_data();
- void moveCursorSelectionSequence();
- void mouseSelection_data();
- void mouseSelection();
- void multilineMouseSelection();
- void deferEnableSelectByMouse_data();
- void deferEnableSelectByMouse();
- void deferDisableSelectByMouse_data();
- void deferDisableSelectByMouse();
- void mouseSelectionMode_data();
- void mouseSelectionMode();
- void dragMouseSelection();
- void inputMethodHints();
-
- void positionAt();
-
- void cursorDelegate();
- void cursorVisible();
- void delegateLoading_data();
- void delegateLoading();
- void navigation();
- void readOnly();
- void copyAndPaste();
- void canPaste();
- void canPasteEmpty();
- void textInput();
- void openInputPanelOnClick();
- void openInputPanelOnFocus();
- void geometrySignals();
- void pastingRichText_QTBUG_14003();
- void implicitSize_data();
- void implicitSize();
- void testQtQuick11Attributes();
- void testQtQuick11Attributes_data();
-
- void preeditMicroFocus();
- void inputContextMouseHandler();
- void inputMethodComposing();
- void cursorRectangleSize();
-
-private:
- void simulateKey(QDeclarativeView *, int key, Qt::KeyboardModifiers modifiers = 0);
- QDeclarativeView *createView(const QString &filename);
-
- QStringList standard;
- QStringList richText;
-
- QStringList hAlignmentStrings;
- QStringList vAlignmentStrings;
-
- QList<Qt::Alignment> vAlignments;
- QList<Qt::Alignment> hAlignments;
-
- QStringList colorStrings;
-
- QDeclarativeEngine engine;
-};
-
-tst_qdeclarativetextedit::tst_qdeclarativetextedit()
-{
- standard << "the quick brown fox jumped over the lazy dog"
- << "the quick brown fox\n jumped over the lazy dog"
- << "Hello, world!"
- << "!dlrow ,olleH";
-
- richText << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a> jumped over the <b>lazy</b> dog</i>"
- << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a><br>jumped over the <b>lazy</b> dog</i>";
-
- hAlignmentStrings << "AlignLeft"
- << "AlignRight"
- << "AlignHCenter";
-
- vAlignmentStrings << "AlignTop"
- << "AlignBottom"
- << "AlignVCenter";
-
- hAlignments << Qt::AlignLeft
- << Qt::AlignRight
- << Qt::AlignHCenter;
-
- vAlignments << Qt::AlignTop
- << Qt::AlignBottom
- << Qt::AlignVCenter;
-
- colorStrings << "aliceblue"
- << "antiquewhite"
- << "aqua"
- << "darkkhaki"
- << "darkolivegreen"
- << "dimgray"
- << "palevioletred"
- << "lightsteelblue"
- << "#000000"
- << "#AAAAAA"
- << "#FFFFFF"
- << "#2AC05F";
- //
- // need a different test to do alpha channel test
- // << "#AA0011DD"
- // << "#00F16B11";
- //
-}
-
-void tst_qdeclarativetextedit::cleanup()
-{
- // ensure not even skipped tests with custom input context leave it dangling
- QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
- inputPanelPrivate->testContext = 0;
-}
-
-void tst_qdeclarativetextedit::text()
-{
- {
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData("import QtQuick 1.0\nTextEdit { text: \"\" }", QUrl());
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->text(), QString(""));
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import QtQuick 1.0\nTextEdit { text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->text(), standard.at(i));
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import QtQuick 1.0\nTextEdit { text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QString actual = textEditObject->text();
- QString expected = richText.at(i);
- actual.replace(QRegExp(".*<body[^>]*>"),"");
- actual.replace(QRegExp("(<[^>]*>)+"),"<>");
- expected.replace(QRegExp("(<[^>]*>)+"),"<>");
- QCOMPARE(actual.simplified(),expected.simplified());
- }
-}
-
-void tst_qdeclarativetextedit::width()
-{
- // uses Font metrics to find the width for standard and document to find the width for rich
- {
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData("import QtQuick 1.0\nTextEdit { text: \"\" }", QUrl());
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), 0.0);
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QFont f;
- QFontMetricsF fm(f);
- qreal metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
- metricWidth = ceil(metricWidth);
-
- QString componentStr = "import QtQuick 1.0\nTextEdit { text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), qreal(metricWidth));
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QTextDocument document;
- document.setHtml(richText.at(i));
- document.setDocumentMargin(0);
-
- int documentWidth = ceil(document.idealWidth());
-
- QString componentStr = "import QtQuick 1.0\nTextEdit { text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), qreal(documentWidth));
- }
-}
-
-void tst_qdeclarativetextedit::wrap()
-{
- // for specified width and wrap set true
- {
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData("import QtQuick 1.0\nTextEdit { text: \"\"; wrapMode: TextEdit.WordWrap; width: 300 }", QUrl());
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), 300.);
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import QtQuick 1.0\nTextEdit { wrapMode: TextEdit.WordWrap; width: 300; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), 300.);
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import QtQuick 1.0\nTextEdit { wrapMode: TextEdit.WordWrap; width: 300; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), 300.);
- }
-
-}
-
-void tst_qdeclarativetextedit::textFormat()
-{
- {
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData("import QtQuick 1.0\nTextEdit { text: \"Hello\"; textFormat: Text.RichText }", QUrl::fromLocalFile(""));
- QDeclarative1TextEdit *textObject = qobject_cast<QDeclarative1TextEdit*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->textFormat() == QDeclarative1TextEdit::RichText);
- }
- {
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData("import QtQuick 1.0\nTextEdit { text: \"<b>Hello</b>\"; textFormat: Text.PlainText }", QUrl::fromLocalFile(""));
- QDeclarative1TextEdit *textObject = qobject_cast<QDeclarative1TextEdit*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->textFormat() == QDeclarative1TextEdit::PlainText);
- }
-}
-
-void tst_qdeclarativetextedit::alignments_data()
-{
- QTest::addColumn<int>("hAlign");
- QTest::addColumn<int>("vAlign");
- QTest::addColumn<QString>("expectfile");
-
- QTest::newRow("LT") << int(Qt::AlignLeft) << int(Qt::AlignTop) << "alignments_lt";
- QTest::newRow("RT") << int(Qt::AlignRight) << int(Qt::AlignTop) << "alignments_rt";
- QTest::newRow("CT") << int(Qt::AlignHCenter) << int(Qt::AlignTop) << "alignments_ct";
-
- QTest::newRow("LB") << int(Qt::AlignLeft) << int(Qt::AlignBottom) << "alignments_lb";
- QTest::newRow("RB") << int(Qt::AlignRight) << int(Qt::AlignBottom) << "alignments_rb";
- QTest::newRow("CB") << int(Qt::AlignHCenter) << int(Qt::AlignBottom) << "alignments_cb";
-
- QTest::newRow("LC") << int(Qt::AlignLeft) << int(Qt::AlignVCenter) << "alignments_lc";
- QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << "alignments_rc";
- QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << "alignments_cc";
-}
-
-
-void tst_qdeclarativetextedit::alignments()
-{
- QFETCH(int, hAlign);
- QFETCH(int, vAlign);
- QFETCH(QString, expectfile);
-
- QDeclarativeView *canvas = createView(SRCDIR "/data/alignments.qml");
-
- canvas->show();
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
-
- QObject *ob = canvas->rootObject();
- QVERIFY(ob != 0);
- ob->setProperty("horizontalAlignment",hAlign);
- ob->setProperty("verticalAlignment",vAlign);
- QTRY_COMPARE(ob->property("running").toBool(),false);
- QImage actual(canvas->width(), canvas->height(), QImage::Format_RGB32);
- actual.fill(qRgb(255,255,255));
- QPainter p(&actual);
- canvas->render(&p);
-
- expectfile = createExpectedFileIfNotFound(expectfile, actual);
-
- QImage expect(expectfile);
-
- QCOMPARE(actual,expect);
-
- delete canvas;
-}
-
-
-//the alignment tests may be trivial o.oa
-void tst_qdeclarativetextedit::hAlign()
-{
- //test one align each, and then test if two align fails.
-
- for (int i = 0; i < standard.size(); i++)
- {
- for (int j=0; j < hAlignmentStrings.size(); j++)
- {
- QString componentStr = "import QtQuick 1.0\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE((int)textEditObject->hAlign(), (int)hAlignments.at(j));
- }
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- for (int j=0; j < hAlignmentStrings.size(); j++)
- {
- QString componentStr = "import QtQuick 1.0\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE((int)textEditObject->hAlign(), (int)hAlignments.at(j));
- }
- }
-
-}
-
-void tst_qdeclarativetextedit::hAlign_RightToLeft()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/horizontalAlignment_RightToLeft.qml");
- QDeclarative1TextEdit *textEdit = canvas->rootObject()->findChild<QDeclarative1TextEdit*>("text");
- QVERIFY(textEdit != 0);
- canvas->show();
-
- const QString rtlText = textEdit->text();
-
- // implicit alignment should follow the reading direction of text
- QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignRight);
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2);
-
- // explicitly left aligned
- textEdit->setHAlign(QDeclarative1TextEdit::AlignLeft);
- QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignLeft);
- QVERIFY(textEdit->positionToRectangle(0).x() < canvas->width()/2);
-
- // explicitly right aligned
- textEdit->setHAlign(QDeclarative1TextEdit::AlignRight);
- QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignRight);
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2);
-
- QString textString = textEdit->text();
- textEdit->setText(QString("<i>") + textString + QString("</i>"));
- textEdit->resetHAlign();
-
- // implicitly aligned rich text should follow the reading direction of RTL text
- QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignRight);
- QCOMPARE(textEdit->effectiveHAlign(), textEdit->hAlign());
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2);
-
- // explicitly left aligned rich text
- textEdit->setHAlign(QDeclarative1TextEdit::AlignLeft);
- QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignLeft);
- QCOMPARE(textEdit->effectiveHAlign(), textEdit->hAlign());
- QVERIFY(textEdit->positionToRectangle(0).x() < canvas->width()/2);
-
- // explicitly right aligned rich text
- textEdit->setHAlign(QDeclarative1TextEdit::AlignRight);
- QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignRight);
- QCOMPARE(textEdit->effectiveHAlign(), textEdit->hAlign());
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2);
-
- textEdit->setText(textString);
-
- // explicitly center aligned
- textEdit->setHAlign(QDeclarative1TextEdit::AlignHCenter);
- QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignHCenter);
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2);
-
- // reseted alignment should go back to following the text reading direction
- textEdit->resetHAlign();
- QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignRight);
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2);
-
- // mirror the text item
- QDeclarativeItemPrivate::get(textEdit)->setLayoutMirror(true);
-
- // mirrored implicit alignment should continue to follow the reading direction of the text
- QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignRight);
- QCOMPARE(textEdit->effectiveHAlign(), QDeclarative1TextEdit::AlignRight);
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2);
-
- // mirrored explicitly right aligned behaves as left aligned
- textEdit->setHAlign(QDeclarative1TextEdit::AlignRight);
- QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignRight);
- QCOMPARE(textEdit->effectiveHAlign(), QDeclarative1TextEdit::AlignLeft);
- QVERIFY(textEdit->positionToRectangle(0).x() < canvas->width()/2);
-
- // mirrored explicitly left aligned behaves as right aligned
- textEdit->setHAlign(QDeclarative1TextEdit::AlignLeft);
- QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignLeft);
- QCOMPARE(textEdit->effectiveHAlign(), QDeclarative1TextEdit::AlignRight);
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2);
-
- // disable mirroring
- QDeclarativeItemPrivate::get(textEdit)->setLayoutMirror(false);
- textEdit->resetHAlign();
-
- // English text should be implicitly left aligned
- textEdit->setText("Hello world!");
- QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignLeft);
- QVERIFY(textEdit->positionToRectangle(0).x() < canvas->width()/2);
-
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
-
- textEdit->setText(QString());
- { QInputMethodEvent ev(rtlText, QList<QInputMethodEvent::Attribute>()); QApplication::sendEvent(canvas, &ev); }
- QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignRight);
- { QInputMethodEvent ev("Hello world!", QList<QInputMethodEvent::Attribute>()); QApplication::sendEvent(canvas, &ev); }
- QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignLeft);
-
-#ifndef Q_OS_MAC // QTBUG-18040
- // empty text with implicit alignment follows the system locale-based
- // keyboard input direction from QInputPanel::inputDirection
- textEdit->setText("");
- QCOMPARE(textEdit->hAlign(), qApp->inputPanel()->inputDirection() == Qt::LeftToRight ?
- QDeclarative1TextEdit::AlignLeft : QDeclarative1TextEdit::AlignRight);
- if (qApp->inputPanel()->inputDirection() == Qt::LeftToRight)
- QVERIFY(textEdit->positionToRectangle(0).x() < canvas->width()/2);
- else
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2);
- textEdit->setHAlign(QDeclarative1TextEdit::AlignRight);
- QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignRight);
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2);
-#endif
-
- delete canvas;
-
-#ifndef Q_OS_MAC // QTBUG-18040
- // alignment of TextEdit with no text set to it
- QString componentStr = "import QtQuick 1.0\nTextEdit {}";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1TextEdit *textObject = qobject_cast<QDeclarative1TextEdit*>(textComponent.create());
- QCOMPARE(textObject->hAlign(), qApp->inputPanel()->inputDirection() == Qt::LeftToRight ?
- QDeclarative1TextEdit::AlignLeft : QDeclarative1TextEdit::AlignRight);
- delete textObject;
-#endif
-}
-
-void tst_qdeclarativetextedit::vAlign()
-{
- //test one align each, and then test if two align fails.
-
- for (int i = 0; i < standard.size(); i++)
- {
- for (int j=0; j < vAlignmentStrings.size(); j++)
- {
- QString componentStr = "import QtQuick 1.0\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE((int)textEditObject->vAlign(), (int)vAlignments.at(j));
- }
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- for (int j=0; j < vAlignmentStrings.size(); j++)
- {
- QString componentStr = "import QtQuick 1.0\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE((int)textEditObject->vAlign(), (int)vAlignments.at(j));
- }
- }
-
-}
-
-void tst_qdeclarativetextedit::font()
-{
- //test size, then bold, then italic, then family
- {
- QString componentStr = "import QtQuick 1.0\nTextEdit { font.pointSize: 40; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font().pointSize(), 40);
- QCOMPARE(textEditObject->font().bold(), false);
- QCOMPARE(textEditObject->font().italic(), false);
- }
-
- {
- QString componentStr = "import QtQuick 1.0\nTextEdit { font.bold: true; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font().bold(), true);
- QCOMPARE(textEditObject->font().italic(), false);
- }
-
- {
- QString componentStr = "import QtQuick 1.0\nTextEdit { font.italic: true; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font().italic(), true);
- QCOMPARE(textEditObject->font().bold(), false);
- }
-
- {
- QString componentStr = "import QtQuick 1.0\nTextEdit { font.family: \"Helvetica\"; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font().family(), QString("Helvetica"));
- QCOMPARE(textEditObject->font().bold(), false);
- QCOMPARE(textEditObject->font().italic(), false);
- }
-
- {
- QString componentStr = "import QtQuick 1.0\nTextEdit { font.family: \"\"; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font().family(), QString(""));
- }
-}
-
-void tst_qdeclarativetextedit::color()
-{
- //test initial color
- {
- QString componentStr = "import QtQuick 1.0\nTextEdit { text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
-
- QDeclarative1TextEditPrivate *textEditPrivate = static_cast<QDeclarative1TextEditPrivate*>(QDeclarativeItemPrivate::get(textEditObject));
-
- QVERIFY(textEditObject);
- QVERIFY(textEditPrivate);
- QVERIFY(textEditPrivate->control);
-
- QPalette pal = textEditPrivate->control->palette();
- QCOMPARE(textEditPrivate->color, QColor("black"));
- QCOMPARE(textEditPrivate->color, pal.color(QPalette::Text));
- }
- //test normal
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import QtQuick 1.0\nTextEdit { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
- //qDebug() << "textEditObject: " << textEditObject->color() << "vs. " << QColor(colorStrings.at(i));
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->color(), QColor(colorStrings.at(i)));
- }
-
- //test selection
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import QtQuick 1.0\nTextEdit { selectionColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->selectionColor(), QColor(colorStrings.at(i)));
- }
-
- //test selected text
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import QtQuick 1.0\nTextEdit { selectedTextColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->selectedTextColor(), QColor(colorStrings.at(i)));
- }
-
- {
- QString colorStr = "#AA001234";
- QColor testColor("#001234");
- testColor.setAlpha(170);
-
- QString componentStr = "import QtQuick 1.0\nTextEdit { color: \"" + colorStr + "\"; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->color(), testColor);
- }
-}
-
-void tst_qdeclarativetextedit::textMargin()
-{
- for(qreal i=0; i<=10; i+=0.3){
- QString componentStr = "import QtQuick 1.0\nTextEdit { textMargin: " + QString::number(i) + "; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->textMargin(), i);
- }
-}
-
-void tst_qdeclarativetextedit::persistentSelection()
-{
- {
- QString componentStr = "import QtQuick 1.0\nTextEdit { persistentSelection: true; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->persistentSelection(), true);
- }
-
- {
- QString componentStr = "import QtQuick 1.0\nTextEdit { persistentSelection: false; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->persistentSelection(), false);
- }
-}
-
-void tst_qdeclarativetextedit::focusOnPress()
-{
- {
- QString componentStr = "import QtQuick 1.0\nTextEdit { activeFocusOnPress: true; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->focusOnPress(), true);
- }
-
- {
- QString componentStr = "import QtQuick 1.0\nTextEdit { activeFocusOnPress: false; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->focusOnPress(), false);
- }
-}
-
-void tst_qdeclarativetextedit::selection()
-{
- QString testStr = standard[0];//TODO: What should happen for multiline/rich text?
- QString componentStr = "import QtQuick 1.0\nTextEdit { text: \""+ testStr +"\"; }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
-
-
- //Test selection follows cursor
- for(int i=0; i<= testStr.size(); i++) {
- textEditObject->setCursorPosition(i);
- QCOMPARE(textEditObject->cursorPosition(), i);
- QCOMPARE(textEditObject->selectionStart(), i);
- QCOMPARE(textEditObject->selectionEnd(), i);
- QVERIFY(textEditObject->selectedText().isNull());
- }
- //Test cursor follows selection
- for(int i=0; i<= testStr.size(); i++) {
- textEditObject->select(i,i);
- QCOMPARE(textEditObject->cursorPosition(), i);
- QCOMPARE(textEditObject->selectionStart(), i);
- QCOMPARE(textEditObject->selectionEnd(), i);
- }
-
-
- textEditObject->setCursorPosition(0);
- QVERIFY(textEditObject->cursorPosition() == 0);
- QVERIFY(textEditObject->selectionStart() == 0);
- QVERIFY(textEditObject->selectionEnd() == 0);
- QVERIFY(textEditObject->selectedText().isNull());
-
- // Verify invalid positions are ignored.
- textEditObject->setCursorPosition(-1);
- QVERIFY(textEditObject->cursorPosition() == 0);
- QVERIFY(textEditObject->selectionStart() == 0);
- QVERIFY(textEditObject->selectionEnd() == 0);
- QVERIFY(textEditObject->selectedText().isNull());
-
- textEditObject->setCursorPosition(textEditObject->text().count()+1);
- QVERIFY(textEditObject->cursorPosition() == 0);
- QVERIFY(textEditObject->selectionStart() == 0);
- QVERIFY(textEditObject->selectionEnd() == 0);
- QVERIFY(textEditObject->selectedText().isNull());
-
- //Test selection
- for(int i=0; i<= testStr.size(); i++) {
- textEditObject->select(0,i);
- QCOMPARE(testStr.mid(0,i), textEditObject->selectedText());
- QCOMPARE(textEditObject->cursorPosition(), i);
- }
- for(int i=0; i<= testStr.size(); i++) {
- textEditObject->select(i,testStr.size());
- QCOMPARE(testStr.mid(i,testStr.size()-i), textEditObject->selectedText());
- QCOMPARE(textEditObject->cursorPosition(), testStr.size());
- }
-
- textEditObject->setCursorPosition(0);
- QVERIFY(textEditObject->cursorPosition() == 0);
- QVERIFY(textEditObject->selectionStart() == 0);
- QVERIFY(textEditObject->selectionEnd() == 0);
- QVERIFY(textEditObject->selectedText().isNull());
-
- //Test Error Ignoring behaviour
- textEditObject->setCursorPosition(0);
- QVERIFY(textEditObject->selectedText().isNull());
- textEditObject->select(-10,0);
- QVERIFY(textEditObject->selectedText().isNull());
- textEditObject->select(100,101);
- QVERIFY(textEditObject->selectedText().isNull());
- textEditObject->select(0,-10);
- QVERIFY(textEditObject->selectedText().isNull());
- textEditObject->select(0,100);
- QVERIFY(textEditObject->selectedText().isNull());
- textEditObject->select(0,10);
- QVERIFY(textEditObject->selectedText().size() == 10);
- textEditObject->select(-10,0);
- QVERIFY(textEditObject->selectedText().size() == 10);
- textEditObject->select(100,101);
- QVERIFY(textEditObject->selectedText().size() == 10);
- textEditObject->select(0,-10);
- QVERIFY(textEditObject->selectedText().size() == 10);
- textEditObject->select(0,100);
- QVERIFY(textEditObject->selectedText().size() == 10);
-
- textEditObject->deselect();
- QVERIFY(textEditObject->selectedText().isNull());
- textEditObject->select(0,10);
- QVERIFY(textEditObject->selectedText().size() == 10);
- textEditObject->deselect();
- QVERIFY(textEditObject->selectedText().isNull());
-}
-
-void tst_qdeclarativetextedit::isRightToLeft_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<bool>("emptyString");
- QTest::addColumn<bool>("firstCharacter");
- QTest::addColumn<bool>("lastCharacter");
- QTest::addColumn<bool>("middleCharacter");
- QTest::addColumn<bool>("startString");
- QTest::addColumn<bool>("midString");
- QTest::addColumn<bool>("endString");
-
- const quint16 arabic_str[] = { 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0647};
- QTest::newRow("Empty") << "" << false << false << false << false << false << false << false;
- QTest::newRow("Neutral") << "23244242" << false << false << false << false << false << false << false;
- QTest::newRow("LTR") << "Hello world" << false << false << false << false << false << false << false;
- QTest::newRow("RTL") << QString::fromUtf16(arabic_str, 11) << false << true << true << true << true << true << true;
- QTest::newRow("Bidi RTL + LTR + RTL") << QString::fromUtf16(arabic_str, 11) + QString("Hello world") + QString::fromUtf16(arabic_str, 11) << false << true << true << false << true << true << true;
- QTest::newRow("Bidi LTR + RTL + LTR") << QString("Hello world") + QString::fromUtf16(arabic_str, 11) + QString("Hello world") << false << false << false << true << false << false << false;
-}
-
-void tst_qdeclarativetextedit::isRightToLeft()
-{
- QFETCH(QString, text);
- QFETCH(bool, emptyString);
- QFETCH(bool, firstCharacter);
- QFETCH(bool, lastCharacter);
- QFETCH(bool, middleCharacter);
- QFETCH(bool, startString);
- QFETCH(bool, midString);
- QFETCH(bool, endString);
-
- QDeclarative1TextEdit textEdit;
- textEdit.setText(text);
-
- // first test that the right string is delivered to the QString::isRightToLeft()
- QCOMPARE(textEdit.isRightToLeft(0,0), text.mid(0,0).isRightToLeft());
- QCOMPARE(textEdit.isRightToLeft(0,1), text.mid(0,1).isRightToLeft());
- QCOMPARE(textEdit.isRightToLeft(text.count()-2, text.count()-1), text.mid(text.count()-2, text.count()-1).isRightToLeft());
- QCOMPARE(textEdit.isRightToLeft(text.count()/2, text.count()/2 + 1), text.mid(text.count()/2, text.count()/2 + 1).isRightToLeft());
- QCOMPARE(textEdit.isRightToLeft(0,text.count()/4), text.mid(0,text.count()/4).isRightToLeft());
- QCOMPARE(textEdit.isRightToLeft(text.count()/4,3*text.count()/4), text.mid(text.count()/4,3*text.count()/4).isRightToLeft());
- if (text.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML TextEdit: isRightToLeft(start, end) called with the end property being smaller than the start.");
- QCOMPARE(textEdit.isRightToLeft(3*text.count()/4,text.count()-1), text.mid(3*text.count()/4,text.count()-1).isRightToLeft());
-
- // then test that the feature actually works
- QCOMPARE(textEdit.isRightToLeft(0,0), emptyString);
- QCOMPARE(textEdit.isRightToLeft(0,1), firstCharacter);
- QCOMPARE(textEdit.isRightToLeft(text.count()-2, text.count()-1), lastCharacter);
- QCOMPARE(textEdit.isRightToLeft(text.count()/2, text.count()/2 + 1), middleCharacter);
- QCOMPARE(textEdit.isRightToLeft(0,text.count()/4), startString);
- QCOMPARE(textEdit.isRightToLeft(text.count()/4,3*text.count()/4), midString);
- if (text.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML TextEdit: isRightToLeft(start, end) called with the end property being smaller than the start.");
- QCOMPARE(textEdit.isRightToLeft(3*text.count()/4,text.count()-1), endString);
-}
-
-void tst_qdeclarativetextedit::keySelection()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/navigation.qml");
- canvas->show();
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
- canvas->setFocus();
-
- QVERIFY(canvas->rootObject() != 0);
-
- QDeclarative1TextEdit *input = qobject_cast<QDeclarative1TextEdit *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
-
- QVERIFY(input != 0);
- QTRY_VERIFY(input->hasActiveFocus() == true);
-
- QSignalSpy spy(input, SIGNAL(selectionChanged()));
-
- simulateKey(canvas, Qt::Key_Right, Qt::ShiftModifier);
- QVERIFY(input->hasActiveFocus() == true);
- QCOMPARE(input->selectedText(), QString("a"));
- QCOMPARE(spy.count(), 1);
- simulateKey(canvas, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == true);
- QCOMPARE(input->selectedText(), QString());
- QCOMPARE(spy.count(), 2);
- simulateKey(canvas, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == false);
- QCOMPARE(input->selectedText(), QString());
- QCOMPARE(spy.count(), 2);
-
- simulateKey(canvas, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == true);
- QCOMPARE(spy.count(), 2);
- simulateKey(canvas, Qt::Key_Left, Qt::ShiftModifier);
- QVERIFY(input->hasActiveFocus() == true);
- QCOMPARE(input->selectedText(), QString("a"));
- QCOMPARE(spy.count(), 3);
- simulateKey(canvas, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == true);
- QCOMPARE(input->selectedText(), QString());
- QCOMPARE(spy.count(), 4);
- simulateKey(canvas, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == false);
- QCOMPARE(input->selectedText(), QString());
- QCOMPARE(spy.count(), 4);
-
- delete canvas;
-}
-
-void tst_qdeclarativetextedit::moveCursorSelection_data()
-{
- QTest::addColumn<QString>("testStr");
- QTest::addColumn<int>("cursorPosition");
- QTest::addColumn<int>("movePosition");
- QTest::addColumn<QDeclarative1TextEdit::SelectionMode>("mode");
- QTest::addColumn<int>("selectionStart");
- QTest::addColumn<int>("selectionEnd");
- QTest::addColumn<bool>("reversible");
-
- QTest::newRow("(t)he|characters")
- << standard[0] << 0 << 1 << QDeclarative1TextEdit::SelectCharacters << 0 << 1 << true;
- QTest::newRow("do(g)|characters")
- << standard[0] << 43 << 44 << QDeclarative1TextEdit::SelectCharacters << 43 << 44 << true;
- QTest::newRow("jum(p)ed|characters")
- << standard[0] << 23 << 24 << QDeclarative1TextEdit::SelectCharacters << 23 << 24 << true;
- QTest::newRow("jumped( )over|characters")
- << standard[0] << 26 << 27 << QDeclarative1TextEdit::SelectCharacters << 26 << 27 << true;
- QTest::newRow("(the )|characters")
- << standard[0] << 0 << 4 << QDeclarative1TextEdit::SelectCharacters << 0 << 4 << true;
- QTest::newRow("( dog)|characters")
- << standard[0] << 40 << 44 << QDeclarative1TextEdit::SelectCharacters << 40 << 44 << true;
- QTest::newRow("( jumped )|characters")
- << standard[0] << 19 << 27 << QDeclarative1TextEdit::SelectCharacters << 19 << 27 << true;
- QTest::newRow("th(e qu)ick|characters")
- << standard[0] << 2 << 6 << QDeclarative1TextEdit::SelectCharacters << 2 << 6 << true;
- QTest::newRow("la(zy d)og|characters")
- << standard[0] << 38 << 42 << QDeclarative1TextEdit::SelectCharacters << 38 << 42 << true;
- QTest::newRow("jum(ped ov)er|characters")
- << standard[0] << 23 << 29 << QDeclarative1TextEdit::SelectCharacters << 23 << 29 << true;
- QTest::newRow("()the|characters")
- << standard[0] << 0 << 0 << QDeclarative1TextEdit::SelectCharacters << 0 << 0 << true;
- QTest::newRow("dog()|characters")
- << standard[0] << 44 << 44 << QDeclarative1TextEdit::SelectCharacters << 44 << 44 << true;
- QTest::newRow("jum()ped|characters")
- << standard[0] << 23 << 23 << QDeclarative1TextEdit::SelectCharacters << 23 << 23 << true;
-
- QTest::newRow("<(t)he>|words")
- << standard[0] << 0 << 1 << QDeclarative1TextEdit::SelectWords << 0 << 3 << true;
- QTest::newRow("<do(g)>|words")
- << standard[0] << 43 << 44 << QDeclarative1TextEdit::SelectWords << 41 << 44 << true;
- QTest::newRow("<jum(p)ed>|words")
- << standard[0] << 23 << 24 << QDeclarative1TextEdit::SelectWords << 20 << 26 << true;
- QTest::newRow("<jumped( )>over|words")
- << standard[0] << 26 << 27 << QDeclarative1TextEdit::SelectWords << 20 << 27 << false;
- QTest::newRow("jumped<( )over>|words,reversed")
- << standard[0] << 27 << 26 << QDeclarative1TextEdit::SelectWords << 26 << 31 << false;
- QTest::newRow("<(the )>quick|words")
- << standard[0] << 0 << 4 << QDeclarative1TextEdit::SelectWords << 0 << 4 << false;
- QTest::newRow("<(the )quick>|words,reversed")
- << standard[0] << 4 << 0 << QDeclarative1TextEdit::SelectWords << 0 << 9 << false;
- QTest::newRow("<lazy( dog)>|words")
- << standard[0] << 40 << 44 << QDeclarative1TextEdit::SelectWords << 36 << 44 << false;
- QTest::newRow("lazy<( dog)>|words,reversed")
- << standard[0] << 44 << 40 << QDeclarative1TextEdit::SelectWords << 40 << 44 << false;
- QTest::newRow("<fox( jumped )>over|words")
- << standard[0] << 19 << 27 << QDeclarative1TextEdit::SelectWords << 16 << 27 << false;
- QTest::newRow("fox<( jumped )over>|words,reversed")
- << standard[0] << 27 << 19 << QDeclarative1TextEdit::SelectWords << 19 << 31 << false;
- QTest::newRow("<th(e qu)ick>|words")
- << standard[0] << 2 << 6 << QDeclarative1TextEdit::SelectWords << 0 << 9 << true;
- QTest::newRow("<la(zy d)og|words>")
- << standard[0] << 38 << 42 << QDeclarative1TextEdit::SelectWords << 36 << 44 << true;
- QTest::newRow("<jum(ped ov)er>|words")
- << standard[0] << 23 << 29 << QDeclarative1TextEdit::SelectWords << 20 << 31 << true;
- QTest::newRow("<()>the|words")
- << standard[0] << 0 << 0 << QDeclarative1TextEdit::SelectWords << 0 << 0 << true;
- QTest::newRow("dog<()>|words")
- << standard[0] << 44 << 44 << QDeclarative1TextEdit::SelectWords << 44 << 44 << true;
- QTest::newRow("jum<()>ped|words")
- << standard[0] << 23 << 23 << QDeclarative1TextEdit::SelectWords << 23 << 23 << true;
-
- QTest::newRow("Hello<(,)> |words")
- << standard[2] << 5 << 6 << QDeclarative1TextEdit::SelectWords << 5 << 6 << true;
- QTest::newRow("Hello<(, )>world|words")
- << standard[2] << 5 << 7 << QDeclarative1TextEdit::SelectWords << 5 << 7 << false;
- QTest::newRow("Hello<(, )world>|words,reversed")
- << standard[2] << 7 << 5 << QDeclarative1TextEdit::SelectWords << 5 << 12 << false;
- QTest::newRow("<Hel(lo, )>world|words")
- << standard[2] << 3 << 7 << QDeclarative1TextEdit::SelectWords << 0 << 7 << false;
- QTest::newRow("<Hel(lo, )world>|words,reversed")
- << standard[2] << 7 << 3 << QDeclarative1TextEdit::SelectWords << 0 << 12 << false;
- QTest::newRow("<Hel(lo)>,|words")
- << standard[2] << 3 << 5 << QDeclarative1TextEdit::SelectWords << 0 << 5 << true;
- QTest::newRow("Hello<()>,|words")
- << standard[2] << 5 << 5 << QDeclarative1TextEdit::SelectWords << 5 << 5 << true;
- QTest::newRow("Hello,<()>|words")
- << standard[2] << 6 << 6 << QDeclarative1TextEdit::SelectWords << 6 << 6 << true;
- QTest::newRow("Hello<,( )>world|words")
- << standard[2] << 6 << 7 << QDeclarative1TextEdit::SelectWords << 5 << 7 << false;
- QTest::newRow("Hello,<( )world>|words,reversed")
- << standard[2] << 7 << 6 << QDeclarative1TextEdit::SelectWords << 6 << 12 << false;
- QTest::newRow("Hello<,( world)>|words")
- << standard[2] << 6 << 12 << QDeclarative1TextEdit::SelectWords << 5 << 12 << false;
- QTest::newRow("Hello,<( world)>|words,reversed")
- << standard[2] << 12 << 6 << QDeclarative1TextEdit::SelectWords << 6 << 12 << false;
- QTest::newRow("Hello<,( world!)>|words")
- << standard[2] << 6 << 13 << QDeclarative1TextEdit::SelectWords << 5 << 13 << false;
- QTest::newRow("Hello,<( world!)>|words,reversed")
- << standard[2] << 13 << 6 << QDeclarative1TextEdit::SelectWords << 6 << 13 << false;
- QTest::newRow("Hello<(, world!)>|words")
- << standard[2] << 5 << 13 << QDeclarative1TextEdit::SelectWords << 5 << 13 << true;
- QTest::newRow("world<(!)>|words")
- << standard[2] << 12 << 13 << QDeclarative1TextEdit::SelectWords << 12 << 13 << true;
- QTest::newRow("world!<()>)|words")
- << standard[2] << 13 << 13 << QDeclarative1TextEdit::SelectWords << 13 << 13 << true;
- QTest::newRow("world<()>!)|words")
- << standard[2] << 12 << 12 << QDeclarative1TextEdit::SelectWords << 12 << 12 << true;
-
- QTest::newRow("<(,)>olleH |words")
- << standard[3] << 7 << 8 << QDeclarative1TextEdit::SelectWords << 7 << 8 << true;
- QTest::newRow("<dlrow( ,)>olleH|words")
- << standard[3] << 6 << 8 << QDeclarative1TextEdit::SelectWords << 1 << 8 << false;
- QTest::newRow("dlrow<( ,)>olleH|words,reversed")
- << standard[3] << 8 << 6 << QDeclarative1TextEdit::SelectWords << 6 << 8 << false;
- QTest::newRow("<dlrow( ,ol)leH>|words")
- << standard[3] << 6 << 10 << QDeclarative1TextEdit::SelectWords << 1 << 13 << false;
- QTest::newRow("dlrow<( ,ol)leH>|words,reversed")
- << standard[3] << 10 << 6 << QDeclarative1TextEdit::SelectWords << 6 << 13 << false;
- QTest::newRow(",<(ol)leH>,|words")
- << standard[3] << 8 << 10 << QDeclarative1TextEdit::SelectWords << 8 << 13 << true;
- QTest::newRow(",<()>olleH|words")
- << standard[3] << 8 << 8 << QDeclarative1TextEdit::SelectWords << 8 << 8 << true;
- QTest::newRow("<()>,olleH|words")
- << standard[3] << 7 << 7 << QDeclarative1TextEdit::SelectWords << 7 << 7 << true;
- QTest::newRow("<dlrow( )>,olleH|words")
- << standard[3] << 6 << 7 << QDeclarative1TextEdit::SelectWords << 1 << 7 << false;
- QTest::newRow("dlrow<( ),>olleH|words,reversed")
- << standard[3] << 7 << 6 << QDeclarative1TextEdit::SelectWords << 6 << 8 << false;
- QTest::newRow("<(dlrow )>,olleH|words")
- << standard[3] << 1 << 7 << QDeclarative1TextEdit::SelectWords << 1 << 7 << false;
- QTest::newRow("<(dlrow ),>olleH|words,reversed")
- << standard[3] << 7 << 1 << QDeclarative1TextEdit::SelectWords << 1 << 8 << false;
- QTest::newRow("<(!dlrow )>,olleH|words")
- << standard[3] << 0 << 7 << QDeclarative1TextEdit::SelectWords << 0 << 7 << false;
- QTest::newRow("<(!dlrow ),>olleH|words,reversed")
- << standard[3] << 7 << 0 << QDeclarative1TextEdit::SelectWords << 0 << 8 << false;
- QTest::newRow("(!dlrow ,)olleH|words")
- << standard[3] << 0 << 8 << QDeclarative1TextEdit::SelectWords << 0 << 8 << true;
- QTest::newRow("<(!)>dlrow|words")
- << standard[3] << 0 << 1 << QDeclarative1TextEdit::SelectWords << 0 << 1 << true;
- QTest::newRow("<()>!dlrow|words")
- << standard[3] << 0 << 0 << QDeclarative1TextEdit::SelectWords << 0 << 0 << true;
- QTest::newRow("!<()>dlrow|words")
- << standard[3] << 1 << 1 << QDeclarative1TextEdit::SelectWords << 1 << 1 << true;
-}
-
-void tst_qdeclarativetextedit::moveCursorSelection()
-{
- QFETCH(QString, testStr);
- QFETCH(int, cursorPosition);
- QFETCH(int, movePosition);
- QFETCH(QDeclarative1TextEdit::SelectionMode, mode);
- QFETCH(int, selectionStart);
- QFETCH(int, selectionEnd);
- QFETCH(bool, reversible);
-
- QString componentStr = "import QtQuick 1.1\nTextEdit { text: \""+ testStr +"\"; }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *texteditObject = qobject_cast<QDeclarative1TextEdit*>(textinputComponent.create());
- QVERIFY(texteditObject != 0);
-
- texteditObject->setCursorPosition(cursorPosition);
- texteditObject->moveCursorSelection(movePosition, mode);
-
- QCOMPARE(texteditObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart));
- QCOMPARE(texteditObject->selectionStart(), selectionStart);
- QCOMPARE(texteditObject->selectionEnd(), selectionEnd);
-
- if (reversible) {
- texteditObject->setCursorPosition(movePosition);
- texteditObject->moveCursorSelection(cursorPosition, mode);
-
- QCOMPARE(texteditObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart));
- QCOMPARE(texteditObject->selectionStart(), selectionStart);
- QCOMPARE(texteditObject->selectionEnd(), selectionEnd);
- }
-}
-
-void tst_qdeclarativetextedit::moveCursorSelectionSequence_data()
-{
- QTest::addColumn<QString>("testStr");
- QTest::addColumn<int>("cursorPosition");
- QTest::addColumn<int>("movePosition1");
- QTest::addColumn<int>("movePosition2");
- QTest::addColumn<int>("selection1Start");
- QTest::addColumn<int>("selection1End");
- QTest::addColumn<int>("selection2Start");
- QTest::addColumn<int>("selection2End");
-
- QTest::newRow("the {<quick( bro)wn> f^ox} jumped|ltr")
- << standard[0]
- << 9 << 13 << 17
- << 4 << 15
- << 4 << 19;
- QTest::newRow("the quick<( {bro)wn> f^ox} jumped|rtl")
- << standard[0]
- << 13 << 9 << 17
- << 9 << 15
- << 10 << 19;
- QTest::newRow("the {<quick( bro)wn> ^}fox jumped|ltr")
- << standard[0]
- << 9 << 13 << 16
- << 4 << 15
- << 4 << 16;
- QTest::newRow("the quick<( {bro)wn> ^}fox jumped|rtl")
- << standard[0]
- << 13 << 9 << 16
- << 9 << 15
- << 10 << 16;
- QTest::newRow("the {<quick( bro)wn^>} fox jumped|ltr")
- << standard[0]
- << 9 << 13 << 15
- << 4 << 15
- << 4 << 15;
- QTest::newRow("the quick<( {bro)wn^>} f^ox jumped|rtl")
- << standard[0]
- << 13 << 9 << 15
- << 9 << 15
- << 10 << 15;
- QTest::newRow("the {<quick() ^}bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 10
- << 4 << 15
- << 4 << 10;
- QTest::newRow("the quick<(^ {^bro)wn>} fox|rtl")
- << standard[0]
- << 13 << 9 << 10
- << 9 << 15
- << 10 << 15;
- QTest::newRow("the {<quick^}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 9
- << 4 << 15
- << 4 << 9;
- QTest::newRow("the quick{<(^ bro)wn>} fox|rtl")
- << standard[0]
- << 13 << 9 << 9
- << 9 << 15
- << 9 << 15;
- QTest::newRow("the {<qui^ck}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 7
- << 4 << 15
- << 4 << 9;
- QTest::newRow("the {<qui^ck}( bro)wn> fox|rtl")
- << standard[0]
- << 13 << 9 << 7
- << 9 << 15
- << 4 << 15;
- QTest::newRow("the {<^quick}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 4
- << 4 << 15
- << 4 << 9;
- QTest::newRow("the {<^quick}( bro)wn> fox|rtl")
- << standard[0]
- << 13 << 9 << 4
- << 9 << 15
- << 4 << 15;
- QTest::newRow("the{^ <quick}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 3
- << 4 << 15
- << 3 << 9;
- QTest::newRow("the{^ <quick}( bro)wn> fox|rtl")
- << standard[0]
- << 13 << 9 << 3
- << 9 << 15
- << 3 << 15;
- QTest::newRow("{t^he <quick}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 1
- << 4 << 15
- << 0 << 9;
- QTest::newRow("{t^he <quick}( bro)wn> fox|rtl")
- << standard[0]
- << 13 << 9 << 1
- << 9 << 15
- << 0 << 15;
-
- QTest::newRow("{<He(ll)o>, w^orld}!|ltr")
- << standard[2]
- << 2 << 4 << 8
- << 0 << 5
- << 0 << 12;
- QTest::newRow("{<He(ll)o>, w^orld}!|rtl")
- << standard[2]
- << 4 << 2 << 8
- << 0 << 5
- << 0 << 12;
-
- QTest::newRow("!{dlro^w ,<o(ll)eH>}|ltr")
- << standard[3]
- << 9 << 11 << 5
- << 8 << 13
- << 1 << 13;
- QTest::newRow("!{dlro^w ,<o(ll)eH>}|rtl")
- << standard[3]
- << 11 << 9 << 5
- << 8 << 13
- << 1 << 13;
-}
-
-void tst_qdeclarativetextedit::moveCursorSelectionSequence()
-{
- QFETCH(QString, testStr);
- QFETCH(int, cursorPosition);
- QFETCH(int, movePosition1);
- QFETCH(int, movePosition2);
- QFETCH(int, selection1Start);
- QFETCH(int, selection1End);
- QFETCH(int, selection2Start);
- QFETCH(int, selection2End);
-
- QString componentStr = "import QtQuick 1.1\nTextEdit { text: \""+ testStr +"\"; }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *texteditObject = qobject_cast<QDeclarative1TextEdit*>(texteditComponent.create());
- QVERIFY(texteditObject != 0);
-
- texteditObject->setCursorPosition(cursorPosition);
-
- texteditObject->moveCursorSelection(movePosition1, QDeclarative1TextEdit::SelectWords);
- QCOMPARE(texteditObject->selectedText(), testStr.mid(selection1Start, selection1End - selection1Start));
- QCOMPARE(texteditObject->selectionStart(), selection1Start);
- QCOMPARE(texteditObject->selectionEnd(), selection1End);
-
- texteditObject->moveCursorSelection(movePosition2, QDeclarative1TextEdit::SelectWords);
- QCOMPARE(texteditObject->selectedText(), testStr.mid(selection2Start, selection2End - selection2Start));
- QCOMPARE(texteditObject->selectionStart(), selection2Start);
- QCOMPARE(texteditObject->selectionEnd(), selection2End);
-}
-
-
-void tst_qdeclarativetextedit::mouseSelection_data()
-{
- QTest::addColumn<QString>("qmlfile");
- QTest::addColumn<int>("from");
- QTest::addColumn<int>("to");
- QTest::addColumn<QString>("selectedText");
-
- // import installed
- QTest::newRow("on") << SRCDIR "/data/mouseselection_true.qml" << 4 << 9 << "45678";
- QTest::newRow("off") << SRCDIR "/data/mouseselection_false.qml" << 4 << 9 << QString();
- QTest::newRow("default") << SRCDIR "/data/mouseselection_default.qml" << 4 << 9 << QString();
- QTest::newRow("off word selection") << SRCDIR "/data/mouseselection_false_words.qml" << 4 << 9 << QString();
- QTest::newRow("on word selection (4,9)") << SRCDIR "/data/mouseselection_true_words.qml" << 4 << 9 << "0123456789";
- QTest::newRow("on word selection (2,13)") << SRCDIR "/data/mouseselection_true_words.qml" << 2 << 13 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- QTest::newRow("on word selection (2,30)") << SRCDIR "/data/mouseselection_true_words.qml" << 2 << 30 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- QTest::newRow("on word selection (9,13)") << SRCDIR "/data/mouseselection_true_words.qml" << 9 << 13 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- QTest::newRow("on word selection (9,30)") << SRCDIR "/data/mouseselection_true_words.qml" << 9 << 30 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- QTest::newRow("on word selection (13,2)") << SRCDIR "/data/mouseselection_true_words.qml" << 13 << 2 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- QTest::newRow("on word selection (20,2)") << SRCDIR "/data/mouseselection_true_words.qml" << 20 << 2 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- QTest::newRow("on word selection (12,9)") << SRCDIR "/data/mouseselection_true_words.qml" << 12 << 9 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- QTest::newRow("on word selection (30,9)") << SRCDIR "/data/mouseselection_true_words.qml" << 30 << 9 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
-}
-
-void tst_qdeclarativetextedit::mouseSelection()
-{
- QFETCH(QString, qmlfile);
- QFETCH(int, from);
- QFETCH(int, to);
- QFETCH(QString, selectedText);
-
- QDeclarativeView *canvas = createView(qmlfile);
-
- canvas->show();
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
-
- QVERIFY(canvas->rootObject() != 0);
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit *>(canvas->rootObject());
- QVERIFY(textEditObject != 0);
-
- // press-and-drag-and-release from x1 to x2
- QPoint p1 = canvas->mapFromScene(textEditObject->positionToRectangle(from).center());
- QPoint p2 = canvas->mapFromScene(textEditObject->positionToRectangle(to).center());
- QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, p1);
- //QTest::mouseMove(canvas->viewport(), canvas->mapFromScene(QPoint(x2,y))); // doesn't work
- QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(p2), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(canvas->viewport(), &mv);
- QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, p2);
- QCOMPARE(textEditObject->selectedText(), selectedText);
-
- // Clicking and shift to clicking between the same points should select the same text.
- textEditObject->setCursorPosition(0);
- QTest::mouseClick(canvas->viewport(), Qt::LeftButton, Qt::NoModifier, p1);
- QTest::mouseClick(canvas->viewport(), Qt::LeftButton, Qt::ShiftModifier, p2);
- QCOMPARE(textEditObject->selectedText(), selectedText);
-
- delete canvas;
-}
-
-void tst_qdeclarativetextedit::multilineMouseSelection()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/mouseselection_multiline.qml");
-
- canvas->show();
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
-
- QVERIFY(canvas->rootObject() != 0);
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit *>(canvas->rootObject());
- QVERIFY(textEditObject != 0);
-
- // press-and-drag from x1,y1 to x2,y1
- int x1 = 10;
- int x2 = textEditObject->width() - 10;
- int y1 = textEditObject->height() / 4;
- int y2 = textEditObject->height() * 3 / 4;
- QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y1)));
- QMouseEvent mv1(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y1)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(canvas->viewport(), &mv1);
- QString str1 = textEditObject->selectedText();
- QVERIFY(str1.length() > 3); // don't reallly care *what* was selected (and it's too sensitive to platform)
-
- // drag-and-release from x2,y1 to x2,y2
- QMouseEvent mv2(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y2)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(canvas->viewport(), &mv2);
- QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x2,y2)));
- QString str2 = textEditObject->selectedText();
- QVERIFY(str1 != str2);
- QVERIFY(str2.length() > 3);
-
- delete canvas;
-}
-
-void tst_qdeclarativetextedit::deferEnableSelectByMouse_data()
-{
- QTest::addColumn<QString>("qmlfile");
-
- QTest::newRow("writable") << SRCDIR "/data/mouseselection_false.qml";
- QTest::newRow("read only") << SRCDIR "/data/mouseselection_false_readonly.qml";
-}
-
-void tst_qdeclarativetextedit::deferEnableSelectByMouse()
-{
- // Verify text isn't selected if selectByMouse is enabled after the mouse button has been pressed.
- QFETCH(QString, qmlfile);
-
- QDeclarativeView *canvas = createView(qmlfile);
-
- canvas->show();
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
-
- QVERIFY(canvas->rootObject() != 0);
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit *>(canvas->rootObject());
- QVERIFY(textEditObject != 0);
-
- // press-and-drag-and-release from x1 to x2
- int x1 = 10;
- int x2 = 70;
- int y = textEditObject->height()/2;
-
- QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y)));
- textEditObject->setSelectByMouse(true);
- //QTest::mouseMove(canvas->viewport(), canvas->mapFromScene(QPoint(x2,y))); // doesn't work
- QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(canvas->viewport(), &mv);
- QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x2,y)));
- QVERIFY(textEditObject->selectedText().isEmpty());
-
- delete canvas;
-}
-
-void tst_qdeclarativetextedit::deferDisableSelectByMouse_data()
-{
- QTest::addColumn<QString>("qmlfile");
-
- QTest::newRow("writable") << SRCDIR "/data/mouseselection_true.qml";
- QTest::newRow("read only") << SRCDIR "/data/mouseselection_true_readonly.qml";
-}
-
-void tst_qdeclarativetextedit::deferDisableSelectByMouse()
-{
- // Verify text isn't selected if selectByMouse is enabled after the mouse button has been pressed.
- QFETCH(QString, qmlfile);
-
- QDeclarativeView *canvas = createView(qmlfile);
-
- canvas->show();
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
-
- QVERIFY(canvas->rootObject() != 0);
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit *>(canvas->rootObject());
- QVERIFY(textEditObject != 0);
-
- // press-and-drag-and-release from x1 to x2
- int x1 = 10;
- int x2 = 70;
- int y = textEditObject->height()/2;
-
- QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y)));
- textEditObject->setSelectByMouse(false);
- //QTest::mouseMove(canvas->viewport(), canvas->mapFromScene(QPoint(x2,y))); // doesn't work
- QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(canvas->viewport(), &mv);
- QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x2,y)));
- QVERIFY(textEditObject->selectedText().length() > 3);
-
- delete canvas;
-}
-
-void tst_qdeclarativetextedit::dragMouseSelection()
-{
- QString qmlfile = SRCDIR "/data/mouseselection_true.qml";
-
- QDeclarativeView *canvas = createView(qmlfile);
-
- canvas->show();
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
-
- QVERIFY(canvas->rootObject() != 0);
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit *>(canvas->rootObject());
- QVERIFY(textEditObject != 0);
-
- textEditObject->setAcceptDrops(true);
-
- // press-and-drag-and-release from x1 to x2
- int x1 = 10;
- int x2 = 70;
- int y = textEditObject->height()/2;
- QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y)));
- {
- QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(canvas->viewport(), &mv);
- }
- QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x2,y)));
- QString str1 = textEditObject->selectedText();
- QVERIFY(str1.length() > 3);
-
- // press and drag the current selection.
- x1 = 40;
- x2 = 100;
- QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y)));
- {
- QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(canvas->viewport(), &mv);
- }
- QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x2,y)));
- QString str2 = textEditObject->selectedText();
- QVERIFY(str2.length() > 3);
-
- QVERIFY(str1 != str2); // Verify the second press and drag is a new selection and doesn't not the first moved.
-
- delete canvas;
-}
-
-void tst_qdeclarativetextedit::mouseSelectionMode_data()
-{
- QTest::addColumn<QString>("qmlfile");
- QTest::addColumn<bool>("selectWords");
-
- // import installed
- QTest::newRow("SelectWords") << SRCDIR "/data/mouseselectionmode_words.qml" << true;
- QTest::newRow("SelectCharacters") << SRCDIR "/data/mouseselectionmode_characters.qml" << false;
- QTest::newRow("default") << SRCDIR "/data/mouseselectionmode_default.qml" << false;
-}
-
-void tst_qdeclarativetextedit::mouseSelectionMode()
-{
- QFETCH(QString, qmlfile);
- QFETCH(bool, selectWords);
-
- QString text = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
-
- QDeclarativeView *canvas = createView(qmlfile);
-
- canvas->show();
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
-
- QVERIFY(canvas->rootObject() != 0);
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit *>(canvas->rootObject());
- QVERIFY(textEditObject != 0);
-
- // press-and-drag-and-release from x1 to x2
- int x1 = 10;
- int x2 = 70;
- int y = textEditObject->height()/2;
- QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y)));
- //QTest::mouseMove(canvas->viewport(), canvas->mapFromScene(QPoint(x2,y))); // doesn't work
- QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(canvas->viewport(), &mv);
- QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x2,y)));
- QString str = textEditObject->selectedText();
- if (selectWords) {
- QCOMPARE(str, text);
- } else {
- QVERIFY(str.length() > 3);
- QVERIFY(str != text);
- }
-
- // Clicking and shift to clicking between the same points should select the same text.
- textEditObject->setCursorPosition(0);
- QTest::mouseClick(canvas->viewport(), Qt::LeftButton, Qt::NoModifier, canvas->mapFromScene(QPoint(x1,y)));
- QTest::mouseClick(canvas->viewport(), Qt::LeftButton, Qt::ShiftModifier, canvas->mapFromScene(QPoint(x2,y)));
- QCOMPARE(textEditObject->selectedText(), str);
-
- delete canvas;
-}
-
-void tst_qdeclarativetextedit::inputMethodHints()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/inputmethodhints.qml");
- canvas->show();
- canvas->setFocus();
-
- QVERIFY(canvas->rootObject() != 0);
- QDeclarative1TextEdit *textEditObject = qobject_cast<QDeclarative1TextEdit *>(canvas->rootObject());
- QVERIFY(textEditObject != 0);
- QVERIFY(textEditObject->inputMethodHints() & Qt::ImhNoPredictiveText);
- textEditObject->setInputMethodHints(Qt::ImhUppercaseOnly);
- QVERIFY(textEditObject->inputMethodHints() & Qt::ImhUppercaseOnly);
-
- delete canvas;
-}
-
-void tst_qdeclarativetextedit::positionAt()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/positionAt.qml");
- QVERIFY(canvas->rootObject() != 0);
- canvas->show();
- canvas->setFocus();
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
-
- QDeclarative1TextEdit *texteditObject = qobject_cast<QDeclarative1TextEdit *>(canvas->rootObject());
- QVERIFY(texteditObject != 0);
-
- QTextLayout layout(texteditObject->text());
- layout.setFont(texteditObject->font());
-
- layout.beginLayout();
- QTextLine line = layout.createLine();
- layout.endLayout();
-
- const int y0 = line.height() / 2;
- const int y1 = line.height() * 3 / 2;
-
- int pos = texteditObject->positionAt(texteditObject->width()/2, y0);
-
- int widthBegin = floor(line.cursorToX(pos - 1));
- int widthEnd = ceil(line.cursorToX(pos + 1));
-
- QVERIFY(widthBegin <= texteditObject->width() / 2);
- QVERIFY(widthEnd >= texteditObject->width() / 2);
-
- const qreal x0 = texteditObject->positionToRectangle(pos).x();
- const qreal x1 = texteditObject->positionToRectangle(pos + 1).x();
-
- QString preeditText = texteditObject->text().mid(0, pos);
- texteditObject->setText(texteditObject->text().mid(pos));
- texteditObject->setCursorPosition(0);
-
- QInputMethodEvent inputEvent(preeditText, QList<QInputMethodEvent::Attribute>());
- QApplication::sendEvent(canvas, &inputEvent);
-
- // Check all points within the preedit text return the same position.
- QCOMPARE(texteditObject->positionAt(0, y0), 0);
- QCOMPARE(texteditObject->positionAt(x0 / 2, y0), 0);
- QCOMPARE(texteditObject->positionAt(x0, y0), 0);
-
- // Verify positioning returns to normal after the preedit text.
- QCOMPARE(texteditObject->positionAt(x1, y0), 1);
- QCOMPARE(texteditObject->positionToRectangle(1).x(), x1);
-
- QVERIFY(texteditObject->positionAt(x0 / 2, y1) > 0);
-
- delete canvas;
-}
-
-void tst_qdeclarativetextedit::cursorDelegate()
-{
- QDeclarativeView* view = createView(SRCDIR "/data/cursorTest.qml");
- view->show();
- view->setFocus();
- QDeclarative1TextEdit *textEditObject = view->rootObject()->findChild<QDeclarative1TextEdit*>("textEditObject");
- QVERIFY(textEditObject != 0);
- QVERIFY(textEditObject->findChild<QDeclarativeItem*>("cursorInstance"));
- //Test Delegate gets created
- textEditObject->setFocus(true);
- QDeclarativeItem* delegateObject = textEditObject->findChild<QDeclarativeItem*>("cursorInstance");
- QVERIFY(delegateObject);
- //Test Delegate gets moved
- for(int i=0; i<= textEditObject->text().length(); i++){
- textEditObject->setCursorPosition(i);
- QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
- QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
- }
- const QString preedit = "preedit";
- for (int i = 0; i <= preedit.length(); i++) {
- QInputMethodEvent event(preedit, QList<QInputMethodEvent::Attribute>()
- << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, i, 1, QVariant()));
- QApplication::sendEvent(view, &event);
-
- QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
- QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
- }
- // Clear preedit text;
- QInputMethodEvent event;
- QApplication::sendEvent(view, &event);
-
-
- // Test delegate gets moved on mouse press.
- textEditObject->setSelectByMouse(true);
- textEditObject->setCursorPosition(0);
- const QPoint point1 = view->mapFromScene(textEditObject->positionToRectangle(5).center());
- QTest::mouseClick(view->viewport(), Qt::LeftButton, 0, point1);
- QVERIFY(textEditObject->cursorPosition() != 0);
- QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
- QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
-
- // Test delegate gets moved on mouse drag
- textEditObject->setCursorPosition(0);
- const QPoint point2 = view->mapFromScene(textEditObject->positionToRectangle(10).center());
- QTest::mousePress(view->viewport(), Qt::LeftButton, 0, point1);
- QMouseEvent mv(QEvent::MouseMove, point2, Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(view->viewport(), &mv);
- QTest::mouseRelease(view->viewport(), Qt::LeftButton, 0, point2);
- QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
- QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
-
- textEditObject->setReadOnly(true);
- textEditObject->setCursorPosition(0);
- QTest::mouseClick(view->viewport(), Qt::LeftButton, 0, view->mapFromScene(textEditObject->positionToRectangle(5).center()));
- QVERIFY(textEditObject->cursorPosition() != 0);
- QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
- QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
-
- textEditObject->setCursorPosition(0);
- QTest::mouseClick(view->viewport(), Qt::LeftButton, 0, view->mapFromScene(textEditObject->positionToRectangle(5).center()));
- QVERIFY(textEditObject->cursorPosition() != 0);
- QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
- QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
-
- textEditObject->setCursorPosition(0);
- QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
- QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
- QVERIFY(textEditObject->cursorRectangle().y() >= 0);
- QVERIFY(textEditObject->cursorRectangle().y() < textEditObject->cursorRectangle().height());
- textEditObject->setVAlign(QDeclarative1TextEdit::AlignVCenter);
- QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
- QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
- QVERIFY(textEditObject->cursorRectangle().y() > (textEditObject->height() / 2) - textEditObject->cursorRectangle().height());
- QVERIFY(textEditObject->cursorRectangle().y() < (textEditObject->height() / 2) + textEditObject->cursorRectangle().height());
- textEditObject->setVAlign(QDeclarative1TextEdit::AlignBottom);
- QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
- QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
- QVERIFY(textEditObject->cursorRectangle().y() > textEditObject->height() - (textEditObject->cursorRectangle().height() * 2));
- QVERIFY(textEditObject->cursorRectangle().y() < textEditObject->height());
-
- //Test Delegate gets deleted
- textEditObject->setCursorDelegate(0);
- QVERIFY(!textEditObject->findChild<QDeclarativeItem*>("cursorInstance"));
-
- delete view;
-}
-
-void tst_qdeclarativetextedit::cursorVisible()
-{
- QGraphicsScene scene;
- QGraphicsView view(&scene);
- view.show();
- QApplication::setActiveWindow(&view);
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
- view.setFocus();
-
- QDeclarative1TextEdit edit;
- QSignalSpy spy(&edit, SIGNAL(cursorVisibleChanged(bool)));
-
- QCOMPARE(edit.isCursorVisible(), false);
-
- edit.setCursorVisible(true);
- QCOMPARE(edit.isCursorVisible(), true);
- QCOMPARE(spy.count(), 1);
-
- edit.setCursorVisible(false);
- QCOMPARE(edit.isCursorVisible(), false);
- QCOMPARE(spy.count(), 2);
-
- edit.setFocus(true);
- QCOMPARE(edit.isCursorVisible(), false);
- QCOMPARE(spy.count(), 2);
-
- scene.addItem(&edit);
- QCOMPARE(edit.isCursorVisible(), true);
- QCOMPARE(spy.count(), 3);
-
- edit.setFocus(false);
- QCOMPARE(edit.isCursorVisible(), false);
- QCOMPARE(spy.count(), 4);
-
- edit.setFocus(true);
- QCOMPARE(edit.isCursorVisible(), true);
- QCOMPARE(spy.count(), 5);
-
- scene.clearFocus();
- QCOMPARE(edit.isCursorVisible(), false);
- QCOMPARE(spy.count(), 6);
-
- scene.setFocus();
- QCOMPARE(edit.isCursorVisible(), true);
- QCOMPARE(spy.count(), 7);
-
- view.clearFocus();
- QCOMPARE(edit.isCursorVisible(), false);
- QCOMPARE(spy.count(), 8);
-
- view.setFocus();
- QCOMPARE(edit.isCursorVisible(), true);
- QCOMPARE(spy.count(), 9);
-
- // on mac, setActiveWindow(0) on mac does not deactivate the current application
- // (you have to switch to a different app or hide the current app to trigger this)
-#if !defined(Q_WS_MAC)
- QApplication::setActiveWindow(0);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(0));
- QCOMPARE(edit.isCursorVisible(), false);
- QCOMPARE(spy.count(), 10);
-
- QApplication::setActiveWindow(&view);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
- QCOMPARE(edit.isCursorVisible(), true);
- QCOMPARE(spy.count(), 11);
-#endif
-}
-
-void tst_qdeclarativetextedit::delegateLoading_data()
-{
- QTest::addColumn<QString>("qmlfile");
- QTest::addColumn<QString>("error");
-
- // import installed
- QTest::newRow("pass") << "cursorHttpTestPass.qml" << "";
- QTest::newRow("fail1") << "cursorHttpTestFail1.qml" << "http://localhost:42332/FailItem.qml: Remote host closed the connection ";
- QTest::newRow("fail2") << "cursorHttpTestFail2.qml" << "http://localhost:42332/ErrItem.qml:4:5: Fungus is not a type ";
-}
-
-void tst_qdeclarativetextedit::delegateLoading()
-{
- QFETCH(QString, qmlfile);
- QFETCH(QString, error);
-
- TestHTTPServer server(42332);
- server.serveDirectory(SRCDIR "/data/httpfail", TestHTTPServer::Disconnect);
- server.serveDirectory(SRCDIR "/data/httpslow", TestHTTPServer::Delay);
- server.serveDirectory(SRCDIR "/data/http");
-
- QDeclarativeView* view = new QDeclarativeView(0);
-
- view->setSource(QUrl(QLatin1String("http://localhost:42332/") + qmlfile));
- view->show();
- view->setFocus();
-
- if (!error.isEmpty()) {
- QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
- QTRY_VERIFY(view->status()==QDeclarativeView::Error);
- QTRY_VERIFY(!view->rootObject()); // there is fail item inside this test
- } else {
- QTRY_VERIFY(view->rootObject());//Wait for loading to finish.
- QDeclarative1TextEdit *textEditObject = view->rootObject()->findChild<QDeclarative1TextEdit*>("textEditObject");
- // view->rootObject()->dumpObjectTree();
- QVERIFY(textEditObject != 0);
- textEditObject->setFocus(true);
- QDeclarativeItem *delegate;
- delegate = view->rootObject()->findChild<QDeclarativeItem*>("delegateOkay");
- QVERIFY(delegate);
- delegate = view->rootObject()->findChild<QDeclarativeItem*>("delegateSlow");
- QVERIFY(delegate);
-
- delete delegate;
- }
-
-
- //A test should be added here with a component which is ready but component.create() returns null
- //Not sure how to accomplish this with QDeclarative1TextEdits cursor delegate
- //###This was only needed for code coverage, and could be a case of overzealous defensive programming
- //delegate = view->rootObject()->findChild<QDeclarativeItem*>("delegateErrorB");
- //QVERIFY(!delegate);
-
- delete view;
-}
-
-/*
-TextEdit element should only handle left/right keys until the cursor reaches
-the extent of the text, then they should ignore the keys.
-*/
-void tst_qdeclarativetextedit::navigation()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/navigation.qml");
- canvas->show();
- canvas->setFocus();
-
- QVERIFY(canvas->rootObject() != 0);
-
- QDeclarativeItem *input = qobject_cast<QDeclarativeItem *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
-
- QVERIFY(input != 0);
- QTRY_VERIFY(input->hasActiveFocus() == true);
- simulateKey(canvas, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == false);
- simulateKey(canvas, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == true);
- simulateKey(canvas, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == true);
- simulateKey(canvas, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == false);
- simulateKey(canvas, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == true);
-
- delete canvas;
-}
-
-void tst_qdeclarativetextedit::copyAndPaste() {
-#ifndef QT_NO_CLIPBOARD
-
-#ifdef Q_WS_MAC
- {
- PasteboardRef pasteboard;
- OSStatus status = PasteboardCreate(0, &pasteboard);
- if (status == noErr)
- CFRelease(pasteboard);
- else
- QSKIP("This machine doesn't support the clipboard");
- }
-#endif
-
- QString componentStr = "import QtQuick 1.0\nTextEdit { text: \"Hello world!\" }";
- QDeclarativeComponent textEditComponent(&engine);
- textEditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *textEdit = qobject_cast<QDeclarative1TextEdit*>(textEditComponent.create());
- QVERIFY(textEdit != 0);
-
- // copy and paste
- QCOMPARE(textEdit->text().length(), 12);
- textEdit->select(0, textEdit->text().length());;
- textEdit->copy();
- QCOMPARE(textEdit->selectedText(), QString("Hello world!"));
- QCOMPARE(textEdit->selectedText().length(), 12);
- textEdit->setCursorPosition(0);
- QVERIFY(textEdit->canPaste());
- textEdit->paste();
- QCOMPARE(textEdit->text(), QString("Hello world!Hello world!"));
- QCOMPARE(textEdit->text().length(), 24);
-
- // canPaste
- QVERIFY(textEdit->canPaste());
- textEdit->setReadOnly(true);
- QVERIFY(!textEdit->canPaste());
- textEdit->setReadOnly(false);
- QVERIFY(textEdit->canPaste());
-
- // QTBUG-12339
- // test that document and internal text attribute are in sync
- QDeclarativeItemPrivate* pri = QDeclarativeItemPrivate::get(textEdit);
- QDeclarative1TextEditPrivate *editPrivate = static_cast<QDeclarative1TextEditPrivate*>(pri);
- QCOMPARE(textEdit->text(), editPrivate->text);
-
- // select word
- textEdit->setCursorPosition(0);
- textEdit->selectWord();
- QCOMPARE(textEdit->selectedText(), QString("Hello"));
-
- // select all and cut
- textEdit->selectAll();
- textEdit->cut();
- QCOMPARE(textEdit->text().length(), 0);
- textEdit->paste();
- QCOMPARE(textEdit->text(), QString("Hello world!Hello world!"));
- QCOMPARE(textEdit->text().length(), 24);
-#endif
-}
-
-void tst_qdeclarativetextedit::canPaste() {
-#ifndef QT_NO_CLIPBOARD
-
- QApplication::clipboard()->setText("Some text");
-
- QString componentStr = "import QtQuick 1.0\nTextEdit { text: \"Hello world!\" }";
- QDeclarativeComponent textEditComponent(&engine);
- textEditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *textEdit = qobject_cast<QDeclarative1TextEdit*>(textEditComponent.create());
- QVERIFY(textEdit != 0);
-
- // check initial value - QTBUG-17765
- QWidgetTextControl tc;
- QCOMPARE(textEdit->canPaste(), tc.canPaste());
-
-#endif
-}
-
-void tst_qdeclarativetextedit::canPasteEmpty() {
-#ifndef QT_NO_CLIPBOARD
-
- QApplication::clipboard()->clear();
-
- QString componentStr = "import QtQuick 1.0\nTextEdit { text: \"Hello world!\" }";
- QDeclarativeComponent textEditComponent(&engine);
- textEditComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextEdit *textEdit = qobject_cast<QDeclarative1TextEdit*>(textEditComponent.create());
- QVERIFY(textEdit != 0);
-
- // check initial value - QTBUG-17765
- QWidgetTextControl tc;
- QCOMPARE(textEdit->canPaste(), tc.canPaste());
-
-#endif
-}
-
-void tst_qdeclarativetextedit::readOnly()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/readOnly.qml");
- canvas->show();
- canvas->setFocus();
-
- QVERIFY(canvas->rootObject() != 0);
-
- QDeclarative1TextEdit *edit = qobject_cast<QDeclarative1TextEdit *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
-
- QVERIFY(edit != 0);
- QTRY_VERIFY(edit->hasActiveFocus() == true);
- QVERIFY(edit->isReadOnly() == true);
- QString initial = edit->text();
- for(int k=Qt::Key_0; k<=Qt::Key_Z; k++)
- simulateKey(canvas, k);
- simulateKey(canvas, Qt::Key_Return);
- simulateKey(canvas, Qt::Key_Space);
- simulateKey(canvas, Qt::Key_Escape);
- QCOMPARE(edit->text(), initial);
-
- delete canvas;
-}
-
-void tst_qdeclarativetextedit::simulateKey(QDeclarativeView *view, int key, Qt::KeyboardModifiers modifiers)
-{
- QKeyEvent press(QKeyEvent::KeyPress, key, modifiers);
- QKeyEvent release(QKeyEvent::KeyRelease, key, modifiers);
-
- QApplication::sendEvent(view, &press);
- QApplication::sendEvent(view, &release);
-}
-
-QDeclarativeView *tst_qdeclarativetextedit::createView(const QString &filename)
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
-
- canvas->setSource(QUrl::fromLocalFile(filename));
- return canvas;
-}
-
-void tst_qdeclarativetextedit::textInput()
-{
- QGraphicsScene scene;
- QGraphicsView view(&scene);
- QDeclarative1TextEdit edit;
- QDeclarativeItemPrivate* pri = QDeclarativeItemPrivate::get(&edit);
- QDeclarative1TextEditPrivate *editPrivate = static_cast<QDeclarative1TextEditPrivate*>(pri);
- edit.setPos(0, 0);
- scene.addItem(&edit);
- view.show();
- QApplication::setActiveWindow(&view);
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
- edit.setFocus(true);
- QVERIFY(edit.hasActiveFocus() == true);
-
- // test that input method event is committed
- QInputMethodEvent event;
- event.setCommitString( "Hello world!", 0, 0);
- QApplication::sendEvent(&view, &event);
- QCOMPARE(edit.text(), QString("Hello world!"));
-
- // QTBUG-12339
- // test that document and internal text attribute are in sync
- QCOMPARE(editPrivate->text, QString("Hello world!"));
-}
-
-void tst_qdeclarativetextedit::openInputPanelOnClick()
-{
- PlatformInputContext ic;
- QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
- inputPanelPrivate->testContext = &ic;
-
- QGraphicsScene scene;
- QGraphicsView view(&scene);
- QDeclarative1TextEdit edit;
- QSignalSpy focusOnPressSpy(&edit, SIGNAL(activeFocusOnPressChanged(bool)));
- edit.setText("Hello world");
- edit.setPos(0, 0);
- scene.addItem(&edit);
- view.show();
- qApp->setAutoSipEnabled(true);
- QApplication::setActiveWindow(&view);
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
-
- QDeclarativeItemPrivate* pri = QDeclarativeItemPrivate::get(&edit);
- QDeclarative1TextEditPrivate *editPrivate = static_cast<QDeclarative1TextEditPrivate*>(pri);
-
- // input panel on click
- editPrivate->showInputPanelOnFocus = false;
-
- QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
- view.style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
- QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
- QApplication::processEvents();
- if (behavior == QStyle::RSIP_OnMouseClickAndAlreadyFocused) {
- QCOMPARE(ic.isInputPanelVisible(), false);
- QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
- QApplication::processEvents();
- QCOMPARE(ic.isInputPanelVisible(), true);
- } else if (behavior == QStyle::RSIP_OnMouseClick) {
- QCOMPARE(ic.isInputPanelVisible(), true);
- }
- ic.clear();
-
- // focus should not cause input panels to open or close
- edit.setFocus(false);
- edit.setFocus(true);
- edit.setFocus(false);
- edit.setFocus(true);
- edit.setFocus(false);
- QApplication::processEvents();
- QCOMPARE(ic.m_showInputPanelCallCount, 0);
- QCOMPARE(ic.m_hideInputPanelCallCount, 0);
-}
-
-void tst_qdeclarativetextedit::openInputPanelOnFocus()
-{
- PlatformInputContext ic;
- QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
- inputPanelPrivate->testContext = &ic;
-
- QGraphicsScene scene;
- QGraphicsView view(&scene);
- QDeclarative1TextEdit edit;
- QSignalSpy focusOnPressSpy(&edit, SIGNAL(activeFocusOnPressChanged(bool)));
- edit.setText("Hello world");
- edit.setPos(0, 0);
- scene.addItem(&edit);
- view.show();
- qApp->setAutoSipEnabled(true);
- QApplication::setActiveWindow(&view);
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
-
- QDeclarativeItemPrivate* pri = QDeclarativeItemPrivate::get(&edit);
- QDeclarative1TextEditPrivate *editPrivate = static_cast<QDeclarative1TextEditPrivate*>(pri);
- editPrivate->showInputPanelOnFocus = true;
-
- // test default values
- QVERIFY(edit.focusOnPress());
- QCOMPARE(ic.m_showInputPanelCallCount, 0);
- QCOMPARE(ic.m_hideInputPanelCallCount, 0);
-
- // focus on press, input panel on focus
- QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
- QApplication::processEvents();
- QVERIFY(edit.hasActiveFocus());
- QCOMPARE(ic.isInputPanelVisible(), true);
- ic.clear();
-
- // no events on release
- QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
- QCOMPARE(ic.isInputPanelVisible(), false);
- ic.clear();
-
- // if already focused, input panel can be opened on press
- QVERIFY(edit.hasActiveFocus());
- QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
- QApplication::processEvents();
- QCOMPARE(ic.isInputPanelVisible(), true);
- ic.clear();
-
- // input method should stay enabled if focus
- // is lost to an item that also accepts inputs
- QDeclarative1TextEdit anotherEdit;
- scene.addItem(&anotherEdit);
- anotherEdit.setFocus(true);
- QApplication::processEvents();
- QCOMPARE(ic.isInputPanelVisible(), true);
- ic.clear();
- QVERIFY(view.testAttribute(Qt::WA_InputMethodEnabled));
-
- // input method should be disabled if focus
- // is lost to an item that doesn't accept inputs
- QDeclarativeItem item;
- scene.addItem(&item);
- item.setFocus(true);
- QApplication::processEvents();
- QCOMPARE(ic.isInputPanelVisible(), false);
- QVERIFY(!view.testAttribute(Qt::WA_InputMethodEnabled));
-
- // no automatic input panel events should
- // be sent if activeFocusOnPress is false
- edit.setFocusOnPress(false);
- QCOMPARE(focusOnPressSpy.count(),1);
- edit.setFocusOnPress(false);
- QCOMPARE(focusOnPressSpy.count(),1);
- edit.setFocus(false);
- edit.setFocus(true);
- QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
- QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
- QApplication::processEvents();
- QCOMPARE(ic.m_showInputPanelCallCount, 0);
- QCOMPARE(ic.m_hideInputPanelCallCount, 0);
-
- // one show input panel event should
- // be set when openSoftwareInputPanel is called
- edit.openSoftwareInputPanel();
- QCOMPARE(ic.isInputPanelVisible(), true);
- QCOMPARE(ic.m_hideInputPanelCallCount, 0);
- ic.clear();
-
- // one close input panel event should
- // be sent when closeSoftwareInputPanel is called
- edit.closeSoftwareInputPanel();
- QCOMPARE(ic.m_showInputPanelCallCount, 0);
- QVERIFY(ic.m_hideInputPanelCallCount > 0);
- ic.clear();
-
- // set activeFocusOnPress back to true
- edit.setFocusOnPress(true);
- QCOMPARE(focusOnPressSpy.count(),2);
- edit.setFocusOnPress(true);
- QCOMPARE(focusOnPressSpy.count(),2);
- edit.setFocus(false);
- QApplication::processEvents();
- QCOMPARE(ic.m_showInputPanelCallCount, 0);
- QCOMPARE(ic.m_hideInputPanelCallCount, 0);
- ic.clear();
-
- // input panel should not re-open
- // if focus has already been set
- edit.setFocus(true);
- QCOMPARE(ic.isInputPanelVisible(), true);
- ic.clear();
- edit.setFocus(true);
- QCOMPARE(ic.isInputPanelVisible(), false);
-
- // input method should be disabled
- // if TextEdit loses focus
- edit.setFocus(false);
- QApplication::processEvents();
- QVERIFY(!view.testAttribute(Qt::WA_InputMethodEnabled));
-
- // input method should not be enabled
- // if TextEdit is read only.
- edit.setReadOnly(true);
- ic.clear();
- edit.setFocus(true);
- QApplication::processEvents();
- QCOMPARE(ic.isInputPanelVisible(), false);
- QVERIFY(!view.testAttribute(Qt::WA_InputMethodEnabled));
-}
-
-void tst_qdeclarativetextedit::geometrySignals()
-{
- QDeclarativeComponent component(&engine, SRCDIR "/data/geometrySignals.qml");
- QObject *o = component.create();
- QVERIFY(o);
- QCOMPARE(o->property("bindingWidth").toInt(), 400);
- QCOMPARE(o->property("bindingHeight").toInt(), 500);
- delete o;
-}
-
-void tst_qdeclarativetextedit::pastingRichText_QTBUG_14003()
-{
-#ifndef QT_NO_CLIPBOARD
- QString componentStr = "import QtQuick 1.0\nTextEdit { textFormat: TextEdit.PlainText }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1TextEdit *obj = qobject_cast<QDeclarative1TextEdit*>(component.create());
-
- QTRY_VERIFY(obj != 0);
- QTRY_VERIFY(obj->textFormat() == QDeclarative1TextEdit::PlainText);
-
- QMimeData *mData = new QMimeData;
- mData->setHtml("<font color=\"red\">Hello</font>");
- QApplication::clipboard()->setMimeData(mData);
-
- obj->paste();
- QTRY_VERIFY(obj->text() == "");
- QTRY_VERIFY(obj->textFormat() == QDeclarative1TextEdit::PlainText);
-#endif
-}
-
-void tst_qdeclarativetextedit::implicitSize_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<QString>("wrap");
- QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog" << "TextEdit.NoWrap";
- QTest::newRow("richtext") << "<b>The quick red fox jumped over the lazy brown dog</b>" << "TextEdit.NoWrap";
- QTest::newRow("plain_wrap") << "The quick red fox jumped over the lazy brown dog" << "TextEdit.Wrap";
- QTest::newRow("richtext_wrap") << "<b>The quick red fox jumped over the lazy brown dog</b>" << "TextEdit.Wrap";
-}
-
-void tst_qdeclarativetextedit::implicitSize()
-{
- QFETCH(QString, text);
- QFETCH(QString, wrap);
- QString componentStr = "import QtQuick 1.1\nTextEdit { text: \"" + text + "\"; width: 50; wrapMode: " + wrap + " }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1TextEdit *textObject = qobject_cast<QDeclarative1TextEdit*>(textComponent.create());
-
- QVERIFY(textObject->width() < textObject->implicitWidth());
- QVERIFY(textObject->height() == textObject->implicitHeight());
-
- textObject->resetWidth();
- QVERIFY(textObject->width() == textObject->implicitWidth());
- QVERIFY(textObject->height() == textObject->implicitHeight());
-}
-
-void tst_qdeclarativetextedit::testQtQuick11Attributes()
-{
- QFETCH(QString, code);
- QFETCH(QString, warning);
- QFETCH(QString, error);
-
- QDeclarativeEngine engine;
- QObject *obj;
-
- QDeclarativeComponent valid(&engine);
- valid.setData("import QtQuick 1.1; TextEdit { " + code.toUtf8() + " }", QUrl(""));
- obj = valid.create();
- QVERIFY(obj);
- QVERIFY(valid.errorString().isEmpty());
- delete obj;
-
- QDeclarativeComponent invalid(&engine);
- invalid.setData("import QtQuick 1.0; TextEdit { " + code.toUtf8() + " }", QUrl(""));
- QTest::ignoreMessage(QtWarningMsg, warning.toUtf8());
- obj = invalid.create();
- QCOMPARE(invalid.errorString(), error);
- delete obj;
-}
-
-void tst_qdeclarativetextedit::testQtQuick11Attributes_data()
-{
- QTest::addColumn<QString>("code");
- QTest::addColumn<QString>("warning");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("canPaste") << "property bool foo: canPaste"
- << "<Unknown File>:1: ReferenceError: Can't find variable: canPaste"
- << "";
-
- QTest::newRow("lineCount") << "property int foo: lineCount"
- << "<Unknown File>:1: ReferenceError: Can't find variable: lineCount"
- << "";
-
- QTest::newRow("moveCursorSelection") << "Component.onCompleted: moveCursorSelection(0, TextEdit.SelectCharacters)"
- << "<Unknown File>:1: ReferenceError: Can't find variable: moveCursorSelection"
- << "";
-
- QTest::newRow("deselect") << "Component.onCompleted: deselect()"
- << "<Unknown File>:1: ReferenceError: Can't find variable: deselect"
- << "";
-
- QTest::newRow("onLinkActivated") << "onLinkActivated: {}"
- << "QDeclarativeComponent: Component is not ready"
- << ":1 \"TextEdit.onLinkActivated\" is not available in QtQuick 1.0.\n";
-}
-
-void tst_qdeclarativetextedit::preeditMicroFocus()
-{
- QString preeditText = "super";
- PlatformInputContext ic;
- QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
- inputPanelPrivate->testContext = &ic;
-
- QGraphicsScene scene;
- QGraphicsView view(&scene);
- QDeclarative1TextEdit edit;
- edit.setFocus(true);
- scene.addItem(&edit);
- view.show();
- QApplication::setActiveWindow(&view);
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
-
- QSignalSpy cursorRectangleSpy(&edit, SIGNAL(cursorRectangleChanged()));
-
- QRect currentRect;
- QRect previousRect = edit.inputMethodQuery(Qt::ImMicroFocus).toRect();
-
- // Verify that the micro focus rect is positioned the same for position 0 as
- // it would be if there was no preedit text.
- ic.clear();
- sendPreeditText(preeditText, 0);
- currentRect = edit.inputMethodQuery(Qt::ImMicroFocus).toRect();
- QCOMPARE(currentRect, previousRect);
-#if defined(Q_WS_X11) || defined(Q_WS_QWS)
- QCOMPARE(ic.updateCallCount, 0); // The cursor position hasn't changed.
-#endif
- QCOMPARE(cursorRectangleSpy.count(), 0);
-
- // Verify that the micro focus rect moves to the left as the cursor position
- // is incremented.
- for (int i = 1; i <= 5; ++i) {
- ic.clear();
- sendPreeditText(preeditText, i);
- currentRect = edit.inputMethodQuery(Qt::ImMicroFocus).toRect();
- QVERIFY(previousRect.left() < currentRect.left());
-#if defined(Q_WS_X11) || defined(Q_WS_QWS)
- QVERIFY(ic.updateCallCount > 0);
-#endif
- QVERIFY(cursorRectangleSpy.count() > 0);
- cursorRectangleSpy.clear();
- previousRect = currentRect;
- }
-
- // Verify that if there is no preedit cursor then the micro focus rect is the
- // same as it would be if it were positioned at the end of the preedit text.
- sendPreeditText(preeditText, 0);
- ic.clear();
- QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>());
- QApplication::sendEvent(qApp->focusObject(), &imEvent);
- currentRect = edit.inputMethodQuery(Qt::ImMicroFocus).toRect();
- QCOMPARE(currentRect, previousRect);
-#if defined(Q_WS_X11) || defined(Q_WS_QWS)
- QVERIFY(ic.updateCallCount > 0);
-#endif
- QVERIFY(cursorRectangleSpy.count() > 0);
-}
-
-void tst_qdeclarativetextedit::inputContextMouseHandler()
-{
- QString text = "supercalifragisiticexpialidocious!";
- PlatformInputContext ic;
- QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
- inputPanelPrivate->testContext = &ic;
-
- QGraphicsScene scene;
- QGraphicsView view(&scene);
- QDeclarative1TextEdit edit;
- edit.setPos(0, 0);
- edit.setWidth(200);
- edit.setText(text.mid(0, 12));
- edit.setPos(0, 0);
- edit.setCursorPosition(12);
- edit.setFocus(true);
- scene.addItem(&edit);
- view.show();
- QApplication::setActiveWindow(&view);
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
- view.setFocus();
-
- QFontMetricsF fm(edit.font());
- const qreal y = fm.height() / 2;
-
- QPoint position2 = view.mapFromScene(edit.mapToScene(QPointF(fm.width(text.mid(0, 2)), y)));
-
- QInputMethodEvent inputEvent(text.mid(0, 12), QList<QInputMethodEvent::Attribute>());
- QApplication::sendEvent(&view, &inputEvent);
-
- QTest::mousePress(view.viewport(), Qt::LeftButton, Qt::NoModifier, position2);
- QTest::mouseRelease(view.viewport(), Qt::RightButton, Qt::ControlModifier, position2);
- QApplication::processEvents();
-
- QCOMPARE(ic.m_action, QInputPanel::Click);
- QCOMPARE(ic.m_invokeActionCallCount, 1);
- QCOMPARE(ic.m_cursorPosition, 2);
-}
-
-void tst_qdeclarativetextedit::inputMethodComposing()
-{
- QString text = "supercalifragisiticexpialidocious!";
-
- QGraphicsScene scene;
- QGraphicsView view(&scene);
- QDeclarative1TextEdit edit;
- edit.setWidth(200);
- edit.setText(text.mid(0, 12));
- edit.setCursorPosition(12);
- edit.setPos(0, 0);
- edit.setFocus(true);
- scene.addItem(&edit);
- view.show();
- QApplication::setActiveWindow(&view);
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
-
- QSignalSpy spy(&edit, SIGNAL(inputMethodComposingChanged()));
-
- QCOMPARE(edit.isInputMethodComposing(), false);
- {
- QInputMethodEvent imEvent(text.mid(3), QList<QInputMethodEvent::Attribute>());
- QApplication::sendEvent(&view, &imEvent);
- }
- QCOMPARE(edit.isInputMethodComposing(), true);
- QCOMPARE(spy.count(), 1);
-
- {
- QInputMethodEvent imEvent(text.mid(12), QList<QInputMethodEvent::Attribute>());
- QApplication::sendEvent(&view, &imEvent);
- }
- QCOMPARE(edit.isInputMethodComposing(), true);
- QCOMPARE(spy.count(), 1);
-
- {
- QInputMethodEvent imEvent;
- QApplication::sendEvent(&view, &imEvent);
- }
- QCOMPARE(edit.isInputMethodComposing(), false);
- QCOMPARE(spy.count(), 2);
-}
-
-void tst_qdeclarativetextedit::cursorRectangleSize()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/CursorRect.qml");
- QVERIFY(canvas->rootObject() != 0);
- canvas->show();
- canvas->setFocus();
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
-
- QDeclarative1TextEdit *textEdit = qobject_cast<QDeclarative1TextEdit *>(canvas->rootObject());
- QVERIFY(textEdit != 0);
- textEdit->setFocus(Qt::OtherFocusReason);
- QRectF cursorRect = textEdit->positionToRectangle(textEdit->cursorPosition());
- QRectF microFocusFromScene = canvas->scene()->inputMethodQuery(Qt::ImMicroFocus).toRectF();
- QRectF microFocusFromApp= QApplication::focusWidget()->inputMethodQuery(Qt::ImMicroFocus).toRectF();
-
- QCOMPARE(microFocusFromScene.size(), cursorRect.size());
- QCOMPARE(microFocusFromApp.size(), cursorRect.size());
-}
-QTEST_MAIN(tst_qdeclarativetextedit)
-
-#include "tst_qdeclarativetextedit.moc"
diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/cursorTest.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/cursorTest.qml
deleted file mode 100644
index 73085c1749..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextinput/data/cursorTest.qml
+++ /dev/null
@@ -1,8 +0,0 @@
-import QtQuick 1.0
-
-Rectangle { width: 300; height: 300; color: "white"
- TextInput { text: "Hello world!"; id: textInputObject; objectName: "textInputObject"
- resources: [ Component { id:cursor; Item { id:cursorInstance; objectName: "cursorInstance";} } ]
- cursorDelegate: cursor
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/echoMode.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/echoMode.qml
deleted file mode 100644
index 0320872b86..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextinput/data/echoMode.qml
+++ /dev/null
@@ -1,11 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- property QtObject myInput: input
-
- width: 400; height: 200; color: "green"
-
- TextInput { id: input; focus: true
- text: "ABCDefgh"
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/geometrySignals.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/geometrySignals.qml
deleted file mode 100644
index 353d0e2f77..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextinput/data/geometrySignals.qml
+++ /dev/null
@@ -1,12 +0,0 @@
-import QtQuick 1.0
-
-Item {
- width: 400; height: 500;
- property int bindingWidth: text.width
- property int bindingHeight: text.height
-
- TextEdit {
- id: text
- anchors.fill: parent
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/halign_center.png b/tests/auto/qtquick1/qdeclarativetextinput/data/halign_center.png
deleted file mode 100644
index 53e09a8e5b..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextinput/data/halign_center.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/halign_left.png b/tests/auto/qtquick1/qdeclarativetextinput/data/halign_left.png
deleted file mode 100644
index 247acbc9df..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextinput/data/halign_left.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/halign_right.png b/tests/auto/qtquick1/qdeclarativetextinput/data/halign_right.png
deleted file mode 100644
index 691bc75c89..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextinput/data/halign_right.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/horizontalAlignment.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/horizontalAlignment.qml
deleted file mode 100644
index 3114c48209..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextinput/data/horizontalAlignment.qml
+++ /dev/null
@@ -1,22 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: top
- width: 70; height: 70;
-
- property alias horizontalAlignment: text.horizontalAlignment
- property string text: "Test"
-
- Rectangle {
- anchors.centerIn: parent
- width: 60
- height: 20
- color: "green"
-
- TextInput {
- id: text
- anchors.fill: parent
- text: top.text
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/horizontalAlignment_RightToLeft.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/horizontalAlignment_RightToLeft.qml
deleted file mode 100644
index 7f27bbe5cb..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextinput/data/horizontalAlignment_RightToLeft.qml
+++ /dev/null
@@ -1,24 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- id: top
- width: 200; height: 70;
-
- property alias horizontalAlignment: text.horizontalAlignment
- property string text: "اختبا"
-
- Rectangle {
- anchors.centerIn: parent
- width: 180
- height: 20
- color: "green"
-
- TextInput {
- id: text
- objectName: "text"
- anchors.fill: parent
- text: top.text
- focus: true
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/inputmethods.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/inputmethods.qml
deleted file mode 100644
index 5063892306..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextinput/data/inputmethods.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import QtQuick 1.0
-
-TextInput {
- text: "Hello world!"
- inputMethodHints: Qt.ImhNoPredictiveText
- Keys.onLeftPressed: {}
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/masks.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/masks.qml
deleted file mode 100644
index c75764af91..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextinput/data/masks.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import QtQuick 1.0
-
-TextInput{
- focus: true
- objectName: "myInput"
- inputMask: "HHHHhhhh; "
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/maxLength.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/maxLength.qml
deleted file mode 100644
index 95902bb687..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextinput/data/maxLength.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import QtQuick 1.0
-
-TextInput{
- focus: true
- objectName: "myInput"
- maximumLength: 10
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_default.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_default.qml
deleted file mode 100644
index eea83ed035..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_default.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import QtQuick 1.0
-
-TextInput {
- focus: true
- text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- selectByMouse: false
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_false.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_false.qml
deleted file mode 100644
index eea83ed035..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_false.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import QtQuick 1.0
-
-TextInput {
- focus: true
- text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- selectByMouse: false
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_false_readonly.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_false_readonly.qml
deleted file mode 100644
index 36a95634e3..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_false_readonly.qml
+++ /dev/null
@@ -1,8 +0,0 @@
-import QtQuick 1.0
-
-TextInput {
- focus: true
- text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- selectByMouse: false
- readOnly: true
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_false_words.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_false_words.qml
deleted file mode 100644
index eea83ed035..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_false_words.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import QtQuick 1.0
-
-TextInput {
- focus: true
- text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- selectByMouse: false
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_true.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_true.qml
deleted file mode 100644
index 8115ba05e3..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_true.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import QtQuick 1.0
-
-TextInput {
- focus: true
- text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- selectByMouse: true
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_true_readonly.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_true_readonly.qml
deleted file mode 100644
index 678a89aa8b..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_true_readonly.qml
+++ /dev/null
@@ -1,8 +0,0 @@
-import QtQuick 1.0
-
-TextInput {
- focus: true
- text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- selectByMouse: true
- readOnly: true
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_true_words.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_true_words.qml
deleted file mode 100644
index 8115ba05e3..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_true_words.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import QtQuick 1.0
-
-TextInput {
- focus: true
- text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- selectByMouse: true
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselectionmode_characters.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselectionmode_characters.qml
deleted file mode 100644
index 0ffc6ff225..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselectionmode_characters.qml
+++ /dev/null
@@ -1,8 +0,0 @@
-import QtQuick 1.1
-
-TextInput {
- focus: true
- text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- selectByMouse: true
- mouseSelectionMode: TextInput.SelectCharacters
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselectionmode_default.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselectionmode_default.qml
deleted file mode 100644
index 87c174be14..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselectionmode_default.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import QtQuick 1.1
-
-TextInput {
- focus: true
- text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- selectByMouse: true
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselectionmode_words.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselectionmode_words.qml
deleted file mode 100644
index df69a7d042..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselectionmode_words.qml
+++ /dev/null
@@ -1,8 +0,0 @@
-import QtQuick 1.1
-
-TextInput {
- focus: true
- text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- selectByMouse: true
- mouseSelectionMode: TextInput.SelectWords
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/navigation.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/navigation.qml
deleted file mode 100644
index af1b14090e..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextinput/data/navigation.qml
+++ /dev/null
@@ -1,24 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- property variant myInput: input
-
- width: 800; height: 600; color: "blue"
-
- Item {
- id: firstItem;
- KeyNavigation.right: input
- }
-
- TextInput { id: input; focus: true
- text: "Needs some text"
- KeyNavigation.left: firstItem
- KeyNavigation.right: lastItem
- KeyNavigation.up: firstItem
- KeyNavigation.down: lastItem
- }
- Item {
- id: lastItem
- KeyNavigation.left: input
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/positionAt.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/positionAt.qml
deleted file mode 100644
index cbbf33d9fd..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextinput/data/positionAt.qml
+++ /dev/null
@@ -1,8 +0,0 @@
-import QtQuick 1.0
-
-TextInput{
- focus: true
- objectName: "myInput"
- width: 50
- text: "This is a long piece of text"
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/readOnly.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/readOnly.qml
deleted file mode 100644
index f173649ef5..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextinput/data/readOnly.qml
+++ /dev/null
@@ -1,12 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- property variant myInput: input
-
- width: 800; height: 600; color: "blue"
-
- TextInput { id: input; focus: true
- readOnly: true
- text: "I am the very model of a modern major general.\n"
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/validators.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/validators.qml
deleted file mode 100644
index e26bcb30e6..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextinput/data/validators.qml
+++ /dev/null
@@ -1,22 +0,0 @@
-import QtQuick 1.0
-
-Item {
- property variant intInput: intInput
- property variant dblInput: dblInput
- property variant strInput: strInput
-
- width: 800; height: 600;
-
- Column{
- TextInput { id: intInput;
- validator: IntValidator{top: 11; bottom: 2}
- }
- TextInput { id: dblInput;
- validator: DoubleValidator{top: 12.12; bottom: 2.93; decimals: 2; notation: DoubleValidator.StandardNotation}
- }
- TextInput { id: strInput;
- validator: RegExpValidator { regExp: /[a-zA-z]{2,4}/ }
- }
- }
-
-}
diff --git a/tests/auto/qtquick1/qdeclarativetextinput/qdeclarativetextinput.pro b/tests/auto/qtquick1/qdeclarativetextinput/qdeclarativetextinput.pro
deleted file mode 100644
index 655c4a27a1..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextinput/qdeclarativetextinput.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativetextinput
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativetextinput.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib
diff --git a/tests/auto/qtquick1/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/qtquick1/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
deleted file mode 100644
index ece6818071..0000000000
--- a/tests/auto/qtquick1/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
+++ /dev/null
@@ -1,2752 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QSignalSpy>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QFile>
-#include <QtQuick1/qdeclarativeview.h>
-#include <QtQuick1/private/qdeclarativetextinput_p.h>
-#include <QtQuick1/private/qdeclarativetextinput_p_p.h>
-#include <QDebug>
-#include <QDir>
-#include <QStyle>
-#include <QtCore/qmath.h>
-#include <private/qapplication_p.h>
-#include <private/qinputpanel_p.h>
-#include "../../shared/platforminputcontext.h"
-
-#include "qplatformdefs.h"
-
-Q_DECLARE_METATYPE(QDeclarative1TextInput::SelectionMode)
-
-QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual)
-{
- // XXX This will be replaced by some clever persistent platform image store.
- QString persistent_dir = SRCDIR "/data";
- QString arch = "unknown-architecture"; // QTest needs to help with this.
-
- QString expectfile = persistent_dir + QDir::separator() + filebasename + "-" + arch + ".png";
-
- if (!QFile::exists(expectfile)) {
- actual.save(expectfile);
- qWarning() << "created" << expectfile;
- }
-
- return expectfile;
-}
-
-void sendPreeditText(const QString &text, int cursor)
-{
- QList<QInputMethodEvent::Attribute> attributes;
- attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, cursor,
- text.length(), QVariant()));
- QInputMethodEvent event(text, attributes);
- QApplication::sendEvent(qApp->focusObject(), &event);
-}
-
-
-class tst_qdeclarativetextinput : public QObject
-
-{
- Q_OBJECT
-public:
- tst_qdeclarativetextinput();
-
-private slots:
- void cleanup();
-
- void text();
- void width();
- void font();
- void color();
- void selection();
- void isRightToLeft_data();
- void isRightToLeft();
- void moveCursorSelection_data();
- void moveCursorSelection();
- void moveCursorSelectionSequence_data();
- void moveCursorSelectionSequence();
- void mouseSelection_data();
- void mouseSelection();
- void deferEnableSelectByMouse_data();
- void deferEnableSelectByMouse();
- void deferDisableSelectByMouse_data();
- void deferDisableSelectByMouse();
- void dragMouseSelection();
- void mouseSelectionMode_data();
- void mouseSelectionMode();
-
- void horizontalAlignment_data();
- void horizontalAlignment();
- void horizontalAlignment_RightToLeft();
-
- void positionAt();
-
- void maxLength();
- void masks();
- void validators();
- void inputMethods();
-
- void passwordCharacter();
- void cursorDelegate();
- void cursorVisible();
- void cursorRectangle();
- void navigation();
- void navigation_RTL();
- void copyAndPaste();
- void canPasteEmpty();
- void canPaste();
- void readOnly();
-
- void openInputPanelOnClick();
- void openInputPanelOnFocus();
- void setHAlignClearCache();
- void focusOutClearSelection();
-
- void echoMode();
-#ifdef QT_GUI_PASSWORD_ECHO_DELAY
- void passwordEchoDelay();
-#endif
- void geometrySignals();
- void testQtQuick11Attributes();
- void testQtQuick11Attributes_data();
-
- void preeditAutoScroll();
- void preeditMicroFocus();
- void inputContextMouseHandler();
- void inputMethodComposing();
- void cursorRectangleSize();
-
-private:
- void simulateKey(QDeclarativeView *, int key);
- QDeclarativeView *createView(const QString &filename);
-
- QDeclarativeEngine engine;
- QStringList standard;
- QStringList colorStrings;
-};
-
-
-tst_qdeclarativetextinput::tst_qdeclarativetextinput()
-{
- standard << "the quick brown fox jumped over the lazy dog"
- << "It's supercalifragisiticexpialidocious!"
- << "Hello, world!"
- << "!dlrow ,olleH"
- << " spacey text ";
-
- colorStrings << "aliceblue"
- << "antiquewhite"
- << "aqua"
- << "darkkhaki"
- << "darkolivegreen"
- << "dimgray"
- << "palevioletred"
- << "lightsteelblue"
- << "#000000"
- << "#AAAAAA"
- << "#FFFFFF"
- << "#2AC05F";
-}
-
-void tst_qdeclarativetextinput::cleanup()
-{
- // ensure not even skipped tests with custom input context leave it dangling
- QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
- inputPanelPrivate->testContext = 0;
-}
-
-void tst_qdeclarativetextinput::text()
-{
- {
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData("import QtQuick 1.0\nTextInput { text: \"\" }", QUrl());
- QDeclarative1TextInput *textinputObject = qobject_cast<QDeclarative1TextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->text(), QString(""));
-
- delete textinputObject;
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import QtQuick 1.0\nTextInput { text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextInput *textinputObject = qobject_cast<QDeclarative1TextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->text(), standard.at(i));
-
- delete textinputObject;
- }
-
-}
-
-void tst_qdeclarativetextinput::width()
-{
- // uses Font metrics to find the width for standard
- {
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData("import QtQuick 1.0\nTextInput { text: \"\" }", QUrl());
- QDeclarative1TextInput *textinputObject = qobject_cast<QDeclarative1TextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->width(), 0.0);
-
- delete textinputObject;
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QFont f;
- QFontMetricsF fm(f);
- qreal metricWidth = fm.width(standard.at(i));
-
- QString componentStr = "import QtQuick 1.0\nTextInput { text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextInput *textinputObject = qobject_cast<QDeclarative1TextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- int delta = abs(int(int(textinputObject->width()) - metricWidth));
- QVERIFY(delta <= 3.0); // As best as we can hope for cross-platform.
-
- delete textinputObject;
- }
-}
-
-void tst_qdeclarativetextinput::font()
-{
- //test size, then bold, then italic, then family
- {
- QString componentStr = "import QtQuick 1.0\nTextInput { font.pointSize: 40; text: \"Hello World\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextInput *textinputObject = qobject_cast<QDeclarative1TextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->font().pointSize(), 40);
- QCOMPARE(textinputObject->font().bold(), false);
- QCOMPARE(textinputObject->font().italic(), false);
-
- delete textinputObject;
- }
-
- {
- QString componentStr = "import QtQuick 1.0\nTextInput { font.bold: true; text: \"Hello World\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextInput *textinputObject = qobject_cast<QDeclarative1TextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->font().bold(), true);
- QCOMPARE(textinputObject->font().italic(), false);
-
- delete textinputObject;
- }
-
- {
- QString componentStr = "import QtQuick 1.0\nTextInput { font.italic: true; text: \"Hello World\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextInput *textinputObject = qobject_cast<QDeclarative1TextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->font().italic(), true);
- QCOMPARE(textinputObject->font().bold(), false);
-
- delete textinputObject;
- }
-
- {
- QString componentStr = "import QtQuick 1.0\nTextInput { font.family: \"Helvetica\"; text: \"Hello World\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextInput *textinputObject = qobject_cast<QDeclarative1TextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->font().family(), QString("Helvetica"));
- QCOMPARE(textinputObject->font().bold(), false);
- QCOMPARE(textinputObject->font().italic(), false);
-
- delete textinputObject;
- }
-
- {
- QString componentStr = "import QtQuick 1.0\nTextInput { font.family: \"\"; text: \"Hello World\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextInput *textinputObject = qobject_cast<QDeclarative1TextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->font().family(), QString(""));
-
- delete textinputObject;
- }
-}
-
-void tst_qdeclarativetextinput::color()
-{
- //test color
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import QtQuick 1.0\nTextInput { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextInput *textinputObject = qobject_cast<QDeclarative1TextInput*>(textinputComponent.create());
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->color(), QColor(colorStrings.at(i)));
-
- delete textinputObject;
- }
-
- //test selection color
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import QtQuick 1.0\nTextInput { selectionColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextInput *textinputObject = qobject_cast<QDeclarative1TextInput*>(textinputComponent.create());
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->selectionColor(), QColor(colorStrings.at(i)));
-
- delete textinputObject;
- }
-
- //test selected text color
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import QtQuick 1.0\nTextInput { selectedTextColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextInput *textinputObject = qobject_cast<QDeclarative1TextInput*>(textinputComponent.create());
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->selectedTextColor(), QColor(colorStrings.at(i)));
-
- delete textinputObject;
- }
-
- {
- QString colorStr = "#AA001234";
- QColor testColor("#001234");
- testColor.setAlpha(170);
-
- QString componentStr = "import QtQuick 1.0\nTextInput { color: \"" + colorStr + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextInput *textinputObject = qobject_cast<QDeclarative1TextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->color(), testColor);
-
- delete textinputObject;
- }
-}
-
-void tst_qdeclarativetextinput::selection()
-{
- QString testStr = standard[0];
- QString componentStr = "import QtQuick 1.0\nTextInput { text: \""+ testStr +"\"; }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextInput *textinputObject = qobject_cast<QDeclarative1TextInput*>(textinputComponent.create());
- QVERIFY(textinputObject != 0);
-
-
- //Test selection follows cursor
- for(int i=0; i<= testStr.size(); i++) {
- textinputObject->setCursorPosition(i);
- QCOMPARE(textinputObject->cursorPosition(), i);
- QCOMPARE(textinputObject->selectionStart(), i);
- QCOMPARE(textinputObject->selectionEnd(), i);
- QVERIFY(textinputObject->selectedText().isNull());
- }
- //Test cursor follows selection
- for(int i=0; i<= testStr.size(); i++) {
- textinputObject->select(i,i);
- QCOMPARE(textinputObject->cursorPosition(), i);
- QCOMPARE(textinputObject->selectionStart(), i);
- QCOMPARE(textinputObject->selectionEnd(), i);
- }
-
- textinputObject->setCursorPosition(0);
- QVERIFY(textinputObject->cursorPosition() == 0);
- QVERIFY(textinputObject->selectionStart() == 0);
- QVERIFY(textinputObject->selectionEnd() == 0);
- QVERIFY(textinputObject->selectedText().isNull());
-
- // Verify invalid positions are ignored.
- textinputObject->setCursorPosition(-1);
- QVERIFY(textinputObject->cursorPosition() == 0);
- QVERIFY(textinputObject->selectionStart() == 0);
- QVERIFY(textinputObject->selectionEnd() == 0);
- QVERIFY(textinputObject->selectedText().isNull());
-
- textinputObject->setCursorPosition(textinputObject->text().count()+1);
- QVERIFY(textinputObject->cursorPosition() == 0);
- QVERIFY(textinputObject->selectionStart() == 0);
- QVERIFY(textinputObject->selectionEnd() == 0);
- QVERIFY(textinputObject->selectedText().isNull());
-
- //Test selection
- for(int i=0; i<= testStr.size(); i++) {
- textinputObject->select(0,i);
- QCOMPARE(testStr.mid(0,i), textinputObject->selectedText());
- QCOMPARE(textinputObject->cursorPosition(), i);
- }
- for(int i=0; i<= testStr.size(); i++) {
- textinputObject->select(i,testStr.size());
- QCOMPARE(testStr.mid(i,testStr.size()-i), textinputObject->selectedText());
- QCOMPARE(textinputObject->cursorPosition(), testStr.size());
- }
-
- textinputObject->setCursorPosition(0);
- QVERIFY(textinputObject->cursorPosition() == 0);
- QVERIFY(textinputObject->selectionStart() == 0);
- QVERIFY(textinputObject->selectionEnd() == 0);
- QVERIFY(textinputObject->selectedText().isNull());
-
- //Test Error Ignoring behaviour
- textinputObject->setCursorPosition(0);
- QVERIFY(textinputObject->selectedText().isNull());
- textinputObject->select(-10,0);
- QVERIFY(textinputObject->selectedText().isNull());
- textinputObject->select(100,110);
- QVERIFY(textinputObject->selectedText().isNull());
- textinputObject->select(0,-10);
- QVERIFY(textinputObject->selectedText().isNull());
- textinputObject->select(0,100);
- QVERIFY(textinputObject->selectedText().isNull());
- textinputObject->select(0,10);
- QVERIFY(textinputObject->selectedText().size() == 10);
- textinputObject->select(-10,10);
- QVERIFY(textinputObject->selectedText().size() == 10);
- textinputObject->select(100,101);
- QVERIFY(textinputObject->selectedText().size() == 10);
- textinputObject->select(0,-10);
- QVERIFY(textinputObject->selectedText().size() == 10);
- textinputObject->select(0,100);
- QVERIFY(textinputObject->selectedText().size() == 10);
-
- textinputObject->deselect();
- QVERIFY(textinputObject->selectedText().isNull());
- textinputObject->select(0,10);
- QVERIFY(textinputObject->selectedText().size() == 10);
- textinputObject->deselect();
- QVERIFY(textinputObject->selectedText().isNull());
-
- delete textinputObject;
-}
-
-void tst_qdeclarativetextinput::isRightToLeft_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<bool>("emptyString");
- QTest::addColumn<bool>("firstCharacter");
- QTest::addColumn<bool>("lastCharacter");
- QTest::addColumn<bool>("middleCharacter");
- QTest::addColumn<bool>("startString");
- QTest::addColumn<bool>("midString");
- QTest::addColumn<bool>("endString");
-
- const quint16 arabic_str[] = { 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0647};
- QTest::newRow("Empty") << "" << false << false << false << false << false << false << false;
- QTest::newRow("Neutral") << "23244242" << false << false << false << false << false << false << false;
- QTest::newRow("LTR") << "Hello world" << false << false << false << false << false << false << false;
- QTest::newRow("RTL") << QString::fromUtf16(arabic_str, 11) << false << true << true << true << true << true << true;
- QTest::newRow("Bidi RTL + LTR + RTL") << QString::fromUtf16(arabic_str, 11) + QString("Hello world") + QString::fromUtf16(arabic_str, 11) << false << true << true << false << true << true << true;
- QTest::newRow("Bidi LTR + RTL + LTR") << QString("Hello world") + QString::fromUtf16(arabic_str, 11) + QString("Hello world") << false << false << false << true << false << false << false;
-}
-
-void tst_qdeclarativetextinput::isRightToLeft()
-{
- QFETCH(QString, text);
- QFETCH(bool, emptyString);
- QFETCH(bool, firstCharacter);
- QFETCH(bool, lastCharacter);
- QFETCH(bool, middleCharacter);
- QFETCH(bool, startString);
- QFETCH(bool, midString);
- QFETCH(bool, endString);
-
- QDeclarative1TextInput textInput;
- textInput.setText(text);
-
- // first test that the right string is delivered to the QString::isRightToLeft()
- QCOMPARE(textInput.isRightToLeft(0,0), text.mid(0,0).isRightToLeft());
- QCOMPARE(textInput.isRightToLeft(0,1), text.mid(0,1).isRightToLeft());
- QCOMPARE(textInput.isRightToLeft(text.count()-2, text.count()-1), text.mid(text.count()-2, text.count()-1).isRightToLeft());
- QCOMPARE(textInput.isRightToLeft(text.count()/2, text.count()/2 + 1), text.mid(text.count()/2, text.count()/2 + 1).isRightToLeft());
- QCOMPARE(textInput.isRightToLeft(0,text.count()/4), text.mid(0,text.count()/4).isRightToLeft());
- QCOMPARE(textInput.isRightToLeft(text.count()/4,3*text.count()/4), text.mid(text.count()/4,3*text.count()/4).isRightToLeft());
- if (text.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML TextInput: isRightToLeft(start, end) called with the end property being smaller than the start.");
- QCOMPARE(textInput.isRightToLeft(3*text.count()/4,text.count()-1), text.mid(3*text.count()/4,text.count()-1).isRightToLeft());
-
- // then test that the feature actually works
- QCOMPARE(textInput.isRightToLeft(0,0), emptyString);
- QCOMPARE(textInput.isRightToLeft(0,1), firstCharacter);
- QCOMPARE(textInput.isRightToLeft(text.count()-2, text.count()-1), lastCharacter);
- QCOMPARE(textInput.isRightToLeft(text.count()/2, text.count()/2 + 1), middleCharacter);
- QCOMPARE(textInput.isRightToLeft(0,text.count()/4), startString);
- QCOMPARE(textInput.isRightToLeft(text.count()/4,3*text.count()/4), midString);
- if (text.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML TextInput: isRightToLeft(start, end) called with the end property being smaller than the start.");
- QCOMPARE(textInput.isRightToLeft(3*text.count()/4,text.count()-1), endString);
-}
-
-void tst_qdeclarativetextinput::moveCursorSelection_data()
-{
- QTest::addColumn<QString>("testStr");
- QTest::addColumn<int>("cursorPosition");
- QTest::addColumn<int>("movePosition");
- QTest::addColumn<QDeclarative1TextInput::SelectionMode>("mode");
- QTest::addColumn<int>("selectionStart");
- QTest::addColumn<int>("selectionEnd");
- QTest::addColumn<bool>("reversible");
-
- // () contains the text selected by the cursor.
- // <> contains the actual selection.
-
- QTest::newRow("(t)he|characters")
- << standard[0] << 0 << 1 << QDeclarative1TextInput::SelectCharacters << 0 << 1 << true;
- QTest::newRow("do(g)|characters")
- << standard[0] << 43 << 44 << QDeclarative1TextInput::SelectCharacters << 43 << 44 << true;
- QTest::newRow("jum(p)ed|characters")
- << standard[0] << 23 << 24 << QDeclarative1TextInput::SelectCharacters << 23 << 24 << true;
- QTest::newRow("jumped( )over|characters")
- << standard[0] << 26 << 27 << QDeclarative1TextInput::SelectCharacters << 26 << 27 << true;
- QTest::newRow("(the )|characters")
- << standard[0] << 0 << 4 << QDeclarative1TextInput::SelectCharacters << 0 << 4 << true;
- QTest::newRow("( dog)|characters")
- << standard[0] << 40 << 44 << QDeclarative1TextInput::SelectCharacters << 40 << 44 << true;
- QTest::newRow("( jumped )|characters")
- << standard[0] << 19 << 27 << QDeclarative1TextInput::SelectCharacters << 19 << 27 << true;
- QTest::newRow("th(e qu)ick|characters")
- << standard[0] << 2 << 6 << QDeclarative1TextInput::SelectCharacters << 2 << 6 << true;
- QTest::newRow("la(zy d)og|characters")
- << standard[0] << 38 << 42 << QDeclarative1TextInput::SelectCharacters << 38 << 42 << true;
- QTest::newRow("jum(ped ov)er|characters")
- << standard[0] << 23 << 29 << QDeclarative1TextInput::SelectCharacters << 23 << 29 << true;
- QTest::newRow("()the|characters")
- << standard[0] << 0 << 0 << QDeclarative1TextInput::SelectCharacters << 0 << 0 << true;
- QTest::newRow("dog()|characters")
- << standard[0] << 44 << 44 << QDeclarative1TextInput::SelectCharacters << 44 << 44 << true;
- QTest::newRow("jum()ped|characters")
- << standard[0] << 23 << 23 << QDeclarative1TextInput::SelectCharacters << 23 << 23 << true;
-
- QTest::newRow("<(t)he>|words")
- << standard[0] << 0 << 1 << QDeclarative1TextInput::SelectWords << 0 << 3 << true;
- QTest::newRow("<do(g)>|words")
- << standard[0] << 43 << 44 << QDeclarative1TextInput::SelectWords << 41 << 44 << true;
- QTest::newRow("<jum(p)ed>|words")
- << standard[0] << 23 << 24 << QDeclarative1TextInput::SelectWords << 20 << 26 << true;
- QTest::newRow("<jumped( )>over|words,ltr")
- << standard[0] << 26 << 27 << QDeclarative1TextInput::SelectWords << 20 << 27 << false;
- QTest::newRow("jumped<( )over>|words,rtl")
- << standard[0] << 27 << 26 << QDeclarative1TextInput::SelectWords << 26 << 31 << false;
- QTest::newRow("<(the )>quick|words,ltr")
- << standard[0] << 0 << 4 << QDeclarative1TextInput::SelectWords << 0 << 4 << false;
- QTest::newRow("<(the )quick>|words,rtl")
- << standard[0] << 4 << 0 << QDeclarative1TextInput::SelectWords << 0 << 9 << false;
- QTest::newRow("<lazy( dog)>|words,ltr")
- << standard[0] << 40 << 44 << QDeclarative1TextInput::SelectWords << 36 << 44 << false;
- QTest::newRow("lazy<( dog)>|words,rtl")
- << standard[0] << 44 << 40 << QDeclarative1TextInput::SelectWords << 40 << 44 << false;
- QTest::newRow("<fox( jumped )>over|words,ltr")
- << standard[0] << 19 << 27 << QDeclarative1TextInput::SelectWords << 16 << 27 << false;
- QTest::newRow("fox<( jumped )over>|words,rtl")
- << standard[0] << 27 << 19 << QDeclarative1TextInput::SelectWords << 19 << 31 << false;
- QTest::newRow("<th(e qu)ick>|words")
- << standard[0] << 2 << 6 << QDeclarative1TextInput::SelectWords << 0 << 9 << true;
- QTest::newRow("<la(zy d)og|words>")
- << standard[0] << 38 << 42 << QDeclarative1TextInput::SelectWords << 36 << 44 << true;
- QTest::newRow("<jum(ped ov)er>|words")
- << standard[0] << 23 << 29 << QDeclarative1TextInput::SelectWords << 20 << 31 << true;
- QTest::newRow("<()>the|words")
- << standard[0] << 0 << 0 << QDeclarative1TextInput::SelectWords << 0 << 0 << true;
- QTest::newRow("dog<()>|words")
- << standard[0] << 44 << 44 << QDeclarative1TextInput::SelectWords << 44 << 44 << true;
- QTest::newRow("jum<()>ped|words")
- << standard[0] << 23 << 23 << QDeclarative1TextInput::SelectWords << 23 << 23 << true;
-
- QTest::newRow("Hello<(,)> |words")
- << standard[2] << 5 << 6 << QDeclarative1TextInput::SelectWords << 5 << 6 << true;
- QTest::newRow("Hello<(, )>world|words,ltr")
- << standard[2] << 5 << 7 << QDeclarative1TextInput::SelectWords << 5 << 7 << false;
- QTest::newRow("Hello<(, )world>|words,rtl")
- << standard[2] << 7 << 5 << QDeclarative1TextInput::SelectWords << 5 << 12 << false;
- QTest::newRow("<Hel(lo, )>world|words,ltr")
- << standard[2] << 3 << 7 << QDeclarative1TextInput::SelectWords << 0 << 7 << false;
- QTest::newRow("<Hel(lo, )world>|words,rtl")
- << standard[2] << 7 << 3 << QDeclarative1TextInput::SelectWords << 0 << 12 << false;
- QTest::newRow("<Hel(lo)>,|words")
- << standard[2] << 3 << 5 << QDeclarative1TextInput::SelectWords << 0 << 5 << true;
- QTest::newRow("Hello<()>,|words")
- << standard[2] << 5 << 5 << QDeclarative1TextInput::SelectWords << 5 << 5 << true;
- QTest::newRow("Hello,<()>|words")
- << standard[2] << 6 << 6 << QDeclarative1TextInput::SelectWords << 6 << 6 << true;
- QTest::newRow("Hello<,( )>world|words,ltr")
- << standard[2] << 6 << 7 << QDeclarative1TextInput::SelectWords << 5 << 7 << false;
- QTest::newRow("Hello,<( )world>|words,rtl")
- << standard[2] << 7 << 6 << QDeclarative1TextInput::SelectWords << 6 << 12 << false;
- QTest::newRow("Hello<,( world)>|words,ltr")
- << standard[2] << 6 << 12 << QDeclarative1TextInput::SelectWords << 5 << 12 << false;
- QTest::newRow("Hello,<( world)>|words,rtl")
- << standard[2] << 12 << 6 << QDeclarative1TextInput::SelectWords << 6 << 12 << false;
- QTest::newRow("Hello<,( world!)>|words,ltr")
- << standard[2] << 6 << 13 << QDeclarative1TextInput::SelectWords << 5 << 13 << false;
- QTest::newRow("Hello,<( world!)>|words,rtl")
- << standard[2] << 13 << 6 << QDeclarative1TextInput::SelectWords << 6 << 13 << false;
- QTest::newRow("Hello<(, world!)>|words")
- << standard[2] << 5 << 13 << QDeclarative1TextInput::SelectWords << 5 << 13 << true;
- QTest::newRow("world<(!)>|words")
- << standard[2] << 12 << 13 << QDeclarative1TextInput::SelectWords << 12 << 13 << true;
- QTest::newRow("world!<()>)|words")
- << standard[2] << 13 << 13 << QDeclarative1TextInput::SelectWords << 13 << 13 << true;
- QTest::newRow("world<()>!)|words")
- << standard[2] << 12 << 12 << QDeclarative1TextInput::SelectWords << 12 << 12 << true;
-
- QTest::newRow("<(,)>olleH |words")
- << standard[3] << 7 << 8 << QDeclarative1TextInput::SelectWords << 7 << 8 << true;
- QTest::newRow("<dlrow( ,)>olleH|words,ltr")
- << standard[3] << 6 << 8 << QDeclarative1TextInput::SelectWords << 1 << 8 << false;
- QTest::newRow("dlrow<( ,)>olleH|words,rtl")
- << standard[3] << 8 << 6 << QDeclarative1TextInput::SelectWords << 6 << 8 << false;
- QTest::newRow("<dlrow( ,ol)leH>|words,ltr")
- << standard[3] << 6 << 10 << QDeclarative1TextInput::SelectWords << 1 << 13 << false;
- QTest::newRow("dlrow<( ,ol)leH>|words,rtl")
- << standard[3] << 10 << 6 << QDeclarative1TextInput::SelectWords << 6 << 13 << false;
- QTest::newRow(",<(ol)leH>,|words")
- << standard[3] << 8 << 10 << QDeclarative1TextInput::SelectWords << 8 << 13 << true;
- QTest::newRow(",<()>olleH|words")
- << standard[3] << 8 << 8 << QDeclarative1TextInput::SelectWords << 8 << 8 << true;
- QTest::newRow("<()>,olleH|words")
- << standard[3] << 7 << 7 << QDeclarative1TextInput::SelectWords << 7 << 7 << true;
- QTest::newRow("<dlrow( )>,olleH|words,ltr")
- << standard[3] << 6 << 7 << QDeclarative1TextInput::SelectWords << 1 << 7 << false;
- QTest::newRow("dlrow<( ),>olleH|words,rtl")
- << standard[3] << 7 << 6 << QDeclarative1TextInput::SelectWords << 6 << 8 << false;
- QTest::newRow("<(dlrow )>,olleH|words,ltr")
- << standard[3] << 1 << 7 << QDeclarative1TextInput::SelectWords << 1 << 7 << false;
- QTest::newRow("<(dlrow ),>olleH|words,rtl")
- << standard[3] << 7 << 1 << QDeclarative1TextInput::SelectWords << 1 << 8 << false;
- QTest::newRow("<(!dlrow )>,olleH|words,ltr")
- << standard[3] << 0 << 7 << QDeclarative1TextInput::SelectWords << 0 << 7 << false;
- QTest::newRow("<(!dlrow ),>olleH|words,rtl")
- << standard[3] << 7 << 0 << QDeclarative1TextInput::SelectWords << 0 << 8 << false;
- QTest::newRow("(!dlrow ,)olleH|words")
- << standard[3] << 0 << 8 << QDeclarative1TextInput::SelectWords << 0 << 8 << true;
- QTest::newRow("<(!)>dlrow|words")
- << standard[3] << 0 << 1 << QDeclarative1TextInput::SelectWords << 0 << 1 << true;
- QTest::newRow("<()>!dlrow|words")
- << standard[3] << 0 << 0 << QDeclarative1TextInput::SelectWords << 0 << 0 << true;
- QTest::newRow("!<()>dlrow|words")
- << standard[3] << 1 << 1 << QDeclarative1TextInput::SelectWords << 1 << 1 << true;
-
- QTest::newRow(" <s(pac)ey> text |words")
- << standard[4] << 1 << 4 << QDeclarative1TextInput::SelectWords << 1 << 7 << true;
- QTest::newRow(" spacey <t(ex)t> |words")
- << standard[4] << 11 << 13 << QDeclarative1TextInput::SelectWords << 10 << 14 << true;
- QTest::newRow("<( )>spacey text |words|ltr")
- << standard[4] << 0 << 1 << QDeclarative1TextInput::SelectWords << 0 << 1 << false;
- QTest::newRow("<( )spacey> text |words|rtl")
- << standard[4] << 1 << 0 << QDeclarative1TextInput::SelectWords << 0 << 7 << false;
- QTest::newRow("spacey <text( )>|words|ltr")
- << standard[4] << 14 << 15 << QDeclarative1TextInput::SelectWords << 10 << 15 << false;
- QTest::newRow("spacey text<( )>|words|rtl")
- << standard[4] << 15 << 14 << QDeclarative1TextInput::SelectWords << 14 << 15 << false;
- QTest::newRow("<()> spacey text |words")
- << standard[4] << 0 << 0 << QDeclarative1TextInput::SelectWords << 0 << 0 << false;
- QTest::newRow(" spacey text <()>|words")
- << standard[4] << 15 << 15 << QDeclarative1TextInput::SelectWords << 15 << 15 << false;
-}
-
-void tst_qdeclarativetextinput::moveCursorSelection()
-{
- QFETCH(QString, testStr);
- QFETCH(int, cursorPosition);
- QFETCH(int, movePosition);
- QFETCH(QDeclarative1TextInput::SelectionMode, mode);
- QFETCH(int, selectionStart);
- QFETCH(int, selectionEnd);
- QFETCH(bool, reversible);
-
- QString componentStr = "import QtQuick 1.1\nTextInput { text: \""+ testStr +"\"; }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextInput *textinputObject = qobject_cast<QDeclarative1TextInput*>(textinputComponent.create());
- QVERIFY(textinputObject != 0);
-
- textinputObject->setCursorPosition(cursorPosition);
- textinputObject->moveCursorSelection(movePosition, mode);
-
- QCOMPARE(textinputObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart));
- QCOMPARE(textinputObject->selectionStart(), selectionStart);
- QCOMPARE(textinputObject->selectionEnd(), selectionEnd);
-
- if (reversible) {
- textinputObject->setCursorPosition(movePosition);
- textinputObject->moveCursorSelection(cursorPosition, mode);
-
- QCOMPARE(textinputObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart));
- QCOMPARE(textinputObject->selectionStart(), selectionStart);
- QCOMPARE(textinputObject->selectionEnd(), selectionEnd);
- }
-
- delete textinputObject;
-}
-
-void tst_qdeclarativetextinput::moveCursorSelectionSequence_data()
-{
- QTest::addColumn<QString>("testStr");
- QTest::addColumn<int>("cursorPosition");
- QTest::addColumn<int>("movePosition1");
- QTest::addColumn<int>("movePosition2");
- QTest::addColumn<int>("selection1Start");
- QTest::addColumn<int>("selection1End");
- QTest::addColumn<int>("selection2Start");
- QTest::addColumn<int>("selection2End");
-
- // () contains the text selected by the cursor.
- // <> contains the actual selection.
- // ^ is the revised cursor position.
- // {} contains the revised selection.
-
- QTest::newRow("the {<quick( bro)wn> f^ox} jumped|ltr")
- << standard[0]
- << 9 << 13 << 17
- << 4 << 15
- << 4 << 19;
- QTest::newRow("the quick<( {bro)wn> f^ox} jumped|rtl")
- << standard[0]
- << 13 << 9 << 17
- << 9 << 15
- << 10 << 19;
- QTest::newRow("the {<quick( bro)wn> ^}fox jumped|ltr")
- << standard[0]
- << 9 << 13 << 16
- << 4 << 15
- << 4 << 16;
- QTest::newRow("the quick<( {bro)wn> ^}fox jumped|rtl")
- << standard[0]
- << 13 << 9 << 16
- << 9 << 15
- << 10 << 16;
- QTest::newRow("the {<quick( bro)wn^>} fox jumped|ltr")
- << standard[0]
- << 9 << 13 << 15
- << 4 << 15
- << 4 << 15;
- QTest::newRow("the quick<( {bro)wn^>} f^ox jumped|rtl")
- << standard[0]
- << 13 << 9 << 15
- << 9 << 15
- << 10 << 15;
- QTest::newRow("the {<quick() ^}bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 10
- << 4 << 15
- << 4 << 10;
- QTest::newRow("the quick<( {^bro)wn>} fox|rtl")
- << standard[0]
- << 13 << 9 << 10
- << 9 << 15
- << 10 << 15;
- QTest::newRow("the {<quick^}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 9
- << 4 << 15
- << 4 << 9;
- QTest::newRow("the quick{<(^ bro)wn>} fox|rtl")
- << standard[0]
- << 13 << 9 << 9
- << 9 << 15
- << 9 << 15;
- QTest::newRow("the {<qui^ck}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 7
- << 4 << 15
- << 4 << 9;
- QTest::newRow("the {<qui^ck}( bro)wn> fox|rtl")
- << standard[0]
- << 13 << 9 << 7
- << 9 << 15
- << 4 << 15;
- QTest::newRow("the {<^quick}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 4
- << 4 << 15
- << 4 << 9;
- QTest::newRow("the {<^quick}( bro)wn> fox|rtl")
- << standard[0]
- << 13 << 9 << 4
- << 9 << 15
- << 4 << 15;
- QTest::newRow("the{^ <quick}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 3
- << 4 << 15
- << 3 << 9;
- QTest::newRow("the{^ <quick}( bro)wn> fox|rtl")
- << standard[0]
- << 13 << 9 << 3
- << 9 << 15
- << 3 << 15;
- QTest::newRow("{t^he <quick}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 1
- << 4 << 15
- << 0 << 9;
- QTest::newRow("{t^he <quick}( bro)wn> fox|rtl")
- << standard[0]
- << 13 << 9 << 1
- << 9 << 15
- << 0 << 15;
-
- QTest::newRow("{<He(ll)o>, w^orld}!|ltr")
- << standard[2]
- << 2 << 4 << 8
- << 0 << 5
- << 0 << 12;
- QTest::newRow("{<He(ll)o>, w^orld}!|rtl")
- << standard[2]
- << 4 << 2 << 8
- << 0 << 5
- << 0 << 12;
-
- QTest::newRow("!{dlro^w ,<o(ll)eH>}|ltr")
- << standard[3]
- << 9 << 11 << 5
- << 8 << 13
- << 1 << 13;
- QTest::newRow("!{dlro^w ,<o(ll)eH>}|rtl")
- << standard[3]
- << 11 << 9 << 5
- << 8 << 13
- << 1 << 13;
-
- QTest::newRow("{<(^} sp)acey> text |ltr")
- << standard[4]
- << 0 << 3 << 0
- << 0 << 7
- << 0 << 0;
- QTest::newRow("{<( ^}sp)acey> text |ltr")
- << standard[4]
- << 0 << 3 << 1
- << 0 << 7
- << 0 << 1;
- QTest::newRow("<( {s^p)acey>} text |rtl")
- << standard[4]
- << 3 << 0 << 2
- << 0 << 7
- << 1 << 7;
- QTest::newRow("<( {^sp)acey>} text |rtl")
- << standard[4]
- << 3 << 0 << 1
- << 0 << 7
- << 1 << 7;
-
- QTest::newRow(" spacey <te(xt {^)>}|rtl")
- << standard[4]
- << 15 << 12 << 15
- << 10 << 15
- << 15 << 15;
- QTest::newRow(" spacey <te(xt{^ )>}|rtl")
- << standard[4]
- << 15 << 12 << 14
- << 10 << 15
- << 14 << 15;
- QTest::newRow(" spacey {<te(x^t} )>|ltr")
- << standard[4]
- << 12 << 15 << 13
- << 10 << 15
- << 10 << 14;
- QTest::newRow(" spacey {<te(xt^} )>|ltr")
- << standard[4]
- << 12 << 15 << 14
- << 10 << 15
- << 10 << 14;
-}
-
-void tst_qdeclarativetextinput::moveCursorSelectionSequence()
-{
- QFETCH(QString, testStr);
- QFETCH(int, cursorPosition);
- QFETCH(int, movePosition1);
- QFETCH(int, movePosition2);
- QFETCH(int, selection1Start);
- QFETCH(int, selection1End);
- QFETCH(int, selection2Start);
- QFETCH(int, selection2End);
-
- QString componentStr = "import QtQuick 1.1\nTextInput { text: \""+ testStr +"\"; }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextInput *textinputObject = qobject_cast<QDeclarative1TextInput*>(textinputComponent.create());
- QVERIFY(textinputObject != 0);
-
- textinputObject->setCursorPosition(cursorPosition);
-
- textinputObject->moveCursorSelection(movePosition1, QDeclarative1TextInput::SelectWords);
- QCOMPARE(textinputObject->selectedText(), testStr.mid(selection1Start, selection1End - selection1Start));
- QCOMPARE(textinputObject->selectionStart(), selection1Start);
- QCOMPARE(textinputObject->selectionEnd(), selection1End);
-
- textinputObject->moveCursorSelection(movePosition2, QDeclarative1TextInput::SelectWords);
- QCOMPARE(textinputObject->selectedText(), testStr.mid(selection2Start, selection2End - selection2Start));
- QCOMPARE(textinputObject->selectionStart(), selection2Start);
- QCOMPARE(textinputObject->selectionEnd(), selection2End);
-
- delete textinputObject;
-}
-
-void tst_qdeclarativetextinput::mouseSelection_data()
-{
- QTest::addColumn<QString>("qmlfile");
- QTest::addColumn<bool>("expectSelection");
-
- // import installed
- QTest::newRow("on") << SRCDIR "/data/mouseselection_true.qml" << true;
- QTest::newRow("off") << SRCDIR "/data/mouseselection_false.qml" << false;
- QTest::newRow("default") << SRCDIR "/data/mouseselection_default.qml" << false;
- QTest::newRow("on word selection") << SRCDIR "/data/mouseselection_true_words.qml" << true;
- QTest::newRow("off word selection") << SRCDIR "/data/mouseselection_false_words.qml" << false;
- QTest::newRow("on read only") << SRCDIR "/data/mouseselection_true_readonly.qml" << true;
- QTest::newRow("off read only") << SRCDIR "/data/mouseselection_false_readonly.qml" << false;
-}
-
-void tst_qdeclarativetextinput::mouseSelection()
-{
- QFETCH(QString, qmlfile);
- QFETCH(bool, expectSelection);
-
- QDeclarativeView *canvas = createView(qmlfile);
-
- canvas->show();
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
-
- QVERIFY(canvas->rootObject() != 0);
- QDeclarative1TextInput *textInputObject = qobject_cast<QDeclarative1TextInput *>(canvas->rootObject());
- QVERIFY(textInputObject != 0);
-
- // press-and-drag-and-release from x1 to x2
- int x1 = 10;
- int x2 = 70;
- int y = textInputObject->height()/2;
- QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y)));
- //QTest::mouseMove(canvas->viewport(), canvas->mapFromScene(QPoint(x2,y))); // doesn't work
- QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(canvas->viewport(), &mv);
- QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x2,y)));
- QString str = textInputObject->selectedText();
- if (expectSelection)
- QVERIFY(str.length() > 3); // don't reallly care *what* was selected (and it's too sensitive to platform)
- else
- QVERIFY(str.isEmpty());
-
- // Clicking and shift to clicking between the same points should select the same text.
- textInputObject->setCursorPosition(0);
- QTest::mouseClick(canvas->viewport(), Qt::LeftButton, Qt::NoModifier, canvas->mapFromScene(QPoint(x1,y)));
- QTest::mouseClick(canvas->viewport(), Qt::LeftButton, Qt::ShiftModifier, canvas->mapFromScene(QPoint(x2,y)));
- QCOMPARE(textInputObject->selectedText(), str);
-
- delete canvas;
-}
-
-void tst_qdeclarativetextinput::deferEnableSelectByMouse_data()
-{
- QTest::addColumn<QString>("qmlfile");
-
- QTest::newRow("writable") << SRCDIR "/data/mouseselection_false.qml";
- QTest::newRow("read only") << SRCDIR "/data/mouseselection_false_readonly.qml";
-}
-
-void tst_qdeclarativetextinput::deferEnableSelectByMouse()
-{
- // Verify text isn't selected if selectByMouse is enabled after the mouse button has been pressed.
- QFETCH(QString, qmlfile);
-
- QDeclarativeView *canvas = createView(qmlfile);
-
- canvas->show();
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
-
- QVERIFY(canvas->rootObject() != 0);
- QDeclarative1TextInput *textInputObject = qobject_cast<QDeclarative1TextInput *>(canvas->rootObject());
- QVERIFY(textInputObject != 0);
-
- // press-and-drag-and-release from x1 to x2
- int x1 = 10;
- int x2 = 70;
- int y = textInputObject->height()/2;
-
- QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y)));
- textInputObject->setSelectByMouse(true);
- //QTest::mouseMove(canvas->viewport(), canvas->mapFromScene(QPoint(x2,y))); // doesn't work
- QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(canvas->viewport(), &mv);
- QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x2,y)));
- QVERIFY(textInputObject->selectedText().isEmpty());
-
- delete canvas;
-}
-
-void tst_qdeclarativetextinput::deferDisableSelectByMouse_data()
-{
- QTest::addColumn<QString>("qmlfile");
-
- QTest::newRow("writable") << SRCDIR "/data/mouseselection_true.qml";
- QTest::newRow("read only") << SRCDIR "/data/mouseselection_true_readonly.qml";
-}
-
-void tst_qdeclarativetextinput::deferDisableSelectByMouse()
-{
- // Verify text isn't selected if selectByMouse is enabled after the mouse button has been pressed.
- QFETCH(QString, qmlfile);
-
- QDeclarativeView *canvas = createView(qmlfile);
-
- canvas->show();
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
-
- QVERIFY(canvas->rootObject() != 0);
- QDeclarative1TextInput *textInputObject = qobject_cast<QDeclarative1TextInput *>(canvas->rootObject());
- QVERIFY(textInputObject != 0);
-
- // press-and-drag-and-release from x1 to x2
- int x1 = 10;
- int x2 = 70;
- int y = textInputObject->height()/2;
-
- QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y)));
- textInputObject->setSelectByMouse(false);
- //QTest::mouseMove(canvas->viewport(), canvas->mapFromScene(QPoint(x2,y))); // doesn't work
- QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(canvas->viewport(), &mv);
- QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x2,y)));
- QVERIFY(textInputObject->selectedText().length() > 3);
-
- delete canvas;
-}
-
-void tst_qdeclarativetextinput::dragMouseSelection()
-{
- QString qmlfile = SRCDIR "/data/mouseselection_true.qml";
-
- QDeclarativeView *canvas = createView(qmlfile);
-
- canvas->show();
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
-
- QVERIFY(canvas->rootObject() != 0);
- QDeclarative1TextInput *textInputObject = qobject_cast<QDeclarative1TextInput *>(canvas->rootObject());
- QVERIFY(textInputObject != 0);
-
- // press-and-drag-and-release from x1 to x2
- int x1 = 10;
- int x2 = 70;
- int y = textInputObject->height()/2;
- QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y)));
- {
- QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(canvas->viewport(), &mv);
- }
- QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x2,y)));
-
- QString str1 = textInputObject->selectedText();
- QVERIFY(str1.length() > 3);
-
- // press and drag the current selection.
- x1 = 40;
- x2 = 100;
- QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y)));
- {
- QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(canvas->viewport(), &mv);
- }
- QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x2,y)));
- QString str2 = textInputObject->selectedText();
- QVERIFY(str2.length() > 3);
-
- QVERIFY(str1 != str2); // Verify the second press and drag is a new selection and doesn't not the first moved.
- delete canvas;
-}
-
-void tst_qdeclarativetextinput::mouseSelectionMode_data()
-{
- QTest::addColumn<QString>("qmlfile");
- QTest::addColumn<bool>("selectWords");
-
- // import installed
- QTest::newRow("SelectWords") << SRCDIR "/data/mouseselectionmode_words.qml" << true;
- QTest::newRow("SelectCharacters") << SRCDIR "/data/mouseselectionmode_characters.qml" << false;
- QTest::newRow("default") << SRCDIR "/data/mouseselectionmode_default.qml" << false;
-}
-
-void tst_qdeclarativetextinput::mouseSelectionMode()
-{
- QFETCH(QString, qmlfile);
- QFETCH(bool, selectWords);
-
- QString text = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
-
- QDeclarativeView *canvas = createView(qmlfile);
-
- canvas->show();
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
-
- QVERIFY(canvas->rootObject() != 0);
- QDeclarative1TextInput *textInputObject = qobject_cast<QDeclarative1TextInput *>(canvas->rootObject());
- QVERIFY(textInputObject != 0);
-
- // press-and-drag-and-release from x1 to x2
- int x1 = 10;
- int x2 = 70;
- int y = textInputObject->height()/2;
- QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y)));
- //QTest::mouseMove(canvas->viewport(), canvas->mapFromScene(QPoint(x2,y))); // doesn't work
- QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QApplication::sendEvent(canvas->viewport(), &mv);
- QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x2,y)));
- QString str = textInputObject->selectedText();
- if (selectWords) {
- QCOMPARE(str, text);
- } else {
- QVERIFY(str.length() > 3);
- QVERIFY(str != text);
- }
-
- delete canvas;
-}
-
-void tst_qdeclarativetextinput::horizontalAlignment_data()
-{
- QTest::addColumn<int>("hAlign");
- QTest::addColumn<QString>("expectfile");
-
- QTest::newRow("L") << int(Qt::AlignLeft) << "halign_left";
- QTest::newRow("R") << int(Qt::AlignRight) << "halign_right";
- QTest::newRow("C") << int(Qt::AlignHCenter) << "halign_center";
-}
-
-void tst_qdeclarativetextinput::horizontalAlignment()
-{
- QFETCH(int, hAlign);
- QFETCH(QString, expectfile);
-
- QDeclarativeView *canvas = createView(SRCDIR "/data/horizontalAlignment.qml");
-
- canvas->show();
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
- QObject *ob = canvas->rootObject();
- QVERIFY(ob != 0);
- ob->setProperty("horizontalAlignment",hAlign);
- QImage actual(canvas->width(), canvas->height(), QImage::Format_RGB32);
- actual.fill(qRgb(255,255,255));
- {
- QPainter p(&actual);
- canvas->render(&p);
- }
-
- expectfile = createExpectedFileIfNotFound(expectfile, actual);
-
- QImage expect(expectfile);
-
- QCOMPARE(actual,expect);
-
- delete canvas;
-}
-
-void tst_qdeclarativetextinput::horizontalAlignment_RightToLeft()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/horizontalAlignment_RightToLeft.qml");
- QDeclarative1TextInput *textInput = canvas->rootObject()->findChild<QDeclarative1TextInput*>("text");
- QVERIFY(textInput != 0);
- canvas->show();
-
- const QString rtlText = textInput->text();
-
- QDeclarative1TextInputPrivate *textInputPrivate = QDeclarative1TextInputPrivate::get(textInput);
- QVERIFY(textInputPrivate != 0);
- QVERIFY(-textInputPrivate->hscroll > canvas->width()/2);
-
- // implicit alignment should follow the reading direction of RTL text
- QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignRight);
- QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
- QVERIFY(-textInputPrivate->hscroll > canvas->width()/2);
-
- // explicitly left aligned
- textInput->setHAlign(QDeclarative1TextInput::AlignLeft);
- QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignLeft);
- QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
- QVERIFY(-textInputPrivate->hscroll < canvas->width()/2);
-
- // explicitly right aligned
- textInput->setHAlign(QDeclarative1TextInput::AlignRight);
- QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
- QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignRight);
- QVERIFY(-textInputPrivate->hscroll > canvas->width()/2);
-
- // explicitly center aligned
- textInput->setHAlign(QDeclarative1TextInput::AlignHCenter);
- QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
- QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignHCenter);
- QVERIFY(-textInputPrivate->hscroll < canvas->width()/2);
- QVERIFY(-textInputPrivate->hscroll + textInputPrivate->width() > canvas->width()/2);
-
- // reseted alignment should go back to following the text reading direction
- textInput->resetHAlign();
- QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignRight);
- QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
- QVERIFY(-textInputPrivate->hscroll > canvas->width()/2);
-
- // mirror the text item
- QDeclarativeItemPrivate::get(textInput)->setLayoutMirror(true);
-
- // mirrored implicit alignment should continue to follow the reading direction of the text
- QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignRight);
- QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
- QVERIFY(-textInputPrivate->hscroll > canvas->width()/2);
-
- // explicitly right aligned behaves as left aligned
- textInput->setHAlign(QDeclarative1TextInput::AlignRight);
- QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignRight);
- QCOMPARE(textInput->effectiveHAlign(), QDeclarative1TextInput::AlignLeft);
- QVERIFY(-textInputPrivate->hscroll < canvas->width()/2);
-
- // mirrored explicitly left aligned behaves as right aligned
- textInput->setHAlign(QDeclarative1TextInput::AlignLeft);
- QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignLeft);
- QCOMPARE(textInput->effectiveHAlign(), QDeclarative1TextInput::AlignRight);
- QVERIFY(-textInputPrivate->hscroll > canvas->width()/2);
-
- // disable mirroring
- QDeclarativeItemPrivate::get(textInput)->setLayoutMirror(false);
- QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
- textInput->resetHAlign();
-
- // English text should be implicitly left aligned
- textInput->setText("Hello world!");
- QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignLeft);
- QVERIFY(-textInputPrivate->hscroll < canvas->width()/2);
-
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
-
- // If there is no commited text, the preedit text should determine the alignment.
- textInput->setText(QString());
- { QInputMethodEvent ev(rtlText, QList<QInputMethodEvent::Attribute>()); QApplication::sendEvent(canvas, &ev); }
- QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignRight);
- { QInputMethodEvent ev("Hello world!", QList<QInputMethodEvent::Attribute>()); QApplication::sendEvent(canvas, &ev); }
- QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignLeft);
-
- // Clear pre-edit text. TextInput should maybe do this itself on setText, but that may be
- // redundant as an actual input method may take care of it.
- { QInputMethodEvent ev; QApplication::sendEvent(canvas, &ev); }
-
-#ifndef Q_OS_MAC // QTBUG-18040
- // empty text with implicit alignment follows the system locale-based
- // keyboard input direction from QInputPanel::inputDirection
- textInput->setText("");
- QCOMPARE(textInput->hAlign(), qApp->inputPanel()->inputDirection() == Qt::LeftToRight ?
- QDeclarative1TextInput::AlignLeft : QDeclarative1TextInput::AlignRight);
- if (qApp->inputPanel()->inputDirection() == Qt::LeftToRight)
- QVERIFY(-textInputPrivate->hscroll < canvas->width()/2);
- else
- QVERIFY(-textInputPrivate->hscroll > canvas->width()/2);
- textInput->setHAlign(QDeclarative1TextInput::AlignRight);
- QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignRight);
- QVERIFY(-textInputPrivate->hscroll > canvas->width()/2);
-#endif
-
- delete canvas;
-
-#ifndef Q_OS_MAC // QTBUG-18040
- // alignment of TextInput with no text set to it
- QString componentStr = "import QtQuick 1.0\nTextInput {}";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarative1TextInput *textObject = qobject_cast<QDeclarative1TextInput*>(textComponent.create());
- QCOMPARE(textObject->hAlign(), qApp->inputPanel()->inputDirection() == Qt::LeftToRight ?
- QDeclarative1TextInput::AlignLeft : QDeclarative1TextInput::AlignRight);
- delete textObject;
-#endif
-}
-
-void tst_qdeclarativetextinput::positionAt()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/positionAt.qml");
- QVERIFY(canvas->rootObject() != 0);
- canvas->show();
- canvas->setFocus();
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
-
- QDeclarative1TextInput *textinputObject = qobject_cast<QDeclarative1TextInput *>(canvas->rootObject());
- QVERIFY(textinputObject != 0);
-
- // Check autoscrolled...
-
- int pos = textinputObject->positionAt(textinputObject->width()/2);
-
- QTextLayout layout(textinputObject->text());
- layout.setFont(textinputObject->font());
- layout.beginLayout();
- QTextLine line = layout.createLine();
- layout.endLayout();
-
- int textLeftWidthBegin = qFloor(line.cursorToX(pos - 1));
- int textLeftWidthEnd = qCeil(line.cursorToX(pos + 1));
- int textWidth = floor(line.horizontalAdvance());
-
- QVERIFY(textLeftWidthBegin <= textWidth - textinputObject->width() / 2);
- QVERIFY(textLeftWidthEnd >= textWidth - textinputObject->width() / 2);
-
- int x = textinputObject->positionToRectangle(pos + 1).x() - 1;
- QCOMPARE(textinputObject->positionAt(x, QDeclarative1TextInput::CursorBetweenCharacters), pos + 1);
- QCOMPARE(textinputObject->positionAt(x, QDeclarative1TextInput::CursorOnCharacter), pos);
-
- // Check without autoscroll...
- textinputObject->setAutoScroll(false);
- pos = textinputObject->positionAt(textinputObject->width()/2);
-
- textLeftWidthBegin = qFloor(line.cursorToX(pos - 1));
- textLeftWidthEnd = qCeil(line.cursorToX(pos + 1));
-
- QVERIFY(textLeftWidthBegin <= textinputObject->width() / 2);
- QVERIFY(textLeftWidthEnd >= textinputObject->width() / 2);
-
- x = textinputObject->positionToRectangle(pos + 1).x() - 1;
- QCOMPARE(textinputObject->positionAt(x, QDeclarative1TextInput::CursorBetweenCharacters), pos + 1);
- QCOMPARE(textinputObject->positionAt(x, QDeclarative1TextInput::CursorOnCharacter), pos);
-
- const qreal x0 = textinputObject->positionToRectangle(pos).x();
- const qreal x1 = textinputObject->positionToRectangle(pos + 1).x();
-
- QString preeditText = textinputObject->text().mid(0, pos);
- textinputObject->setText(textinputObject->text().mid(pos));
- textinputObject->setCursorPosition(0);
-
- QInputMethodEvent inputEvent(preeditText, QList<QInputMethodEvent::Attribute>());
- QApplication::sendEvent(canvas, &inputEvent);
-
- // Check all points within the preedit text return the same position.
- QCOMPARE(textinputObject->positionAt(0), 0);
- QCOMPARE(textinputObject->positionAt(x0 / 2), 0);
- QCOMPARE(textinputObject->positionAt(x0), 0);
-
- // Verify positioning returns to normal after the preedit text.
- QCOMPARE(textinputObject->positionAt(x1), 1);
- QCOMPARE(textinputObject->positionToRectangle(1).x(), x1);
-
- delete canvas;
-}
-
-void tst_qdeclarativetextinput::maxLength()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/maxLength.qml");
- QVERIFY(canvas->rootObject() != 0);
- canvas->show();
- canvas->setFocus();
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
-
- QDeclarative1TextInput *textinputObject = qobject_cast<QDeclarative1TextInput *>(canvas->rootObject());
- QVERIFY(textinputObject != 0);
- QVERIFY(textinputObject->text().isEmpty());
- QVERIFY(textinputObject->maxLength() == 10);
- foreach(const QString &str, standard){
- QVERIFY(textinputObject->text().length() <= 10);
- textinputObject->setText(str);
- QVERIFY(textinputObject->text().length() <= 10);
- }
-
- textinputObject->setText("");
- QTRY_VERIFY(textinputObject->hasActiveFocus() == true);
- for(int i=0; i<20; i++){
- QCOMPARE(textinputObject->text().length(), qMin(i,10));
- //simulateKey(canvas, Qt::Key_A);
- QTest::keyPress(canvas, Qt::Key_A);
- QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
- }
-
- delete canvas;
-}
-
-void tst_qdeclarativetextinput::masks()
-{
- //Not a comprehensive test of the possible masks, that's done elsewhere (QLineEdit)
- //QString componentStr = "import QtQuick 1.0\nTextInput { inputMask: 'HHHHhhhh'; }";
- QDeclarativeView *canvas = createView(SRCDIR "/data/masks.qml");
- canvas->show();
- canvas->setFocus();
- QVERIFY(canvas->rootObject() != 0);
- QDeclarative1TextInput *textinputObject = qobject_cast<QDeclarative1TextInput *>(canvas->rootObject());
- QVERIFY(textinputObject != 0);
- QTRY_VERIFY(textinputObject->hasActiveFocus() == true);
- QVERIFY(textinputObject->text().length() == 0);
- QCOMPARE(textinputObject->inputMask(), QString("HHHHhhhh; "));
- for(int i=0; i<10; i++){
- QCOMPARE(qMin(i,8), textinputObject->text().length());
- QCOMPARE(i>=4, textinputObject->hasAcceptableInput());
- //simulateKey(canvas, Qt::Key_A);
- QTest::keyPress(canvas, Qt::Key_A);
- QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
- }
-
- delete canvas;
-}
-
-void tst_qdeclarativetextinput::validators()
-{
- // Note that this test assumes that the validators are working properly
- // so you may need to run their tests first. All validators are checked
- // here to ensure that their exposure to QML is working.
-
- QDeclarativeView *canvas = createView(SRCDIR "/data/validators.qml");
- canvas->show();
- canvas->setFocus();
-
- QVERIFY(canvas->rootObject() != 0);
-
- QDeclarative1TextInput *intInput = qobject_cast<QDeclarative1TextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("intInput")));
- QVERIFY(intInput);
- intInput->setFocus(true);
- QTRY_VERIFY(intInput->hasActiveFocus());
- QTest::keyPress(canvas, Qt::Key_1);
- QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
- QCOMPARE(intInput->text(), QLatin1String("1"));
- QCOMPARE(intInput->hasAcceptableInput(), false);
- QTest::keyPress(canvas, Qt::Key_2);
- QTest::keyRelease(canvas, Qt::Key_2, Qt::NoModifier ,10);
- QCOMPARE(intInput->text(), QLatin1String("1"));
- QCOMPARE(intInput->hasAcceptableInput(), false);
- QTest::keyPress(canvas, Qt::Key_1);
- QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
- QCOMPARE(intInput->text(), QLatin1String("11"));
- QCOMPARE(intInput->hasAcceptableInput(), true);
- QTest::keyPress(canvas, Qt::Key_0);
- QTest::keyRelease(canvas, Qt::Key_0, Qt::NoModifier ,10);
- QCOMPARE(intInput->text(), QLatin1String("11"));
- QCOMPARE(intInput->hasAcceptableInput(), true);
-
- QDeclarative1TextInput *dblInput = qobject_cast<QDeclarative1TextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("dblInput")));
- QTRY_VERIFY(dblInput);
- dblInput->setFocus(true);
- QVERIFY(dblInput->hasActiveFocus() == true);
- QTest::keyPress(canvas, Qt::Key_1);
- QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
- QCOMPARE(dblInput->text(), QLatin1String("1"));
- QCOMPARE(dblInput->hasAcceptableInput(), false);
- QTest::keyPress(canvas, Qt::Key_2);
- QTest::keyRelease(canvas, Qt::Key_2, Qt::NoModifier ,10);
- QCOMPARE(dblInput->text(), QLatin1String("12"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QTest::keyPress(canvas, Qt::Key_Period);
- QTest::keyRelease(canvas, Qt::Key_Period, Qt::NoModifier ,10);
- QCOMPARE(dblInput->text(), QLatin1String("12."));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QTest::keyPress(canvas, Qt::Key_1);
- QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
- QCOMPARE(dblInput->text(), QLatin1String("12.1"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QTest::keyPress(canvas, Qt::Key_1);
- QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
- QCOMPARE(dblInput->text(), QLatin1String("12.11"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QTest::keyPress(canvas, Qt::Key_1);
- QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
- QCOMPARE(dblInput->text(), QLatin1String("12.11"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
-
- QDeclarative1TextInput *strInput = qobject_cast<QDeclarative1TextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("strInput")));
- QTRY_VERIFY(strInput);
- strInput->setFocus(true);
- QVERIFY(strInput->hasActiveFocus() == true);
- QTest::keyPress(canvas, Qt::Key_1);
- QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
- QCOMPARE(strInput->text(), QLatin1String(""));
- QCOMPARE(strInput->hasAcceptableInput(), false);
- QTest::keyPress(canvas, Qt::Key_A);
- QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
- QCOMPARE(strInput->text(), QLatin1String("a"));
- QCOMPARE(strInput->hasAcceptableInput(), false);
- QTest::keyPress(canvas, Qt::Key_A);
- QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
- QCOMPARE(strInput->text(), QLatin1String("aa"));
- QCOMPARE(strInput->hasAcceptableInput(), true);
- QTest::keyPress(canvas, Qt::Key_A);
- QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
- QCOMPARE(strInput->text(), QLatin1String("aaa"));
- QCOMPARE(strInput->hasAcceptableInput(), true);
- QTest::keyPress(canvas, Qt::Key_A);
- QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
- QCOMPARE(strInput->text(), QLatin1String("aaaa"));
- QCOMPARE(strInput->hasAcceptableInput(), true);
- QTest::keyPress(canvas, Qt::Key_A);
- QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
- QCOMPARE(strInput->text(), QLatin1String("aaaa"));
- QCOMPARE(strInput->hasAcceptableInput(), true);
-
- delete canvas;
-}
-
-void tst_qdeclarativetextinput::inputMethods()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/inputmethods.qml");
- canvas->show();
- canvas->setFocus();
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
-
- // test input method hints
- QVERIFY(canvas->rootObject() != 0);
- QDeclarative1TextInput *input = qobject_cast<QDeclarative1TextInput *>(canvas->rootObject());
- QVERIFY(input != 0);
- QVERIFY(input->imHints() & Qt::ImhNoPredictiveText);
- QVERIFY(input->inputMethodHints() & Qt::ImhNoPredictiveText);
- input->setIMHints(Qt::ImhUppercaseOnly);
- QVERIFY(input->imHints() & Qt::ImhUppercaseOnly);
- QVERIFY(input->inputMethodHints() & Qt::ImhUppercaseOnly);
-
- QVERIFY(canvas->rootObject() != 0);
-
- input->setFocus(true);
- QVERIFY(input->hasActiveFocus() == true);
- // test that input method event is committed
- QInputMethodEvent event;
- event.setCommitString( "My ", -12, 0);
- QApplication::sendEvent(canvas, &event);
- QCOMPARE(input->text(), QString("My Hello world!"));
-
- input->setCursorPosition(2);
- event.setCommitString("Your", -2, 2);
- QApplication::sendEvent(canvas, &event);
- QCOMPARE(input->text(), QString("Your Hello world!"));
- QCOMPARE(input->cursorPosition(), 4);
-
- input->setCursorPosition(7);
- event.setCommitString("Goodbye", -2, 5);
- QApplication::sendEvent(canvas, &event);
- QCOMPARE(input->text(), QString("Your Goodbye world!"));
- QCOMPARE(input->cursorPosition(), 12);
-
- input->setCursorPosition(8);
- event.setCommitString("Our", -8, 4);
- QApplication::sendEvent(canvas, &event);
- QCOMPARE(input->text(), QString("Our Goodbye world!"));
- QCOMPARE(input->cursorPosition(), 7);
-
- // test that basic tentative commit gets to text property on preedit state
- input->setText("");
- QList<QInputMethodEvent::Attribute> attributes;
- QInputMethodEvent preeditEvent("test", attributes);
- preeditEvent.setTentativeCommitString("test");
- QApplication::sendEvent(canvas, &preeditEvent);
- QCOMPARE(input->text(), QString("test"));
-
- // tentative commit not allowed present in surrounding text
- QInputMethodQueryEvent queryEvent(Qt::ImSurroundingText);
- QApplication::sendEvent(canvas, &queryEvent);
- QCOMPARE(queryEvent.value(Qt::ImSurroundingText).toString(), QString(""));
-
- // if text with tentative commit does not validate, not allowed to be part of text property
- input->setText(""); // ensure input state is reset
- QValidator *validator = new QIntValidator(0, 100);
- input->setValidator(validator);
- QApplication::sendEvent(canvas, &preeditEvent);
- QCOMPARE(input->text(), QString(""));
- input->setValidator(0);
- delete validator;
-
- delete canvas;
-}
-
-/*
-TextInput element should only handle left/right keys until the cursor reaches
-the extent of the text, then they should ignore the keys.
-
-*/
-void tst_qdeclarativetextinput::navigation()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/navigation.qml");
- canvas->show();
- canvas->setFocus();
-
- QVERIFY(canvas->rootObject() != 0);
-
- QDeclarative1TextInput *input = qobject_cast<QDeclarative1TextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
-
- QVERIFY(input != 0);
- input->setCursorPosition(0);
- QTRY_VERIFY(input->hasActiveFocus() == true);
- simulateKey(canvas, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == false);
- simulateKey(canvas, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == true);
- //QT-2944: If text is selected, ensure we deselect upon cursor motion
- input->setCursorPosition(input->text().length());
- input->select(0,input->text().length());
- QVERIFY(input->selectionStart() != input->selectionEnd());
- simulateKey(canvas, Qt::Key_Right);
- QVERIFY(input->selectionStart() == input->selectionEnd());
- QVERIFY(input->selectionStart() == input->text().length());
- QVERIFY(input->hasActiveFocus() == true);
- simulateKey(canvas, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == false);
- simulateKey(canvas, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == true);
-
- // Up and Down should NOT do Home/End, even on Mac OS X (QTBUG-10438).
- input->setCursorPosition(2);
- QCOMPARE(input->cursorPosition(),2);
- simulateKey(canvas, Qt::Key_Up);
- QCOMPARE(input->cursorPosition(),2);
- simulateKey(canvas, Qt::Key_Down);
- QCOMPARE(input->cursorPosition(),2);
-
- delete canvas;
-}
-
-void tst_qdeclarativetextinput::navigation_RTL()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/navigation.qml");
- canvas->show();
- canvas->setFocus();
-
- QVERIFY(canvas->rootObject() != 0);
-
- QDeclarative1TextInput *input = qobject_cast<QDeclarative1TextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
-
- QVERIFY(input != 0);
- const quint16 arabic_str[] = { 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0647};
- input->setText(QString::fromUtf16(arabic_str, 11));
-
- input->setCursorPosition(0);
- QTRY_VERIFY(input->hasActiveFocus() == true);
-
- // move off
- simulateKey(canvas, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == false);
-
- // move back
- simulateKey(canvas, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == true);
-
- input->setCursorPosition(input->text().length());
- QVERIFY(input->hasActiveFocus() == true);
-
- // move off
- simulateKey(canvas, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == false);
-
- // move back
- simulateKey(canvas, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == true);
-
- delete canvas;
-}
-
-void tst_qdeclarativetextinput::copyAndPaste() {
-#ifndef QT_NO_CLIPBOARD
-
-#ifdef Q_WS_MAC
- {
- PasteboardRef pasteboard;
- OSStatus status = PasteboardCreate(0, &pasteboard);
- if (status == noErr)
- CFRelease(pasteboard);
- else
- QSKIP("This machine doesn't support the clipboard");
- }
-#endif
-
- QString componentStr = "import QtQuick 1.0\nTextInput { text: \"Hello world!\" }";
- QDeclarativeComponent textInputComponent(&engine);
- textInputComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextInput *textInput = qobject_cast<QDeclarative1TextInput*>(textInputComponent.create());
- QVERIFY(textInput != 0);
-
- // copy and paste
- QCOMPARE(textInput->text().length(), 12);
- textInput->select(0, textInput->text().length());;
- textInput->copy();
- QCOMPARE(textInput->selectedText(), QString("Hello world!"));
- QCOMPARE(textInput->selectedText().length(), 12);
- textInput->setCursorPosition(0);
- QVERIFY(textInput->canPaste());
- textInput->paste();
- QCOMPARE(textInput->text(), QString("Hello world!Hello world!"));
- QCOMPARE(textInput->text().length(), 24);
-
- // can paste
- QVERIFY(textInput->canPaste());
- textInput->setReadOnly(true);
- QVERIFY(!textInput->canPaste());
- textInput->setReadOnly(false);
- QVERIFY(textInput->canPaste());
-
- // select word
- textInput->setCursorPosition(0);
- textInput->selectWord();
- QCOMPARE(textInput->selectedText(), QString("Hello"));
-
- // select all and cut
- textInput->selectAll();
- textInput->cut();
- QCOMPARE(textInput->text().length(), 0);
- textInput->paste();
- QCOMPARE(textInput->text(), QString("Hello world!Hello world!"));
- QCOMPARE(textInput->text().length(), 24);
-
- // clear copy buffer
- QClipboard *clipboard = QApplication::clipboard();
- QVERIFY(clipboard);
- clipboard->clear();
- QVERIFY(!textInput->canPaste());
-
- // test that copy functionality is disabled
- // when echo mode is set to hide text/password mode
- int index = 0;
- while (index < 4) {
- QDeclarative1TextInput::EchoMode echoMode = QDeclarative1TextInput::EchoMode(index);
- textInput->setEchoMode(echoMode);
- textInput->setText("My password");
- textInput->select(0, textInput->text().length());;
- textInput->copy();
- if (echoMode == QDeclarative1TextInput::Normal) {
- QVERIFY(!clipboard->text().isEmpty());
- QCOMPARE(clipboard->text(), QString("My password"));
- clipboard->clear();
- } else {
- QVERIFY(clipboard->text().isEmpty());
- }
- index++;
- }
-
- delete textInput;
-#endif
-}
-
-void tst_qdeclarativetextinput::canPasteEmpty() {
-#ifndef QT_NO_CLIPBOARD
-
- QApplication::clipboard()->clear();
-
- QString componentStr = "import QtQuick 1.0\nTextInput { text: \"Hello world!\" }";
- QDeclarativeComponent textInputComponent(&engine);
- textInputComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextInput *textInput = qobject_cast<QDeclarative1TextInput*>(textInputComponent.create());
- QVERIFY(textInput != 0);
-
- QWidgetLineControl lc;
- bool cp = !lc.isReadOnly() && QApplication::clipboard()->text().length() != 0;
- QCOMPARE(textInput->canPaste(), cp);
-
-#endif
-}
-
-void tst_qdeclarativetextinput::canPaste() {
-#ifndef QT_NO_CLIPBOARD
-
- QApplication::clipboard()->setText("Some text");
-
- QString componentStr = "import QtQuick 1.0\nTextInput { text: \"Hello world!\" }";
- QDeclarativeComponent textInputComponent(&engine);
- textInputComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextInput *textInput = qobject_cast<QDeclarative1TextInput*>(textInputComponent.create());
- QVERIFY(textInput != 0);
-
- QWidgetLineControl lc;
- bool cp = !lc.isReadOnly() && QApplication::clipboard()->text().length() != 0;
- QCOMPARE(textInput->canPaste(), cp);
-
-#endif
-}
-
-void tst_qdeclarativetextinput::passwordCharacter()
-{
- QString componentStr = "import QtQuick 1.0\nTextInput { text: \"Hello world!\"; font.family: \"Helvetica\"; echoMode: TextInput.Password }";
- QDeclarativeComponent textInputComponent(&engine);
- textInputComponent.setData(componentStr.toLatin1(), QUrl());
- QDeclarative1TextInput *textInput = qobject_cast<QDeclarative1TextInput*>(textInputComponent.create());
- QVERIFY(textInput != 0);
-
- textInput->setPasswordCharacter("X");
- QSize contentsSize = textInput->contentsSize();
- textInput->setPasswordCharacter(".");
- // QTBUG-12383 content is updated and redrawn
- QVERIFY(contentsSize != textInput->contentsSize());
-
- delete textInput;
-}
-
-void tst_qdeclarativetextinput::cursorDelegate()
-{
- QDeclarativeView* view = createView(SRCDIR "/data/cursorTest.qml");
- view->show();
- view->setFocus();
- QDeclarative1TextInput *textInputObject = view->rootObject()->findChild<QDeclarative1TextInput*>("textInputObject");
- QVERIFY(textInputObject != 0);
- QVERIFY(textInputObject->findChild<QDeclarativeItem*>("cursorInstance"));
- //Test Delegate gets created
- textInputObject->setFocus(true);
- QDeclarativeItem* delegateObject = textInputObject->findChild<QDeclarativeItem*>("cursorInstance");
- QVERIFY(delegateObject);
- //Test Delegate gets moved
- for(int i=0; i<= textInputObject->text().length(); i++){
- textInputObject->setCursorPosition(i);
- QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x()));
- QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y()));
- }
- const QString preedit = "preedit";
- for (int i = 0; i <= preedit.length(); i++) {
- QInputMethodEvent event(preedit, QList<QInputMethodEvent::Attribute>()
- << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, i, 1, QVariant()));
- QApplication::sendEvent(view, &event);
-
- QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x()));
- QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y()));
- }
- textInputObject->setCursorPosition(0);
- QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x()));
- QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y()));
- //Test Delegate gets deleted
- textInputObject->setCursorDelegate(0);
- QVERIFY(!textInputObject->findChild<QDeclarativeItem*>("cursorInstance"));
-
- delete view;
-}
-
-void tst_qdeclarativetextinput::cursorVisible()
-{
- QGraphicsScene scene;
- QGraphicsView view(&scene);
- view.show();
- QApplication::setActiveWindow(&view);
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
-
- QDeclarative1TextInput input;
- QSignalSpy spy(&input, SIGNAL(cursorVisibleChanged(bool)));
-
- QCOMPARE(input.isCursorVisible(), false);
-
- input.setCursorVisible(true);
- QCOMPARE(input.isCursorVisible(), true);
- QCOMPARE(spy.count(), 1);
-
- input.setCursorVisible(false);
- QCOMPARE(input.isCursorVisible(), false);
- QCOMPARE(spy.count(), 2);
-
- input.setFocus(true);
- QCOMPARE(input.isCursorVisible(), false);
- QCOMPARE(spy.count(), 2);
-
- scene.addItem(&input);
- QCOMPARE(input.isCursorVisible(), true);
- QCOMPARE(spy.count(), 3);
-
- input.setFocus(false);
- QCOMPARE(input.isCursorVisible(), false);
- QCOMPARE(spy.count(), 4);
-
- input.setFocus(true);
- QCOMPARE(input.isCursorVisible(), true);
- QCOMPARE(spy.count(), 5);
-
- scene.clearFocus();
- QCOMPARE(input.isCursorVisible(), false);
- QCOMPARE(spy.count(), 6);
-
- scene.setFocus();
- QCOMPARE(input.isCursorVisible(), true);
- QCOMPARE(spy.count(), 7);
-
- view.clearFocus();
- QCOMPARE(input.isCursorVisible(), false);
- QCOMPARE(spy.count(), 8);
-
- view.setFocus();
- QCOMPARE(input.isCursorVisible(), true);
- QCOMPARE(spy.count(), 9);
-
- // on mac, setActiveWindow(0) on mac does not deactivate the current application
- // (you have to switch to a different app or hide the current app to trigger this)
-#if !defined(Q_WS_MAC)
- QApplication::setActiveWindow(0);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(0));
- QCOMPARE(input.isCursorVisible(), false);
- QCOMPARE(spy.count(), 10);
-
- QApplication::setActiveWindow(&view);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
- QCOMPARE(input.isCursorVisible(), true);
- QCOMPARE(spy.count(), 11);
-#endif
-}
-
-void tst_qdeclarativetextinput::cursorRectangle()
-{
- QString text = "Hello World!";
-
- QDeclarative1TextInput input;
- input.setText(text);
- QFontMetricsF fm(input.font());
- input.setWidth(fm.width(text.mid(0, 5)));
-
- QRect r;
-
- // some tolerance for different fonts.
-#ifdef Q_OS_LINUX
- const int error = 2;
-#else
- const int error = 5;
-#endif
-
- for (int i = 0; i <= 5; ++i) {
- input.setCursorPosition(i);
- r = input.cursorRectangle();
- int textWidth = fm.width(text.mid(0, i));
-
- QVERIFY(r.left() < textWidth + error);
- QVERIFY(r.right() > textWidth - error);
- QCOMPARE(input.inputMethodQuery(Qt::ImMicroFocus).toRect(), r);
- }
-
- // Check the cursor rectangle remains within the input bounding rect when auto scrolling.
- QVERIFY(r.left() < input.boundingRect().width());
- QVERIFY(r.right() >= input.width() - error);
-
- for (int i = 6; i < text.length(); ++i) {
- input.setCursorPosition(i);
- QCOMPARE(r, input.cursorRectangle());
- QCOMPARE(input.inputMethodQuery(Qt::ImMicroFocus).toRect(), r);
- }
-
- for (int i = text.length() - 2; i >= 0; --i) {
- input.setCursorPosition(i);
- r = input.cursorRectangle();
- QVERIFY(r.right() >= 0);
- QCOMPARE(input.inputMethodQuery(Qt::ImMicroFocus).toRect(), r);
- }
-}
-
-void tst_qdeclarativetextinput::readOnly()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/readOnly.qml");
- canvas->show();
- canvas->setFocus();
-
- QVERIFY(canvas->rootObject() != 0);
-
- QDeclarative1TextInput *input = qobject_cast<QDeclarative1TextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
-
- QVERIFY(input != 0);
- QTRY_VERIFY(input->hasActiveFocus() == true);
- QVERIFY(input->isReadOnly() == true);
- QString initial = input->text();
- for(int k=Qt::Key_0; k<=Qt::Key_Z; k++)
- simulateKey(canvas, k);
- simulateKey(canvas, Qt::Key_Return);
- simulateKey(canvas, Qt::Key_Space);
- simulateKey(canvas, Qt::Key_Escape);
- QCOMPARE(input->text(), initial);
-
- delete canvas;
-}
-
-void tst_qdeclarativetextinput::echoMode()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/echoMode.qml");
- canvas->show();
- canvas->setFocus();
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
-
- QVERIFY(canvas->rootObject() != 0);
-
- QDeclarative1TextInput *input = qobject_cast<QDeclarative1TextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
-
- QVERIFY(input != 0);
- QTRY_VERIFY(input->hasActiveFocus() == true);
- QString initial = input->text();
- Qt::InputMethodHints ref;
- QCOMPARE(initial, QLatin1String("ABCDefgh"));
- QCOMPARE(input->echoMode(), QDeclarative1TextInput::Normal);
- QCOMPARE(input->displayText(), input->text());
- //Normal
- ref &= ~Qt::ImhHiddenText;
- ref &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
- QCOMPARE(input->inputMethodHints(), ref);
- QCOMPARE(input->imHints(), Qt::ImhNone);
- input->setEchoMode(QDeclarative1TextInput::NoEcho);
- QCOMPARE(input->text(), initial);
- QCOMPARE(input->displayText(), QLatin1String(""));
- QCOMPARE(input->passwordCharacter(), QLatin1String("*"));
- //NoEcho
- ref |= Qt::ImhHiddenText;
- ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
- QCOMPARE(input->inputMethodHints(), ref);
- QCOMPARE(input->imHints(), Qt::ImhNone);
- input->setEchoMode(QDeclarative1TextInput::Password);
- //Password
- ref |= Qt::ImhHiddenText;
- ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
- QCOMPARE(input->text(), initial);
- QCOMPARE(input->displayText(), QLatin1String("********"));
- QCOMPARE(input->inputMethodHints(), ref);
- QCOMPARE(input->imHints(), Qt::ImhNone);
- input->setPasswordCharacter(QChar('Q'));
- QCOMPARE(input->passwordCharacter(), QLatin1String("Q"));
- QCOMPARE(input->text(), initial);
- QCOMPARE(input->displayText(), QLatin1String("QQQQQQQQ"));
- input->setEchoMode(QDeclarative1TextInput::PasswordEchoOnEdit);
- //PasswordEchoOnEdit
- ref &= ~Qt::ImhHiddenText;
- ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
- QCOMPARE(input->inputMethodHints(), ref);
- QCOMPARE(input->imHints(), Qt::ImhNone);
- QCOMPARE(input->text(), initial);
- QCOMPARE(input->displayText(), QLatin1String("QQQQQQQQ"));
- QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("QQQQQQQQ"));
- QTest::keyPress(canvas, Qt::Key_A);//Clearing previous entry is part of PasswordEchoOnEdit
- QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
- QCOMPARE(input->text(), QLatin1String("a"));
- QCOMPARE(input->displayText(), QLatin1String("a"));
- QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("a"));
- input->setFocus(false);
- QVERIFY(input->hasActiveFocus() == false);
- QCOMPARE(input->displayText(), QLatin1String("Q"));
- QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("Q"));
- input->setFocus(true);
- QInputMethodEvent inputEvent;
- inputEvent.setCommitString(initial);
- QApplication::sendEvent(canvas, &inputEvent);
- QCOMPARE(input->text(), initial);
- QCOMPARE(input->displayText(), initial);
- QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), initial);
-
- // Test echo mode doesn't override imHints.
- input->setIMHints(Qt::ImhHiddenText | Qt::ImhDialableCharactersOnly);
- ref |= Qt::ImhDialableCharactersOnly;
- //Normal
- input->setEchoMode(QDeclarative1TextInput::Normal);
- ref |= Qt::ImhHiddenText;
- ref &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
- QCOMPARE(input->inputMethodHints(), ref);
- QCOMPARE(input->imHints(), Qt::ImhHiddenText | Qt::ImhDialableCharactersOnly);
- //NoEcho
- input->setEchoMode(QDeclarative1TextInput::NoEcho);
- ref |= Qt::ImhHiddenText;
- ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
- QCOMPARE(input->inputMethodHints(), ref);
- QCOMPARE(input->imHints(), Qt::ImhHiddenText | Qt::ImhDialableCharactersOnly);
- //Password
- input->setEchoMode(QDeclarative1TextInput::Password);
- ref |= Qt::ImhHiddenText;
- ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
- QCOMPARE(input->inputMethodHints(), ref);
- QCOMPARE(input->imHints(), Qt::ImhHiddenText | Qt::ImhDialableCharactersOnly);
- //PasswordEchoOnEdit
- input->setEchoMode(QDeclarative1TextInput::PasswordEchoOnEdit);
- ref &= ~Qt::ImhHiddenText;
- ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
- QCOMPARE(input->inputMethodHints(), ref);
- QCOMPARE(input->imHints(), Qt::ImhHiddenText | Qt::ImhDialableCharactersOnly);
- //Normal
- input->setEchoMode(QDeclarative1TextInput::Normal);
- ref |= Qt::ImhHiddenText;
- ref &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
- QCOMPARE(input->inputMethodHints(), ref);
- QCOMPARE(input->imHints(), Qt::ImhHiddenText | Qt::ImhDialableCharactersOnly);
-
- delete canvas;
-}
-
-
-#ifdef QT_GUI_PASSWORD_ECHO_DELAY
-void tst_qdeclarativetextinput::passwordEchoDelay()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/echoMode.qml");
- canvas->show();
- canvas->setFocus();
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
-
- QVERIFY(canvas->rootObject() != 0);
-
- QDeclarative1TextInput *input = qobject_cast<QDeclarative1TextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
-
- QChar fillChar = QLatin1Char('*');
-
- input->setEchoMode(QDeclarativeTextInput::Password);
- QCOMPARE(input->displayText(), QString(8, fillChar));
- input->setText(QString());
- QCOMPARE(input->displayText(), QString());
-
- QTest::keyPress(canvas, '0');
- QTest::keyPress(canvas, '1');
- QTest::keyPress(canvas, '2');
- QCOMPARE(input->displayText(), QString(2, fillChar) + QLatin1Char('2'));
- QTest::keyPress(canvas, '3');
- QTest::keyPress(canvas, '4');
- QCOMPARE(input->displayText(), QString(4, fillChar) + QLatin1Char('4'));
- QTest::keyPress(canvas, Qt::Key_Backspace);
- 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);
- QTRY_COMPARE(input->displayText(), QString(5, fillChar));
- QTest::keyPress(canvas, '5');
- QCOMPARE(input->displayText(), QString(5, fillChar) + QLatin1Char('5'));
- input->setFocus(false);
- QVERIFY(!input->hasFocus());
- QCOMPARE(input->displayText(), QString(6, fillChar));
- input->setFocus(true);
- QTRY_VERIFY(input->hasFocus());
- QCOMPARE(input->displayText(), QString(6, fillChar));
- QTest::keyPress(canvas, '6');
- QCOMPARE(input->displayText(), QString(6, fillChar) + QLatin1Char('6'));
-
- QInputMethodEvent ev;
- ev.setCommitString(QLatin1String("7"));
- QApplication::sendEvent(canvas, &ev);
- QCOMPARE(input->displayText(), QString(7, fillChar) + QLatin1Char('7'));
-
- delete canvas;
-}
-#endif
-
-
-void tst_qdeclarativetextinput::simulateKey(QDeclarativeView *view, int key)
-{
- QKeyEvent press(QKeyEvent::KeyPress, key, 0);
- QKeyEvent release(QKeyEvent::KeyRelease, key, 0);
-
- QApplication::sendEvent(view, &press);
- QApplication::sendEvent(view, &release);
-}
-
-QDeclarativeView *tst_qdeclarativetextinput::createView(const QString &filename)
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
-
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- return canvas;
-}
-
-void tst_qdeclarativetextinput::openInputPanelOnClick()
-{
- PlatformInputContext ic;
- QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
- inputPanelPrivate->testContext = &ic;
-
- QGraphicsScene scene;
- QGraphicsView view(&scene);
- QDeclarative1TextInput input;
- QSignalSpy focusOnPressSpy(&input, SIGNAL(activeFocusOnPressChanged(bool)));
- input.setText("Hello world");
- input.setPos(0, 0);
- scene.addItem(&input);
- view.show();
- qApp->setAutoSipEnabled(true);
- QApplication::setActiveWindow(&view);
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
-
- QDeclarativeItemPrivate* pri = QDeclarativeItemPrivate::get(&input);
- QDeclarative1TextInputPrivate *inputPrivate = static_cast<QDeclarative1TextInputPrivate*>(pri);
-
- // input panel on click
- inputPrivate->showInputPanelOnFocus = false;
-
- QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
- view.style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
- QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos()));
- QApplication::processEvents();
- if (behavior == QStyle::RSIP_OnMouseClickAndAlreadyFocused) {
- QCOMPARE(ic.isInputPanelVisible(), false);
- QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos()));
- QApplication::processEvents();
- QCOMPARE(ic.isInputPanelVisible(), true);
- } else if (behavior == QStyle::RSIP_OnMouseClick) {
- QCOMPARE(ic.isInputPanelVisible(), true);
- }
-
- ic.m_showInputPanelCallCount = 0;
- ic.m_hideInputPanelCallCount = 0;
-
- // focus should not cause input panels to open or close
- input.setFocus(false);
- input.setFocus(true);
- input.setFocus(false);
- input.setFocus(true);
- input.setFocus(false);
- QCOMPARE(ic.m_showInputPanelCallCount, 0);
- QCOMPARE(ic.m_hideInputPanelCallCount, 0);
-}
-
-void tst_qdeclarativetextinput::openInputPanelOnFocus()
-{
- PlatformInputContext ic;
- QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
- inputPanelPrivate->testContext = &ic;
-
- ic.clear();
-
- QGraphicsScene scene;
- QGraphicsView view(&scene);
- QDeclarative1TextInput input;
- QSignalSpy focusOnPressSpy(&input, SIGNAL(activeFocusOnPressChanged(bool)));
- input.setText("Hello world");
- input.setPos(0, 0);
- scene.addItem(&input);
- view.show();
- qApp->setAutoSipEnabled(true);
- QApplication::setActiveWindow(&view);
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
-
- QDeclarativeItemPrivate* pri = QDeclarativeItemPrivate::get(&input);
- QDeclarative1TextInputPrivate *inputPrivate = static_cast<QDeclarative1TextInputPrivate*>(pri);
- inputPrivate->showInputPanelOnFocus = true;
-
- // test default values
- QVERIFY(input.focusOnPress());
- QCOMPARE(ic.m_showInputPanelCallCount, 0);
- QCOMPARE(ic.m_hideInputPanelCallCount, 0);
-
- // focus on press, input panel on focus
- QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos()));
- QApplication::processEvents();
- QVERIFY(input.hasActiveFocus());
- QCOMPARE(ic.isInputPanelVisible(), true);
- ic.clear();
-
- // no events on release
- QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos()));
- QCOMPARE(ic.isInputPanelVisible(), false);
- ic.clear();
-
- // if already focused, input panel can be opened on press
- QVERIFY(input.hasActiveFocus());
- QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos()));
- QApplication::processEvents();
- QCOMPARE(ic.isInputPanelVisible(), true);
- ic.clear();
-
- // input method should stay enabled if focus
- // is lost to an item that also accepts inputs
- QDeclarative1TextInput anotherInput;
- scene.addItem(&anotherInput);
- anotherInput.setFocus(true);
- QApplication::processEvents();
- QCOMPARE(ic.isInputPanelVisible(), true);
- ic.clear();
- QVERIFY(view.testAttribute(Qt::WA_InputMethodEnabled));
-
- // input method should be disabled if focus
- // is lost to an item that doesn't accept inputs
- QDeclarativeItem item;
- scene.addItem(&item);
- item.setFocus(true);
- QApplication::processEvents();
- QCOMPARE(ic.isInputPanelVisible(), false);
- QVERIFY(!view.testAttribute(Qt::WA_InputMethodEnabled));
- ic.clear();
-
- // no automatic input panel events should
- // be sent if activeFocusOnPress is false
- input.setFocusOnPress(false);
- QCOMPARE(focusOnPressSpy.count(),1);
- input.setFocusOnPress(false);
- QCOMPARE(focusOnPressSpy.count(),1);
- input.setFocus(false);
- input.setFocus(true);
- QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos()));
- QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos()));
- QApplication::processEvents();
- QCOMPARE(ic.m_showInputPanelCallCount, 0);
- QCOMPARE(ic.m_hideInputPanelCallCount, 0);
-
- // one show input panel event should
- // be set when openSoftwareInputPanel is called
- input.openSoftwareInputPanel();
- QCOMPARE(ic.isInputPanelVisible(), true);
- QCOMPARE(ic.m_hideInputPanelCallCount, 0);
- ic.clear();
-
- // one close input panel event should
- // be sent when closeSoftwareInputPanel is called
- input.closeSoftwareInputPanel();
- QCOMPARE(ic.m_showInputPanelCallCount, 0);
- QVERIFY(ic.m_hideInputPanelCallCount > 0);
- ic.clear();
-
- // set activeFocusOnPress back to true
- input.setFocusOnPress(true);
- QCOMPARE(focusOnPressSpy.count(),2);
- input.setFocusOnPress(true);
- QCOMPARE(focusOnPressSpy.count(),2);
- input.setFocus(false);
- QApplication::processEvents();
- QCOMPARE(ic.m_showInputPanelCallCount, 0);
- QCOMPARE(ic.m_hideInputPanelCallCount, 0);
- ic.clear();
-
- // input panel should not re-open
- // if focus has already been set
- input.setFocus(true);
- QCOMPARE(ic.isInputPanelVisible(), true);
- ic.clear();
- input.setFocus(true);
- QCOMPARE(ic.isInputPanelVisible(), false);
-
- // input method should be disabled
- // if TextInput loses focus
- input.setFocus(false);
- QApplication::processEvents();
- QVERIFY(!view.testAttribute(Qt::WA_InputMethodEnabled));
-
- // input method should not be enabled
- // if TextEdit is read only.
- input.setReadOnly(true);
- ic.clear();
- input.setFocus(true);
- QApplication::processEvents();
- QCOMPARE(ic.isInputPanelVisible(), false);
- QVERIFY(!view.testAttribute(Qt::WA_InputMethodEnabled));
-}
-
-class MyTextInput : public QDeclarative1TextInput
-{
-public:
- MyTextInput(QDeclarativeItem *parent = 0) : QDeclarative1TextInput(parent)
- {
- nbPaint = 0;
- }
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
- {
- nbPaint++;
- QDeclarative1TextInput::paint(painter, option, widget);
- }
- int nbPaint;
-};
-
-void tst_qdeclarativetextinput::setHAlignClearCache()
-{
- QGraphicsScene scene;
- QGraphicsView view(&scene);
- MyTextInput input;
- input.setText("Hello world");
- scene.addItem(&input);
- view.show();
- QApplication::setActiveWindow(&view);
- QTest::qWaitForWindowShown(&view);
- QTRY_VERIFY(input.nbPaint >= 1);
- input.nbPaint = 0;
- input.setHAlign(QDeclarative1TextInput::AlignRight);
- QApplication::processEvents();
- //Changing the alignment should trigger a repaint
- QTRY_VERIFY(input.nbPaint >= 1);
-}
-
-void tst_qdeclarativetextinput::focusOutClearSelection()
-{
- QGraphicsScene scene;
- QGraphicsView view(&scene);
- QDeclarative1TextInput input;
- QDeclarative1TextInput input2;
- input.setText(QLatin1String("Hello world"));
- input.setFocus(true);
- scene.addItem(&input2);
- scene.addItem(&input);
- view.show();
- QApplication::setActiveWindow(&view);
- QTest::qWaitForWindowShown(&view);
- input.select(2,5);
- //The selection should work
- QTRY_COMPARE(input.selectedText(), QLatin1String("llo"));
- input2.setFocus(true);
- QApplication::processEvents();
- //The input lost the focus selection should be cleared
- QTRY_COMPARE(input.selectedText(), QLatin1String(""));
-}
-
-void tst_qdeclarativetextinput::geometrySignals()
-{
- QDeclarativeComponent component(&engine, SRCDIR "/data/geometrySignals.qml");
- QObject *o = component.create();
- QVERIFY(o);
- QCOMPARE(o->property("bindingWidth").toInt(), 400);
- QCOMPARE(o->property("bindingHeight").toInt(), 500);
- delete o;
-}
-
-void tst_qdeclarativetextinput::testQtQuick11Attributes()
-{
- QFETCH(QString, code);
- QFETCH(QString, warning);
- QFETCH(QString, error);
-
- QDeclarativeEngine engine;
- QObject *obj;
-
- QDeclarativeComponent valid(&engine);
- valid.setData("import QtQuick 1.1; TextInput { " + code.toUtf8() + " }", QUrl(""));
- obj = valid.create();
- QVERIFY(obj);
- QVERIFY(valid.errorString().isEmpty());
- delete obj;
-
- QDeclarativeComponent invalid(&engine);
- invalid.setData("import QtQuick 1.0; TextInput { " + code.toUtf8() + " }", QUrl(""));
- QTest::ignoreMessage(QtWarningMsg, warning.toUtf8());
- obj = invalid.create();
- QCOMPARE(invalid.errorString(), error);
- delete obj;
-}
-
-void tst_qdeclarativetextinput::testQtQuick11Attributes_data()
-{
- QTest::addColumn<QString>("code");
- QTest::addColumn<QString>("warning");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("canPaste") << "property bool foo: canPaste"
- << "<Unknown File>:1: ReferenceError: Can't find variable: canPaste"
- << "";
-
- QTest::newRow("moveCursorSelection") << "Component.onCompleted: moveCursorSelection(0, TextEdit.SelectCharacters)"
- << "<Unknown File>:1: ReferenceError: Can't find variable: moveCursorSelection"
- << "";
-
- QTest::newRow("deselect") << "Component.onCompleted: deselect()"
- << "<Unknown File>:1: ReferenceError: Can't find variable: deselect"
- << "";
-}
-
-void tst_qdeclarativetextinput::preeditAutoScroll()
-{
- QString committedText = "super";
- QString preeditText = "califragisiticexpialidocious!";
-
- QGraphicsScene scene;
- QGraphicsView view(&scene);
- QDeclarative1TextInput input;
- QFontMetricsF fm(input.font());
- input.setWidth(fm.width(committedText));
- input.setText(committedText);
- input.setPos(0, 0);
- input.setFocus(true);
- scene.addItem(&input);
- view.show();
- QApplication::setActiveWindow(&view);
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
-
- QSignalSpy cursorRectangleSpy(&input, SIGNAL(cursorRectangleChanged()));
- int cursorRectangleChanges = 0;
-
- // test the text is scrolled so the preedit is visible.
- sendPreeditText(preeditText.mid(0, 3), 1);
- QVERIFY(input.positionAt(0) != 0);
- QVERIFY(input.cursorRectangle().left() < input.boundingRect().width());
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
-
- // test the text is scrolled back when the preedit is removed.
- QInputMethodEvent emptyEvent;
- QApplication::sendEvent(&view, &emptyEvent);
- QCOMPARE(input.positionAt(0), 0);
- QCOMPARE(input.positionAt(input.width()), 5);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
-
- // some tolerance for different fonts.
-#ifdef Q_OS_LINUX
- const int error = 2;
-#else
- const int error = 5;
-#endif
-
- // test if the preedit is larger than the text input that the
- // character preceding the cursor is still visible.
- qreal x = input.positionToRectangle(0).x();
- for (int i = 0; i < 3; ++i) {
- sendPreeditText(preeditText, i + 1);
- QVERIFY(input.cursorRectangle().right() >= fm.width(preeditText.at(i)) - error);
- QVERIFY(input.positionToRectangle(0).x() < x);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
- x = input.positionToRectangle(0).x();
- }
- for (int i = 1; i >= 0; --i) {
- sendPreeditText(preeditText, i + 1);
- QVERIFY(input.cursorRectangle().right() >= fm.width(preeditText.at(i)) - error);
- QVERIFY(input.positionToRectangle(0).x() > x);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
- x = input.positionToRectangle(0).x();
- }
-
- // Test incrementing the preedit cursor doesn't cause further
- // scrolling when right most text is visible.
- sendPreeditText(preeditText, preeditText.length() - 3);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
- x = input.positionToRectangle(0).x();
- for (int i = 2; i >= 0; --i) {
- sendPreeditText(preeditText, preeditText.length() - i);
- QCOMPARE(input.positionToRectangle(0).x(), x);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
- }
- for (int i = 1; i < 3; ++i) {
- sendPreeditText(preeditText, preeditText.length() - i);
- QCOMPARE(input.positionToRectangle(0).x(), x);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
- }
-
- // Test disabling auto scroll.
- QApplication::sendEvent(&view, &emptyEvent);
-
- input.setAutoScroll(false);
- sendPreeditText(preeditText.mid(0, 3), 1);
- QCOMPARE(input.positionAt(0), 0);
- QCOMPARE(input.positionAt(input.width()), 5);
-
- QApplication::sendEvent(&view, &emptyEvent);
- input.setAutoScroll(true);
- // Test committing pre-edit text at the start of the string. QTBUG-18789
- input.setCursorPosition(0);
- sendPreeditText(input.text(), 5);
- QCOMPARE(input.positionAt(0), 0);
-
- QInputMethodEvent event;
- event.setCommitString(input.text());
- QApplication::sendEvent(&view, &emptyEvent);
-
- QCOMPARE(input.positionAt(0), 0);
- QCOMPARE(input.positionAt(input.width()), 5);
-}
-
-void tst_qdeclarativetextinput::preeditMicroFocus()
-{
- QString preeditText = "super";
- PlatformInputContext ic;
- QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
- inputPanelPrivate->testContext = &ic;
-
- QGraphicsScene scene;
- QGraphicsView view(&scene);
- QDeclarative1TextInput input;
- input.setPos(0, 0);
- input.setAutoScroll(false);
- input.setFocus(true);
- scene.addItem(&input);
- view.show();
- QApplication::setActiveWindow(&view);
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
-
- QRect currentRect;
- QRect previousRect = input.inputMethodQuery(Qt::ImMicroFocus).toRect();
-
- // Verify that the micro focus rect is positioned the same for position 0 as
- // it would be if there was no preedit text.
- ic.clear();
- sendPreeditText(preeditText, 0);
- currentRect = input.inputMethodQuery(Qt::ImMicroFocus).toRect();
- QCOMPARE(currentRect, previousRect);
-#if defined(Q_WS_X11) || defined(Q_WS_QWS)
- QVERIFY(ic.updateCallCount > 0);
-#endif
-
- // Verify that the micro focus rect moves to the left as the cursor position
- // is incremented.
- for (int i = 1; i <= 5; ++i) {
- ic.clear();
- sendPreeditText(preeditText, i);
- currentRect = input.inputMethodQuery(Qt::ImMicroFocus).toRect();
- QVERIFY(previousRect.left() < currentRect.left());
-#if defined(Q_WS_X11) || defined(Q_WS_QWS)
- QVERIFY(ic.updateCallCount > 0);
-#endif
- previousRect = currentRect;
- }
-
- // Verify that if there is no preedit cursor then the micro focus rect is the
- // same as it would be if it were positioned at the end of the preedit text.
- sendPreeditText(preeditText, 0);
- ic.clear();
- QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>());
- QApplication::sendEvent(qApp->focusObject(), &imEvent);
- currentRect = input.inputMethodQuery(Qt::ImMicroFocus).toRect();
- QCOMPARE(currentRect, previousRect);
-#if defined(Q_WS_X11) || defined(Q_WS_QWS)
- QVERIFY(ic.updateCallCount > 0);
-#endif
-}
-
-void tst_qdeclarativetextinput::inputContextMouseHandler()
-{
- PlatformInputContext platformInputContext;
- QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
- inputPanelPrivate->testContext = &platformInputContext;
-
- QString text = "supercalifragisiticexpialidocious!";
-
- QGraphicsScene scene;
- QGraphicsView view(&scene);
-
- QDeclarative1TextInput input;
- input.setWidth(200);
- input.setCursorPosition(12);
- input.setPos(0, 0);
- input.setFocus(true);
- scene.addItem(&input);
- view.show();
- QApplication::setActiveWindow(&view);
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
-
- QFontMetricsF fm(input.font());
- const qreal y = fm.height() / 2;
-
- QPoint position2 = view.mapFromScene(input.mapToScene(QPointF(fm.width(text.mid(0, 2)), y)));
-
- QInputMethodEvent inputEvent(text.mid(0, 5), QList<QInputMethodEvent::Attribute>());
- QApplication::sendEvent(&view, &inputEvent);
-
- QTest::mousePress(view.viewport(), Qt::LeftButton, Qt::NoModifier, position2);
- QTest::mouseRelease(view.viewport(), Qt::LeftButton, Qt::NoModifier, position2);
- QApplication::processEvents();
-
- QCOMPARE(platformInputContext.m_action, QInputPanel::Click);
- QCOMPARE(platformInputContext.m_invokeActionCallCount, 1);
- QCOMPARE(platformInputContext.m_cursorPosition, 2);
-}
-
-void tst_qdeclarativetextinput::inputMethodComposing()
-{
- QString text = "supercalifragisiticexpialidocious!";
-
- QGraphicsScene scene;
- QGraphicsView view(&scene);
- QDeclarative1TextInput input;
- input.setWidth(200);
- input.setText(text.mid(0, 12));
- input.setCursorPosition(12);
- input.setPos(0, 0);
- input.setFocus(true);
- scene.addItem(&input);
- view.show();
- QApplication::setActiveWindow(&view);
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
-
- QSignalSpy spy(&input, SIGNAL(inputMethodComposingChanged()));
-
- QCOMPARE(input.isInputMethodComposing(), false);
-
- {
- QInputMethodEvent inputEvent(text.mid(3), QList<QInputMethodEvent::Attribute>());
- QApplication::sendEvent(qApp->focusObject(), &inputEvent);
- }
-
- QCOMPARE(input.isInputMethodComposing(), true);
- QCOMPARE(spy.count(), 1);
-
- {
- QInputMethodEvent inputEvent(text.mid(12), QList<QInputMethodEvent::Attribute>());
- QApplication::sendEvent(qApp->focusObject(), &inputEvent);
- }
-
- QCOMPARE(input.isInputMethodComposing(), true);
- QCOMPARE(spy.count(), 1);
-
- {
- QInputMethodEvent inputEvent;
- QApplication::sendEvent(qApp->focusObject(), &inputEvent);
- }
- QCOMPARE(input.isInputMethodComposing(), false);
- QCOMPARE(spy.count(), 2);
-}
-
-void tst_qdeclarativetextinput::cursorRectangleSize()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/positionAt.qml");
- QVERIFY(canvas->rootObject() != 0);
- canvas->show();
- canvas->setFocus();
- QApplication::setActiveWindow(canvas);
- QTest::qWaitForWindowShown(canvas);
-
- QDeclarative1TextInput *textInput = qobject_cast<QDeclarative1TextInput *>(canvas->rootObject());
- QVERIFY(textInput != 0);
- textInput->setFocus(Qt::OtherFocusReason);
- QRectF cursorRect = textInput->positionToRectangle(textInput->cursorPosition());
- QRectF microFocusFromScene = canvas->scene()->inputMethodQuery(Qt::ImMicroFocus).toRectF();
- QRectF microFocusFromApp= QApplication::focusWidget()->inputMethodQuery(Qt::ImMicroFocus).toRectF();
-
- QCOMPARE(microFocusFromScene.size(), cursorRect.size());
- QCOMPARE(microFocusFromApp.size(), cursorRect.size());
-}
-
-QTEST_MAIN(tst_qdeclarativetextinput)
-
-#include "tst_qdeclarativetextinput.moc"
diff --git a/tests/auto/qtquick1/qdeclarativetimer/qdeclarativetimer.pro b/tests/auto/qtquick1/qdeclarativetimer/qdeclarativetimer.pro
deleted file mode 100644
index 4709d21ac0..0000000000
--- a/tests/auto/qtquick1/qdeclarativetimer/qdeclarativetimer.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativetimer
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativetimer.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-QT += core-private gui-private widgets-private declarative-private qtquick1-private testlib
diff --git a/tests/auto/qtquick1/qdeclarativetimer/tst_qdeclarativetimer.cpp b/tests/auto/qtquick1/qdeclarativetimer/tst_qdeclarativetimer.cpp
deleted file mode 100644
index 189f6c6dc0..0000000000
--- a/tests/auto/qtquick1/qdeclarativetimer/tst_qdeclarativetimer.cpp
+++ /dev/null
@@ -1,334 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtTest/QSignalSpy>
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick1/private/qdeclarativetimer_p.h>
-#include <QtQuick1/qdeclarativeitem.h>
-#include <QDebug>
-
-class tst_qdeclarativetimer : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativetimer();
-
-private slots:
- void notRepeating();
- void notRepeatingStart();
- void repeat();
- void noTriggerIfNotRunning();
- void triggeredOnStart();
- void triggeredOnStartRepeat();
- void changeDuration();
- void restart();
- void parentProperty();
-};
-
-class TimerHelper : public QObject
-{
- Q_OBJECT
-public:
- TimerHelper() : QObject(), count(0)
- {
- }
-
- int count;
-
-public slots:
- void timeout() {
- ++count;
- }
-};
-
-#define TIMEOUT_TIMEOUT 200
-
-tst_qdeclarativetimer::tst_qdeclarativetimer()
-{
-}
-
-void tst_qdeclarativetimer::notRepeating()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 1.0\nTimer { interval: 100; running: true }"), QUrl::fromLocalFile(""));
- QDeclarative1Timer *timer = qobject_cast<QDeclarative1Timer*>(component.create());
- QVERIFY(timer != 0);
- QVERIFY(timer->isRunning());
- QVERIFY(!timer->isRepeating());
- QCOMPARE(timer->interval(), 100);
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
-
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(helper.count, 1);
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(helper.count, 1);
- QVERIFY(timer->isRunning() == false);
-}
-
-void tst_qdeclarativetimer::notRepeatingStart()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 1.0\nTimer { interval: 100 }"), QUrl::fromLocalFile(""));
- QDeclarative1Timer *timer = qobject_cast<QDeclarative1Timer*>(component.create());
- QVERIFY(timer != 0);
- QVERIFY(!timer->isRunning());
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
-
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(helper.count, 0);
-
- timer->start();
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(helper.count, 1);
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(helper.count, 1);
- QVERIFY(timer->isRunning() == false);
-
- delete timer;
-}
-
-void tst_qdeclarativetimer::repeat()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 1.0\nTimer { interval: 100; repeat: true; running: true }"), QUrl::fromLocalFile(""));
- QDeclarative1Timer *timer = qobject_cast<QDeclarative1Timer*>(component.create());
- QVERIFY(timer != 0);
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
- QCOMPARE(helper.count, 0);
-
- QTest::qWait(TIMEOUT_TIMEOUT);
- QVERIFY(helper.count > 0);
- int oldCount = helper.count;
-
- QTest::qWait(TIMEOUT_TIMEOUT);
- QVERIFY(helper.count > oldCount);
- QVERIFY(timer->isRunning());
-
- oldCount = helper.count;
- timer->stop();
-
- QTest::qWait(TIMEOUT_TIMEOUT);
- QVERIFY(helper.count == oldCount);
- QVERIFY(timer->isRunning() == false);
-
- QSignalSpy spy(timer, SIGNAL(repeatChanged()));
-
- timer->setRepeating(false);
- QVERIFY(!timer->isRepeating());
- QCOMPARE(spy.count(),1);
-
- timer->setRepeating(false);
- QCOMPARE(spy.count(),1);
-
- timer->setRepeating(true);
- QCOMPARE(spy.count(),2);
-
- delete timer;
-}
-
-void tst_qdeclarativetimer::triggeredOnStart()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 1.0\nTimer { interval: 100; running: true; triggeredOnStart: true }"), QUrl::fromLocalFile(""));
- QDeclarative1Timer *timer = qobject_cast<QDeclarative1Timer*>(component.create());
- QVERIFY(timer != 0);
- QVERIFY(timer->triggeredOnStart());
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
- QTest::qWait(1);
- QCOMPARE(helper.count, 1);
-
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(helper.count, 2);
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(helper.count, 2);
- QVERIFY(timer->isRunning() == false);
-
- QSignalSpy spy(timer, SIGNAL(triggeredOnStartChanged()));
-
- timer->setTriggeredOnStart(false);
- QVERIFY(!timer->triggeredOnStart());
- QCOMPARE(spy.count(),1);
-
- timer->setTriggeredOnStart(false);
- QCOMPARE(spy.count(),1);
-
- timer->setTriggeredOnStart(true);
- QCOMPARE(spy.count(),2);
-
- delete timer;
-}
-
-void tst_qdeclarativetimer::triggeredOnStartRepeat()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 1.0\nTimer { interval: 100; running: true; triggeredOnStart: true; repeat: true }"), QUrl::fromLocalFile(""));
- QDeclarative1Timer *timer = qobject_cast<QDeclarative1Timer*>(component.create());
- QVERIFY(timer != 0);
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
- QTest::qWait(1);
- QCOMPARE(helper.count, 1);
-
- QTest::qWait(TIMEOUT_TIMEOUT);
- QVERIFY(helper.count > 1);
- int oldCount = helper.count;
- QTest::qWait(TIMEOUT_TIMEOUT);
- QVERIFY(helper.count > oldCount);
- QVERIFY(timer->isRunning());
-
- delete timer;
-}
-
-void tst_qdeclarativetimer::noTriggerIfNotRunning()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray(
- "import QtQuick 1.0\n"
- "Item { property bool ok: true\n"
- "Timer { id: t1; interval: 100; repeat: true; running: true; onTriggered: if (!running) ok=false }"
- "Timer { interval: 10; running: true; onTriggered: t1.running=false }"
- "}"
- ), QUrl::fromLocalFile(""));
- QObject *item = component.create();
- QVERIFY(item != 0);
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(item->property("ok").toBool(), true);
-
- delete item;
-}
-
-void tst_qdeclarativetimer::changeDuration()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 1.0\nTimer { interval: 200; repeat: true; running: true }"), QUrl::fromLocalFile(""));
- QDeclarative1Timer *timer = qobject_cast<QDeclarative1Timer*>(component.create());
- QVERIFY(timer != 0);
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
- QCOMPARE(helper.count, 0);
-
- QTest::qWait(500);
- QCOMPARE(helper.count, 2);
-
- timer->setInterval(500);
-
- QTest::qWait(600);
- QCOMPARE(helper.count, 3);
- QVERIFY(timer->isRunning());
-
- QSignalSpy spy(timer, SIGNAL(intervalChanged()));
-
- timer->setInterval(200);
- QCOMPARE(timer->interval(), 200);
- QCOMPARE(spy.count(),1);
-
- timer->setInterval(200);
- QCOMPARE(spy.count(),1);
-
- timer->setInterval(300);
- QCOMPARE(spy.count(),2);
-
- delete timer;
-}
-
-void tst_qdeclarativetimer::restart()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 1.0\nTimer { interval: 500; repeat: true; running: true }"), QUrl::fromLocalFile(""));
- QDeclarative1Timer *timer = qobject_cast<QDeclarative1Timer*>(component.create());
- QVERIFY(timer != 0);
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
- QCOMPARE(helper.count, 0);
-
- QTest::qWait(600);
- QCOMPARE(helper.count, 1);
-
- QTest::qWait(300);
-
- timer->restart();
-
- QTest::qWait(700);
-
- QCOMPARE(helper.count, 2);
- QVERIFY(timer->isRunning());
-
- delete timer;
-}
-
-void tst_qdeclarativetimer::parentProperty()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 1.0\nItem { Timer { objectName: \"timer\"; running: parent.visible } }"), QUrl::fromLocalFile(""));
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create());
- QVERIFY(item != 0);
- QDeclarative1Timer *timer = item->findChild<QDeclarative1Timer*>("timer");
- QVERIFY(timer != 0);
-
- QVERIFY(timer->isRunning());
-
- delete timer;
-}
-
-QTEST_MAIN(tst_qdeclarativetimer)
-
-#include "tst_qdeclarativetimer.moc"
diff --git a/tests/auto/qtquick1/qdeclarativeview/data/error1.qml b/tests/auto/qtquick1/qdeclarativeview/data/error1.qml
deleted file mode 100644
index 4887ff908f..0000000000
--- a/tests/auto/qtquick1/qdeclarativeview/data/error1.qml
+++ /dev/null
@@ -1,5 +0,0 @@
-import QtQuick 1.0
-
-Rectangle {
- nonExistentProperty: 5
-}
diff --git a/tests/auto/qtquick1/qdeclarativeview/data/resizemodedeclarativeitem.qml b/tests/auto/qtquick1/qdeclarativeview/data/resizemodedeclarativeitem.qml
deleted file mode 100644
index e5501a10dc..0000000000
--- a/tests/auto/qtquick1/qdeclarativeview/data/resizemodedeclarativeitem.qml
+++ /dev/null
@@ -1,5 +0,0 @@
-import QtQuick 1.0
-Item {
- width: 200
- height: 200
-}
diff --git a/tests/auto/qtquick1/qdeclarativeview/data/resizemodegraphicswidget.qml b/tests/auto/qtquick1/qdeclarativeview/data/resizemodegraphicswidget.qml
deleted file mode 100644
index f27090888b..0000000000
--- a/tests/auto/qtquick1/qdeclarativeview/data/resizemodegraphicswidget.qml
+++ /dev/null
@@ -1,5 +0,0 @@
-import QtQuick 1.0
-QGraphicsWidget {
- width: 200
- height: 200
-}
diff --git a/tests/auto/qtquick1/qdeclarativeview/qdeclarativeview.pro b/tests/auto/qtquick1/qdeclarativeview/qdeclarativeview.pro
deleted file mode 100644
index 08f10dfc9e..0000000000
--- a/tests/auto/qtquick1/qdeclarativeview/qdeclarativeview.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeview
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeview.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-QT += core-private gui-private widgets-private declarative-private qtquick1-private widgets testlib
diff --git a/tests/auto/qtquick1/qdeclarativeview/tst_qdeclarativeview.cpp b/tests/auto/qtquick1/qdeclarativeview/tst_qdeclarativeview.cpp
deleted file mode 100644
index bcbeb1a480..0000000000
--- a/tests/auto/qtquick1/qdeclarativeview/tst_qdeclarativeview.cpp
+++ /dev/null
@@ -1,333 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QSignalSpy>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtQuick1/qdeclarativeview.h>
-#include <QtQuick1/qdeclarativeitem.h>
-#include <QtWidgets/qgraphicswidget.h>
-
-class tst_QDeclarativeView : public QObject
-{
- Q_OBJECT
-public:
- tst_QDeclarativeView();
-
-private slots:
- void scene();
- void resizemodedeclarativeitem();
- void resizemodegraphicswidget();
- void errors();
-
-private:
- template<typename T>
- T *findItem(QGraphicsObject *parent, const QString &objectName);
-};
-
-
-tst_QDeclarativeView::tst_QDeclarativeView()
-{
-}
-
-void tst_QDeclarativeView::scene()
-{
- // QTBUG-14771
- QGraphicsScene scene;
- scene.setItemIndexMethod(QGraphicsScene::NoIndex);
- scene.setStickyFocus(true);
-
- QDeclarativeView *view = new QDeclarativeView();
- QVERIFY(view);
- QVERIFY(view->scene());
- view->setScene(&scene);
- QCOMPARE(view->scene(), &scene);
-
- view->setSource(QUrl::fromLocalFile(SRCDIR "/data/resizemodedeclarativeitem.qml"));
- QDeclarativeItem* declarativeItem = qobject_cast<QDeclarativeItem*>(view->rootObject());
- QVERIFY(declarativeItem);
- QVERIFY(scene.items().count() > 0);
- QCOMPARE(scene.items().at(0), declarativeItem);
-
- delete view;
-}
-
-void tst_QDeclarativeView::resizemodedeclarativeitem()
-{
- QWidget window;
- QDeclarativeView *canvas = new QDeclarativeView(&window);
- QVERIFY(canvas);
- QSignalSpy sceneResizedSpy(canvas, SIGNAL(sceneResized(QSize)));
- canvas->setResizeMode(QDeclarativeView::SizeRootObjectToView);
- QCOMPARE(QSize(0,0), canvas->initialSize());
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/resizemodedeclarativeitem.qml"));
- QDeclarativeItem* declarativeItem = qobject_cast<QDeclarativeItem*>(canvas->rootObject());
- QVERIFY(declarativeItem);
- window.show();
-
- // initial size from root object
- QCOMPARE(declarativeItem->width(), 200.0);
- QCOMPARE(declarativeItem->height(), 200.0);
- QCOMPARE(canvas->size(), QSize(200, 200));
- QCOMPARE(canvas->size(), canvas->sizeHint());
- QCOMPARE(canvas->size(), canvas->initialSize());
- QCOMPARE(sceneResizedSpy.count(), 1);
-
- // size update from view
- canvas->resize(QSize(80,100));
- QCOMPARE(declarativeItem->width(), 80.0);
- QCOMPARE(declarativeItem->height(), 100.0);
- QCOMPARE(canvas->size(), QSize(80, 100));
- QCOMPARE(canvas->size(), canvas->sizeHint());
- QCOMPARE(sceneResizedSpy.count(), 2);
-
- canvas->setResizeMode(QDeclarativeView::SizeViewToRootObject);
-
- // size update from view disabled
- canvas->resize(QSize(60,80));
- QCOMPARE(declarativeItem->width(), 80.0);
- QCOMPARE(declarativeItem->height(), 100.0);
- QCOMPARE(canvas->size(), QSize(60, 80));
- QCOMPARE(sceneResizedSpy.count(), 3);
-
- // size update from root object
- declarativeItem->setWidth(250);
- declarativeItem->setHeight(350);
- QCOMPARE(declarativeItem->width(), 250.0);
- QCOMPARE(declarativeItem->height(), 350.0);
- QTRY_COMPARE(canvas->size(), QSize(250, 350));
- QCOMPARE(canvas->size(), QSize(250, 350));
- QCOMPARE(canvas->size(), canvas->sizeHint());
- QCOMPARE(sceneResizedSpy.count(), 4);
-
- // reset canvas
- window.hide();
- delete canvas;
- canvas = new QDeclarativeView(&window);
- QVERIFY(canvas);
- QSignalSpy sceneResizedSpy2(canvas, SIGNAL(sceneResized(QSize)));
- canvas->setResizeMode(QDeclarativeView::SizeViewToRootObject);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/resizemodedeclarativeitem.qml"));
- declarativeItem = qobject_cast<QDeclarativeItem*>(canvas->rootObject());
- QVERIFY(declarativeItem);
- window.show();
-
- // initial size for root object
- QCOMPARE(declarativeItem->width(), 200.0);
- QCOMPARE(declarativeItem->height(), 200.0);
- QCOMPARE(canvas->size(), canvas->sizeHint());
- QCOMPARE(canvas->size(), canvas->initialSize());
- QCOMPARE(sceneResizedSpy2.count(), 1);
-
- // size update from root object
- declarativeItem->setWidth(80);
- declarativeItem->setHeight(100);
- QCOMPARE(declarativeItem->width(), 80.0);
- QCOMPARE(declarativeItem->height(), 100.0);
- QTRY_COMPARE(canvas->size(), QSize(80, 100));
- QCOMPARE(canvas->size(), QSize(80, 100));
- QCOMPARE(canvas->size(), canvas->sizeHint());
- QCOMPARE(sceneResizedSpy2.count(), 2);
-
- // size update from root object disabled
- canvas->setResizeMode(QDeclarativeView::SizeRootObjectToView);
- declarativeItem->setWidth(60);
- declarativeItem->setHeight(80);
- QCOMPARE(canvas->width(), 80);
- QCOMPARE(canvas->height(), 100);
- QCOMPARE(QSize(declarativeItem->width(), declarativeItem->height()), canvas->sizeHint());
- QCOMPARE(sceneResizedSpy2.count(), 2);
-
- // size update from view
- canvas->resize(QSize(200,300));
- QCOMPARE(declarativeItem->width(), 200.0);
- QCOMPARE(declarativeItem->height(), 300.0);
- QCOMPARE(canvas->size(), QSize(200, 300));
- QCOMPARE(canvas->size(), canvas->sizeHint());
- QCOMPARE(sceneResizedSpy2.count(), 3);
-
- delete canvas;
-
- canvas = new QDeclarativeView(&window);
- canvas->resize(300, 300);
- canvas->setResizeMode(QDeclarativeView::SizeRootObjectToView);
- QCOMPARE(QSize(0,0), canvas->initialSize());
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/resizemodedeclarativeitem.qml"));
- declarativeItem = qobject_cast<QDeclarativeItem*>(canvas->rootObject());
- QVERIFY(declarativeItem);
- window.show();
-
- // initial size from root object
- QCOMPARE(declarativeItem->width(), 300.0);
- QCOMPARE(declarativeItem->height(), 300.0);
- QCOMPARE(canvas->size(), QSize(300, 300));
- QCOMPARE(canvas->size(), canvas->sizeHint());
- QCOMPARE(canvas->initialSize(), QSize(200, 200));
- delete canvas;
-}
-
-void tst_QDeclarativeView::resizemodegraphicswidget()
-{
- QWidget window;
- QDeclarativeView *canvas = new QDeclarativeView(&window);
- QVERIFY(canvas);
- QSignalSpy sceneResizedSpy(canvas, SIGNAL(sceneResized(QSize)));
- canvas->setResizeMode(QDeclarativeView::SizeRootObjectToView);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/resizemodegraphicswidget.qml"));
- QGraphicsWidget* graphicsWidget = qobject_cast<QGraphicsWidget*>(canvas->rootObject());
- QVERIFY(graphicsWidget);
- window.show();
-
- // initial size from root object
- QCOMPARE(graphicsWidget->size(), QSizeF(200.0, 200.0));
- QCOMPARE(canvas->size(), QSize(200, 200));
- QCOMPARE(canvas->size(), QSize(200, 200));
- QCOMPARE(canvas->size(), canvas->sizeHint());
- QCOMPARE(canvas->size(), canvas->initialSize());
- QCOMPARE(sceneResizedSpy.count(), 1);
-
- // size update from view
- canvas->resize(QSize(80,100));
- QCOMPARE(graphicsWidget->size(), QSizeF(80.0,100.0));
- QCOMPARE(canvas->size(), QSize(80,100));
- QCOMPARE(canvas->size(), canvas->sizeHint());
- QCOMPARE(sceneResizedSpy.count(), 2);
-
- // size update from view disabled
- canvas->setResizeMode(QDeclarativeView::SizeViewToRootObject);
- canvas->resize(QSize(60,80));
- QCOMPARE(graphicsWidget->size(), QSizeF(80.0,100.0));
- QCOMPARE(canvas->size(), QSize(60, 80));
- QCOMPARE(sceneResizedSpy.count(), 3);
-
- // size update from root object
- graphicsWidget->resize(QSizeF(250.0, 350.0));
- QCOMPARE(graphicsWidget->size(), QSizeF(250.0,350.0));
- QCOMPARE(canvas->size(), QSize(250, 350));
- QCOMPARE(canvas->size(), canvas->sizeHint());
- QCOMPARE(sceneResizedSpy.count(), 4);
-
- // reset canvas
- window.hide();
- delete canvas;
- canvas = new QDeclarativeView(&window);
- QVERIFY(canvas);
- QSignalSpy sceneResizedSpy2(canvas, SIGNAL(sceneResized(QSize)));
- canvas->setResizeMode(QDeclarativeView::SizeViewToRootObject);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/resizemodegraphicswidget.qml"));
- graphicsWidget = qobject_cast<QGraphicsWidget*>(canvas->rootObject());
- QVERIFY(graphicsWidget);
- window.show();
-
- // initial size from root object
- QCOMPARE(graphicsWidget->size(), QSizeF(200.0, 200.0));
- QCOMPARE(canvas->size(), QSize(200, 200));
- QCOMPARE(canvas->size(), canvas->sizeHint());
- QCOMPARE(canvas->size(), canvas->initialSize());
- QCOMPARE(sceneResizedSpy2.count(), 1);
-
- // size update from root object
- graphicsWidget->resize(QSizeF(80, 100));
- QCOMPARE(graphicsWidget->size(), QSizeF(80.0, 100.0));
- QCOMPARE(canvas->size(), QSize(80, 100));
- QCOMPARE(canvas->size(), canvas->sizeHint());
- QCOMPARE(sceneResizedSpy2.count(), 2);
-
- // size update from root object disabled
- canvas->setResizeMode(QDeclarativeView::SizeRootObjectToView);
- graphicsWidget->resize(QSizeF(60,80));
- QCOMPARE(canvas->size(), QSize(80,100));
- QCOMPARE(QSize(graphicsWidget->size().width(), graphicsWidget->size().height()), canvas->sizeHint());
- QCOMPARE(sceneResizedSpy2.count(), 2);
-
- // size update from view
- canvas->resize(QSize(200,300));
- QCOMPARE(graphicsWidget->size(), QSizeF(200.0, 300.0));
- QCOMPARE(canvas->size(), QSize(200, 300));
- QCOMPARE(canvas->size(), canvas->sizeHint());
- QCOMPARE(sceneResizedSpy2.count(), 3);
-
- window.show();
- delete canvas;
-}
-
-static void silentErrorsMsgHandler(QtMsgType, const char *)
-{
-}
-
-void tst_QDeclarativeView::errors()
-{
- QDeclarativeView *canvas = new QDeclarativeView;
- QVERIFY(canvas);
- QtMsgHandler old = qInstallMsgHandler(silentErrorsMsgHandler);
- canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/error1.qml"));
- qInstallMsgHandler(old);
- QVERIFY(canvas->status() == QDeclarativeView::Error);
- QVERIFY(canvas->errors().count() == 1);
- delete canvas;
-}
-
-template<typename T>
-T *tst_QDeclarativeView::findItem(QGraphicsObject *parent, const QString &objectName)
-{
- if (!parent)
- return 0;
-
- const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->QGraphicsObject::children().count() << "children";
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- //qDebug() << "try" << item;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName))
- return static_cast<T*>(item);
- item = findItem<T>(item, objectName);
- if (item)
- return static_cast<T*>(item);
- }
-
- return 0;
-}
-
-QTEST_MAIN(tst_QDeclarativeView)
-
-#include "tst_qdeclarativeview.moc"
diff --git a/tests/auto/qtquick1/qdeclarativeviewer/data/orientation.qml b/tests/auto/qtquick1/qdeclarativeviewer/data/orientation.qml
deleted file mode 100644
index fb343120f1..0000000000
--- a/tests/auto/qtquick1/qdeclarativeviewer/data/orientation.qml
+++ /dev/null
@@ -1,19 +0,0 @@
-import QtQuick 1.0
-Rectangle {
- color: "black"
- width: (runtime.orientation == Orientation.Landscape || runtime.orientation == Orientation.LandscapeInverted) ? 300 : 200
- height: (runtime.orientation == Orientation.Landscape || runtime.orientation == Orientation.LandscapeInverted) ? 200 : 300
- Text {
- text: {
- if (runtime.orientation == Orientation.Portrait)
- return "Portrait"
- if (runtime.orientation == Orientation.PortraitInverted)
- return "PortraitInverted"
- if (runtime.orientation == Orientation.Landscape)
- return "Landscape"
- if (runtime.orientation == Orientation.LandscapeInverted)
- return "LandscapeInverted"
- }
- color: "white"
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativeviewer/qdeclarativeviewer.pro b/tests/auto/qtquick1/qdeclarativeviewer/qdeclarativeviewer.pro
deleted file mode 100644
index b49264bcca..0000000000
--- a/tests/auto/qtquick1/qdeclarativeviewer/qdeclarativeviewer.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeviewer
-macx:CONFIG -= app_bundle
-
-include(../../../../tools/qmlviewer/qml.pri)
-
-SOURCES += tst_qdeclarativeviewer.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test insignificant_test
-QT += core-private gui-private widgets-private declarative-private qtquick1-private v8-private testlib
diff --git a/tests/auto/qtquick1/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/qtquick1/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
deleted file mode 100644
index fb52c3b862..0000000000
--- a/tests/auto/qtquick1/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
+++ /dev/null
@@ -1,388 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtQuick1/qdeclarativeview.h>
-#include <QtQuick1/qdeclarativeitem.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtWidgets/qmenubar.h>
-#include <QSignalSpy>
-#include "qmlruntime.h"
-#include "deviceorientation.h"
-
-#if defined(Q_OS_MAC) || defined(Q_WS_MAEMO_5)
-# define MENUBAR_HEIGHT(mw) 0
-#else
-# define MENUBAR_HEIGHT(mw) (mw->menuBar()->height())
-#endif
-
-
-class QDeclarativeViewerTest : public QDeclarativeViewer
-{
-public:
- QDeclarativeViewerTest() : QDeclarativeViewer(), resizeCount(0) {}
-
- void resizeEvent (QResizeEvent *event) {
- QDeclarativeViewer::resizeEvent(event);
- ++resizeCount;
- }
-
- int resizeCount;
-};
-
-class tst_QDeclarativeViewer : public QObject
-
-{
- Q_OBJECT
-public:
- tst_QDeclarativeViewer();
-
-private slots:
- void runtimeContextProperty();
- void loading();
- void fileBrowser();
- void resizing();
- void paths();
- void slowMode();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_QDeclarativeViewer::tst_QDeclarativeViewer()
-{
-}
-
-#define TEST_INITIAL_SIZES(viewer) { \
- QDeclarativeItem* rootItem = qobject_cast<QDeclarativeItem*>(viewer->view()->rootObject()); \
- QVERIFY(rootItem); \
-\
- QCOMPARE(rootItem->width(), 200.0); \
- QCOMPARE(rootItem->height(), 300.0); \
- QTRY_COMPARE(viewer->view()->size(), QSize(200, 300)); \
- QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); \
- QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer))); \
- QCOMPARE(viewer->size(), viewer->sizeHint()); \
-}
-
-void tst_QDeclarativeViewer::runtimeContextProperty()
-{
- QDeclarativeViewer *viewer = new QDeclarativeViewer();
- QVERIFY(viewer);
- viewer->open(SRCDIR "/data/orientation.qml");
- QVERIFY(viewer->view());
- QVERIFY(viewer->menuBar());
- QDeclarativeItem* rootItem = qobject_cast<QDeclarativeItem*>(viewer->view()->rootObject());
- QVERIFY(rootItem);
- QObject *runtimeObject = qvariant_cast<QObject*>(viewer->view()->engine()->rootContext()->contextProperty("runtime"));
- QVERIFY(runtimeObject);
-
- // test isActiveWindow property
- QVERIFY(!runtimeObject->property("isActiveWindow").toBool());
-
- viewer->show();
- QApplication::setActiveWindow(viewer);
- QTest::qWaitForWindowShown(viewer);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(viewer));
-
- QVERIFY(runtimeObject->property("isActiveWindow").toBool());
-
- TEST_INITIAL_SIZES(viewer);
-
- // test orientation property
- QCOMPARE(runtimeObject->property("orientation").toInt(), int(DeviceOrientation::Portrait));
-
- viewer->rotateOrientation();
- qApp->processEvents();
-
- QCOMPARE(runtimeObject->property("orientation").toInt(), int(DeviceOrientation::Landscape));
- QCOMPARE(rootItem->width(), 300.0);
-
- QCOMPARE(rootItem->width(), 300.0);
- QCOMPARE(rootItem->height(), 200.0);
- QTRY_COMPARE(viewer->view()->size(), QSize(300, 200));
- QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(300, 200));
- QCOMPARE(viewer->size(), QSize(300, 200 + MENUBAR_HEIGHT(viewer)));
- QCOMPARE(viewer->size(), viewer->sizeHint());
-
- viewer->rotateOrientation();
- qApp->processEvents();
-
- QCOMPARE(runtimeObject->property("orientation").toInt(), int(DeviceOrientation::PortraitInverted));
-
- QCOMPARE(rootItem->width(), 200.0);
- QCOMPARE(rootItem->height(), 300.0);
- QTRY_COMPARE(viewer->view()->size(), QSize(200, 300));
- QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300));
- QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer)));
- QCOMPARE(viewer->size(), viewer->sizeHint());
-
- viewer->rotateOrientation();
- qApp->processEvents();
-
- QCOMPARE(runtimeObject->property("orientation").toInt(), int(DeviceOrientation::LandscapeInverted));
-
- viewer->rotateOrientation();
- qApp->processEvents();
-
- QCOMPARE(runtimeObject->property("orientation").toInt(), int(DeviceOrientation::Portrait));
-
- viewer->hide();
- QVERIFY(!runtimeObject->property("isActiveWindow").toBool());
-
- delete viewer;
-}
-
-void tst_QDeclarativeViewer::loading()
-{
- QDeclarativeViewer *viewer = new QDeclarativeViewer();
- QVERIFY(viewer);
- viewer->setSizeToView(true);
- viewer->open(SRCDIR "/data/orientation.qml");
- QVERIFY(viewer->view());
- QVERIFY(viewer->menuBar());
- QDeclarativeItem* rootItem = qobject_cast<QDeclarativeItem*>(viewer->view()->rootObject());
- QVERIFY(rootItem);
- viewer->show();
-
- QApplication::setActiveWindow(viewer);
- QTest::qWaitForWindowShown(viewer);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(viewer));
-
- TEST_INITIAL_SIZES(viewer);
-
- viewer->resize(QSize(250, 350));
- qApp->processEvents();
-
- // window resized
- QTRY_COMPARE(rootItem->width(), 250.0);
- QTRY_COMPARE(rootItem->height(), 350.0 - MENUBAR_HEIGHT(viewer));
- QCOMPARE(viewer->view()->size(), QSize(250, 350 - MENUBAR_HEIGHT(viewer)));
- QCOMPARE(viewer->view()->initialSize(), QSize(200, 300));
- QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(250, 350 - MENUBAR_HEIGHT(viewer)));
- QCOMPARE(viewer->size(), QSize(250, 350));
- QCOMPARE(viewer->size(), viewer->sizeHint());
-
- QSignalSpy statusSpy(viewer->view(), SIGNAL(statusChanged(QDeclarativeView::Status)));
- viewer->reload();
- QTRY_VERIFY(statusSpy.count() == 1);
- rootItem = qobject_cast<QDeclarativeItem*>(viewer->view()->rootObject());
- QVERIFY(rootItem);
-
- // reload cause the window to return back to initial size
- QTRY_COMPARE(rootItem->width(), 200.0);
- QTRY_COMPARE(rootItem->height(), 300.0);
- QCOMPARE(viewer->view()->size(), QSize(200, 300));
- QCOMPARE(viewer->view()->initialSize(), QSize(200, 300));
- QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300));
- QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer)));
- QCOMPARE(viewer->size(), viewer->sizeHint());
-
- viewer->resize(QSize(250, 350));
- qApp->processEvents();
-
- // window resized again
- QTRY_COMPARE(rootItem->width(), 250.0);
- QTRY_COMPARE(rootItem->height(), 350.0 - MENUBAR_HEIGHT(viewer));
- QCOMPARE(viewer->view()->size(), QSize(250, 350 - MENUBAR_HEIGHT(viewer)));
- QCOMPARE(viewer->view()->initialSize(), QSize(200, 300));
- QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(250, 350 - MENUBAR_HEIGHT(viewer)));
- QCOMPARE(viewer->size(), QSize(250, 350));
- QCOMPARE(viewer->size(), viewer->sizeHint());
-
- viewer->open(SRCDIR "/data/orientation.qml");
- rootItem = qobject_cast<QDeclarativeItem*>(viewer->view()->rootObject());
- QVERIFY(rootItem);
-
- // open also causes the window to return back to initial size
- QTRY_COMPARE(rootItem->width(), 200.0);
- QTRY_COMPARE(rootItem->height(), 300.0);
- QCOMPARE(viewer->view()->size(), QSize(200, 300));
- QCOMPARE(viewer->view()->initialSize(), QSize(200, 300));
- QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300));
- QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer)));
- QCOMPARE(viewer->size(), viewer->sizeHint());
-
- delete viewer;
-}
-
-static int numberOfWarnings = 0;
-static void checkWarnings(QtMsgType, const char *)
-{
- numberOfWarnings++;
-}
-
-void tst_QDeclarativeViewer::fileBrowser()
-{
- QtMsgHandler previousMsgHandler = qInstallMsgHandler(checkWarnings);
- QDeclarativeViewer *viewer = new QDeclarativeViewer();
- QVERIFY(viewer);
- viewer->setUseNativeFileBrowser(false);
- viewer->openFile();
- viewer->show();
- QCoreApplication::processEvents();
- qInstallMsgHandler(previousMsgHandler);
-
- // QTBUG-15720
- QVERIFY(numberOfWarnings == 0);
-
- QApplication::setActiveWindow(viewer);
- QTest::qWaitForWindowShown(viewer);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(viewer));
-
- // Browser.qml successfully loaded
- QDeclarativeItem* browserItem = qobject_cast<QDeclarativeItem*>(viewer->view()->rootObject());
- QVERIFY(viewer->view());
- QVERIFY(viewer->menuBar());
- QVERIFY(browserItem);
-
- // load something
- viewer->open(SRCDIR "/data/orientation.qml");
- QVERIFY(viewer->view());
- QVERIFY(viewer->menuBar());
- QDeclarativeItem* rootItem = qobject_cast<QDeclarativeItem*>(viewer->view()->rootObject());
- QVERIFY(rootItem);
- QVERIFY(browserItem != rootItem);
-
- // go back to Browser.qml
- viewer->openFile();
- browserItem = qobject_cast<QDeclarativeItem*>(viewer->view()->rootObject());
- QVERIFY(viewer->view());
- QVERIFY(viewer->menuBar());
- QVERIFY(browserItem);
-
- delete viewer;
-}
-
-void tst_QDeclarativeViewer::resizing()
-{
- QDeclarativeViewerTest *viewer = new QDeclarativeViewerTest();
- QVERIFY(viewer);
- viewer->open(SRCDIR "/data/orientation.qml");
- QVERIFY(viewer->view());
- QVERIFY(viewer->menuBar());
- QDeclarativeItem* rootItem = qobject_cast<QDeclarativeItem*>(viewer->view()->rootObject());
- QVERIFY(rootItem);
- viewer->show();
-
- QApplication::setActiveWindow(viewer);
- QTest::qWaitForWindowShown(viewer);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(viewer));
-
- TEST_INITIAL_SIZES(viewer);
-
- QCOMPARE(viewer->resizeCount, 1);
-
- viewer->setSizeToView(false);
-
- // size view to root object
- rootItem->setWidth(150);
- rootItem->setHeight(200);
- qApp->processEvents();
-
- QCOMPARE(rootItem->width(), 150.0);
- QCOMPARE(rootItem->height(), 200.0);
- QTRY_COMPARE(viewer->view()->size(), QSize(150, 200));
- QCOMPARE(viewer->view()->initialSize(), QSize(200, 300));
- QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(150, 200));
- QCOMPARE(viewer->size(), QSize(150, 200 + MENUBAR_HEIGHT(viewer)));
-
- QCOMPARE(viewer->resizeCount, 2);
-
- // do not size root object to view
- viewer->resize(QSize(180,250));
- QCOMPARE(rootItem->width(), 150.0);
- QCOMPARE(rootItem->height(), 200.0);
-
- viewer->setSizeToView(true);
-
- // size root object to view
- viewer->resize(QSize(250,350));
- qApp->processEvents();
-
- QTRY_COMPARE(rootItem->width(), 250.0);
- QTRY_COMPARE(rootItem->height(), 350.0 - MENUBAR_HEIGHT(viewer));
- QTRY_COMPARE(viewer->view()->size(), QSize(250, 350 - MENUBAR_HEIGHT(viewer)));
- QCOMPARE(viewer->view()->initialSize(), QSize(200, 300));
- QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(250, 350 - MENUBAR_HEIGHT(viewer)));
- QCOMPARE(viewer->size(), QSize(250, 350));
-
- // do not size view to root object
- viewer->resizeCount = 0;
-
- rootItem->setWidth(150);
- rootItem->setHeight(200);
- QTRY_COMPARE(viewer->size(), QSize(250, 350));
-
- QCOMPARE(viewer->resizeCount, 0);
-
- delete viewer;
-}
-
-void tst_QDeclarativeViewer::paths()
-{
- QDeclarativeViewer *viewer = new QDeclarativeViewer();
- QVERIFY(viewer);
-
- viewer->addLibraryPath("miscImportPath");
- viewer->view()->engine()->importPathList().contains("miscImportPath");
-
- viewer->addPluginPath("miscPluginPath");
- viewer->view()->engine()->pluginPathList().contains("miscPluginPath");
-
- delete viewer;
-}
-
-void tst_QDeclarativeViewer::slowMode()
-{
- QDeclarativeViewer *viewer = new QDeclarativeViewer();
- QVERIFY(viewer);
-
- viewer->setSlowMode(true);
- viewer->setSlowMode(false);
-
- delete viewer;
-}
-
-QTEST_MAIN(tst_QDeclarativeViewer)
-
-#include "tst_qdeclarativeviewer.moc"
diff --git a/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/datalist.qml b/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/datalist.qml
deleted file mode 100644
index ebf1eea674..0000000000
--- a/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/datalist.qml
+++ /dev/null
@@ -1,19 +0,0 @@
-import QtQuick 1.0
-
-ListView {
- width: 100
- height: 100
- anchors.fill: parent
- model: VisualDataModel {
- id: visualModel
- objectName: "visualModel"
- model: myModel
- delegate: Component {
- Rectangle {
- height: 25
- width: 100
- Text { objectName: "display"; text: display }
- }
- }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/modelproperties.qml b/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/modelproperties.qml
deleted file mode 100644
index 8cd5763684..0000000000
--- a/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/modelproperties.qml
+++ /dev/null
@@ -1,17 +0,0 @@
-import QtQuick 1.0
-
-ListView {
- model: myModel
- delegate: Item {
- objectName: "delegate"
- property variant test1: name
- property variant test2: model.name
- property variant test3: modelData
- property variant test4: model.modelData
- property variant test5: modelData.name
- property variant test6: model
- property variant test7: index
- property variant test8: model.index
- property variant test9: model.modelData.name
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/modelproperties2.qml b/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/modelproperties2.qml
deleted file mode 100644
index 67721c92a1..0000000000
--- a/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/modelproperties2.qml
+++ /dev/null
@@ -1,17 +0,0 @@
-import QtQuick 1.0
-
-ListView {
- model: myModel
- delegate: Item {
- objectName: "delegate"
- property variant test1: display
- property variant test2: model.display
- property variant test3: modelData
- property variant test4: model.modelData
- property variant test5: modelData.display
- property variant test6: model
- property variant test7: index
- property variant test8: model.index
- property variant test9: model.modelData.display
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/objectlist.qml b/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/objectlist.qml
deleted file mode 100644
index 4134259714..0000000000
--- a/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/objectlist.qml
+++ /dev/null
@@ -1,19 +0,0 @@
-import QtQuick 1.0
-
-ListView {
- width: 100
- height: 100
- anchors.fill: parent
- model: myModel
- delegate: Component {
- Rectangle {
- height: 25
- width: 100
- color: model.modelData.color
- Text { objectName: "name"; text: name }
- Text { objectName: "section"; text: parent.ListView.section }
- }
- }
- section.property: "name"
- section.criteria: ViewSection.FullString
-}
diff --git a/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/singlerole1.qml b/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/singlerole1.qml
deleted file mode 100644
index d72e128b82..0000000000
--- a/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/singlerole1.qml
+++ /dev/null
@@ -1,11 +0,0 @@
-import QtQuick 1.0
-
-ListView {
- width: 100
- height: 100
- anchors.fill: parent
- model: myModel
- delegate: Component {
- Text { objectName: "name"; text: name }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/singlerole2.qml b/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/singlerole2.qml
deleted file mode 100644
index b9e666cec3..0000000000
--- a/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/singlerole2.qml
+++ /dev/null
@@ -1,11 +0,0 @@
-import QtQuick 1.0
-
-ListView {
- width: 100
- height: 100
- anchors.fill: parent
- model: myModel
- delegate: Component {
- Text { objectName: "name"; text: modelData }
- }
-}
diff --git a/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/visualdatamodel.qml b/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/visualdatamodel.qml
deleted file mode 100644
index a5c44d0151..0000000000
--- a/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/visualdatamodel.qml
+++ /dev/null
@@ -1,11 +0,0 @@
-import QtQuick 1.0
-
-VisualDataModel {
- function setRoot() {
- rootIndex = modelIndex(0);
- }
- function setRootToParent() {
- rootIndex = parentModelIndex();
- }
- model: myModel
-}
diff --git a/tests/auto/qtquick1/qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro b/tests/auto/qtquick1/qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro
deleted file mode 100644
index 128e4ff244..0000000000
--- a/tests/auto/qtquick1/qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativevisualdatamodel
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativevisualdatamodel.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
-QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib
diff --git a/tests/auto/qtquick1/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp b/tests/auto/qtquick1/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
deleted file mode 100644
index 18bce6860a..0000000000
--- a/tests/auto/qtquick1/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
+++ /dev/null
@@ -1,528 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QSignalSpy>
-#include <QStandardItemModel>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtQuick1/qdeclarativeview.h>
-#include <QtQuick1/private/qdeclarativelistview_p.h>
-#include <QtQuick1/private/qdeclarativetext_p.h>
-#include <QtQuick1/private/qdeclarativevisualitemmodel_p.h>
-#include <private/qdeclarativevaluetype_p.h>
-#include <math.h>
-
-static void initStandardTreeModel(QStandardItemModel *model)
-{
- QStandardItem *item;
- item = new QStandardItem(QLatin1String("Row 1 Item"));
- model->insertRow(0, item);
-
- item = new QStandardItem(QLatin1String("Row 2 Item"));
- item->setCheckable(true);
- model->insertRow(1, item);
-
- QStandardItem *childItem = new QStandardItem(QLatin1String("Row 2 Child Item"));
- item->setChild(0, childItem);
-
- item = new QStandardItem(QLatin1String("Row 3 Item"));
- item->setIcon(QIcon());
- model->insertRow(2, item);
-}
-
-class SingleRoleModel : public QAbstractListModel
-{
- Q_OBJECT
-
-public:
- SingleRoleModel(QObject *parent = 0) {
- QHash<int, QByteArray> roles;
- roles.insert(Qt::DisplayRole , "name");
- setRoleNames(roles);
- list << "one" << "two" << "three" << "four";
- }
-
-public slots:
- void set(int idx, QString string) {
- list[idx] = string;
- emit dataChanged(index(idx,0), index(idx,0));
- }
-
-protected:
- int rowCount(const QModelIndex &parent = QModelIndex()) const {
- return list.count();
- }
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const {
- if (role == Qt::DisplayRole)
- return list.at(index.row());
- return QVariant();
- }
-
-private:
- QStringList list;
-};
-
-
-class tst_qdeclarativevisualdatamodel : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativevisualdatamodel();
-
-private slots:
- void rootIndex();
- void updateLayout();
- void childChanged();
- void objectListModel();
- void singleRole();
- void modelProperties();
- void noDelegate();
-
-private:
- QDeclarativeEngine engine;
- template<typename T>
- T *findItem(QGraphicsObject *parent, const QString &objectName, int index);
-};
-
-class DataObject : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
- Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged)
-
-public:
- DataObject(QObject *parent=0) : QObject(parent) {}
- DataObject(const QString &name, const QString &color, QObject *parent=0)
- : QObject(parent), m_name(name), m_color(color) { }
-
-
- QString name() const { return m_name; }
- void setName(const QString &name) {
- if (name != m_name) {
- m_name = name;
- emit nameChanged();
- }
- }
-
- QString color() const { return m_color; }
- void setColor(const QString &color) {
- if (color != m_color) {
- m_color = color;
- emit colorChanged();
- }
- }
-
-signals:
- void nameChanged();
- void colorChanged();
-
-private:
- QString m_name;
- QString m_color;
-};
-
-tst_qdeclarativevisualdatamodel::tst_qdeclarativevisualdatamodel()
-{
-}
-
-void tst_qdeclarativevisualdatamodel::rootIndex()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/visualdatamodel.qml"));
-
- QStandardItemModel model;
- initStandardTreeModel(&model);
-
- engine.rootContext()->setContextProperty("myModel", &model);
-
- QDeclarative1VisualDataModel *obj = qobject_cast<QDeclarative1VisualDataModel*>(c.create());
- QVERIFY(obj != 0);
-
- QMetaObject::invokeMethod(obj, "setRoot");
- QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == model.index(0,0));
-
- QMetaObject::invokeMethod(obj, "setRootToParent");
- QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == QModelIndex());
-
- QMetaObject::invokeMethod(obj, "setRoot");
- QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == model.index(0,0));
- model.clear(); // will emit modelReset()
- QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == QModelIndex());
-
- delete obj;
-}
-
-void tst_qdeclarativevisualdatamodel::updateLayout()
-{
- QDeclarativeView view;
-
- QStandardItemModel model;
- initStandardTreeModel(&model);
-
- view.rootContext()->setContextProperty("myModel", &model);
-
- view.setSource(QUrl::fromLocalFile(SRCDIR "/data/datalist.qml"));
-
- QDeclarative1ListView *listview = qobject_cast<QDeclarative1ListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QDeclarative1Text *name = findItem<QDeclarative1Text>(contentItem, "display", 0);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 1 Item"));
- name = findItem<QDeclarative1Text>(contentItem, "display", 1);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 2 Item"));
- name = findItem<QDeclarative1Text>(contentItem, "display", 2);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 3 Item"));
-
- model.invisibleRootItem()->sortChildren(0, Qt::DescendingOrder);
-
- name = findItem<QDeclarative1Text>(contentItem, "display", 0);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 3 Item"));
- name = findItem<QDeclarative1Text>(contentItem, "display", 1);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 2 Item"));
- name = findItem<QDeclarative1Text>(contentItem, "display", 2);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 1 Item"));
-}
-
-void tst_qdeclarativevisualdatamodel::childChanged()
-{
- QDeclarativeView view;
-
- QStandardItemModel model;
- initStandardTreeModel(&model);
-
- view.rootContext()->setContextProperty("myModel", &model);
-
- view.setSource(QUrl::fromLocalFile(SRCDIR "/data/datalist.qml"));
-
- QDeclarative1ListView *listview = qobject_cast<QDeclarative1ListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QDeclarative1VisualDataModel *vdm = listview->findChild<QDeclarative1VisualDataModel*>("visualModel");
- vdm->setRootIndex(QVariant::fromValue(model.indexFromItem(model.item(1,0))));
-
- QDeclarative1Text *name = findItem<QDeclarative1Text>(contentItem, "display", 0);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 2 Child Item"));
-
- model.item(1,0)->child(0,0)->setText("Row 2 updated child");
-
- name = findItem<QDeclarative1Text>(contentItem, "display", 0);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 2 updated child"));
-
- model.item(1,0)->appendRow(new QStandardItem(QLatin1String("Row 2 Child Item 2")));
- QTest::qWait(300);
-
- name = findItem<QDeclarative1Text>(contentItem, "display", 1);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), QString("Row 2 Child Item 2"));
-
- model.item(1,0)->takeRow(1);
- name = findItem<QDeclarative1Text>(contentItem, "display", 1);
- QVERIFY(name == 0);
-
- vdm->setRootIndex(QVariant::fromValue(QModelIndex()));
- QTest::qWait(300);
- name = findItem<QDeclarative1Text>(contentItem, "display", 0);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 1 Item"));
- name = findItem<QDeclarative1Text>(contentItem, "display", 1);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 2 Item"));
- name = findItem<QDeclarative1Text>(contentItem, "display", 2);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 3 Item"));
-}
-
-void tst_qdeclarativevisualdatamodel::objectListModel()
-{
- QDeclarativeView view;
-
- QList<QObject*> dataList;
- dataList.append(new DataObject("Item 1", "red"));
- dataList.append(new DataObject("Item 2", "green"));
- dataList.append(new DataObject("Item 3", "blue"));
- dataList.append(new DataObject("Item 4", "yellow"));
-
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
-
- view.setSource(QUrl::fromLocalFile(SRCDIR "/data/objectlist.qml"));
-
- QDeclarative1ListView *listview = qobject_cast<QDeclarative1ListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QDeclarative1Text *name = findItem<QDeclarative1Text>(contentItem, "name", 0);
- QCOMPARE(name->text(), QString("Item 1"));
-
- QDeclarative1Text *section = findItem<QDeclarative1Text>(contentItem, "section", 0);
- QCOMPARE(section->text(), QString("Item 1"));
-
- dataList[0]->setProperty("name", QLatin1String("Changed"));
- QCOMPARE(name->text(), QString("Changed"));
-}
-
-void tst_qdeclarativevisualdatamodel::singleRole()
-{
- {
- QDeclarativeView view;
-
- SingleRoleModel model;
-
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", &model);
-
- view.setSource(QUrl::fromLocalFile(SRCDIR "/data/singlerole1.qml"));
-
- QDeclarative1ListView *listview = qobject_cast<QDeclarative1ListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QDeclarative1Text *name = findItem<QDeclarative1Text>(contentItem, "name", 1);
- QCOMPARE(name->text(), QString("two"));
-
- model.set(1, "Changed");
- QCOMPARE(name->text(), QString("Changed"));
- }
- {
- QDeclarativeView view;
-
- SingleRoleModel model;
-
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", &model);
-
- view.setSource(QUrl::fromLocalFile(SRCDIR "/data/singlerole2.qml"));
-
- QDeclarative1ListView *listview = qobject_cast<QDeclarative1ListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QDeclarative1Text *name = findItem<QDeclarative1Text>(contentItem, "name", 1);
- QCOMPARE(name->text(), QString("two"));
-
- model.set(1, "Changed");
- QCOMPARE(name->text(), QString("Changed"));
- }
-}
-
-void tst_qdeclarativevisualdatamodel::modelProperties()
-{
- {
- QDeclarativeView view;
-
- SingleRoleModel model;
-
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", &model);
-
- view.setSource(QUrl::fromLocalFile(SRCDIR "/data/modelproperties.qml"));
-
- QDeclarative1ListView *listview = qobject_cast<QDeclarative1ListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QDeclarativeItem *delegate = findItem<QDeclarativeItem>(contentItem, "delegate", 1);
- QCOMPARE(delegate->property("test1").toString(),QString("two"));
- QCOMPARE(delegate->property("test2").toString(),QString("two"));
- QCOMPARE(delegate->property("test3").toString(),QString("two"));
- QCOMPARE(delegate->property("test4").toString(),QString("two"));
- QVERIFY(!delegate->property("test9").isValid());
- QCOMPARE(delegate->property("test5").toString(),QString(""));
- QVERIFY(delegate->property("test6").value<QObject*>() != 0);
- QCOMPARE(delegate->property("test7").toInt(),1);
- QCOMPARE(delegate->property("test8").toInt(),1);
- }
-
- {
- QDeclarativeView view;
-
- QList<QObject*> dataList;
- dataList.append(new DataObject("Item 1", "red"));
- dataList.append(new DataObject("Item 2", "green"));
- dataList.append(new DataObject("Item 3", "blue"));
- dataList.append(new DataObject("Item 4", "yellow"));
-
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
-
- view.setSource(QUrl::fromLocalFile(SRCDIR "/data/modelproperties.qml"));
-
- QDeclarative1ListView *listview = qobject_cast<QDeclarative1ListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QDeclarativeItem *delegate = findItem<QDeclarativeItem>(contentItem, "delegate", 1);
- QCOMPARE(delegate->property("test1").toString(),QString("Item 2"));
- QEXPECT_FAIL("", "QTBUG-13576", Continue);
- QCOMPARE(delegate->property("test2").toString(),QString("Item 2"));
- QVERIFY(qobject_cast<DataObject*>(delegate->property("test3").value<QObject*>()) != 0);
- QVERIFY(qobject_cast<DataObject*>(delegate->property("test4").value<QObject*>()) != 0);
- QCOMPARE(delegate->property("test5").toString(),QString("Item 2"));
- QCOMPARE(delegate->property("test9").toString(),QString("Item 2"));
- QVERIFY(delegate->property("test6").value<QObject*>() != 0);
- QCOMPARE(delegate->property("test7").toInt(),1);
- QCOMPARE(delegate->property("test8").toInt(),1);
- }
-
- {
- QDeclarativeView view;
-
- QStandardItemModel model;
- initStandardTreeModel(&model);
-
- view.rootContext()->setContextProperty("myModel", &model);
-
- QUrl source(QUrl::fromLocalFile(SRCDIR "/data/modelproperties2.qml"));
-
- //3 items, 3 warnings each
- QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: Can't find variable: modelData");
- QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: Can't find variable: modelData");
- QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: Can't find variable: modelData");
- QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":9: ReferenceError: Can't find variable: modelData");
- QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":9: ReferenceError: Can't find variable: modelData");
- QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":9: ReferenceError: Can't find variable: modelData");
- QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":15: TypeError: Cannot read property 'display' of undefined");
- QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":15: TypeError: Cannot read property 'display' of undefined");
- QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":15: TypeError: Cannot read property 'display' of undefined");
-
- view.setSource(source);
-
- QDeclarative1ListView *listview = qobject_cast<QDeclarative1ListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QDeclarativeItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QDeclarativeItem *delegate = findItem<QDeclarativeItem>(contentItem, "delegate", 1);
- QCOMPARE(delegate->property("test1").toString(),QString("Row 2 Item"));
- QCOMPARE(delegate->property("test2").toString(),QString("Row 2 Item"));
- QVERIFY(!delegate->property("test3").isValid());
- QVERIFY(!delegate->property("test4").isValid());
- QVERIFY(!delegate->property("test5").isValid());
- QVERIFY(!delegate->property("test9").isValid());
- QVERIFY(delegate->property("test6").value<QObject*>() != 0);
- QCOMPARE(delegate->property("test7").toInt(),1);
- QCOMPARE(delegate->property("test8").toInt(),1);
- }
-
- //### should also test QStringList and QVariantList
-}
-
-void tst_qdeclarativevisualdatamodel::noDelegate()
-{
- QDeclarativeView view;
-
- QStandardItemModel model;
- initStandardTreeModel(&model);
-
- view.rootContext()->setContextProperty("myModel", &model);
-
- view.setSource(QUrl::fromLocalFile(SRCDIR "/data/datalist.qml"));
-
- QDeclarative1ListView *listview = qobject_cast<QDeclarative1ListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QDeclarative1VisualDataModel *vdm = listview->findChild<QDeclarative1VisualDataModel*>("visualModel");
- QVERIFY(vdm != 0);
- QCOMPARE(vdm->count(), 3);
-
- vdm->setDelegate(0);
- QCOMPARE(vdm->count(), 0);
-}
-
-
-template<typename T>
-T *tst_qdeclarativevisualdatamodel::findItem(QGraphicsObject *parent, const QString &objectName, int index)
-{
- const QMetaObject &mo = T::staticMetaObject;
- //qDebug() << parent->childItems().count() << "children";
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent->childItems().at(i));
- if(!item)
- continue;
- //qDebug() << "try" << item;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
- if (index != -1) {
- QDeclarativeExpression e(qmlContext(item), item, "index");
- if (e.evaluate().toInt() == index)
- return static_cast<T*>(item);
- } else {
- return static_cast<T*>(item);
- }
- }
- item = findItem<T>(item, objectName, index);
- if (item)
- return static_cast<T*>(item);
- }
-
- return 0;
-}
-
-QTEST_MAIN(tst_qdeclarativevisualdatamodel)
-
-#include "tst_qdeclarativevisualdatamodel.moc"
diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/get.qml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/get.qml
deleted file mode 100644
index 4e03503f90..0000000000
--- a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/get.qml
+++ /dev/null
@@ -1,61 +0,0 @@
-import QtQuick 1.0
-
-XmlListModel {
- source: "model.xml"
- query: "/Pets/Pet"
- XmlRole { name: "name"; query: "name/string()" }
- XmlRole { name: "type"; query: "type/string()" }
- XmlRole { name: "age"; query: "age/number()" }
- XmlRole { name: "size"; query: "size/string()" }
-
- id: root
-
- property bool preTest: false
- property bool postTest: false
-
- function runPreTest() {
- if (root.get(0) != undefined)
- return;
-
- preTest = true;
- }
-
- function runPostTest() {
- if (root.get(-1) != undefined)
- return;
-
- var row = root.get(0);
- if (row.name != "Polly" ||
- row.type != "Parrot" ||
- row.age != 12 ||
- row.size != "Small")
- return;
-
- row = root.get(1);
- if (row.name != "Penny" ||
- row.type != "Turtle" ||
- row.age != 4 ||
- row.size != "Small")
- return;
-
- row = root.get(7);
- if (row.name != "Rover" ||
- row.type != "Dog" ||
- row.age != 0 ||
- row.size != "Large")
- return;
-
- row = root.get(8);
- if (row.name != "Tiny" ||
- row.type != "Elephant" ||
- row.age != 15 ||
- row.size != "Large")
- return;
-
- if (root.get(9) != undefined)
- return;
-
- postTest = true;
- }
-}
-
diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/model.qml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/model.qml
deleted file mode 100644
index fdacb6c445..0000000000
--- a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/model.qml
+++ /dev/null
@@ -1,10 +0,0 @@
-import QtQuick 1.0
-
-XmlListModel {
- source: "model.xml"
- query: "/Pets/Pet"
- XmlRole { name: "name"; query: "name/string()" }
- XmlRole { name: "type"; query: "type/string()" }
- XmlRole { name: "age"; query: "age/number()" }
- XmlRole { name: "size"; query: "size/string()" }
-}
diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/model.xml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/model.xml
deleted file mode 100644
index 40cd6d0432..0000000000
--- a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/model.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<Pets>
- <Pet>
- <name>Polly</name>
- <type>Parrot</type>
- <age>12</age>
- <size>Small</size>
- </Pet>
- <Pet>
- <name>Penny</name>
- <type>Turtle</type>
- <age>4</age>
- <size>Small</size>
- </Pet>
- <Pet>
- <name>Warren</name>
- <type>Rabbit</type>
- <age>2</age>
- <size>Small</size>
- </Pet>
- <Pet>
- <name>Spot</name>
- <type>Dog</type>
- <age>9</age>
- <size>Medium</size>
- </Pet>
- <Pet>
- <name>Whiskers</name>
- <type>Cat</type>
- <age>2</age>
- <size>Medium</size>
- </Pet>
- <Pet>
- <name>Joey</name>
- <type>Kangaroo</type>
- <age>1</age>
- </Pet>
- <Pet>
- <name>Kimba</name>
- <type>Bunny</type>
- <age>65</age>
- <size>Large</size>
- </Pet>
- <Pet>
- <name>Rover</name>
- <type>Dog</type>
- <size>Large</size>
- </Pet>
- <Pet>
- <name>Tiny</name>
- <type>Elephant</type>
- <age>15</age>
- <size>Large</size>
- </Pet>
-</Pets>
diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/model2.xml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/model2.xml
deleted file mode 100644
index dab2ec6dc0..0000000000
--- a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/model2.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<Pets>
- <Pet>
- <name>Polly</name>
- <type>Parrot</type>
- <age>12</age>
- <size>Small</size>
- </Pet>
- <Pet>
- <name>Penny</name>
- <type>Turtle</type>
- <age>4</age>
- <size>Small</size>
- </Pet>
-</Pets>
diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/propertychanges.qml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/propertychanges.qml
deleted file mode 100644
index ed674ce36f..0000000000
--- a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/propertychanges.qml
+++ /dev/null
@@ -1,10 +0,0 @@
-import QtQuick 1.0
-
-XmlListModel {
- source: "model.xml"
- query: "/Pets/Pet"
- XmlRole { objectName: "role"; name: "name"; query: "name/string()" }
- XmlRole { name: "type"; query: "type/string()" }
- XmlRole { name: "age"; query: "age/number()" }
- XmlRole { name: "size"; query: "size/string()" }
-}
diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/recipes.qml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/recipes.qml
deleted file mode 100644
index 6345101d9a..0000000000
--- a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/recipes.qml
+++ /dev/null
@@ -1,10 +0,0 @@
-import QtQuick 1.0
-
-XmlListModel {
- source: "recipes.xml"
- query: "/recipes/recipe"
- XmlRole { name: "title"; query: "@title/string()" }
- XmlRole { name: "picture"; query: "picture/string()" }
- XmlRole { name: "ingredients"; query: "ingredients/string()" }
- XmlRole { name: "preparation"; query: "method/string()" }
-}
diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/recipes.xml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/recipes.xml
deleted file mode 100644
index d71de60710..0000000000
--- a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/recipes.xml
+++ /dev/null
@@ -1,90 +0,0 @@
-<recipes>
- <recipe title="Pancakes">
- <picture>content/pics/pancakes.jpg</picture>
- <ingredients><![CDATA[<html>
- <ul>
- <li> 1 cup (150g) self-raising flour
- <li> 1 tbs caster sugar
- <li> 3/4 cup (185ml) milk
- <li> 1 egg
- </ul>
- </html>
- ]]></ingredients>
- <method><![CDATA[<html>
- <ol>
- <li> Sift flour and sugar together into a bowl. Add a pinch of salt.
- <li> Beat milk and egg together, then add to dry ingredients. Beat until smooth.
- <li> Pour mixture into a pan on medium heat and cook until bubbles appear on the surface.
- <li> Turn over and cook other side until golden.
- </ol>
- </html>
- ]]></method>
- </recipe>
- <recipe title="Fruit Salad">
- <picture>content/pics/fruit-salad.jpg</picture>
- <ingredients><![CDATA[* Seasonal Fruit]]></ingredients>
- <method><![CDATA[* Chop fruit and place in a bowl.]]></method>
- </recipe>
- <recipe title="Vegetable Soup">
- <picture>content/pics/vegetable-soup.jpg</picture>
- <ingredients><![CDATA[<html>
- <ul>
- <li> 1 onion
- <li> 1 turnip
- <li> 1 potato
- <li> 1 carrot
- <li> 1 head of celery
- <li> 1 1/2 litres of water
- </ul>
- </html>
- ]]></ingredients>
- <method><![CDATA[<html>
- <ol>
- <li> Chop vegetables.
- <li> Boil in water until vegetables soften.
- <li> Season with salt and pepper to taste.
- </ol>
- </html>
- ]]></method>
- </recipe>
- <recipe title="Hamburger">
- <picture>content/pics/hamburger.jpg</picture>
- <ingredients><![CDATA[<html>
- <ul>
- <li> 500g minced beef
- <li> Seasoning
- <li> lettuce, tomato, onion, cheese
- <li> 1 hamburger bun for each burger
- </ul>
- </html>
- ]]></ingredients>
- <method><![CDATA[<html>
- <ol>
- <li> Mix the beef, together with seasoning, in a food processor.
- <li> Shape the beef into burgers.
- <li> Grill the burgers for about 5 mins on each side (until cooked through)
- <li> Serve each burger on a bun with ketchup, cheese, lettuce, tomato and onion.
- </ol>
- </html>
- ]]></method>
- </recipe>
- <recipe title="Lemonade">
- <picture>content/pics/lemonade.jpg</picture>
- <ingredients><![CDATA[<html>
- <ul>
- <li> 1 cup Lemon Juice
- <li> 1 cup Sugar
- <li> 6 Cups of Water (2 cups warm water, 4 cups cold water)
- </ul>
- </html>
- ]]></ingredients>
- <method><![CDATA[<html>
- <ol>
- <li> Pour 2 cups of warm water into a pitcher and stir in sugar until it dissolves.
- <li> Pour in lemon juice, stir again, and add 4 cups of cold water.
- <li> Chill or serve over ice cubes.
- </ol>
- </html>
- ]]></method>
- </recipe>
-</recipes>
diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleCrash.qml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleCrash.qml
deleted file mode 100644
index 492dad920f..0000000000
--- a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleCrash.qml
+++ /dev/null
@@ -1,7 +0,0 @@
-import QtQuick 1.0
-
-XmlListModel {
- id: model
- XmlRole {}
- Component.onCompleted: model.roles = 0
-}
diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleErrors.qml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleErrors.qml
deleted file mode 100644
index a0d846f188..0000000000
--- a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleErrors.qml
+++ /dev/null
@@ -1,10 +0,0 @@
-import QtQuick 1.0
-
-XmlListModel {
- source: "model.xml"
- query: "/Pets/Pet"
- XmlRole { name: "name"; query: "/name/string()" } //starts with '/'
- XmlRole { name: "type"; query: "type" } //no type
- XmlRole { name: "age"; query: "age/" } //ends with '/'
- XmlRole { name: "size"; query: "size/number()" } //wrong type
-}
diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleKeys.qml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleKeys.qml
deleted file mode 100644
index d90cd61096..0000000000
--- a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleKeys.qml
+++ /dev/null
@@ -1,13 +0,0 @@
-import QtQuick 1.0
-
-XmlListModel {
- query: "/data/item"
- XmlRole { id: nameRole; name: "name"; query: "name/string()"; isKey: true }
- XmlRole { name: "age"; query: "age/number()"; isKey: true }
- XmlRole { name: "sport"; query: "sport/string()" }
-
- function disableNameKey() {
- nameRole.isKey = false;
- }
-}
-
diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/testtypes.qml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/testtypes.qml
deleted file mode 100644
index 4dbcc029e0..0000000000
--- a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/testtypes.qml
+++ /dev/null
@@ -1,8 +0,0 @@
-import QtQuick 1.0
-
-XmlListModel {
- query: "/data"
- XmlRole { name: "stringValue"; query: "a-string/string()" }
- XmlRole { name: "numberValue"; query: "a-number/number()" }
-}
-
diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/unique.qml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/unique.qml
deleted file mode 100644
index dab8ffa78e..0000000000
--- a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/unique.qml
+++ /dev/null
@@ -1,8 +0,0 @@
-import QtQuick 1.0
-
-XmlListModel {
- source: "model.xml"
- query: "/Pets/Pet"
- XmlRole { name: "name"; query: "name/string()" }
- XmlRole { name: "name"; query: "type/string()" }
-}
diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro b/tests/auto/qtquick1/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro
deleted file mode 100644
index fc74409802..0000000000
--- a/tests/auto/qtquick1/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativexmllistmodel
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativexmllistmodel.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
-QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private network testlib xmlpatterns
diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/qtquick1/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
deleted file mode 100644
index 77c8322e03..0000000000
--- a/tests/auto/qtquick1/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
+++ /dev/null
@@ -1,954 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <private/qdeclarativeengine_p.h>
-
-#include <QtTest/QtTest>
-#include <QtGlobal>
-#include <math.h>
-
-#include <qtest.h>
-#include <QtTest/qsignalspy.h>
-#include <QtDeclarative/qdeclarativenetworkaccessmanagerfactory.h>
-#include <QtNetwork/qnetworkaccessmanager.h>
-#include <QtNetwork/qnetworkrequest.h>
-#include <QtCore/qtimer.h>
-#include <QtCore/qfile.h>
-#include <QtCore/qtemporaryfile.h>
-
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick1/private/qdeclarativexmllistmodel_p.h>
-
-typedef QPair<int, int> QDeclarativeXmlListRange;
-typedef QList<QVariantList> QDeclarativeXmlModelData;
-
-Q_DECLARE_METATYPE(QList<QDeclarativeXmlListRange>)
-Q_DECLARE_METATYPE(QDeclarativeXmlModelData)
-Q_DECLARE_METATYPE(QDeclarative1XmlListModel::Status)
-
-class tst_qdeclarativexmllistmodel : public QObject
-
-{
- Q_OBJECT
-public:
- tst_qdeclarativexmllistmodel() {}
-
-private slots:
- void initTestCase() {
- qRegisterMetaType<QDeclarative1XmlListModel::Status>("QDeclarative1XmlListModel::Status");
- }
-
- void buildModel();
- void testTypes();
- void testTypes_data();
- void cdata();
- void attributes();
- void roles();
- void roleErrors();
- void uniqueRoleNames();
- void headers();
- void xml();
- void xml_data();
- void source();
- void source_data();
- void data();
- void get();
- void reload();
- void useKeys();
- void useKeys_data();
- void noKeysValueChanges();
- void keysChanged();
- void threading();
- void threading_data();
- void propertyChanges();
-
- void roleCrash();
-
-private:
- QString makeItemXmlAndData(const QString &data, QDeclarativeXmlModelData *modelData = 0) const
- {
- if (modelData)
- modelData->clear();
- QString xml;
-
- if (!data.isEmpty()) {
- QStringList items = data.split(";");
- foreach(const QString &item, items) {
- if (item.isEmpty())
- continue;
- QVariantList variants;
- xml += QLatin1String("<item>");
- QStringList fields = item.split(",");
- foreach(const QString &field, fields) {
- QStringList values = field.split("=");
- if (values.count() != 2) {
- qWarning() << "makeItemXmlAndData: invalid field:" << field;
- continue;
- }
- xml += QString("<%1>%2</%1>").arg(values[0], values[1]);
- if (!modelData)
- continue;
- bool isNum = false;
- int number = values[1].toInt(&isNum);
- if (isNum)
- variants << number;
- else
- variants << values[1];
- }
- xml += QLatin1String("</item>");
- if (modelData)
- modelData->append(variants);
- }
- }
-
- QString decl = "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>";
- return decl + QLatin1String("<data>") + xml + QLatin1String("</data>");
- }
-
- QDeclarativeEngine engine;
-};
-
-class CustomNetworkAccessManagerFactory : public QObject, public QDeclarativeNetworkAccessManagerFactory
-{
- Q_OBJECT
-public:
- QVariantMap lastSentHeaders;
-
-protected:
- QNetworkAccessManager *create(QObject *parent);
-};
-
-class CustomNetworkAccessManager : public QNetworkAccessManager
-{
- Q_OBJECT
-public:
- CustomNetworkAccessManager(CustomNetworkAccessManagerFactory *factory, QObject *parent)
- : QNetworkAccessManager(parent), m_factory(factory) {}
-
-protected:
- QNetworkReply *createRequest(Operation op, const QNetworkRequest &req, QIODevice * outgoingData = 0)
- {
- if (m_factory) {
- QVariantMap map;
- foreach (const QString &header, req.rawHeaderList())
- map[header] = req.rawHeader(header.toUtf8());
- m_factory->lastSentHeaders = map;
- }
- return QNetworkAccessManager::createRequest(op, req, outgoingData);
- }
-
- QPointer<CustomNetworkAccessManagerFactory> m_factory;
-};
-
-QNetworkAccessManager *CustomNetworkAccessManagerFactory::create(QObject *parent)
-{
- return new CustomNetworkAccessManager(this, parent);
-}
-
-
-void tst_qdeclarativexmllistmodel::buildModel()
-{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml"));
- QDeclarative1XmlListModel *model = qobject_cast<QDeclarative1XmlListModel*>(component.create());
- QVERIFY(model != 0);
- QTRY_COMPARE(model->count(), 9);
-
- QList<int> roles;
- roles << Qt::UserRole << Qt::UserRole + 1 << Qt::UserRole + 2 << Qt::UserRole + 3;
- QHash<int, QVariant> data = model->data(3, roles);
- QVERIFY(data.count() == 4);
- QCOMPARE(data.value(Qt::UserRole).toString(), QLatin1String("Spot"));
- QCOMPARE(data.value(Qt::UserRole+1).toString(), QLatin1String("Dog"));
- QCOMPARE(data.value(Qt::UserRole+2).toInt(), 9);
- QCOMPARE(data.value(Qt::UserRole+3).toString(), QLatin1String("Medium"));
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::testTypes()
-{
- QFETCH(QString, xml);
- QFETCH(QString, roleName);
- QFETCH(QVariant, expectedValue);
-
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/testtypes.qml"));
- QDeclarative1XmlListModel *model = qobject_cast<QDeclarative1XmlListModel*>(component.create());
- QVERIFY(model != 0);
- model->setXml(xml.toUtf8());
- model->reload();
- QTRY_COMPARE(model->count(), 1);
-
- int role = -1;
- foreach (int i, model->roles()) {
- if (model->toString(i) == roleName) {
- role = i;
- break;
- }
- }
- QVERIFY(role >= 0);
-
- if (expectedValue.toString() == "nan")
- QVERIFY(qIsNaN(model->data(0, role).toDouble()));
- else
- QCOMPARE(model->data(0, role), expectedValue);
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::testTypes_data()
-{
- QTest::addColumn<QString>("xml");
- QTest::addColumn<QString>("roleName");
- QTest::addColumn<QVariant>("expectedValue");
-
- QTest::newRow("missing string field") << "<data></data>"
- << "stringValue" << QVariant("");
- QTest::newRow("empty string") << "<data><a-string></a-string></data>"
- << "stringValue" << QVariant("");
- QTest::newRow("1-char string") << "<data><a-string>5</a-string></data>"
- << "stringValue" << QVariant("5");
- QTest::newRow("string ok") << "<data><a-string>abc def g</a-string></data>"
- << "stringValue" << QVariant("abc def g");
-
- QTest::newRow("missing number field") << "<data></data>"
- << "numberValue" << QVariant("");
- double nan = qQNaN();
- QTest::newRow("empty number field") << "<data><a-number></a-number></data>"
- << "numberValue" << QVariant(nan);
- QTest::newRow("number field with string") << "<data><a-number>a string</a-number></data>"
- << "numberValue" << QVariant(nan);
- QTest::newRow("-1") << "<data><a-number>-1</a-number></data>"
- << "numberValue" << QVariant("-1");
- QTest::newRow("-1.5") << "<data><a-number>-1.5</a-number></data>"
- << "numberValue" << QVariant("-1.5");
- QTest::newRow("0") << "<data><a-number>0</a-number></data>"
- << "numberValue" << QVariant("0");
- QTest::newRow("+1") << "<data><a-number>1</a-number></data>"
- << "numberValue" << QVariant("1");
- QTest::newRow("+1.5") << "<data><a-number>1.5</a-number></data>"
- << "numberValue" << QVariant("1.5");
-}
-
-void tst_qdeclarativexmllistmodel::cdata()
-{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/recipes.qml"));
- QDeclarative1XmlListModel *model = qobject_cast<QDeclarative1XmlListModel*>(component.create());
- QVERIFY(model != 0);
- QTRY_COMPARE(model->count(), 5);
-
- QList<int> roles;
- roles << Qt::UserRole + 2;
- QHash<int, QVariant> data = model->data(2, roles);
- QVERIFY(data.count() == 1);
- QVERIFY(data.value(Qt::UserRole+2).toString().startsWith(QLatin1String("<html>")));
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::attributes()
-{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/recipes.qml"));
- QDeclarative1XmlListModel *model = qobject_cast<QDeclarative1XmlListModel*>(component.create());
- QVERIFY(model != 0);
- QTRY_COMPARE(model->count(), 5);
- QList<int> roles;
- roles << Qt::UserRole;
- QHash<int, QVariant> data = model->data(2, roles);
- QVERIFY(data.count() == 1);
- QCOMPARE(data.value(Qt::UserRole).toString(), QLatin1String("Vegetable Soup"));
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::roles()
-{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml"));
- QDeclarative1XmlListModel *model = qobject_cast<QDeclarative1XmlListModel*>(component.create());
- QVERIFY(model != 0);
- QTRY_COMPARE(model->count(), 9);
-
- QList<int> roles = model->roles();
- QCOMPARE(roles.count(), 4);
- QCOMPARE(model->toString(roles.at(0)), QLatin1String("name"));
- QCOMPARE(model->toString(roles.at(1)), QLatin1String("type"));
- QCOMPARE(model->toString(roles.at(2)), QLatin1String("age"));
- QCOMPARE(model->toString(roles.at(3)), QLatin1String("size"));
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::roleErrors()
-{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleErrors.qml"));
- QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(SRCDIR "/data/roleErrors.qml").toString() + ":6:5: QML XmlRole: An XmlRole query must not start with '/'").toUtf8().constData());
- QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(SRCDIR "/data/roleErrors.qml").toString() + ":9:5: QML XmlRole: invalid query: \"age/\"").toUtf8().constData());
-
- //### make sure we receive all expected warning messages.
- QDeclarative1XmlListModel *model = qobject_cast<QDeclarative1XmlListModel*>(component.create());
- QVERIFY(model != 0);
- QTRY_COMPARE(model->count(), 9);
-
- QList<int> roles;
- roles << Qt::UserRole << Qt::UserRole + 1 << Qt::UserRole + 2 << Qt::UserRole + 3;
- QHash<int, QVariant> data = model->data(3, roles);
- QVERIFY(data.count() == 4);
-
- //### should any of these return valid values?
- QCOMPARE(data.value(Qt::UserRole), QVariant());
- QCOMPARE(data.value(Qt::UserRole+1), QVariant());
- QCOMPARE(data.value(Qt::UserRole+2), QVariant());
-
- QEXPECT_FAIL("", "QTBUG-10797", Continue);
- QCOMPARE(data.value(Qt::UserRole+3), QVariant());
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::uniqueRoleNames()
-{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/unique.qml"));
- QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(SRCDIR "/data/unique.qml").toString() + ":7:5: QML XmlRole: \"name\" duplicates a previous role name and will be disabled.").toUtf8().constData());
- QDeclarative1XmlListModel *model = qobject_cast<QDeclarative1XmlListModel*>(component.create());
- QVERIFY(model != 0);
- QTRY_COMPARE(model->count(), 9);
-
- QList<int> roles = model->roles();
- QCOMPARE(roles.count(), 1);
-
- delete model;
-}
-
-
-void tst_qdeclarativexmllistmodel::xml()
-{
- QFETCH(QString, xml);
- QFETCH(int, count);
-
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml"));
- QDeclarative1XmlListModel *model = qobject_cast<QDeclarative1XmlListModel*>(component.create());
- QSignalSpy spy(model, SIGNAL(statusChanged(QDeclarative1XmlListModel::Status)));
-
- QVERIFY(model->errorString().isEmpty());
- QCOMPARE(model->progress(), qreal(0.0));
- QCOMPARE(model->status(), QDeclarative1XmlListModel::Loading);
- QTRY_COMPARE(spy.count(), 1); spy.clear();
- QCOMPARE(model->status(), QDeclarative1XmlListModel::Ready);
- QVERIFY(model->errorString().isEmpty());
- QCOMPARE(model->progress(), qreal(1.0));
- QCOMPARE(model->count(), 9);
-
- // if xml is empty (i.e. clearing) it won't have any effect if a source is set
- if (xml.isEmpty())
- model->setSource(QUrl());
- model->setXml(xml);
- QCOMPARE(model->progress(), qreal(1.0)); // immediately goes to 1.0 if using setXml()
- QTRY_COMPARE(spy.count(), 1); spy.clear();
- QCOMPARE(model->status(), QDeclarative1XmlListModel::Loading);
- QTRY_COMPARE(spy.count(), 1); spy.clear();
- QCOMPARE(model->status(), QDeclarative1XmlListModel::Ready);
- QVERIFY(model->errorString().isEmpty());
- QCOMPARE(model->count(), count);
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::xml_data()
-{
- QTest::addColumn<QString>("xml");
- QTest::addColumn<int>("count");
-
- QTest::newRow("xml with no items") << "<Pets></Pets>" << 0;
- QTest::newRow("empty xml") << "" << 0;
- QTest::newRow("one item") << "<Pets><Pet><name>Hobbes</name><type>Tiger</type><age>7</age><size>Large</size></Pet></Pets>" << 1;
-}
-
-void tst_qdeclarativexmllistmodel::headers()
-{
- // ensure the QNetworkAccessManagers created for this test are immediately deleted
- QDeclarativeEngine qmlEng;
-
- CustomNetworkAccessManagerFactory factory;
- qmlEng.setNetworkAccessManagerFactory(&factory);
-
- QDeclarativeComponent component(&qmlEng, QUrl::fromLocalFile(SRCDIR "/data/model.qml"));
- QDeclarative1XmlListModel *model = qobject_cast<QDeclarative1XmlListModel*>(component.create());
- QVERIFY(model != 0);
- QTRY_COMPARE(model->status(), QDeclarative1XmlListModel::Ready);
-
- QVariantMap expectedHeaders;
- expectedHeaders["Accept"] = "application/xml,*/*";
-
- QCOMPARE(factory.lastSentHeaders.count(), expectedHeaders.count());
- foreach (const QString &header, expectedHeaders.keys()) {
- QVERIFY(factory.lastSentHeaders.contains(header));
- QCOMPARE(factory.lastSentHeaders[header].toString(), expectedHeaders[header].toString());
- }
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::source()
-{
- QFETCH(QUrl, source);
- QFETCH(int, count);
- QFETCH(QDeclarative1XmlListModel::Status, status);
-
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml"));
- QDeclarative1XmlListModel *model = qobject_cast<QDeclarative1XmlListModel*>(component.create());
- QSignalSpy spy(model, SIGNAL(statusChanged(QDeclarative1XmlListModel::Status)));
-
- QVERIFY(model->errorString().isEmpty());
- QCOMPARE(model->progress(), qreal(0.0));
- QCOMPARE(model->status(), QDeclarative1XmlListModel::Loading);
- QTRY_COMPARE(spy.count(), 1); spy.clear();
- QCOMPARE(model->status(), QDeclarative1XmlListModel::Ready);
- QVERIFY(model->errorString().isEmpty());
- QCOMPARE(model->progress(), qreal(1.0));
- QCOMPARE(model->count(), 9);
-
- model->setSource(source);
- QCOMPARE(model->progress(), qreal(0.0));
- QTRY_COMPARE(spy.count(), 1); spy.clear();
- QCOMPARE(model->status(), QDeclarative1XmlListModel::Loading);
- QVERIFY(model->errorString().isEmpty());
-
- QEventLoop loop;
- QTimer timer;
- timer.setSingleShot(true);
- connect(model, SIGNAL(statusChanged(QDeclarative1XmlListModel::Status)), &loop, SLOT(quit()));
- connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
- timer.start(20000);
- loop.exec();
-
- if (spy.count() == 0 && status != QDeclarative1XmlListModel::Ready) {
- qWarning("QDeclarative1XmlListModel invalid source test timed out");
- } else {
- QCOMPARE(spy.count(), 1); spy.clear();
- }
-
- QCOMPARE(model->status(), status);
- QCOMPARE(model->count(), count);
-
- if (status == QDeclarative1XmlListModel::Ready)
- QCOMPARE(model->progress(), qreal(1.0));
-
- QCOMPARE(model->errorString().isEmpty(), status == QDeclarative1XmlListModel::Ready);
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::source_data()
-{
- QTest::addColumn<QUrl>("source");
- QTest::addColumn<int>("count");
- QTest::addColumn<QDeclarative1XmlListModel::Status>("status");
-
- QTest::newRow("valid") << QUrl::fromLocalFile(SRCDIR "/data/model2.xml") << 2 << QDeclarative1XmlListModel::Ready;
- QTest::newRow("invalid") << QUrl("http://blah.blah/blah.xml") << 0 << QDeclarative1XmlListModel::Error;
-
- // empty file
- QTemporaryFile *temp = new QTemporaryFile(this);
- if (temp->open())
- QTest::newRow("empty file") << QUrl::fromLocalFile(temp->fileName()) << 0 << QDeclarative1XmlListModel::Ready;
- temp->close();
-}
-
-void tst_qdeclarativexmllistmodel::data()
-{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml"));
- QDeclarative1XmlListModel *model = qobject_cast<QDeclarative1XmlListModel*>(component.create());
- QVERIFY(model != 0);
-
- QHash<int,QVariant> blank;
- for (int i=0; i<model->roles().count(); i++)
- blank.insert(model->roles()[i], QVariant());
- for (int i=0; i<9; i++) {
- QCOMPARE(model->data(i, model->roles()), blank);
- for (int j=0; j<model->roles().count(); j++) {
- QCOMPARE(model->data(i, j), QVariant());
- }
- }
- QTRY_COMPARE(model->count(), 9);
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::get()
-{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/get.qml"));
- QDeclarative1XmlListModel *model = qobject_cast<QDeclarative1XmlListModel*>(component.create());
- QVERIFY(model != 0);
-
- QVERIFY(QMetaObject::invokeMethod(model, "runPreTest"));
- QCOMPARE(model->property("preTest").toBool(), true);
-
- QTRY_COMPARE(model->count(), 9);
-
- QVERIFY(QMetaObject::invokeMethod(model, "runPostTest"));
- QCOMPARE(model->property("postTest").toBool(), true);
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::reload()
-{
- // If no keys are used, the model should be rebuilt from scratch when
- // reload() is called.
-
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml"));
- QDeclarative1XmlListModel *model = qobject_cast<QDeclarative1XmlListModel*>(component.create());
- QVERIFY(model != 0);
- QTRY_COMPARE(model->count(), 9);
-
- QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
- QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
- QSignalSpy spyCount(model, SIGNAL(countChanged()));
-
- //reload multiple times to test the xml query aborting
- model->reload();
- model->reload();
- QCoreApplication::processEvents();
- model->reload();
- model->reload();
- QTRY_COMPARE(spyCount.count(), 1);
- QTRY_COMPARE(spyInsert.count(), 1);
- QTRY_COMPARE(spyRemove.count(), 1);
-
- QCOMPARE(spyInsert[0][0].toInt(), 0);
- QCOMPARE(spyInsert[0][1].toInt(), 9);
-
- QCOMPARE(spyRemove[0][0].toInt(), 0);
- QCOMPARE(spyRemove[0][1].toInt(), 9);
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::useKeys()
-{
- // If using incremental updates through keys, the model should only
- // insert & remove some of the items, instead of throwing everything
- // away and causing the view to repaint the whole view.
-
- QFETCH(QString, oldXml);
- QFETCH(int, oldCount);
- QFETCH(QString, newXml);
- QFETCH(QDeclarativeXmlModelData, newData);
- QFETCH(QList<QDeclarativeXmlListRange>, insertRanges);
- QFETCH(QList<QDeclarativeXmlListRange>, removeRanges);
-
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleKeys.qml"));
- QDeclarative1XmlListModel *model = qobject_cast<QDeclarative1XmlListModel*>(component.create());
- QVERIFY(model != 0);
-
- model->setXml(oldXml);
- QTRY_COMPARE(model->count(), oldCount);
-
- QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
- QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
- QSignalSpy spyCount(model, SIGNAL(countChanged()));
-
- model->setXml(newXml);
-
- if (oldCount != newData.count()) {
- QTRY_COMPARE(model->count(), newData.count());
- QCOMPARE(spyCount.count(), 1);
- } else {
- QTRY_VERIFY(spyInsert.count() > 0 || spyRemove.count() > 0);
- QCOMPARE(spyCount.count(), 0);
- }
-
- QList<int> roles = model->roles();
- for (int i=0; i<model->count(); i++) {
- for (int j=0; j<roles.count(); j++)
- QCOMPARE(model->data(i, roles[j]), newData[i][j]);
- }
-
- QCOMPARE(spyInsert.count(), insertRanges.count());
- for (int i=0; i<spyInsert.count(); i++) {
- QCOMPARE(spyInsert[i][0].toInt(), insertRanges[i].first);
- QCOMPARE(spyInsert[i][1].toInt(), insertRanges[i].second);
- }
-
- QCOMPARE(spyRemove.count(), removeRanges.count());
- for (int i=0; i<spyRemove.count(); i++) {
- QCOMPARE(spyRemove[i][0].toInt(), removeRanges[i].first);
- QCOMPARE(spyRemove[i][1].toInt(), removeRanges[i].second);
- }
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::useKeys_data()
-{
- QTest::addColumn<QString>("oldXml");
- QTest::addColumn<int>("oldCount");
- QTest::addColumn<QString>("newXml");
- QTest::addColumn<QDeclarativeXmlModelData>("newData");
- QTest::addColumn<QList<QDeclarativeXmlListRange> >("insertRanges");
- QTest::addColumn<QList<QDeclarativeXmlListRange> >("removeRanges");
-
- QDeclarativeXmlModelData modelData;
-
- QTest::newRow("append 1")
- << makeItemXmlAndData("name=A,age=25,sport=Football") << 1
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics", &modelData)
- << modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 1))
- << QList<QDeclarativeXmlListRange>();
-
- QTest::newRow("append multiple")
- << makeItemXmlAndData("name=A,age=25,sport=Football") << 1
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling", &modelData)
- << modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 2))
- << QList<QDeclarativeXmlListRange>();
-
- QTest::newRow("insert in different spots")
- << makeItemXmlAndData("name=B,age=35,sport=Athletics") << 1
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData)
- << modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 1) << qMakePair(2,2))
- << QList<QDeclarativeXmlListRange>();
-
- QTest::newRow("insert in middle")
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=D,age=55,sport=Golf") << 2
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData)
- << modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 2))
- << QList<QDeclarativeXmlListRange>();
-
- QTest::newRow("remove first")
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics") << 2
- << makeItemXmlAndData("name=B,age=35,sport=Athletics", &modelData)
- << modelData
- << QList<QDeclarativeXmlListRange>()
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 1));
-
- QTest::newRow("remove last")
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics") << 2
- << makeItemXmlAndData("name=A,age=25,sport=Football", &modelData)
- << modelData
- << QList<QDeclarativeXmlListRange>()
- << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 1));
-
- QTest::newRow("remove from multiple spots")
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing") << 5
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=C,age=45,sport=Curling", &modelData)
- << modelData
- << QList<QDeclarativeXmlListRange>()
- << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 1) << qMakePair(3,2));
-
- QTest::newRow("remove all")
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling") << 3
- << makeItemXmlAndData("", &modelData)
- << modelData
- << QList<QDeclarativeXmlListRange>()
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 3));
-
- QTest::newRow("replace item")
- << makeItemXmlAndData("name=A,age=25,sport=Football") << 1
- << makeItemXmlAndData("name=ZZZ,age=25,sport=Football", &modelData)
- << modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 1))
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 1));
-
- QTest::newRow("add and remove simultaneously, in different spots")
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf") << 4
- << makeItemXmlAndData("name=B,age=35,sport=Athletics;name=E,age=65,sport=Fencing", &modelData)
- << modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 1))
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 1) << qMakePair(2,2));
-
- QTest::newRow("insert at start, remove at end i.e. rss feed")
- << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing") << 3
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling", &modelData)
- << modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 2))
- << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 2));
-
- QTest::newRow("remove at start, insert at end")
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling") << 3
- << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing", &modelData)
- << modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 2))
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 2));
-
- QTest::newRow("all data has changed")
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35") << 2
- << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData)
- << modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 2))
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 2));
-}
-
-void tst_qdeclarativexmllistmodel::noKeysValueChanges()
-{
- // The 'key' roles are 'name' and 'age', as defined in roleKeys.qml.
- // If a 'sport' value is changed, the model should not be reloaded,
- // since 'sport' is not marked as a key.
-
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleKeys.qml"));
- QDeclarative1XmlListModel *model = qobject_cast<QDeclarative1XmlListModel*>(component.create());
- QVERIFY(model != 0);
-
- QString xml;
-
- xml = makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics");
- model->setXml(xml);
- QTRY_COMPARE(model->count(), 2);
-
- model->setXml("");
-
- QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
- QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
- QSignalSpy spyCount(model, SIGNAL(countChanged()));
-
- xml = makeItemXmlAndData("name=A,age=25,sport=AussieRules;name=B,age=35,sport=Athletics");
- model->setXml(xml);
-
- // wait for the new xml data to be set, and verify no signals were emitted
- QTRY_VERIFY(model->data(0, model->roles()[2]).toString() != QLatin1String("Football"));
- QCOMPARE(model->data(0, model->roles()[2]).toString(), QLatin1String("AussieRules"));
-
- QVERIFY(spyInsert.count() == 0);
- QVERIFY(spyRemove.count() == 0);
- QVERIFY(spyCount.count() == 0);
-
- QCOMPARE(model->count(), 2);
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::keysChanged()
-{
- // If the key roles change, the next time the data is reloaded, it should
- // delete all its data and build a clean model (i.e. same behaviour as
- // if no keys are set).
-
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleKeys.qml"));
- QDeclarative1XmlListModel *model = qobject_cast<QDeclarative1XmlListModel*>(component.create());
- QVERIFY(model != 0);
-
- QString xml = makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics");
- model->setXml(xml);
- QTRY_COMPARE(model->count(), 2);
-
- model->setXml("");
-
- QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
- QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
- QSignalSpy spyCount(model, SIGNAL(countChanged()));
-
- QVERIFY(QMetaObject::invokeMethod(model, "disableNameKey"));
- model->setXml(xml);
-
- QTRY_VERIFY(spyInsert.count() > 0 && spyRemove.count() > 0);
-
- QCOMPARE(spyInsert.count(), 1);
- QCOMPARE(spyInsert[0][0].toInt(), 0);
- QCOMPARE(spyInsert[0][1].toInt(), 2);
-
- QCOMPARE(spyRemove.count(), 1);
- QCOMPARE(spyRemove[0][0].toInt(), 0);
- QCOMPARE(spyRemove[0][1].toInt(), 2);
-
- QCOMPARE(spyCount.count(), 0);
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::threading()
-{
- QFETCH(int, xmlDataCount);
-
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleKeys.qml"));
-
- QDeclarative1XmlListModel *m1 = qobject_cast<QDeclarative1XmlListModel*>(component.create());
- QVERIFY(m1 != 0);
- QDeclarative1XmlListModel *m2 = qobject_cast<QDeclarative1XmlListModel*>(component.create());
- QVERIFY(m2 != 0);
- QDeclarative1XmlListModel *m3 = qobject_cast<QDeclarative1XmlListModel*>(component.create());
- QVERIFY(m3 != 0);
-
- for (int dataCount=0; dataCount<xmlDataCount; dataCount++) {
-
- QString data1, data2, data3;
- for (int i=0; i<dataCount; i++) {
- data1 += "name=A" + QString::number(i) + ",age=1" + QString::number(i) + ",sport=Football;";
- data2 += "name=B" + QString::number(i) + ",age=2" + QString::number(i) + ",sport=Athletics;";
- data3 += "name=C" + QString::number(i) + ",age=3" + QString::number(i) + ",sport=Curling;";
- }
-
- //Set the xml data multiple times with randomized order and mixed with multiple event loops
- //to test the xml query reloading/aborting, the result should be stable.
- m1->setXml(makeItemXmlAndData(data1));
- m2->setXml(makeItemXmlAndData(data2));
- m3->setXml(makeItemXmlAndData(data3));
- QCoreApplication::processEvents();
- m2->setXml(makeItemXmlAndData(data2));
- m1->setXml(makeItemXmlAndData(data1));
- m2->setXml(makeItemXmlAndData(data2));
- QCoreApplication::processEvents();
- m3->setXml(makeItemXmlAndData(data3));
- QCoreApplication::processEvents();
- m2->setXml(makeItemXmlAndData(data2));
- m1->setXml(makeItemXmlAndData(data1));
- m2->setXml(makeItemXmlAndData(data2));
- m3->setXml(makeItemXmlAndData(data3));
- QCoreApplication::processEvents();
- m2->setXml(makeItemXmlAndData(data2));
- m3->setXml(makeItemXmlAndData(data3));
- m3->setXml(makeItemXmlAndData(data3));
- QCoreApplication::processEvents();
-
- QTRY_VERIFY(m1->count() == dataCount && m2->count() == dataCount && m3->count() == dataCount);
-
- for (int i=0; i<dataCount; i++) {
- QCOMPARE(m1->data(i, m1->roles()[0]).toString(), QString("A" + QString::number(i)));
- QCOMPARE(m1->data(i, m1->roles()[1]).toString(), QString("1" + QString::number(i)));
- QCOMPARE(m1->data(i, m1->roles()[2]).toString(), QString("Football"));
-
- QCOMPARE(m2->data(i, m2->roles()[0]).toString(), QString("B" + QString::number(i)));
- QCOMPARE(m2->data(i, m2->roles()[1]).toString(), QString("2" + QString::number(i)));
- QCOMPARE(m2->data(i, m2->roles()[2]).toString(), QString("Athletics"));
-
- QCOMPARE(m3->data(i, m3->roles()[0]).toString(), QString("C" + QString::number(i)));
- QCOMPARE(m3->data(i, m3->roles()[1]).toString(), QString("3" + QString::number(i)));
- QCOMPARE(m3->data(i, m3->roles()[2]).toString(), QString("Curling"));
- }
- }
-
- delete m1;
- delete m2;
- delete m3;
-}
-
-void tst_qdeclarativexmllistmodel::threading_data()
-{
- QTest::addColumn<int>("xmlDataCount");
-
- QTest::newRow("1") << 1;
- QTest::newRow("2") << 2;
- QTest::newRow("10") << 10;
-}
-
-void tst_qdeclarativexmllistmodel::propertyChanges()
-{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
- QDeclarative1XmlListModel *model = qobject_cast<QDeclarative1XmlListModel*>(component.create());
- QVERIFY(model != 0);
- QTRY_COMPARE(model->count(), 9);
-
- QDeclarative1XmlListModelRole *role = model->findChild<QDeclarative1XmlListModelRole*>("role");
- QVERIFY(role);
-
- QSignalSpy nameSpy(role, SIGNAL(nameChanged()));
- QSignalSpy querySpy(role, SIGNAL(queryChanged()));
- QSignalSpy isKeySpy(role, SIGNAL(isKeyChanged()));
-
- role->setName("size");
- role->setQuery("size/string()");
- role->setIsKey(true);
-
- QCOMPARE(role->name(), QString("size"));
- QCOMPARE(role->query(), QString("size/string()"));
- QVERIFY(role->isKey());
-
- QCOMPARE(nameSpy.count(),1);
- QCOMPARE(querySpy.count(),1);
- QCOMPARE(isKeySpy.count(),1);
-
- role->setName("size");
- role->setQuery("size/string()");
- role->setIsKey(true);
-
- QCOMPARE(nameSpy.count(),1);
- QCOMPARE(querySpy.count(),1);
- QCOMPARE(isKeySpy.count(),1);
-
- QSignalSpy sourceSpy(model, SIGNAL(sourceChanged()));
- QSignalSpy xmlSpy(model, SIGNAL(xmlChanged()));
- QSignalSpy modelQuerySpy(model, SIGNAL(queryChanged()));
- QSignalSpy namespaceDeclarationsSpy(model, SIGNAL(namespaceDeclarationsChanged()));
-
- model->setSource(QUrl(""));
- model->setXml("<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>");
- model->setQuery("/Pets");
- model->setNamespaceDeclarations("declare namespace media=\"http://search.yahoo.com/mrss/\";");
-
- QCOMPARE(model->source(), QUrl(""));
- QCOMPARE(model->xml(), QString("<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>"));
- QCOMPARE(model->query(), QString("/Pets"));
- QCOMPARE(model->namespaceDeclarations(), QString("declare namespace media=\"http://search.yahoo.com/mrss/\";"));
-
- QTRY_VERIFY(model->count() == 1);
-
- QCOMPARE(sourceSpy.count(),1);
- QCOMPARE(xmlSpy.count(),1);
- QCOMPARE(modelQuerySpy.count(),1);
- QCOMPARE(namespaceDeclarationsSpy.count(),1);
-
- model->setSource(QUrl(""));
- model->setXml("<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>");
- model->setQuery("/Pets");
- model->setNamespaceDeclarations("declare namespace media=\"http://search.yahoo.com/mrss/\";");
-
- QCOMPARE(sourceSpy.count(),1);
- QCOMPARE(xmlSpy.count(),1);
- QCOMPARE(modelQuerySpy.count(),1);
- QCOMPARE(namespaceDeclarationsSpy.count(),1);
-
- QTRY_VERIFY(model->count() == 1);
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::roleCrash()
-{
- // don't crash
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleCrash.qml"));
- QDeclarative1XmlListModel *model = qobject_cast<QDeclarative1XmlListModel*>(component.create());
- QVERIFY(model != 0);
- delete model;
-}
-
-QTEST_MAIN(tst_qdeclarativexmllistmodel)
-
-#include "tst_qdeclarativexmllistmodel.moc"
diff --git a/tests/auto/qtquick1/qtquick1.pro b/tests/auto/qtquick1/qtquick1.pro
deleted file mode 100644
index f1177cd0f2..0000000000
--- a/tests/auto/qtquick1/qtquick1.pro
+++ /dev/null
@@ -1,50 +0,0 @@
-TEMPLATE = subdirs
-
-SUBDIRS += \
- qdeclarativeview \
- qdeclarativeviewer \
- moduleqt47
-
-contains(QT_CONFIG, private_tests) {
- SUBDIRS += \
- qdeclarativeanchors \
- qdeclarativeanimatedimage \
- qdeclarativeanimations \
- qdeclarativeapplication \
- qdeclarativebehaviors \
- qdeclarativebinding \
- qdeclarativeborderimage \
- qdeclarativeconnection \
- qdeclarativeflickable \
- qdeclarativeflipable \
- qdeclarativefocusscope \
- qdeclarativefontloader \
- qdeclarativegridview \
- qdeclarativeimage \
- qdeclarativeimageprovider \
- qdeclarativeitem \
- qdeclarativelayoutitem \
-# qdeclarativelistmodel \
- qdeclarativelistview \
- qdeclarativeloader \
- qdeclarativemousearea \
- qdeclarativeparticles \
- qdeclarativepathview \
- qdeclarativepincharea \
- qdeclarativepositioners \
- qdeclarativerepeater \
- qdeclarativesmoothedanimation \
- qdeclarativespringanimation \
- qdeclarativestates \
- qdeclarativesystempalette \
- qdeclarativetext \
- qdeclarativetextedit \
- qdeclarativetextinput \
- qdeclarativetimer \
- qdeclarativevisualdatamodel \
- qdeclarativexmllistmodel \
- examples
-
- # This test needs the xmlpatterns module
- !contains(QT_CONFIG,xmlpatterns): SUBDIRS -= qdeclarativexmllistmodel
-}