~ahayzen/volleyball2d/new-logo

« back to all changes in this revision

Viewing changes to tests/autopilot/volleyball/test_menu.py

  • Committer: Andrew Hayzen
  • Date: 2014-12-14 17:51:40 UTC
  • Revision ID: ahayzen@gmail.com-20141214175140-f58uxnu5f07lu80b
* Cleanups of gameFinished and roundWon
* Add support for shell rotation
* Create separate settings page
* Add deadzone option
* Use fixtures for mocking of $HOME

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
from autopilot.matchers import Eventually
20
20
from testtools.matchers import Equals
21
21
 
22
 
import volleyball
23
 
 
24
 
 
25
 
class MenuSceneTestCase(volleyball.ClickAppTestCase):
 
22
from volleyball import ClickAppTestCase
 
23
 
 
24
INSTRUCTION_MOTION_STR = "Rotate your device to move your player\nTap to jump"
 
25
INSTRUCTION_NO_MOTION_STR = ("Press on the left or right of the screen to "
 
26
                             "move\nTap in the center or a two finger press "
 
27
                             "to jump")
 
28
 
 
29
 
 
30
class MenuSceneTestCase(ClickAppTestCase):
26
31
    """Tests for the menu scene"""
27
32
 
28
 
    instructionMotionStr = ("Rotate your device to move your player\n"
29
 
                            "Tap to jump")
30
 
    instructionNoMotionStr = ("Press on the left or right of the screen to "
31
 
                              "move\nTap in the center or a two finger press "
32
 
                              "to jump")
33
 
 
34
33
    def test_inital_labels(self):
35
34
        """Test inital states of labels are correct"""
36
35
 
37
36
        self.assertThat(self.menu_scene.visible, Eventually(Equals(True)))
38
37
 
39
 
        # Ensure state of motion is correct
40
 
        self.menu_scene.set_motion_switch_state(True)
41
 
 
42
38
        # Ensure labels are correct
43
39
        self.assertThat(self.menu_scene.get_main_label().text,
44
40
                        Equals("Volleyball"))
46
42
                        Equals("Tap to play"))
47
43
 
48
44
        self.assertThat(self.menu_scene.get_instruction_label().text,
49
 
                        Equals(self.instructionMotionStr))
50
 
 
51
 
    def test_switch_motion(self):
52
 
        """Test the motion switch changes and the labels"""
53
 
 
54
 
        self.assertThat(self.menu_scene.visible, Eventually(Equals(True)))
55
 
 
56
 
        # Enable motion - check the switch and labels
57
 
        self.menu_scene.set_motion_switch_state(True)
58
 
        self.assertThat(self.menu_scene.get_motion_switch_state(),
59
 
                        Eventually(Equals(True)))
60
 
        self.assertThat(self.menu_scene.get_instruction_label().text,
61
 
                        Eventually(Equals(self.instructionMotionStr)))
62
 
 
63
 
        # Disable motion - check the switch and labels
64
 
        self.menu_scene.set_motion_switch_state(False)
65
 
        self.assertThat(self.menu_scene.get_motion_switch_state(),
66
 
                        Eventually(Equals(False)))
67
 
        self.assertThat(self.menu_scene.get_instruction_label().text,
68
 
                        Eventually(Equals(self.instructionNoMotionStr)))
69
 
 
70
 
        # Enable motion - check the switch and labels
71
 
        self.menu_scene.set_motion_switch_state(True)
72
 
        self.assertThat(self.menu_scene.get_motion_switch_state(),
73
 
                        Eventually(Equals(True)))
74
 
        self.assertThat(self.menu_scene.get_instruction_label().text,
75
 
                        Eventually(Equals(self.instructionMotionStr)))
 
45
                        Equals(INSTRUCTION_MOTION_STR))