aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/controls/data/tst_tumbler.qml
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2018-01-16 15:22:40 +0100
committerMitch Curtis <mitch.curtis@qt.io>2018-01-17 14:22:18 +0000
commitda7d894deb4cc36155ade5e6a1ebecc3262363f8 (patch)
tree9b8337edd90dbdf2e4601a025cd2c72161e15a44 /tests/auto/controls/data/tst_tumbler.qml
parentd61567f3cfa100aeab865bd6b436de87970575f5 (diff)
Make Tumbler compatible with deferred execution
Now that the contentItem is created at a different stage, we have to shuffle some code around and add some null checks. Task-number: QTBUG-50992 Change-Id: I34d3a9ea9cb9ab54008a1015b37b1666538c085e Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'tests/auto/controls/data/tst_tumbler.qml')
-rw-r--r--tests/auto/controls/data/tst_tumbler.qml21
1 files changed, 18 insertions, 3 deletions
diff --git a/tests/auto/controls/data/tst_tumbler.qml b/tests/auto/controls/data/tst_tumbler.qml
index 825c2489..36808b8f 100644
--- a/tests/auto/controls/data/tst_tumbler.qml
+++ b/tests/auto/controls/data/tst_tumbler.qml
@@ -287,11 +287,10 @@ TestCase {
compare(tumblerView.currentIndex, data.currentIndex);
compare(tumblerView.currentItem.text, data.currentIndex.toString());
- var fuzz = 1;
if (data.wrap) {
- fuzzyCompare(tumblerView.offset, data.currentIndex > 0 ? tumblerView.count - data.currentIndex : 0, fuzz);
+ tryCompare(tumblerView, "offset", data.currentIndex > 0 ? tumblerView.count - data.currentIndex : 0);
} else {
- fuzzyCompare(tumblerView.contentY, tumblerDelegateHeight * data.currentIndex - tumblerView.preferredHighlightBegin, fuzz);
+ tryCompare(tumblerView, "contentY", tumblerDelegateHeight * data.currentIndex - tumblerView.preferredHighlightBegin);
}
}
@@ -680,6 +679,17 @@ TestCase {
compare(tumbler.currentIndex, 3);
}
+ function findFirstDelegateWithText(view, text) {
+ var delegate = null;
+ var contentItem = view.hasOwnProperty("contentItem") ? view.contentItem : view;
+ for (var i = 0; i < contentItem.children.length && !delegate; ++i) {
+ var child = contentItem.children[i];
+ if (child.hasOwnProperty("text") && child.text === text)
+ delegate = child;
+ }
+ return delegate;
+ }
+
function test_customContentItemAfterConstruction_data() {
return [
{ tag: "ListView", componentPath: "TumblerListView.qml" },
@@ -705,6 +715,11 @@ TestCase {
tumblerView = findView(tumbler);
compare(tumblerView.currentIndex, 2);
+ var delegate = findFirstDelegateWithText(tumblerView, "Custom2");
+ verify(delegate);
+ compare(delegate.height, defaultImplicitDelegateHeight);
+ tryCompare(delegate.Tumbler, "displacement", 0);
+
tumblerView.incrementCurrentIndex();
compare(tumblerView.currentIndex, 3);
compare(tumbler.currentIndex, 3);