diff options
Diffstat (limited to 'tests/auto/qmltest/listview/tst_listview.qml')
-rw-r--r-- | tests/auto/qmltest/listview/tst_listview.qml | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/auto/qmltest/listview/tst_listview.qml b/tests/auto/qmltest/listview/tst_listview.qml index f7a34cbce2..5e9bb22e8e 100644 --- a/tests/auto/qmltest/listview/tst_listview.qml +++ b/tests/auto/qmltest/listview/tst_listview.qml @@ -50,6 +50,7 @@ import QtQuick 2.1 import QtTest 1.1 +import "data" Item { id: top @@ -204,6 +205,14 @@ Item { ListElement { component: "data/asynclistviewloader.qml" } } + MultiDelegate { + id: multiDelegate + } + + MultiDelegate2 { + id: multiDelegate2 + } + TestCase { name: "ListView" when: windowShown @@ -363,5 +372,47 @@ Item { function test_viewWithAction() { compare(viewWithActionModel.funcResult, "one") } + + function test_multipleDelegates_data() { + return [ + { y: 25, type: "Rectangle", value: "red" }, + { y: 75, type: "Image", value: Qt.resolvedUrl("data/logo.png") }, + { y: 125, type: "Text", value: "Hello" }, + { y: 175, type: "Text", value: "World" }, + { y: 225, type: "Rectangle", value: "green" }, + { y: 275, type: "Image", value: Qt.resolvedUrl("data/logo.png") }, + { y: 325, type: "Rectangle", value: "blue" }, + { y: 375, type: "Item", value: "" } + ] + } + + function test_multipleDelegates(row) { + var delegate = multiDelegate.itemAt(10, row.y) + verify(delegate.toString().includes(row.type)) + switch (row.type) { + case "Rectangle": verify(Qt.colorEqual(delegate.color, row.value)); break + case "Text": compare(delegate.text, row.value); break + case "Image": compare(delegate.source, row.value); break + case "Item": break + } + } + + function test_multipleDelegates2_data() { + return [ + { y: 25, type: "1" }, + { y: 75, type: "2" }, + { y: 125, type: "3" }, + { y: 175, type: "4" }, + { y: 225, type: "4" }, + { y: 275, type: "3" }, + { y: 325, type: "4" }, + { y: 375, type: "4" } + ] + } + + function test_multipleDelegates2(row) { + var delegate = multiDelegate2.itemAt(10, row.y) + compare(delegate.choiceType, row.type) + } } } |