From b7b8713feacce4155cacd4bdadf78cc17cb0ecd3 Mon Sep 17 00:00:00 2001
From: Karol Polak <permotion88@o2.pl>
Date: Mon, 10 Apr 2017 21:29:44 +0200
Subject: [PATCH] Add mapReady to test case start conditions

It is reasonable to add mapReady property to the condition
for the start of test cases where it is required that the
map is initialized. This covers the case when one of the
initialization steps runs asynchronously.

Change-Id: I2eff52dbe3a7bec0b2f3fb26d607398829b5c9f2
Reviewed-by: Paolo Angelelli <paolo.angelelli@qt.io>
---
 tests/auto/declarative_ui/tst_map.qml                  | 10 +++++++++-
 .../declarative_ui/tst_map_coordinateanimation.qml     |  2 +-
 tests/auto/declarative_ui/tst_map_flick.qml            |  2 +-
 tests/auto/declarative_ui/tst_map_item.qml             |  2 +-
 tests/auto/declarative_ui/tst_map_item_details.qml     |  2 +-
 .../auto/declarative_ui/tst_map_item_fit_viewport.qml  |  2 +-
 tests/auto/declarative_ui/tst_map_itemview.qml         |  7 ++++++-
 tests/auto/declarative_ui/tst_map_keepgrab.qml         |  2 +-
 tests/auto/declarative_ui/tst_map_mouse.qml            |  2 +-
 .../auto/declarative_ui/tst_map_pinch.qml.QTBUG-47970  |  2 +-
 10 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/tests/auto/declarative_ui/tst_map.qml b/tests/auto/declarative_ui/tst_map.qml
