@@ -273,6 +273,33 @@ Item {
273273 tryCompare(scopesModel.get(2), "isActive", data.active2);
274274 }
275275
276+ function doFindMusicButton(parent) {
277+ console.log("P", parent);
278+ for (var i = 0; i < parent.children.length; i++) {
279+ var c = parent.children[i];
280+ if (UT.Util.isInstanceOf(c, "AbstractButton") && parent.x >= 0) {
281+ for (var ii = 0; ii < c.children.length; ii++) {
282+ var cc = c.children[ii];
283+ if (UT.Util.isInstanceOf(cc, "Label") && cc.text == "Music") {
284+ return c;
285+ }
286+ }
287+ }
288+ var r = doFindMusicButton(c);
289+ if (r !== undefined) {
290+ return r;
291+ }
292+ }
293+ return undefined;
294+ }
295+
296+ function findMusicButton() {
297+ // We need to find a AbstractButton that has a Label child
298+ // with text Music and it's parent x is >= 0
299+ var tabbar = findChild(dashContent, "tabbar");
300+ return doFindMusicButton(tabbar);
301+ }
302+
276303 function test_tabBar_index_change() {
277304 console.log("A");
278305 tryCompare(scopesModel, "loaded", true);
@@ -292,20 +319,10 @@ Item {
292319 tryCompare(dashContent, "currentIndex", 0);
293320
294321 var button;
295− tryCompareFunction(function() {
296− if (tabbar.children[0].children[0].children[0].children[1].x >= 0) {
297− button = tabbar.children[0].children[0].children[0].children[1].children[1];
298− } else {
299− button = tabbar.children[0].children[0].children[0].children[2].children[1];
300− }
301− return button != undefined;
302− }, true);
322+ tryCompareFunction(function() { button = findMusicButton(); return button != undefined; }, true);
303323 console.log("E", button);
304324 waitForRendering(button);
305325
306− UT.Util.isInstanceOf(button, "AbstractButton");
307− UT.Util.isInstanceOf(button.children[3], "Label");
308− tryCompare(button.children[3], "text", "Music");
309326 console.log("F");
310327
311328 mouseClick(button, button.width / 2, button.height / 2)