~ubuntu-branches/ubuntu/utopic/mediaplayer-app/utopic-proposed

« back to all changes in this revision

Viewing changes to tests/autopilot/mediaplayer_app/tests/test_player_with_video.py

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Leo Arias, Brendan Donegan
  • Date: 2014-07-18 21:28:23 UTC
  • mfrom: (1.1.24)
  • Revision ID: package-import@ubuntu.com-20140718212823-c9yqkcm4g53tj44g
Tags: 0.20.5+14.10.20140718.1-0ubuntu1
[ Leo Arias ]
* Skip the no video dialog test in desktop. (LP: #1341956)

[ Brendan Donegan ]
* We remove the two scene selector tests because this feature is
  dropped.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 
8
8
"""Tests for the Mediaplayer App"""
9
9
 
10
 
from __future__ import absolute_import
11
 
 
12
10
from autopilot.matchers import Eventually
13
11
from autopilot.platform import model
14
12
from testtools import skipIf
26
24
        In the testfarm, the application may take some time to show up."""
27
25
    def setUp(self):
28
26
        super(TestPlayerWithVideo, self).setUp()
29
 
        print model()
30
 
        if model() == 'Nexus 4' or model() == 'Galaxy Nexus' or model() == "Nexus 7 (2013) Wi-Fi" or model() == "Nexus 10":
 
27
        print(model())
 
28
        if model() in (
 
29
                'Nexus 4', 'Galaxy Nexus', "Nexus 7 (2013) Wi-Fi", "Nexus 10"):
31
30
            self.launch_app("h264.avi")
32
31
        else:
33
32
            self.launch_app("small.ogg")
37
36
        player = self.main_window.get_player()
38
37
        self.assertThat(player.playing, Eventually(Equals(True)))
39
38
 
40
 
    def tearDown(self):
41
 
        super(TestPlayerWithVideo, self).tearDown()
42
 
 
43
39
    def show_controls(self):
44
40
        video_area = self.main_window.get_video_area()
45
41
        self.pointing_device.click_object(video_area)
56
52
        playback_button = self.main_window.get_playback_button()
57
53
        player = self.main_window.get_player()
58
54
 
59
 
        """ Default state after load the video is playing and with pause
60
 
        icon.
61
 
        """
 
55
        # Default state after load the video is playing and with pause icon.
62
56
        self.assertProperty(player, playing=True, paused=False)
63
57
        self.assertProperty(playback_button, icon="pause")
64
58
 
65
59
        self.pointing_device.click_object(playback_button)
66
60
 
67
 
        """ First click must pause the video, change playing state and show
68
 
        play icon. """
 
61
        # First click must pause the video, change playing state and show play
 
62
        # icon.
69
63
        self.assertProperty(player, playing=False, paused=True)
70
64
        self.assertProperty(playback_button, icon="play")
71
65
 
72
66
        self.pointing_device.click()
73
67
 
74
 
        """ Second click should change the state to playing again """
 
68
        # Second click should change the state to playing again
75
69
        self.assertProperty(player, playing=True, paused=False)
76
70
        self.assertProperty(playback_button, icon="pause")
77
71
 
78
 
    @skip("New backend work needed. bug 1231147")
79
 
    def test_scene_selector_visibility(self):
80
 
        self.show_controls()
81
 
        self.pause_video()
82
 
 
83
 
        scene_selector = self.main_window.get_scene_selector()
84
 
        slider = self.main_window.get_slider()
85
 
 
86
 
        """ Default state is hide """
87
 
        self.assertProperty(scene_selector, visible=False)
88
 
 
89
 
        """ Scene selector must apper when clicking int the slider handler """
90
 
        self.pointing_device.click_object(slider)
91
 
        self.assertProperty(scene_selector, visible=True)
92
 
 
93
 
        """ click again must dismiss the scene selector """
94
 
        self.pointing_device.click()
95
 
        self.assertProperty(scene_selector, visible=False)
96
 
 
97
 
    @skip("fails on touch and is not reliable on different screen resolutions. bug 1183245")
98
 
    def test_scene_selector_operation(self):
99
 
        self.show_controls()
100
 
        self.pause_video()
101
 
 
102
 
        slider = self.main_window.get_slider()
103
 
        time_line = self.main_window.get_timeline()
104
 
        selector = self.main_window.get_scene_selector()
105
 
        self.assertThat(selector.count, Eventually(GreaterThan(3)))
106
 
 
107
 
        """ Show scene selector """
108
 
        self.pointing_device.click_object(slider)
109
 
 
110
 
        """ Make sure that the scenes are in correct place """
111
 
        scene_0 = self.main_window.get_scene_0()
112
 
        selectorRect = selector.globalRect
113
 
        self.pointing_device.drag(
114
 
            selectorRect[0], selectorRect[1] + selectorRect[3] / 2,
115
 
            selectorRect[0] + selectorRect[2], selectorRect[1] + selectorRect[3] / 2)
116
 
        self.assertThat(selector.moving, Eventually(Equals(False)))
117
 
        self.assertThat(scene_0.x, Eventually(Equals(0)))
118
 
 
119
 
        """ Click in the second scene """
120
 
        scene_2 = self.main_window.get_scene_2()
121
 
        self.assertThat(scene_2.ready, Eventually(Equals(True)))
122
 
        self.pointing_device.click_object(scene_2)
123
 
        self.assertThat(selector.currentIndex, Eventually(Equals(2)))
124
 
        self.assertProperty(time_line, value=1.107)
125
 
 
126
 
    @skipIf(model() == 'Nexus 4' or model() == 'Galaxy Nexus', 'Screen width not enough for seekbar')
 
72
    @skipIf(model() in ('Nexus 4', 'Galaxy Nexus'),
 
73
            'Screen width not enough for seekbar')
127
74
    def test_time_display_behavior(self):
128
75
        self.show_controls()
129
76
        self.pause_video()
131
78
        time_line = self.main_window.get_slider()
132
79
        time_label = self.main_window.get_time_label()
133
80
 
134
 
        """ Seek to the midle of the movie """
 
81
        # Seek to the midle of the movie
135
82
        self.pointing_device.click_object(time_line)
136
83
 
137
 
        """ Time label must show the current video time (diff from zero or empty) """
 
84
        # Time label must show the current video time (diff from zero or empty)
138
85
        self.assertNotEqual(time_label.text, "00:00:00")
139
86
        self.assertNotEqual(time_label.text, "")
140
87
 
141
 
        """ Click in the label to change the state """
 
88
        # Click in the label to change the state
142
89
        self.pointing_device.click_object(time_label)
143
90
 
144
 
        """ After the click the label must show the remaning time (with '-' signal) """
 
91
        # After the click the label must show the remaning time (with '-'
 
92
        # signal)
145
93
        self.assertEqual(time_label.text[0:1], "-")
146
94
 
147
 
    @skipIf(model() == 'Nexus 4' or model() == 'Galaxy Nexus', 'Screen width not enough for seekbar')
 
95
    @skipIf(model() in ('Nexus 4', 'Galaxy Nexus'),
 
96
            'Screen width not enough for seekbar')
148
97
    def test_show_controls_at_end(self):
149
98
        controls = self.main_window.get_controls()
150
 
        """ The controls are invisible by default """
 
99
        # The controls are invisible by default
151
100
        self.assertThat(controls.visible, Eventually(Equals(False)))
152
101
 
153
 
        """ wait for video ends and control appears """
 
102
        # wait for video ends and control appears
154
103
        self.assertThat(controls.visible, Eventually(Equals(True), timeout=35))