From da7d894deb4cc36155ade5e6a1ebecc3262363f8 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 16 Jan 2018 15:22:40 +0100 Subject: 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 --- tests/auto/controls/data/TumblerListView.qml | 12 +++++++++--- tests/auto/controls/data/TumblerPathView.qml | 11 +++++++++-- tests/auto/controls/data/tst_tumbler.qml | 21 ++++++++++++++++++--- tests/auto/customization/tst_customization.cpp | 2 +- 4 files changed, 37 insertions(+), 9 deletions(-) (limited to 'tests') 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 -- cgit v1.2.3 From c9cbee192263998bd3a9fe9d1414a4b539b9e4a2 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 17 Jan 2018 15:51:18 +0100 Subject: Imagine/SpinBox: cleanup internal IDs for deferred execution Task-number: QTBUG-50992 Change-Id: Iaabd561b2bd009d3db970f370eff6fa717164961 Reviewed-by: Mitch Curtis --- tests/auto/sanity/BLACKLIST | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/sanity/BLACKLIST b/tests/auto/sanity/BLACKLIST index 94e4fd32..b2038576 100644 --- a/tests/auto/sanity/BLACKLIST +++ b/tests/auto/sanity/BLACKLIST @@ -12,8 +12,6 @@ * [ids:imagine/ProgressBar.qml] * -[ids:imagine/SpinBox.qml] -* [ids:imagine/Switch.qml] * [ids:imagine/SwitchDelegate.qml] -- cgit v1.2.3 From 47168eb73bbe888042a1735e424ae35c9af04e2f Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 17 Jan 2018 15:52:55 +0100 Subject: Imagine/GroupBox: cleanup internal IDs for deferred execution Task-number: QTBUG-50992 Change-Id: Ied6b4365d03fc1ef3ae3a69667f1cb1fc8cdb9ac Reviewed-by: Mitch Curtis --- tests/auto/sanity/BLACKLIST | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/sanity/BLACKLIST b/tests/auto/sanity/BLACKLIST index b2038576..ab9673a7 100644 --- a/tests/auto/sanity/BLACKLIST +++ b/tests/auto/sanity/BLACKLIST @@ -6,8 +6,6 @@ * [ids:imagine/DelayButton.qml] * -[ids:imagine/GroupBox.qml] -* [ids:imagine/ProgressBar.qml] * [ids:imagine/ProgressBar.qml] -- cgit v1.2.3 From 035990f2695e57526e5960b55fdefdaea3299ecb Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 18 Jan 2018 11:05:36 +0100 Subject: Imagine/BusyIndicator: cleanup internal IDs for deferred execution Task-number: QTBUG-50992 Change-Id: Idee1a13355e36e9221b32cdf9b89b4090dcf87b4 Reviewed-by: Mitch Curtis --- tests/auto/sanity/BLACKLIST | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/sanity/BLACKLIST b/tests/auto/sanity/BLACKLIST index ab9673a7..c34a6ebd 100644 --- a/tests/auto/sanity/BLACKLIST +++ b/tests/auto/sanity/BLACKLIST @@ -2,8 +2,6 @@ * [attachedObjects:material/SwitchDelegate.qml] * -[ids:imagine/BusyIndicator.qml] -* [ids:imagine/DelayButton.qml] * [ids:imagine/ProgressBar.qml] -- cgit v1.2.3 From 81ff2b14c317545e6f7b44b722cf057badd1e322 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 18 Jan 2018 11:56:38 +0100 Subject: Imagine/ProgressBar: cleanup internal IDs for deferred execution Task-number: QTBUG-50992 Change-Id: I1f31b23f3db23e5582b74b18ed643e8263d99142 Reviewed-by: Mitch Curtis --- tests/auto/sanity/BLACKLIST | 4 ---- 1 file changed, 4 deletions(-) (limited to 'tests') diff --git a/tests/auto/sanity/BLACKLIST b/tests/auto/sanity/BLACKLIST index c34a6ebd..53b27412 100644 --- a/tests/auto/sanity/BLACKLIST +++ b/tests/auto/sanity/BLACKLIST @@ -4,10 +4,6 @@ * [ids:imagine/DelayButton.qml] * -[ids:imagine/ProgressBar.qml] -* -[ids:imagine/ProgressBar.qml] -* [ids:imagine/Switch.qml] * [ids:imagine/SwitchDelegate.qml] -- cgit v1.2.3 From 8244e2e36af2f6923c5be586da37c0facf7152a8 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 18 Jan 2018 12:16:48 +0100 Subject: Imagine/DelayButton: cleanup internal IDs for deferred execution Task-number: QTBUG-50992 Change-Id: I5f2708bc0e9f37232b10e2cd6f1c61ab779156e3 Reviewed-by: Mitch Curtis --- tests/auto/sanity/BLACKLIST | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/sanity/BLACKLIST b/tests/auto/sanity/BLACKLIST index 53b27412..a595d354 100644 --- a/tests/auto/sanity/BLACKLIST +++ b/tests/auto/sanity/BLACKLIST @@ -2,8 +2,6 @@ * [attachedObjects:material/SwitchDelegate.qml] * -[ids:imagine/DelayButton.qml] -* [ids:imagine/Switch.qml] * [ids:imagine/SwitchDelegate.qml] -- cgit v1.2.3 From 26056b52b182b4452855f54a2c811d64246c434a Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 18 Jan 2018 12:19:27 +0100 Subject: Imagine/Switch(Delegate): cleanup internal IDs for deferred execution Task-number: QTBUG-50992 Change-Id: I621343bef562b4ed85202a0690a0cccfc0a053c5 Reviewed-by: Mitch Curtis --- tests/auto/sanity/BLACKLIST | 4 ---- 1 file changed, 4 deletions(-) (limited to 'tests') diff --git a/tests/auto/sanity/BLACKLIST b/tests/auto/sanity/BLACKLIST index a595d354..42ad3448 100644 --- a/tests/auto/sanity/BLACKLIST +++ b/tests/auto/sanity/BLACKLIST @@ -2,7 +2,3 @@ * [attachedObjects:material/SwitchDelegate.qml] * -[ids:imagine/Switch.qml] -* -[ids:imagine/SwitchDelegate.qml] -* -- cgit v1.2.3