aboutsummaryrefslogtreecommitdiffstats
path: root/tests
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
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')
-rw-r--r--tests/auto/controls/data/TumblerListView.qml12
-rw-r--r--tests/auto/controls/data/TumblerPathView.qml11
-rw-r--r--tests/auto/controls/data/tst_tumbler.qml21
-rw-r--r--tests/auto/customization/tst_customization.cpp2
4 files changed, 37 insertions, 9 deletions
diff --git a/tests/auto/controls/data/TumblerListView.qml b/tests/auto/controls/data/TumblerListView.qml
index 4e71f471..1248bec0 100644
--- a/tests/auto/controls/data/TumblerListView.qml
+++ b/tests/auto/controls/data/TumblerListView.qml
@@ -49,15 +49,21 @@
****************************************************************************/
import QtQuick 2.6
+import QtQuick.Controls 2.2
ListView {
anchors.fill: parent
- model: parent.model
- delegate: parent.delegate
-
snapMode: ListView.SnapToItem
highlightRangeMode: ListView.StrictlyEnforceRange
preferredHighlightBegin: height / 2 - (height / parent.visibleItemCount / 2)
preferredHighlightEnd: height / 2 + (height / parent.visibleItemCount / 2)
clip: true
+ model: parent.model
+ delegate: Text {
+ objectName: text
+ text: "Custom" + modelData
+ opacity: 1.0 - Math.abs(Tumbler.displacement) / (Tumbler.tumbler.visibleItemCount / 2)
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
}
diff --git a/tests/auto/controls/data/TumblerPathView.qml b/tests/auto/controls/data/TumblerPathView.qml
index 4f6f653f..7b7cd5f4 100644
--- a/tests/auto/controls/data/TumblerPathView.qml
+++ b/tests/auto/controls/data/TumblerPathView.qml
@@ -49,16 +49,23 @@
****************************************************************************/
import QtQuick 2.6
+import QtQuick.Controls 2.2
PathView {
id: pathView
- model: parent.model
- delegate: parent.delegate
clip: true
pathItemCount: parent.visibleItemCount + 1
preferredHighlightBegin: 0.5
preferredHighlightEnd: 0.5
dragMargin: width / 2
+ model: parent.model
+ delegate: Text {
+ objectName: text
+ text: "Custom" + modelData
+ opacity: 1.0 - Math.abs(Tumbler.displacement) / (Tumbler.tumbler.visibleItemCount / 2)
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
path: Path {
startX: pathView.width / 2
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);
diff --git a/tests/auto/customization/tst_customization.cpp b/tests/auto/customization/tst_customization.cpp
index 05d95ec8..3010565c 100644
--- a/tests/auto/customization/tst_customization.cpp
+++ b/tests/auto/customization/tst_customization.cpp
@@ -101,7 +101,7 @@ static const ControlInfo ControlInfos[] = {
{ "ToolButton", QStringList() << "background" << "contentItem" },
{ "ToolSeparator", QStringList() << "background" << "contentItem" },
{ "ToolTip", QStringList() << "background" << "contentItem" },
- // { "Tumbler", QStringList() << "background" << "contentItem" } ### TODO: fix and enable deferred execution
+ { "Tumbler", QStringList() << "background" << "contentItem" }
};
class tst_customization : public QQmlDataTest