on xenial help sign in
Fix racing in MenuPopup tests

* Move the mouse out of the way at the start of tests * Fix use of compare vs tryCompare, which caused a race condition

commit38bbc54fd84cb69f945b81adf527cdd9b66a926f authorDalton Durst <dalton@ubports.com> dateThu 23 May 2019, 17:02 (7 years ago) parentaf83d0a
1 file changed+10−9
tests/qmltests/ApplicationMenus/tst_MenuPopup.qml+10−9
tests/qmltests/ApplicationMenus/tst_MenuPopup.qml+10−9
@@ -76,6 +76,7 @@ Item {
7676 property var menu: loader.status === Loader.Ready ? loader.item : null
7777
7878 function init() {
79+ mouseMove(root, 0, 0);
7980 loader.active = true;
8081 menu.show();
8182 }
@@ -141,7 +142,7 @@ Item {
141142
142143 mouseClick(menuItem, menuItem.width/2, menuItem.height/2);
143144
144− compare(menuItem.action.checked, true, "Checkable menu item should have toggled");
145+ tryCompare(menuItem.action, "checked", true, 5000, "Checkable menu item should have toggled");
145146 }
146147
147148 function test_keyboardNavigation_DownKeySelectsAndOpensNextMenuItemAndRotates() {
@@ -154,16 +155,16 @@ Item {
154155 var priv = findInvisibleChild(menu, "d");
155156
156157 keyClick(Qt.Key_Down, Qt.NoModifier);
157− compare(priv.currentItem, item1, "CurrentItem should have moved to item 1");
158+ tryCompare(priv, "currentItem", item1);
158159
159160 keyClick(Qt.Key_Down, Qt.NoModifier);
160− compare(priv.currentItem, item2, "CurrentItem should have moved to item 2");
161+ tryCompare(priv, "currentItem", item2);
161162
162163 keyClick(Qt.Key_Down, Qt.NoModifier);
163− compare(priv.currentItem, item0, "CurrentItem should have moved to item 0");
164+ tryCompare(priv, "currentItem", item0);
164165
165166 keyClick(Qt.Key_Down, Qt.NoModifier);
166− compare(priv.currentItem, item1, "CurrentItem should have moved to item 1");
167+ tryCompare(priv, "currentItem", item1);
167168 }
168169
169170 function test_keyboardNavigation_UpKeySelectsAndOpensPreviousMenuItemAndRotates() {
@@ -176,16 +177,16 @@ Item {
176177 var priv = findInvisibleChild(menu, "d");
177178
178179 keyClick(Qt.Key_Up, Qt.NoModifier);
179− compare(priv.currentItem, item2, "CurrentItem should have moved to item 2");
180+ tryCompare(priv, "currentItem", item2);
180181
181182 keyClick(Qt.Key_Up, Qt.NoModifier);
182− compare(priv.currentItem, item1, "CurrentItem should have moved to item 1");
183+ tryCompare(priv, "currentItem", item1);
183184
184185 keyClick(Qt.Key_Up, Qt.NoModifier);
185− compare(priv.currentItem, item0, "CurrentItem should have moved to item 0");
186+ tryCompare(priv, "currentItem", item0);
186187
187188 keyClick(Qt.Key_Up, Qt.NoModifier);
188− compare(priv.currentItem, item2, "CurrentItem should have moved to item 2");
189+ tryCompare(priv, "currentItem", item2);
189190 }
190191
191192 function test_aboutToShow() {