on xenial help sign in
Make tutorial qmltests more robust.

Use the tutorial Loader objects instead of the tutorial objects themselves when checking that the tutorial objects are hidden or shown. Individual tutorial objects are unloaded when they have been completed and their hide animations are done running. But their loaders are always available. Individual tutorial objects used to always be available. But when I refactored things a little while ago, I changed that and didn't update the tests because I didn't notice the race I had created. The race happens because when the tests do "swipe to dismiss tutorial" and then check that the tutorial is !shown, if we finish the hide animation first and unload the object, the check will fail. So instead, check the loaders for shown/hidden state. (LP: #1590810)

commit63f6e13d364618f4ff0281f382ba207ad9f9d112 authorMichael Terry <michael.terry@canonical.com> dateFri 17 Jun 2016, 01:18 (10 years ago) parenta56d6598d5437f
1 file changed+18−21
tests/qmltests/Tutorial/tst_Tutorial.qml+18−21
tests/qmltests/Tutorial/tst_Tutorial.qml+18−21
@@ -528,10 +528,10 @@ Rectangle {
528528 // Test that we skip the tutorial if user uses top edge themselves
529529
530530 var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
531− var tutorialTop = findChild(shell, "tutorialTop");
531+ var tutorialTopLoader = findChild(shell, "tutorialTopLoader");
532532 AccountsService.demoEdgesCompleted = ["left"];
533533 tryCompare(tutorialLeftLoader, "active", false);
534− verify(!tutorialTop.shown);
534+ verify(!tutorialTopLoader.shown);
535535
536536 touchFlick(shell, halfWidth, 0, halfWidth, shell.height);
537537 tryCompare(AccountsService, "demoEdgesCompleted", ["left", "top"]);
@@ -584,8 +584,8 @@ Rectangle {
584584 function test_tutorialRightDelay() {
585585 // Test that if we exit the top tutorial, we don't immediately
586586 // jump into right tutorial.
587− var tutorialRight = findChild(shell, "tutorialRight");
588− var tutorialRightTimer = findInvisibleChild(tutorialRight, "tutorialRightTimer");
587+ var tutorialRightLoader = findChild(shell, "tutorialRightLoader");
588+ var tutorialRightTimer = findInvisibleChild(tutorialRightLoader, "tutorialRightTimer");
589589
590590 openTutorialTop();
591591 ApplicationManager.startApplication("gallery-app");
@@ -595,9 +595,9 @@ Rectangle {
595595
596596 AccountsService.demoEdgesCompleted = ["left", "top", "left-long"];
597597 verify(tutorialRightTimer.running);
598− verify(!tutorialRight.shown);
598+ verify(!tutorialRightLoader.shown);
599599 tutorialRightTimer.interval = 1;
600− tryCompare(tutorialRight, "shown", true);
600+ tryCompare(tutorialRightLoader, "shown", true);
601601 }
602602
603603 function test_tutorialRightAutoSkipped() {
@@ -691,25 +691,25 @@ Rectangle {
691691 function test_desktopTutorialRightFinish() {
692692 loadShell("desktop");
693693
694− var tutorialRight = findChild(shell, "tutorialRight");
695− var tutorialRightTimer = findInvisibleChild(tutorialRight, "tutorialRightTimer");
694+ var tutorialRightLoader = findChild(shell, "tutorialRightLoader");
695+ var tutorialRightTimer = findInvisibleChild(tutorialRightLoader, "tutorialRightTimer");
696696 tutorialRightTimer.interval = 1;
697697 ApplicationManager.startApplication("dialer-app");
698698 ApplicationManager.startApplication("camera-app");
699699 ApplicationManager.startApplication("facebook-webapp");
700− tryCompare(tutorialRight, "shown", true);
700+ tryCompare(tutorialRightLoader, "shown", true);
701701
702702 var stage = findChild(shell, "stage");
703703 mouseMove(shell, shell.width, shell.height / 2);
704704 stage.pushRightEdge(units.gu(8));
705− tryCompare(tutorialRight, "shown", false);
705+ tryCompare(tutorialRightLoader, "shown", false);
706706
707707 tryCompare(AccountsService, "demoEdges", false);
708708 }
709709
710710 function test_oskDoesNotHideTutorial() {
711− var tutorialLeft = findChild(shell, "tutorialLeft");
712− verify(tutorialLeft.shown);
711+ var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
712+ verify(tutorialLeftLoader.shown);
713713
714714 var surface = SurfaceManager.inputMethodSurface;
715715 surface.setState(Mir.RestoredState);
@@ -717,7 +717,7 @@ Rectangle {
717717 var inputMethod = findInvisibleChild(shell, "inputMethod");
718718 tryCompare(inputMethod, "state", "shown");
719719
720− verify(tutorialLeft.shown);
720+ verify(tutorialLeftLoader.shown);
721721 }
722722
723723 function test_oskDelaysTutorial() {
@@ -777,18 +777,15 @@ Rectangle {
777777 }
778778
779779 function test_accountsServiceSettings() {
780− var tutorialLeft = findChild(shell, "tutorialLeft");
781− verify(tutorialLeft != null);
782− verify(tutorialLeft.shown);
780+ var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
781+ verify(tutorialLeftLoader.shown);
783782
784783 AccountsService.demoEdges = false;
785− verify(findChild(shell, "tutorialLeft") == null);
784+ verify(findChild(shell, "tutorialLeftLoader") == null);
786785
787786 AccountsService.demoEdges = true;
788− tutorialLeft = findChild(shell, "tutorialLeft");
789− verify(tutorialLeft != null);
790−
791− var tutorialLeftTimer = findChild(tutorialLeft, "tutorialLeftTimer");
787+ tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
788+ var tutorialLeftTimer = findChild(tutorialLeftLoader, "tutorialLeftTimer");
792789 verify(tutorialLeftTimer.running);
793790 }
794791 }