on xenial help sign in
Fix racing in MenuPopup tests
38bbc54Dalton Durst
tests/qmltests/ApplicationMenus/tst_MenuPopup.qml+10−9
@@ -76,6 +76,7 @@ Item {
76 property var menu: loader.status === Loader.Ready ? loader.item : null
76 property var menu: loader.status === Loader.Ready ? loader.item : null
77
77
78 function init() {
78 function init() {
79+ mouseMove(root, 0, 0);
79 loader.active = true;
80 loader.active = true;
80 menu.show();
81 menu.show();
81 }
82 }
@@ -141,7 +142,7 @@ Item {
141
142
142 mouseClick(menuItem, menuItem.width/2, menuItem.height/2);
143 mouseClick(menuItem, menuItem.width/2, menuItem.height/2);
143
144
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");
145 }
146 }
146
147
147 function test_keyboardNavigation_DownKeySelectsAndOpensNextMenuItemAndRotates() {
148 function test_keyboardNavigation_DownKeySelectsAndOpensNextMenuItemAndRotates() {
@@ -154,16 +155,16 @@ Item {
154 var priv = findInvisibleChild(menu, "d");
155 var priv = findInvisibleChild(menu, "d");
155
156
156 keyClick(Qt.Key_Down, Qt.NoModifier);
157 keyClick(Qt.Key_Down, Qt.NoModifier);
157− compare(priv.currentItem, item1, "CurrentItem should have moved to item 1");
158+ tryCompare(priv, "currentItem", item1);
158
159
159 keyClick(Qt.Key_Down, Qt.NoModifier);
160 keyClick(Qt.Key_Down, Qt.NoModifier);
160− compare(priv.currentItem, item2, "CurrentItem should have moved to item 2");
161+ tryCompare(priv, "currentItem", item2);
161
162
162 keyClick(Qt.Key_Down, Qt.NoModifier);
163 keyClick(Qt.Key_Down, Qt.NoModifier);
163− compare(priv.currentItem, item0, "CurrentItem should have moved to item 0");
164+ tryCompare(priv, "currentItem", item0);
164
165
165 keyClick(Qt.Key_Down, Qt.NoModifier);
166 keyClick(Qt.Key_Down, Qt.NoModifier);
166− compare(priv.currentItem, item1, "CurrentItem should have moved to item 1");
167+ tryCompare(priv, "currentItem", item1);
167 }
168 }
168
169
169 function test_keyboardNavigation_UpKeySelectsAndOpensPreviousMenuItemAndRotates() {
170 function test_keyboardNavigation_UpKeySelectsAndOpensPreviousMenuItemAndRotates() {
@@ -176,16 +177,16 @@ Item {
176 var priv = findInvisibleChild(menu, "d");
177 var priv = findInvisibleChild(menu, "d");
177
178
178 keyClick(Qt.Key_Up, Qt.NoModifier);
179 keyClick(Qt.Key_Up, Qt.NoModifier);
179− compare(priv.currentItem, item2, "CurrentItem should have moved to item 2");
180+ tryCompare(priv, "currentItem", item2);
180
181
181 keyClick(Qt.Key_Up, Qt.NoModifier);
182 keyClick(Qt.Key_Up, Qt.NoModifier);
182− compare(priv.currentItem, item1, "CurrentItem should have moved to item 1");
183+ tryCompare(priv, "currentItem", item1);
183
184
184 keyClick(Qt.Key_Up, Qt.NoModifier);
185 keyClick(Qt.Key_Up, Qt.NoModifier);
185− compare(priv.currentItem, item0, "CurrentItem should have moved to item 0");
186+ tryCompare(priv, "currentItem", item0);
186
187
187 keyClick(Qt.Key_Up, Qt.NoModifier);
188 keyClick(Qt.Key_Up, Qt.NoModifier);
188− compare(priv.currentItem, item2, "CurrentItem should have moved to item 2");
189+ tryCompare(priv, "currentItem", item2);
189 }
190 }
190
191
191 function test_aboutToShow() {
192 function test_aboutToShow() {