19
19
from autopilot.matchers import Eventually
20
20
from testtools.matchers import Equals
25
class MenuSceneTestCase(volleyball.ClickAppTestCase):
22
from volleyball import ClickAppTestCase
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 "
30
class MenuSceneTestCase(ClickAppTestCase):
26
31
"""Tests for the menu scene"""
28
instructionMotionStr = ("Rotate your device to move your player\n"
30
instructionNoMotionStr = ("Press on the left or right of the screen to "
31
"move\nTap in the center or a two finger press "
34
33
def test_inital_labels(self):
35
34
"""Test inital states of labels are correct"""
37
36
self.assertThat(self.menu_scene.visible, Eventually(Equals(True)))
39
# Ensure state of motion is correct
40
self.menu_scene.set_motion_switch_state(True)
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"))
48
44
self.assertThat(self.menu_scene.get_instruction_label().text,
49
Equals(self.instructionMotionStr))
51
def test_switch_motion(self):
52
"""Test the motion switch changes and the labels"""
54
self.assertThat(self.menu_scene.visible, Eventually(Equals(True)))
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)))
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)))
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))