This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
test_browser_play_youtube_video.py
63 lines (49 loc) · 2.27 KB
/
test_browser_play_youtube_video.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from marionette.by import By
from gaiatest import GaiaTestCase
from gaiatest.apps.search.app import Search
from gaiatest.apps.browser.regions.html5_player import HTML5Player
class TestYouTube(GaiaTestCase):
video_URL = 'http://m.youtube.com/watch?v=5MzuGWFIfio'
acceptable_delay = 2.0
# YouTube video locators
_video_container_locator = (By.CSS_SELECTOR, 'div[style^="background-image"]')
_video_element_locator = (By.TAG_NAME, 'video')
def setUp(self):
GaiaTestCase.setUp(self)
self.connect_to_network()
self.apps.set_permission('Browser', 'geolocation', 'deny')
def test_play_youtube_video(self):
"""Confirm YouTube video playback
https://moztrap.mozilla.org/manage/case/6073/
"""
search = Search(self.marionette)
search.launch()
browser = search.go_to_url(self.video_URL)
browser.wait_for_page_to_load(180)
browser.switch_to_content()
# Tap the video container to load the <video> element and start playing
self.wait_for_element_displayed(*self._video_container_locator)
self.marionette.find_element(*self._video_container_locator).tap()
# Wait HTML5 player to appear
self.wait_for_element_displayed(*self._video_element_locator)
video = self.marionette.find_element(*self._video_element_locator)
player = HTML5Player(self.marionette, video)
# Check that video is playing
player.wait_for_video_loaded()
self.assertTrue(player.is_video_playing())
# Pause playback
player.pause()
stopped_at = player.current_timestamp
self.assertFalse(player.is_video_playing())
# Resume playback
player.play()
resumed_at = player.current_timestamp
self.assertTrue(player.is_video_playing())
# Ensure that video resumes to play
# from the place where it was paused
delay = resumed_at - stopped_at
self.assertLessEqual(delay, self.acceptable_delay,
'video resumed to play not from place where it was paused')