From 15839147c2e2320520286501310951cab16cabdd Mon Sep 17 00:00:00 2001 From: Muhammad Ammar Date: Fri, 20 Jun 2014 13:47:20 +0000 Subject: [PATCH] Youtube Video Quality Button Tests --- .../test/acceptance/pages/lms/video/video.py | 33 ++++++++++++- common/test/acceptance/tests/helpers.py | 23 +++++++++ .../tests/video/test_video_module.py | 48 +++++++++++++++++++ .../courseware/features/video.feature | 17 ------- 4 files changed, 103 insertions(+), 18 deletions(-) diff --git a/common/test/acceptance/pages/lms/video/video.py b/common/test/acceptance/pages/lms/video/video.py index c3e1b0f460..464e74bff0 100644 --- a/common/test/acceptance/pages/lms/video/video.py +++ b/common/test/acceptance/pages/lms/video/video.py @@ -17,7 +17,8 @@ VIDEO_BUTTONS = { 'pause': '.video_control.pause', 'fullscreen': '.add-fullscreen', 'download_transcript': '.video-tracks > a', - 'speed': '.speeds' + 'speed': '.speeds', + 'quality': '.quality-control', } CSS_CLASS_NAMES = { @@ -852,3 +853,33 @@ class VideoPage(PageObject): lambda: self.position(video_display_name) == position, 'Position is {position}'.format(position=position) ) + + def is_quality_button_visible(self, video_display_name=None): + """ + Get the visibility state of quality button + + Arguments: + video_display_name (str or None): Display name of a Video. + + Returns: + bool: visibility status + + """ + selector = self.get_element_selector(video_display_name, VIDEO_BUTTONS['quality']) + return self.q(css=selector).visible + + def is_quality_button_active(self, video_display_name=None): + """ + Check if quality button is active or not. + + Arguments: + video_display_name (str or None): Display name of a Video. + + Returns: + bool: active status + + """ + selector = self.get_element_selector(video_display_name, VIDEO_BUTTONS['quality']) + + classes = self.q(css=selector).attrs('class')[0].split() + return 'active' in classes diff --git a/common/test/acceptance/tests/helpers.py b/common/test/acceptance/tests/helpers.py index b2b416b909..29458ceda6 100644 --- a/common/test/acceptance/tests/helpers.py +++ b/common/test/acceptance/tests/helpers.py @@ -1,11 +1,34 @@ """ Test helper functions and base classes. """ +import unittest +import functools import requests from path import path from bok_choy.web_app_test import WebAppTest +def skip_if_browser(browser): + """ + Method decorator that skips a test if browser is `browser` + + Args: + browser (str): name of internet browser + + Returns: + Decorated function + + """ + def decorator(test_function): + @functools.wraps(test_function) + def wrapper(self, *args, **kwargs): + if self.browser.name == browser: + raise unittest.SkipTest('Skipping as this test will not work with {}'.format(browser)) + test_function(self, *args, **kwargs) + return wrapper + return decorator + + def is_youtube_available(): """ Check if the required youtube urls are available. diff --git a/common/test/acceptance/tests/video/test_video_module.py b/common/test/acceptance/tests/video/test_video_module.py index f2d61e831d..2500b57769 100644 --- a/common/test/acceptance/tests/video/test_video_module.py +++ b/common/test/acceptance/tests/video/test_video_module.py @@ -15,6 +15,8 @@ from ...pages.lms.course_nav import CourseNavPage from ...pages.lms.auto_auth import AutoAuthPage from ...pages.lms.course_info import CourseInfoPage from ...fixtures.course import CourseFixture, XBlockFixtureDesc +from ..helpers import skip_if_browser + VIDEO_SOURCE_PORT = 8777 @@ -917,3 +919,49 @@ class Html5VideoTest(VideoBaseTest): self.assertTrue(self.video.is_video_rendered('html5')) self.assertTrue(all([source in HTML5_SOURCES for source in self.video.sources()])) + + +class YouTubeQualityTest(VideoBaseTest): + """ Test YouTube Video Quality Button """ + + def setUp(self): + super(YouTubeQualityTest, self).setUp() + + @skip_if_browser('firefox') + def test_quality_button_visibility(self): + """ + Scenario: Quality button appears on play. + + Given the course has a Video component in "Youtube" mode + Then I see video button "quality" is hidden + And I click video button "play" + Then I see video button "quality" is visible + """ + self.navigate_to_video() + + self.assertFalse(self.video.is_quality_button_visible()) + + self.video.click_player_button('play') + + self.assertTrue(self.video.is_quality_button_visible()) + + @skip_if_browser('firefox') + def test_quality_button_works_correctly(self): + """ + Scenario: Quality button works correctly. + + Given the course has a Video component in "Youtube" mode + And I click video button "play" + And I see video button "quality" is inactive + And I click video button "quality" + Then I see video button "quality" is active + """ + self.navigate_to_video() + + self.video.click_player_button('play') + + self.assertFalse(self.video.is_quality_button_active()) + + self.video.click_player_button('quality') + + self.assertTrue(self.video.is_quality_button_active()) diff --git a/lms/djangoapps/courseware/features/video.feature b/lms/djangoapps/courseware/features/video.feature index 7bb6b98c50..21883c5057 100644 --- a/lms/djangoapps/courseware/features/video.feature +++ b/lms/djangoapps/courseware/features/video.feature @@ -30,20 +30,3 @@ Feature: LMS.Video component When I open video "D" Then the video has rendered in "HTML5" mode And the video does not show the captions - - # 4 - @skip_firefox - Scenario: Quality button appears on play - Given the course has a Video component in "Youtube" mode - Then I see video button "quality" is hidden - And I click video button "play" - Then I see video button "quality" is visible - - # 5 - @skip_firefox - Scenario: Quality button works correctly - Given the course has a Video component in "Youtube" mode - And I click video button "play" - And I see video button "quality" is inactive - And I click video button "quality" - Then I see video button "quality" is active