index 6691580e5..846a621fe 100644
--- a/tests/auto/declarative_ui/tst_map.qml
+++ b/tests/auto/declarative_ui/tst_map.qml
@@ -57,6 +57,14 @@ Item {
     property variant coordinate5: QtPositioning.coordinate(20, 180)
     property variant invalidCoordinate: QtPositioning.coordinate()
     property variant altitudelessCoordinate: QtPositioning.coordinate(50, 50)
+    property bool allMapsReady: mapZoomOnCompleted.mapReady
+                                && mapZoomDefault.mapReady
+                                && mapZoomUserInit.mapReady
+                                && map.mapReady
+                                && mapPar.mapReady
+                                && coordinateMap.mapReady
+                                && mapTiltBearing.mapReady
+                                && mapTiltBearingHere.mapReady
 
     Map { id: mapZoomOnCompleted; width: 200; height: 200;
         zoomLevel: 3; center: coordinate1; plugin: testPlugin;
@@ -98,7 +106,7 @@ Item {
 
 
     TestCase {
-        when: windowShown
+        when: windowShown && allMapsReady
         name: "MapProperties"
 
         function fuzzy_compare(val, ref) {
diff --git a/tests/auto/declarative_ui/tst_map_coordinateanimation.qml b/tests/auto/declarative_ui/tst_map_coordinateanimation.qml
index d9b71edda..204775099 100644
--- a/tests/auto/declarative_ui/tst_map_coordinateanimation.qml
+++ b/tests/auto/declarative_ui/tst_map_coordinateanimation.qml
@@ -79,7 +79,7 @@ Item {
     }
 
     TestCase {
-        when: windowShown
+        when: windowShown && map.mapReady
         name: "CoordinateAnimation"
 
         function test_coordinate_animation() {
diff --git a/tests/auto/declarative_ui/tst_map_flick.qml b/tests/auto/declarative_ui/tst_map_flick.qml
index 8da712b26..84ffa4294 100644
--- a/tests/auto/declarative_ui/tst_map_flick.qml
+++ b/tests/auto/declarative_ui/tst_map_flick.qml
@@ -94,7 +94,7 @@ Item {
     SignalSpy {id: mouseAreaBottomSpy; target: mouseAreaBottom; signalName: 'onPressed'}
 
     TestCase {
-        when: windowShown
+        when: windowShown && map.mapReady
         name: "MapFlick"
 
         function init()
diff --git a/tests/auto/declarative_ui/tst_map_item.qml b/tests/auto/declarative_ui/tst_map_item.qml
index b75daf381..1646fdbaf 100644
--- a/tests/auto/declarative_ui/tst_map_item.qml
+++ b/tests/auto/declarative_ui/tst_map_item.qml
@@ -216,7 +216,7 @@ Item {
     }
     TestCase {
         name: "MapItems"
-        when: windowShown
+        when: windowShown && map.mapReady
 
         function initTestCase()
         {
diff --git a/tests/auto/declarative_ui/tst_map_item_details.qml b/tests/auto/declarative_ui/tst_map_item_details.qml
index 0c5f5c0ba..80225c169 100644
--- a/tests/auto/declarative_ui/tst_map_item_details.qml
+++ b/tests/auto/declarative_ui/tst_map_item_details.qml
@@ -278,7 +278,7 @@ Item {
 
     TestCase {
         name: "MapItemDetails"
-        when: windowShown
+        when: windowShown && map.mapReady
 
     /*
 
diff --git a/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml b/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml
index fe4d9e491..adf9c3477 100644
--- a/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml
+++ b/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml
@@ -217,7 +217,7 @@ Item {
 
     TestCase {
         name: "MapItemsFitViewport"
-        when: windowShown
+        when: windowShown && map.mapReady
 
         function initTestCase()
         {
diff --git a/tests/auto/declarative_ui/tst_map_itemview.qml b/tests/auto/declarative_ui/tst_map_itemview.qml
index db788ace6..bbd70c8ee 100644
--- a/tests/auto/declarative_ui/tst_map_itemview.qml
+++ b/tests/auto/declarative_ui/tst_map_itemview.qml
@@ -40,6 +40,11 @@ Item {
     Plugin { id: testPlugin; name : "qmlgeo.test.plugin"; allowExperimental: true }
 
     property variant mapDefaultCenter: QtPositioning.coordinate(10, 30)
+    property bool allMapsReady: map.mapReady
+                                && map3.mapReady
+                                && mapForView.mapReady
+                                && mapForTestingListModel.mapReady
+                                && mapForTestingRouteModel.mapReady
 
     Map {
         id: map
@@ -259,7 +264,7 @@ Item {
 
     TestCase {
         name: "MapItem"
-        when: windowShown
+        when: windowShown && allMapsReady
         function clear_data() {
             mapItemSpy.clear()
         }
diff --git a/tests/auto/declarative_ui/tst_map_keepgrab.qml b/tests/auto/declarative_ui/tst_map_keepgrab.qml
index fa47eec86..7690b78de 100644
--- a/tests/auto/declarative_ui/tst_map_keepgrab.qml
+++ b/tests/auto/declarative_ui/tst_map_keepgrab.qml
@@ -61,7 +61,7 @@ Item {
 
 
     TestCase {
-        when: windowShown
+        when: windowShown && map.mapReady
         name: "MapKeepGrabAndPreventSteal"
 
         function initTestCase()
diff --git a/tests/auto/declarative_ui/tst_map_mouse.qml b/tests/auto/declarative_ui/tst_map_mouse.qml
index 99aff03d6..dd9de73ad 100644
--- a/tests/auto/declarative_ui/tst_map_mouse.qml
+++ b/tests/auto/declarative_ui/tst_map_mouse.qml
@@ -161,7 +161,7 @@ Item {
 
     TestCase {
         name: "MouseArea"
-        when: windowShown
+        when: windowShown && map.mapReady
         SignalSpy {id: mouseUpperClickedSpy; target: mouseUpper; signalName: "clicked"}
         SignalSpy {id: mouseLowerClickedSpy; target: mouseLower; signalName: "clicked"}
         SignalSpy {id: mouseOverlapperClickedSpy; target: mouseOverlapper; signalName: "clicked"}
diff --git a/tests/auto/declarative_ui/tst_map_pinch.qml.QTBUG-47970 b/tests/auto/declarative_ui/tst_map_pinch.qml.QTBUG-47970
index f80e44a17..6d913eab0 100644
--- a/tests/auto/declarative_ui/tst_map_pinch.qml.QTBUG-47970
+++ b/tests/auto/declarative_ui/tst_map_pinch.qml.QTBUG-47970
@@ -102,7 +102,7 @@ Item {
     SignalSpy {id: mouseAreaBottomSpy; target: mouseAreaBottom; signalName: 'onPressed'}
 
     TestCase {
-        when: windowShown
+        when: windowShown && map.mapReady
         name: "MapPinch"
 
         function init()
-- 
GitLab