diff options
author | fukino <fukino@chromium.org> | 2015-11-12 04:45:02 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-12 12:46:09 +0000 |
commit | e48ba349d22dfa01b379b3ef55869070bce25083 (patch) | |
tree | 046b21e6636f579e7d79f8ed5d478bbd9e088b40 | |
parent | c3f683678512035cceb2426a590991d28ccf4d9e (diff) | |
download | chromium_src-e48ba349d22dfa01b379b3ef55869070bce25083.zip chromium_src-e48ba349d22dfa01b379b3ef55869070bce25083.tar.gz chromium_src-e48ba349d22dfa01b379b3ef55869070bce25083.tar.bz2 |
Video Player: Add a UI test to click control buttons.
BUG=none
TEST=run browser_tests --gtest_filter=VideoPlayerBrowserTest.ClickControlButtons
Review URL: https://codereview.chromium.org/1433333002
Cr-Commit-Position: refs/heads/master@{#359307}
4 files changed, 115 insertions, 8 deletions
diff --git a/chrome/browser/chromeos/file_manager/video_player_browsertest.cc b/chrome/browser/chromeos/file_manager/video_player_browsertest.cc index 34b0c1d..e7ffefe 100644 --- a/chrome/browser/chromeos/file_manager/video_player_browsertest.cc +++ b/chrome/browser/chromeos/file_manager/video_player_browsertest.cc @@ -76,4 +76,15 @@ IN_PROC_BROWSER_TEST_F(VideoPlayerBrowserTest, MAYBE_CheckInitialElements) { StartTest(); } +// http://crbug.com/508949 +#if defined(MEMORY_SANITIZER) +#define MAYBE_ClickControlButtons DISABLED_ClickControlButtons +#else +#define MAYBE_ClickControlButtons ClickControlButtons +#endif +IN_PROC_BROWSER_TEST_F(VideoPlayerBrowserTest, MAYBE_ClickControlButtons) { + set_test_case_name("clickControlButtons"); + StartTest(); +} + } // namespace file_manager diff --git a/ui/file_manager/integration_tests/video_player/click_control_buttons.js b/ui/file_manager/integration_tests/video_player/click_control_buttons.js new file mode 100644 index 0000000..44d5e07 --- /dev/null +++ b/ui/file_manager/integration_tests/video_player/click_control_buttons.js @@ -0,0 +1,73 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +'use strict'; + +/** + * Waits that calling callRemoteTestUtil for |funcName| function with |filename| + * returns |expectedResult|. + * @param {string} funcName Function name for callRemoteTestUtil. + * @param {string} filename File name to pass to callRemoteTestUtil. + * @param {*} expectedResult Expected result for the remote call. + * @return {Promise} Promise which will be fullfiled when the expected result is + * given. + */ +function waitForFunctionResult(funcName, filename, expectedResult) { + return repeatUntil(function() { + return remoteCallVideoPlayer.callRemoteTestUtil(funcName, null, [filename]) + .then(function(result) { + if (result === expectedResult) + return true; + return pending('Waiting for %s return %s.', funcName, expectedResult); + }); + }); +} + +/** + * The openSingleImage test for Downloads. + * @return {Promise} Promise to be fulfilled with on success. + */ +testcase.clickControlButtons = function() { + var openVideo = openSingleVideo('local', 'downloads', ENTRIES.world); + var appId; + return openVideo.then(function(args) { + appId = args[0]; + // Video player starts playing given file automatically. + return waitForFunctionResult('isPlaying', 'world.ogv', true); + }).then(function() { + // Play will finish in 2 seconds (world.ogv is 2-second short movie.) + return waitForFunctionResult('isPlaying', 'world.ogv', false); + }).then(function() { + // Conform that clicking play button will re-play the video. + return remoteCallVideoPlayer.callRemoteTestUtil( + 'fakeMouseClick', appId, ['.media-button.play']); }).then(function() { + return waitForFunctionResult('isPlaying', 'world.ogv', true); + }).then(function() { + // Confirm that clicking volume button mutes the video. + return remoteCallVideoPlayer.callRemoteTestUtil( + 'fakeMouseClick', appId, ['.media-button.sound']); + }).then(function() { + return waitForFunctionResult('isMuted', 'world.ogv', true); + }).then(function() { + // Confirm that clicking volume button again unmutes the video. + return remoteCallVideoPlayer.callRemoteTestUtil( + 'fakeMouseClick', appId, ['.media-button.sound']); + }).then(function() { + return waitForFunctionResult('isMuted', 'world.ogv', false); + }).then(function() { + // Confirm that clicking fullscreen button enables fullscreen mode. + return remoteCallVideoPlayer.callRemoteTestUtil( + 'fakeMouseClick', appId, ['.media-button.fullscreen']); + }).then(function() { + return remoteCallVideoPlayer.waitForElement(appId, + '#controls[fullscreen]'); + }).then(function() { + // Confirm that clicking fullscreen-exit button disables fullscreen mode. + return remoteCallVideoPlayer.callRemoteTestUtil( + 'fakeMouseClick', appId, ['.media-button.fullscreen']); + }).then(function() { + return remoteCallVideoPlayer.waitForElement(appId, + '#controls:not([fullscreen])'); + }); +}; diff --git a/ui/file_manager/integration_tests/video_player_test_manifest.json b/ui/file_manager/integration_tests/video_player_test_manifest.json index 5a85ce1..cd2623c 100644 --- a/ui/file_manager/integration_tests/video_player_test_manifest.json +++ b/ui/file_manager/integration_tests/video_player_test_manifest.json @@ -11,7 +11,8 @@ "remote_call.js", "video_player/background.js", "video_player/open_video_files.js", - "video_player/check_elements.js" + "video_player/check_elements.js", + "video_player/click_control_buttons.js" ]}, "incognito" : "split", "permissions": ["commandLinePrivate"] diff --git a/ui/file_manager/video_player/js/test_util.js b/ui/file_manager/video_player/js/test_util.js index 787d74f..2415cd6 100644 --- a/ui/file_manager/video_player/js/test_util.js +++ b/ui/file_manager/video_player/js/test_util.js @@ -3,23 +3,45 @@ // found in the LICENSE file. /** - * Returns if the specified file is being played. - * - * @param {string} filename Name of audio file to be checked. This must be same - * as entry.name() of the audio file. - * @return {boolean} True if the video is playing, false otherwise. + * Returns if a video element playing the specified file meet the condition + * which is given by a parameter. + * @param {string} filename Name of video file to be checked. This must be same + * as entry.name() of the video file. + * @param {function(!HTMLElement):boolean} testFunction */ -test.util.sync.isPlaying = function(filename) { +function testElement(filename, testFunction) { for (var appId in window.background.appWindows) { var contentWindow = window.background.appWindows[appId].contentWindow; if (contentWindow && contentWindow.document.title === filename) { var element = contentWindow.document.querySelector('video[src]'); - if (element && !element.paused) + if (element && testFunction(element)) return true; } } return false; +} + +/** + * Returns if the specified file is being played. + * + * @param {string} filename Name of video file to be checked. This must be same + * as entry.name() of the video file. + * @return {boolean} True if the video is playing, false otherwise. + */ +test.util.sync.isPlaying = function(filename) { + return testElement(filename, element => !element.paused); +}; + +/** + * Returns if the specified file is being played. + * + * @param {string} filename Name of video file to be checked. This must be same + * as entry.name() of the video file. + * @return {boolean} True if the video is playing, false otherwise. + */ +test.util.sync.isMuted = function(filename) { + return testElement(filename, element => element.volume === 0); }; /** |