Commit 0fe9ca37 authored by Clifford Cheng's avatar Clifford Cheng Committed by Commit Bot

Add pixel-by-pixel comparison tests for play/pause controls in PiP. Modify the...

Add pixel-by-pixel comparison tests for play/pause controls in PiP. Modify the pixel comparison function to use an actual (expected) image instead of just RGB values.

Change-Id: I1604df59d390a460fe5a0200cbae273bdd60e023
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1574451
Auto-Submit: Clifford Cheng <cliffordcheng@chromium.org>
Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Reviewed-by: default avatarBecca Hughes <beccahughes@chromium.org>
Commit-Queue: Clifford Cheng <cliffordcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#663880}
parent 3ceab7f7
...@@ -93,6 +93,9 @@ class MockPictureInPictureWindowController ...@@ -93,6 +93,9 @@ class MockPictureInPictureWindowController
DISALLOW_COPY_AND_ASSIGN(MockPictureInPictureWindowController); DISALLOW_COPY_AND_ASSIGN(MockPictureInPictureWindowController);
}; };
const base::FilePath::CharType kPictureInPictureWindowSizePage[] =
FILE_PATH_LITERAL("media/picture-in-picture/window-size.html");
} // namespace } // namespace
class PictureInPictureWindowControllerBrowserTest class PictureInPictureWindowControllerBrowserTest
...@@ -120,11 +123,10 @@ class PictureInPictureWindowControllerBrowserTest ...@@ -120,11 +123,10 @@ class PictureInPictureWindowControllerBrowserTest
return mock_controller_; return mock_controller_;
} }
void LoadTabAndEnterPictureInPicture(Browser* browser) { void LoadTabAndEnterPictureInPicture(Browser* browser,
const base::FilePath& file_path) {
GURL test_page_url = ui_test_utils::GetTestUrl( GURL test_page_url = ui_test_utils::GetTestUrl(
base::FilePath(base::FilePath::kCurrentDirectory), base::FilePath(base::FilePath::kCurrentDirectory), file_path);
base::FilePath(
FILE_PATH_LITERAL("media/picture-in-picture/window-size.html")));
ui_test_utils::NavigateToURL(browser, test_page_url); ui_test_utils::NavigateToURL(browser, test_page_url);
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
...@@ -203,8 +205,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -203,8 +205,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
CreationAndVisibilityAndActivation) { CreationAndVisibilityAndActivation) {
GURL test_page_url = ui_test_utils::GetTestUrl( GURL test_page_url = ui_test_utils::GetTestUrl(
base::FilePath(base::FilePath::kCurrentDirectory), base::FilePath(base::FilePath::kCurrentDirectory),
base::FilePath( base::FilePath(kPictureInPictureWindowSizePage));
FILE_PATH_LITERAL("media/picture-in-picture/window-size.html")));
ui_test_utils::NavigateToURL(browser(), test_page_url); ui_test_utils::NavigateToURL(browser(), test_page_url);
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
...@@ -267,12 +268,12 @@ class PictureInPicturePixelComparisonBrowserTest ...@@ -267,12 +268,12 @@ class PictureInPicturePixelComparisonBrowserTest
quit_run_loop.Run(); quit_run_loop.Run();
} }
bool SaveBitmap(base::FilePath& file_path, SkBitmap& bitmap) { bool ReadImageFile(const base::FilePath& file_path, SkBitmap* read_image) {
std::vector<unsigned char> png_data; std::string png_string;
CHECK(gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false, &png_data)); base::ReadFileToString(file_path, &png_string);
char* data = reinterpret_cast<char*>(&png_data[0]); return gfx::PNGCodec::Decode(
int size = static_cast<int>(png_data.size()); reinterpret_cast<const unsigned char*>(png_string.data()),
return base::WriteFile(file_path, data, size) == size; png_string.length(), read_image);
} }
void TakeOverlayWindowScreenshot(OverlayWindowViews* overlay_window_views) { void TakeOverlayWindowScreenshot(OverlayWindowViews* overlay_window_views) {
...@@ -288,12 +289,10 @@ class PictureInPicturePixelComparisonBrowserTest ...@@ -288,12 +289,10 @@ class PictureInPicturePixelComparisonBrowserTest
run_loop.Run(); run_loop.Run();
} }
bool CompareImages(const SkBitmap& actual_bmp) { bool CompareImages(const SkBitmap& actual_bmp, const SkBitmap& expected_bmp) {
// Allowable error and thresholds because of small color shift by // Allowable error and thresholds because of small color shift by
// video to image conversion and GPU issues. // video to image conversion and GPU issues.
const int allowable_error = 2; const int kAllowableError = 3;
const unsigned high_threshold = 0xff - allowable_error;
const unsigned low_threshold = 0x00 + allowable_error;
// Number of pixels with an error // Number of pixels with an error
int error_pixels_count = 0; int error_pixels_count = 0;
gfx::Rect error_bounding_rect; gfx::Rect error_bounding_rect;
...@@ -301,12 +300,13 @@ class PictureInPicturePixelComparisonBrowserTest ...@@ -301,12 +300,13 @@ class PictureInPicturePixelComparisonBrowserTest
for (int x = 0; x < actual_bmp.width(); ++x) { for (int x = 0; x < actual_bmp.width(); ++x) {
for (int y = 0; y < actual_bmp.height(); ++y) { for (int y = 0; y < actual_bmp.height(); ++y) {
SkColor actual_color = actual_bmp.getColor(x, y); SkColor actual_color = actual_bmp.getColor(x, y);
// Check color is Yellow and is within the tolerance range. SkColor expected_color = expected_bmp.getColor(x, y);
// TODO(cliffordcheng): Compare with an expected image instead of just if ((fabs(SkColorGetR(actual_color) - SkColorGetR(expected_color)) >
// checking pixel RGB color. kAllowableError) ||
if (SkColorGetR(actual_color) < high_threshold && (fabs(SkColorGetG(actual_color) - SkColorGetG(expected_color)) >
SkColorGetG(actual_color) < high_threshold && kAllowableError) ||
SkColorGetB(actual_color) > low_threshold) { (fabs(SkColorGetB(actual_color) - SkColorGetB(expected_color))) >
kAllowableError) {
++error_pixels_count; ++error_pixels_count;
error_bounding_rect.Union(gfx::Rect(x, y, 1, 1)); error_bounding_rect.Union(gfx::Rect(x, y, 1, 1));
} }
...@@ -338,50 +338,105 @@ class PictureInPicturePixelComparisonBrowserTest ...@@ -338,50 +338,105 @@ class PictureInPicturePixelComparisonBrowserTest
// Picture-in-Picture window and verifies it's as expected. // Picture-in-Picture window and verifies it's as expected.
IN_PROC_BROWSER_TEST_F(PictureInPicturePixelComparisonBrowserTest, VideoPlay) { IN_PROC_BROWSER_TEST_F(PictureInPicturePixelComparisonBrowserTest, VideoPlay) {
base::ScopedAllowBlockingForTesting allow_blocking; base::ScopedAllowBlockingForTesting allow_blocking;
GURL test_page_url = ui_test_utils::GetTestUrl( LoadTabAndEnterPictureInPicture(
base::FilePath(base::FilePath::kCurrentDirectory), browser(), base::FilePath(FILE_PATH_LITERAL(
base::FilePath( "media/picture-in-picture/pixel_test.html")));
FILE_PATH_LITERAL("media/picture-in-picture/pixel_test.html")));
ui_test_utils::NavigateToURL(browser(), test_page_url);
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
browser()->tab_strip_model()->GetActiveWebContents(); browser()->tab_strip_model()->GetActiveWebContents();
ASSERT_NE(nullptr, active_web_contents);
bool in_picture_in_picture = false;
ASSERT_TRUE(ExecuteScriptAndExtractBool(
active_web_contents, "isInPictureInPicture();", &in_picture_in_picture));
EXPECT_TRUE(in_picture_in_picture);
EXPECT_TRUE(content::ExecuteScript(active_web_contents, "video.play();")); EXPECT_TRUE(content::ExecuteScript(active_web_contents, "video.play();"));
SetUpWindowController(active_web_contents); SetUpWindowController(active_web_contents);
ASSERT_NE(nullptr, window_controller()); ASSERT_NE(nullptr, window_controller());
EXPECT_TRUE(window_controller()->GetWindowForTesting()->IsVisible());
ASSERT_NE(nullptr, window_controller()->GetWindowForTesting()); OverlayWindowViews* overlay_window_views = static_cast<OverlayWindowViews*>(
ASSERT_FALSE(window_controller()->GetWindowForTesting()->IsVisible()); window_controller()->GetWindowForTesting());
overlay_window_views->SetSize(gfx::Size(402, 268));
base::string16 expected_title = base::ASCIIToUTF16("resized");
EXPECT_EQ(expected_title,
content::TitleWatcher(active_web_contents, expected_title)
.WaitAndGetTitle());
Wait(base::TimeDelta::FromSeconds(3));
TakeOverlayWindowScreenshot(overlay_window_views);
bool result = false; SkBitmap expected_image;
ASSERT_TRUE(content::ExecuteScriptAndExtractBool( base::FilePath expected_image_path =
active_web_contents, "enterPictureInPicture();", &result)); GetFilePath(FILE_PATH_LITERAL("pixel_expected_video_play.png"));
EXPECT_TRUE(result); ASSERT_TRUE(ReadImageFile(expected_image_path, &expected_image));
EXPECT_TRUE(CompareImages(GetResultBitmap(), expected_image));
}
// Plays a video in PiP. Trigger the play and pause control in PiP by using a
// mouse move. Capture the images and verift they are expected.
IN_PROC_BROWSER_TEST_F(PictureInPicturePixelComparisonBrowserTest,
PlayAndPauseControls) {
base::ScopedAllowBlockingForTesting allow_blocking;
LoadTabAndEnterPictureInPicture(
browser(), base::FilePath(FILE_PATH_LITERAL(
"media/picture-in-picture/pixel_test.html")));
content::WebContents* active_web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
bool in_picture_in_picture = false; bool in_picture_in_picture = false;
ASSERT_TRUE(ExecuteScriptAndExtractBool( ASSERT_TRUE(ExecuteScriptAndExtractBool(
active_web_contents, "isInPictureInPicture();", &in_picture_in_picture)); active_web_contents, "isInPictureInPicture();", &in_picture_in_picture));
EXPECT_TRUE(in_picture_in_picture); EXPECT_TRUE(in_picture_in_picture);
EXPECT_TRUE(window_controller()->GetWindowForTesting()->IsVisible()); EXPECT_TRUE(window_controller()->GetWindowForTesting()->IsVisible());
OverlayWindowViews* overlay_window_views = static_cast<OverlayWindowViews*>( OverlayWindowViews* overlay_window_views = static_cast<OverlayWindowViews*>(
window_controller()->GetWindowForTesting()); window_controller()->GetWindowForTesting());
overlay_window_views->SetSize(gfx::Size(600, 400));
bool result = false;
ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
active_web_contents, "changeVideoSrc();", &result));
const int resize_width = 402, resize_height = 268;
overlay_window_views->SetSize(gfx::Size(resize_width, resize_height));
base::string16 expected_title = base::ASCIIToUTF16("resized"); base::string16 expected_title = base::ASCIIToUTF16("resized");
EXPECT_EQ(expected_title, EXPECT_EQ(expected_title,
content::TitleWatcher(active_web_contents, expected_title) content::TitleWatcher(active_web_contents, expected_title)
.WaitAndGetTitle()); .WaitAndGetTitle());
EXPECT_TRUE(content::ExecuteScript(active_web_contents, "video.play();"));
Wait(base::TimeDelta::FromSeconds(3)); Wait(base::TimeDelta::FromSeconds(3));
MoveMouseOver(overlay_window_views);
TakeOverlayWindowScreenshot(overlay_window_views); TakeOverlayWindowScreenshot(overlay_window_views);
const base::FilePath::StringPieceType test_image = base::FilePath expected_pause_image_path =
FILE_PATH_LITERAL("pixel_test_actual_0.png"); GetFilePath(FILE_PATH_LITERAL("pixel_expected_pause_control.png"));
base::FilePath test_image_path = GetFilePath(test_image); base::FilePath expected_play_image_path =
ASSERT_TRUE(SaveBitmap(test_image_path, GetResultBitmap())); GetFilePath(FILE_PATH_LITERAL("pixel_expected_play_control.png"));
EXPECT_TRUE(CompareImages(GetResultBitmap())); // If the test image is cropped, usually off by 1 pixel, use another image.
if (GetResultBitmap().width() < resize_width ||
GetResultBitmap().height() < resize_height) {
LOG(INFO) << "Actual image is cropped and backup images are used. "
<< "Test image dimension: "
<< "(" << GetResultBitmap().width() << "x"
<< GetResultBitmap().height() << "). "
<< "Expected image dimension: "
<< "(" << resize_width << "x" << resize_height << ")";
expected_pause_image_path =
GetFilePath(FILE_PATH_LITERAL("pixel_expected_pause_control_crop.png"));
expected_play_image_path =
GetFilePath(FILE_PATH_LITERAL("pixel_expected_play_control_crop.png"));
}
SkBitmap expected_image;
ASSERT_TRUE(ReadImageFile(expected_pause_image_path, &expected_image));
EXPECT_TRUE(CompareImages(GetResultBitmap(), expected_image));
EXPECT_TRUE(content::ExecuteScript(active_web_contents, "video.pause();"));
Wait(base::TimeDelta::FromSeconds(3));
MoveMouseOver(overlay_window_views);
TakeOverlayWindowScreenshot(overlay_window_views);
ASSERT_TRUE(ReadImageFile(expected_play_image_path, &expected_image));
EXPECT_TRUE(CompareImages(GetResultBitmap(), expected_image));
} }
#endif // !defined(OS_CHROMEOS) #endif // !defined(OS_CHROMEOS)
...@@ -391,8 +446,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -391,8 +446,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
TabIconUpdated) { TabIconUpdated) {
GURL test_page_url = ui_test_utils::GetTestUrl( GURL test_page_url = ui_test_utils::GetTestUrl(
base::FilePath(base::FilePath::kCurrentDirectory), base::FilePath(base::FilePath::kCurrentDirectory),
base::FilePath( base::FilePath(kPictureInPictureWindowSizePage));
FILE_PATH_LITERAL("media/picture-in-picture/window-size.html")));
ui_test_utils::NavigateToURL(browser(), test_page_url); ui_test_utils::NavigateToURL(browser(), test_page_url);
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
...@@ -428,8 +482,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -428,8 +482,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
ResizeEventFired) { ResizeEventFired) {
GURL test_page_url = ui_test_utils::GetTestUrl( GURL test_page_url = ui_test_utils::GetTestUrl(
base::FilePath(base::FilePath::kCurrentDirectory), base::FilePath(base::FilePath::kCurrentDirectory),
base::FilePath( base::FilePath(kPictureInPictureWindowSizePage));
FILE_PATH_LITERAL("media/picture-in-picture/window-size.html")));
ui_test_utils::NavigateToURL(browser(), test_page_url); ui_test_utils::NavigateToURL(browser(), test_page_url);
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
...@@ -464,8 +517,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -464,8 +517,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
CloseWindowWhilePlaying) { CloseWindowWhilePlaying) {
GURL test_page_url = ui_test_utils::GetTestUrl( GURL test_page_url = ui_test_utils::GetTestUrl(
base::FilePath(base::FilePath::kCurrentDirectory), base::FilePath(base::FilePath::kCurrentDirectory),
base::FilePath( base::FilePath(kPictureInPictureWindowSizePage));
FILE_PATH_LITERAL("media/picture-in-picture/window-size.html")));
ui_test_utils::NavigateToURL(browser(), test_page_url); ui_test_utils::NavigateToURL(browser(), test_page_url);
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
...@@ -505,8 +557,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -505,8 +557,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
CloseWindowWithoutPlaying) { CloseWindowWithoutPlaying) {
GURL test_page_url = ui_test_utils::GetTestUrl( GURL test_page_url = ui_test_utils::GetTestUrl(
base::FilePath(base::FilePath::kCurrentDirectory), base::FilePath(base::FilePath::kCurrentDirectory),
base::FilePath( base::FilePath(kPictureInPictureWindowSizePage));
FILE_PATH_LITERAL("media/picture-in-picture/window-size.html")));
ui_test_utils::NavigateToURL(browser(), test_page_url); ui_test_utils::NavigateToURL(browser(), test_page_url);
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
...@@ -540,8 +591,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -540,8 +591,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
CloseWindowCantEnterPictureInPictureAgain) { CloseWindowCantEnterPictureInPictureAgain) {
GURL test_page_url = ui_test_utils::GetTestUrl( GURL test_page_url = ui_test_utils::GetTestUrl(
base::FilePath(base::FilePath::kCurrentDirectory), base::FilePath(base::FilePath::kCurrentDirectory),
base::FilePath( base::FilePath(kPictureInPictureWindowSizePage));
FILE_PATH_LITERAL("media/picture-in-picture/window-size.html")));
ui_test_utils::NavigateToURL(browser(), test_page_url); ui_test_utils::NavigateToURL(browser(), test_page_url);
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
...@@ -579,8 +629,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -579,8 +629,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
CloseWindowFromWebAPIWhilePlaying) { CloseWindowFromWebAPIWhilePlaying) {
GURL test_page_url = ui_test_utils::GetTestUrl( GURL test_page_url = ui_test_utils::GetTestUrl(
base::FilePath(base::FilePath::kCurrentDirectory), base::FilePath(base::FilePath::kCurrentDirectory),
base::FilePath( base::FilePath(kPictureInPictureWindowSizePage));
FILE_PATH_LITERAL("media/picture-in-picture/window-size.html")));
ui_test_utils::NavigateToURL(browser(), test_page_url); ui_test_utils::NavigateToURL(browser(), test_page_url);
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
...@@ -618,8 +667,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -618,8 +667,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
RequestPictureInPictureTwiceFromSameVideo) { RequestPictureInPictureTwiceFromSameVideo) {
GURL test_page_url = ui_test_utils::GetTestUrl( GURL test_page_url = ui_test_utils::GetTestUrl(
base::FilePath(base::FilePath::kCurrentDirectory), base::FilePath(base::FilePath::kCurrentDirectory),
base::FilePath( base::FilePath(kPictureInPictureWindowSizePage));
FILE_PATH_LITERAL("media/picture-in-picture/window-size.html")));
ui_test_utils::NavigateToURL(browser(), test_page_url); ui_test_utils::NavigateToURL(browser(), test_page_url);
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
...@@ -676,8 +724,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -676,8 +724,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
OpenSecondPictureInPictureStopsFirst) { OpenSecondPictureInPictureStopsFirst) {
GURL test_page_url = ui_test_utils::GetTestUrl( GURL test_page_url = ui_test_utils::GetTestUrl(
base::FilePath(base::FilePath::kCurrentDirectory), base::FilePath(base::FilePath::kCurrentDirectory),
base::FilePath( base::FilePath(kPictureInPictureWindowSizePage));
FILE_PATH_LITERAL("media/picture-in-picture/window-size.html")));
ui_test_utils::NavigateToURL(browser(), test_page_url); ui_test_utils::NavigateToURL(browser(), test_page_url);
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
...@@ -722,7 +769,8 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -722,7 +769,8 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
// keep Picture-in-Picture window opened. // keep Picture-in-Picture window opened.
IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
ResetVideoSrcKeepsPictureInPictureWindowOpened) { ResetVideoSrcKeepsPictureInPictureWindowOpened) {
LoadTabAndEnterPictureInPicture(browser()); LoadTabAndEnterPictureInPicture(
browser(), base::FilePath(kPictureInPictureWindowSizePage));
EXPECT_TRUE(window_controller()->GetWindowForTesting()->IsVisible()); EXPECT_TRUE(window_controller()->GetWindowForTesting()->IsVisible());
...@@ -748,7 +796,8 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -748,7 +796,8 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
// keep Picture-in-Picture window opened. // keep Picture-in-Picture window opened.
IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
UpdateVideoSrcKeepsPictureInPictureWindowOpened) { UpdateVideoSrcKeepsPictureInPictureWindowOpened) {
LoadTabAndEnterPictureInPicture(browser()); LoadTabAndEnterPictureInPicture(
browser(), base::FilePath(kPictureInPictureWindowSizePage));
EXPECT_TRUE(window_controller()->GetWindowForTesting()->IsVisible()); EXPECT_TRUE(window_controller()->GetWindowForTesting()->IsVisible());
...@@ -787,7 +836,8 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -787,7 +836,8 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
IN_PROC_BROWSER_TEST_F( IN_PROC_BROWSER_TEST_F(
PictureInPictureWindowControllerBrowserTest, PictureInPictureWindowControllerBrowserTest,
ChangeVideoSrcToMediaStreamKeepsPictureInPictureWindowOpened) { ChangeVideoSrcToMediaStreamKeepsPictureInPictureWindowOpened) {
LoadTabAndEnterPictureInPicture(browser()); LoadTabAndEnterPictureInPicture(
browser(), base::FilePath(kPictureInPictureWindowSizePage));
EXPECT_TRUE(window_controller()->GetWindowForTesting()->IsVisible()); EXPECT_TRUE(window_controller()->GetWindowForTesting()->IsVisible());
...@@ -850,8 +900,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -850,8 +900,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
CloseTwiceSideEffects) { CloseTwiceSideEffects) {
GURL test_page_url = ui_test_utils::GetTestUrl( GURL test_page_url = ui_test_utils::GetTestUrl(
base::FilePath(base::FilePath::kCurrentDirectory), base::FilePath(base::FilePath::kCurrentDirectory),
base::FilePath( base::FilePath(kPictureInPictureWindowSizePage));
FILE_PATH_LITERAL("media/picture-in-picture/window-size.html")));
ui_test_utils::NavigateToURL(browser(), test_page_url); ui_test_utils::NavigateToURL(browser(), test_page_url);
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
...@@ -901,8 +950,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -901,8 +950,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
PictureInPictureAfterClosingTab) { PictureInPictureAfterClosingTab) {
GURL test_page_url = ui_test_utils::GetTestUrl( GURL test_page_url = ui_test_utils::GetTestUrl(
base::FilePath(base::FilePath::kCurrentDirectory), base::FilePath(base::FilePath::kCurrentDirectory),
base::FilePath( base::FilePath(kPictureInPictureWindowSizePage));
FILE_PATH_LITERAL("media/picture-in-picture/window-size.html")));
ui_test_utils::NavigateToURL(browser(), test_page_url); ui_test_utils::NavigateToURL(browser(), test_page_url);
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
...@@ -953,8 +1001,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -953,8 +1001,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
PictureInPictureDoNotCloseAfterClosingTab) { PictureInPictureDoNotCloseAfterClosingTab) {
GURL test_page_url = ui_test_utils::GetTestUrl( GURL test_page_url = ui_test_utils::GetTestUrl(
base::FilePath(base::FilePath::kCurrentDirectory), base::FilePath(base::FilePath::kCurrentDirectory),
base::FilePath( base::FilePath(kPictureInPictureWindowSizePage));
FILE_PATH_LITERAL("media/picture-in-picture/window-size.html")));
ui_test_utils::NavigateToURL(browser(), test_page_url); ui_test_utils::NavigateToURL(browser(), test_page_url);
content::WebContents* initial_web_contents = content::WebContents* initial_web_contents =
...@@ -1093,8 +1140,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -1093,8 +1140,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
RequestPictureInPictureAfterDisablePictureInPicture) { RequestPictureInPictureAfterDisablePictureInPicture) {
GURL test_page_url = ui_test_utils::GetTestUrl( GURL test_page_url = ui_test_utils::GetTestUrl(
base::FilePath(base::FilePath::kCurrentDirectory), base::FilePath(base::FilePath::kCurrentDirectory),
base::FilePath( base::FilePath(kPictureInPictureWindowSizePage));
FILE_PATH_LITERAL("media/picture-in-picture/window-size.html")));
ui_test_utils::NavigateToURL(browser(), test_page_url); ui_test_utils::NavigateToURL(browser(), test_page_url);
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
...@@ -1200,14 +1246,16 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -1200,14 +1246,16 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
MultipleBrowserWindowOnePIPWindow) { MultipleBrowserWindowOnePIPWindow) {
LoadTabAndEnterPictureInPicture(browser()); LoadTabAndEnterPictureInPicture(
browser(), base::FilePath(kPictureInPictureWindowSizePage));
content::PictureInPictureWindowController* first_controller = content::PictureInPictureWindowController* first_controller =
window_controller(); window_controller();
EXPECT_TRUE(first_controller->GetWindowForTesting()->IsVisible()); EXPECT_TRUE(first_controller->GetWindowForTesting()->IsVisible());
Browser* second_browser = CreateBrowser(browser()->profile()); Browser* second_browser = CreateBrowser(browser()->profile());
LoadTabAndEnterPictureInPicture(second_browser); LoadTabAndEnterPictureInPicture(
second_browser, base::FilePath(kPictureInPictureWindowSizePage));
content::PictureInPictureWindowController* second_controller = content::PictureInPictureWindowController* second_controller =
window_controller(); window_controller();
...@@ -1217,7 +1265,8 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -1217,7 +1265,8 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
EnterPictureInPictureThenFullscreen) { EnterPictureInPictureThenFullscreen) {
LoadTabAndEnterPictureInPicture(browser()); LoadTabAndEnterPictureInPicture(
browser(), base::FilePath(kPictureInPictureWindowSizePage));
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
browser()->tab_strip_model()->GetActiveWebContents(); browser()->tab_strip_model()->GetActiveWebContents();
...@@ -1236,8 +1285,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -1236,8 +1285,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
EnterFullscreenThenPictureInPicture) { EnterFullscreenThenPictureInPicture) {
GURL test_page_url = ui_test_utils::GetTestUrl( GURL test_page_url = ui_test_utils::GetTestUrl(
base::FilePath(base::FilePath::kCurrentDirectory), base::FilePath(base::FilePath::kCurrentDirectory),
base::FilePath( base::FilePath(kPictureInPictureWindowSizePage));
FILE_PATH_LITERAL("media/picture-in-picture/window-size.html")));
ui_test_utils::NavigateToURL(browser(), test_page_url); ui_test_utils::NavigateToURL(browser(), test_page_url);
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
...@@ -1266,8 +1314,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -1266,8 +1314,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
EnterPictureInPictureThenNavigateAwayCloseWindow) { EnterPictureInPictureThenNavigateAwayCloseWindow) {
GURL test_page_url = ui_test_utils::GetTestUrl( GURL test_page_url = ui_test_utils::GetTestUrl(
base::FilePath(base::FilePath::kCurrentDirectory), base::FilePath(base::FilePath::kCurrentDirectory),
base::FilePath( base::FilePath(kPictureInPictureWindowSizePage));
FILE_PATH_LITERAL("media/picture-in-picture/window-size.html")));
ui_test_utils::NavigateToURL(browser(), test_page_url); ui_test_utils::NavigateToURL(browser(), test_page_url);
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
...@@ -1302,7 +1349,8 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -1302,7 +1349,8 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
// doesn't move back to its default position. // doesn't move back to its default position.
IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
SurfaceIdChangeDoesNotMoveWindow) { SurfaceIdChangeDoesNotMoveWindow) {
LoadTabAndEnterPictureInPicture(browser()); LoadTabAndEnterPictureInPicture(
browser(), base::FilePath(kPictureInPictureWindowSizePage));
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
browser()->tab_strip_model()->GetActiveWebContents(); browser()->tab_strip_model()->GetActiveWebContents();
...@@ -1352,7 +1400,8 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -1352,7 +1400,8 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
// is closed at a system level. // is closed at a system level.
IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
CloseWindowNotifiesController) { CloseWindowNotifiesController) {
LoadTabAndEnterPictureInPicture(browser()); LoadTabAndEnterPictureInPicture(
browser(), base::FilePath(kPictureInPictureWindowSizePage));
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
browser()->tab_strip_model()->GetActiveWebContents(); browser()->tab_strip_model()->GetActiveWebContents();
...@@ -1372,7 +1421,8 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -1372,7 +1421,8 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
// Picture-in-Picture is created after a reload. // Picture-in-Picture is created after a reload.
IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
PlayPauseStateAtCreation) { PlayPauseStateAtCreation) {
LoadTabAndEnterPictureInPicture(browser()); LoadTabAndEnterPictureInPicture(
browser(), base::FilePath(kPictureInPictureWindowSizePage));
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
browser()->tab_strip_model()->GetActiveWebContents(); browser()->tab_strip_model()->GetActiveWebContents();
...@@ -1435,7 +1485,8 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -1435,7 +1485,8 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
EnterUsingWebContentsThenUsingController) { EnterUsingWebContentsThenUsingController) {
// Enter using WebContents. // Enter using WebContents.
LoadTabAndEnterPictureInPicture(browser()); LoadTabAndEnterPictureInPicture(
browser(), base::FilePath(kPictureInPictureWindowSizePage));
OverlayWindowViews* overlay_window = static_cast<OverlayWindowViews*>( OverlayWindowViews* overlay_window = static_cast<OverlayWindowViews*>(
window_controller()->GetWindowForTesting()); window_controller()->GetWindowForTesting());
...@@ -1468,7 +1519,8 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -1468,7 +1519,8 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
// Now show the WebContents based Picture-in-Picture window controller. // Now show the WebContents based Picture-in-Picture window controller.
// This should close the existing window and show the new one. // This should close the existing window and show the new one.
EXPECT_CALL(mock_controller(), Close(_)); EXPECT_CALL(mock_controller(), Close(_));
LoadTabAndEnterPictureInPicture(browser()); LoadTabAndEnterPictureInPicture(
browser(), base::FilePath(kPictureInPictureWindowSizePage));
OverlayWindowViews* overlay_window = static_cast<OverlayWindowViews*>( OverlayWindowViews* overlay_window = static_cast<OverlayWindowViews*>(
window_controller()->GetWindowForTesting()); window_controller()->GetWindowForTesting());
...@@ -1585,8 +1637,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -1585,8 +1637,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
HandleMediaKeyPlayPause) { HandleMediaKeyPlayPause) {
GURL test_page_url = ui_test_utils::GetTestUrl( GURL test_page_url = ui_test_utils::GetTestUrl(
base::FilePath(base::FilePath::kCurrentDirectory), base::FilePath(base::FilePath::kCurrentDirectory),
base::FilePath( base::FilePath(kPictureInPictureWindowSizePage));
FILE_PATH_LITERAL("media/picture-in-picture/window-size.html")));
ui_test_utils::NavigateToURL(browser(), test_page_url); ui_test_utils::NavigateToURL(browser(), test_page_url);
content::WebContents* first_active_web_contents = content::WebContents* first_active_web_contents =
...@@ -1631,8 +1682,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -1631,8 +1682,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
MovingQuadrantsMovesBackToTabAndResizeControls) { MovingQuadrantsMovesBackToTabAndResizeControls) {
GURL test_page_url = ui_test_utils::GetTestUrl( GURL test_page_url = ui_test_utils::GetTestUrl(
base::FilePath(base::FilePath::kCurrentDirectory), base::FilePath(base::FilePath::kCurrentDirectory),
base::FilePath( base::FilePath(kPictureInPictureWindowSizePage));
FILE_PATH_LITERAL("media/picture-in-picture/window-size.html")));
ui_test_utils::NavigateToURL(browser(), test_page_url); ui_test_utils::NavigateToURL(browser(), test_page_url);
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
...@@ -1737,7 +1787,8 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -1737,7 +1787,8 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
// Picture-in-Picture window. // Picture-in-Picture window.
IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
PlayPauseButtonVisibility) { PlayPauseButtonVisibility) {
LoadTabAndEnterPictureInPicture(browser()); LoadTabAndEnterPictureInPicture(
browser(), base::FilePath(kPictureInPictureWindowSizePage));
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
browser()->tab_strip_model()->GetActiveWebContents(); browser()->tab_strip_model()->GetActiveWebContents();
...@@ -1776,8 +1827,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -1776,8 +1827,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
PageVisibilityEventsFired) { PageVisibilityEventsFired) {
GURL test_page_url = ui_test_utils::GetTestUrl( GURL test_page_url = ui_test_utils::GetTestUrl(
base::FilePath(base::FilePath::kCurrentDirectory), base::FilePath(base::FilePath::kCurrentDirectory),
base::FilePath( base::FilePath(kPictureInPictureWindowSizePage));
FILE_PATH_LITERAL("media/picture-in-picture/window-size.html")));
ui_test_utils::NavigateToURL(browser(), test_page_url); ui_test_utils::NavigateToURL(browser(), test_page_url);
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
...@@ -1813,7 +1863,8 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -1813,7 +1863,8 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
// Picture-in-Picture and video playback is not disrupted. // Picture-in-Picture and video playback is not disrupted.
IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
PageVisibilityEventsFiredWhenPictureInPicture) { PageVisibilityEventsFiredWhenPictureInPicture) {
LoadTabAndEnterPictureInPicture(browser()); LoadTabAndEnterPictureInPicture(
browser(), base::FilePath(kPictureInPictureWindowSizePage));
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
browser()->tab_strip_model()->GetActiveWebContents(); browser()->tab_strip_model()->GetActiveWebContents();
...@@ -1896,7 +1947,8 @@ class MediaSessionPictureInPictureWindowControllerBrowserTest ...@@ -1896,7 +1947,8 @@ class MediaSessionPictureInPictureWindowControllerBrowserTest
// when Media Session Action "skipad" is handled by the website. // when Media Session Action "skipad" is handled by the website.
IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest, IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest,
SkipAdButtonVisibility) { SkipAdButtonVisibility) {
LoadTabAndEnterPictureInPicture(browser()); LoadTabAndEnterPictureInPicture(
browser(), base::FilePath(kPictureInPictureWindowSizePage));
OverlayWindowViews* overlay_window = static_cast<OverlayWindowViews*>( OverlayWindowViews* overlay_window = static_cast<OverlayWindowViews*>(
window_controller()->GetWindowForTesting()); window_controller()->GetWindowForTesting());
ASSERT_TRUE(overlay_window); ASSERT_TRUE(overlay_window);
...@@ -1942,7 +1994,8 @@ IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest, ...@@ -1942,7 +1994,8 @@ IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest,
// website even if video is a media stream. // website even if video is a media stream.
IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest, IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest,
PlayPauseButtonVisibility) { PlayPauseButtonVisibility) {
LoadTabAndEnterPictureInPicture(browser()); LoadTabAndEnterPictureInPicture(
browser(), base::FilePath(kPictureInPictureWindowSizePage));
OverlayWindowViews* overlay_window = static_cast<OverlayWindowViews*>( OverlayWindowViews* overlay_window = static_cast<OverlayWindowViews*>(
window_controller()->GetWindowForTesting()); window_controller()->GetWindowForTesting());
...@@ -2015,7 +2068,8 @@ IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest, ...@@ -2015,7 +2068,8 @@ IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest,
// when Media Session Action "nexttrack" is handled by the website. // when Media Session Action "nexttrack" is handled by the website.
IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest, IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest,
NextTrackButtonVisibility) { NextTrackButtonVisibility) {
LoadTabAndEnterPictureInPicture(browser()); LoadTabAndEnterPictureInPicture(
browser(), base::FilePath(kPictureInPictureWindowSizePage));
OverlayWindowViews* overlay_window = static_cast<OverlayWindowViews*>( OverlayWindowViews* overlay_window = static_cast<OverlayWindowViews*>(
window_controller()->GetWindowForTesting()); window_controller()->GetWindowForTesting());
ASSERT_TRUE(overlay_window); ASSERT_TRUE(overlay_window);
...@@ -2069,7 +2123,8 @@ IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest, ...@@ -2069,7 +2123,8 @@ IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest,
// Picture-in-Picture window controls are hidden. // Picture-in-Picture window controls are hidden.
IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest, IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest,
NextTrackButtonBounds) { NextTrackButtonBounds) {
LoadTabAndEnterPictureInPicture(browser()); LoadTabAndEnterPictureInPicture(
browser(), base::FilePath(kPictureInPictureWindowSizePage));
OverlayWindowViews* overlay_window = static_cast<OverlayWindowViews*>( OverlayWindowViews* overlay_window = static_cast<OverlayWindowViews*>(
window_controller()->GetWindowForTesting()); window_controller()->GetWindowForTesting());
ASSERT_TRUE(overlay_window); ASSERT_TRUE(overlay_window);
...@@ -2095,7 +2150,8 @@ IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest, ...@@ -2095,7 +2150,8 @@ IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest,
// window when Media Session Action "previoustrack" is handled by the website. // window when Media Session Action "previoustrack" is handled by the website.
IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest, IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest,
PreviousTrackButtonVisibility) { PreviousTrackButtonVisibility) {
LoadTabAndEnterPictureInPicture(browser()); LoadTabAndEnterPictureInPicture(
browser(), base::FilePath(kPictureInPictureWindowSizePage));
OverlayWindowViews* overlay_window = static_cast<OverlayWindowViews*>( OverlayWindowViews* overlay_window = static_cast<OverlayWindowViews*>(
window_controller()->GetWindowForTesting()); window_controller()->GetWindowForTesting());
ASSERT_TRUE(overlay_window); ASSERT_TRUE(overlay_window);
...@@ -2149,7 +2205,8 @@ IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest, ...@@ -2149,7 +2205,8 @@ IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest,
// Picture-in-Picture window controls are hidden. // Picture-in-Picture window controls are hidden.
IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest, IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest,
PreviousTrackButtonBounds) { PreviousTrackButtonBounds) {
LoadTabAndEnterPictureInPicture(browser()); LoadTabAndEnterPictureInPicture(
browser(), base::FilePath(kPictureInPictureWindowSizePage));
OverlayWindowViews* overlay_window = static_cast<OverlayWindowViews*>( OverlayWindowViews* overlay_window = static_cast<OverlayWindowViews*>(
window_controller()->GetWindowForTesting()); window_controller()->GetWindowForTesting());
ASSERT_TRUE(overlay_window); ASSERT_TRUE(overlay_window);
...@@ -2175,7 +2232,8 @@ IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest, ...@@ -2175,7 +2232,8 @@ IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest,
// calls the Media Session Action "skipad" handler function. // calls the Media Session Action "skipad" handler function.
IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest, IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest,
SkipAdHandlerCalled) { SkipAdHandlerCalled) {
LoadTabAndEnterPictureInPicture(browser()); LoadTabAndEnterPictureInPicture(
browser(), base::FilePath(kPictureInPictureWindowSizePage));
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
browser()->tab_strip_model()->GetActiveWebContents(); browser()->tab_strip_model()->GetActiveWebContents();
ASSERT_TRUE(content::ExecuteScript(active_web_contents, "video.play();")); ASSERT_TRUE(content::ExecuteScript(active_web_contents, "video.play();"));
...@@ -2195,7 +2253,8 @@ IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest, ...@@ -2195,7 +2253,8 @@ IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest,
// calls the Media Session actions "play" and "pause" handler functions. // calls the Media Session actions "play" and "pause" handler functions.
IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest, IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest,
PlayPauseHandlersCalled) { PlayPauseHandlersCalled) {
LoadTabAndEnterPictureInPicture(browser()); LoadTabAndEnterPictureInPicture(
browser(), base::FilePath(kPictureInPictureWindowSizePage));
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
browser()->tab_strip_model()->GetActiveWebContents(); browser()->tab_strip_model()->GetActiveWebContents();
ASSERT_TRUE(content::ExecuteScript(active_web_contents, "video.play();")); ASSERT_TRUE(content::ExecuteScript(active_web_contents, "video.play();"));
...@@ -2228,7 +2287,8 @@ IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest, ...@@ -2228,7 +2287,8 @@ IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest,
// calls the Media Session Action "nexttrack" handler function. // calls the Media Session Action "nexttrack" handler function.
IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest, IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest,
NextTrackHandlerCalled) { NextTrackHandlerCalled) {
LoadTabAndEnterPictureInPicture(browser()); LoadTabAndEnterPictureInPicture(
browser(), base::FilePath(kPictureInPictureWindowSizePage));
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
browser()->tab_strip_model()->GetActiveWebContents(); browser()->tab_strip_model()->GetActiveWebContents();
ASSERT_TRUE(content::ExecuteScript(active_web_contents, "video.play();")); ASSERT_TRUE(content::ExecuteScript(active_web_contents, "video.play();"));
...@@ -2249,7 +2309,8 @@ IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest, ...@@ -2249,7 +2309,8 @@ IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest,
// window calls the Media Session Action "previoustrack" handler function. // window calls the Media Session Action "previoustrack" handler function.
IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest, IN_PROC_BROWSER_TEST_F(MediaSessionPictureInPictureWindowControllerBrowserTest,
PreviousTrackHandlerCalled) { PreviousTrackHandlerCalled) {
LoadTabAndEnterPictureInPicture(browser()); LoadTabAndEnterPictureInPicture(
browser(), base::FilePath(kPictureInPictureWindowSizePage));
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
browser()->tab_strip_model()->GetActiveWebContents(); browser()->tab_strip_model()->GetActiveWebContents();
ASSERT_TRUE(content::ExecuteScript(active_web_contents, "video.play();")); ASSERT_TRUE(content::ExecuteScript(active_web_contents, "video.play();"));
...@@ -2283,8 +2344,7 @@ IN_PROC_BROWSER_TEST_F(AutoPictureInPictureWindowControllerBrowserTest, ...@@ -2283,8 +2344,7 @@ IN_PROC_BROWSER_TEST_F(AutoPictureInPictureWindowControllerBrowserTest,
AutoEnterPictureInPictureIsNotTriggeredInRegularWebApp) { AutoEnterPictureInPictureIsNotTriggeredInRegularWebApp) {
GURL test_page_url = ui_test_utils::GetTestUrl( GURL test_page_url = ui_test_utils::GetTestUrl(
base::FilePath(base::FilePath::kCurrentDirectory), base::FilePath(base::FilePath::kCurrentDirectory),
base::FilePath( base::FilePath(kPictureInPictureWindowSizePage));
FILE_PATH_LITERAL("media/picture-in-picture/window-size.html")));
ui_test_utils::NavigateToURL(browser(), test_page_url); ui_test_utils::NavigateToURL(browser(), test_page_url);
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
...@@ -2318,8 +2378,7 @@ IN_PROC_BROWSER_TEST_F(AutoPictureInPictureWindowControllerBrowserTest, ...@@ -2318,8 +2378,7 @@ IN_PROC_BROWSER_TEST_F(AutoPictureInPictureWindowControllerBrowserTest,
AutoExitPictureInPictureIsTriggeredInRegularWebApp) { AutoExitPictureInPictureIsTriggeredInRegularWebApp) {
GURL test_page_url = ui_test_utils::GetTestUrl( GURL test_page_url = ui_test_utils::GetTestUrl(
base::FilePath(base::FilePath::kCurrentDirectory), base::FilePath(base::FilePath::kCurrentDirectory),
base::FilePath( base::FilePath(kPictureInPictureWindowSizePage));
FILE_PATH_LITERAL("media/picture-in-picture/window-size.html")));
ui_test_utils::NavigateToURL(browser(), test_page_url); ui_test_utils::NavigateToURL(browser(), test_page_url);
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
...@@ -2363,8 +2422,7 @@ IN_PROC_BROWSER_TEST_F(AutoPictureInPictureWindowControllerBrowserTest, ...@@ -2363,8 +2422,7 @@ IN_PROC_BROWSER_TEST_F(AutoPictureInPictureWindowControllerBrowserTest,
AutoPictureInPictureTriggeredWhenFullscreen) { AutoPictureInPictureTriggeredWhenFullscreen) {
GURL test_page_url = ui_test_utils::GetTestUrl( GURL test_page_url = ui_test_utils::GetTestUrl(
base::FilePath(base::FilePath::kCurrentDirectory), base::FilePath(base::FilePath::kCurrentDirectory),
base::FilePath( base::FilePath(kPictureInPictureWindowSizePage));
FILE_PATH_LITERAL("media/picture-in-picture/window-size.html")));
ui_test_utils::NavigateToURL(browser(), test_page_url); ui_test_utils::NavigateToURL(browser(), test_page_url);
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
...@@ -2804,8 +2862,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -2804,8 +2862,7 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
VideoWithNoAudioPausedWhenHiddenResumesPlayback) { VideoWithNoAudioPausedWhenHiddenResumesPlayback) {
GURL test_page_url = ui_test_utils::GetTestUrl( GURL test_page_url = ui_test_utils::GetTestUrl(
base::FilePath(base::FilePath::kCurrentDirectory), base::FilePath(base::FilePath::kCurrentDirectory),
base::FilePath( base::FilePath(kPictureInPictureWindowSizePage));
FILE_PATH_LITERAL("media/picture-in-picture/window-size.html")));
ui_test_utils::NavigateToURL(browser(), test_page_url); ui_test_utils::NavigateToURL(browser(), test_page_url);
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
...@@ -2846,7 +2903,8 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -2846,7 +2903,8 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
// event and resolves the callback. // event and resolves the callback.
IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
ExitFireEventAndCallbackWhenNoSource) { ExitFireEventAndCallbackWhenNoSource) {
LoadTabAndEnterPictureInPicture(browser()); LoadTabAndEnterPictureInPicture(
browser(), base::FilePath(kPictureInPictureWindowSizePage));
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
browser()->tab_strip_model()->GetActiveWebContents(); browser()->tab_strip_model()->GetActiveWebContents();
...@@ -2873,7 +2931,8 @@ class MuteButtonPictureInPictureWindowControllerBrowserTest ...@@ -2873,7 +2931,8 @@ class MuteButtonPictureInPictureWindowControllerBrowserTest
// experimental feature MuteButton is enabled. // experimental feature MuteButton is enabled.
IN_PROC_BROWSER_TEST_F(MuteButtonPictureInPictureWindowControllerBrowserTest, IN_PROC_BROWSER_TEST_F(MuteButtonPictureInPictureWindowControllerBrowserTest,
MuteButtonEnabled) { MuteButtonEnabled) {
LoadTabAndEnterPictureInPicture(browser()); LoadTabAndEnterPictureInPicture(
browser(), base::FilePath(kPictureInPictureWindowSizePage));
OverlayWindowViews* overlay_window = static_cast<OverlayWindowViews*>( OverlayWindowViews* overlay_window = static_cast<OverlayWindowViews*>(
window_controller()->GetWindowForTesting()); window_controller()->GetWindowForTesting());
...@@ -2992,7 +3051,8 @@ IN_PROC_BROWSER_TEST_F(MuteButtonPictureInPictureWindowControllerBrowserTest, ...@@ -2992,7 +3051,8 @@ IN_PROC_BROWSER_TEST_F(MuteButtonPictureInPictureWindowControllerBrowserTest,
// experimental feature MuteButton is disabled. // experimental feature MuteButton is disabled.
IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
MuteButtonDisabled) { MuteButtonDisabled) {
LoadTabAndEnterPictureInPicture(browser()); LoadTabAndEnterPictureInPicture(
browser(), base::FilePath(kPictureInPictureWindowSizePage));
OverlayWindowViews* overlay_window = static_cast<OverlayWindowViews*>( OverlayWindowViews* overlay_window = static_cast<OverlayWindowViews*>(
window_controller()->GetWindowForTesting()); window_controller()->GetWindowForTesting());
...@@ -3054,7 +3114,8 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, ...@@ -3054,7 +3114,8 @@ IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
// element is still notified. // element is still notified.
IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest, IN_PROC_BROWSER_TEST_F(PictureInPictureWindowControllerBrowserTest,
ResetPlayerCloseWindowNotifiesElement) { ResetPlayerCloseWindowNotifiesElement) {
LoadTabAndEnterPictureInPicture(browser()); LoadTabAndEnterPictureInPicture(
browser(), base::FilePath(kPictureInPictureWindowSizePage));
content::WebContents* active_web_contents = content::WebContents* active_web_contents =
browser()->tab_strip_model()->GetActiveWebContents(); browser()->tab_strip_model()->GetActiveWebContents();
......
...@@ -26,5 +26,16 @@ ...@@ -26,5 +26,16 @@
window.domAutomationController.send(false); window.domAutomationController.send(false);
}); });
} }
function changeVideoSrc() {
if (video.srcObject) {
video.srcObject.getTracks().forEach(track => track.stop());
video.srcObject = null;
}
video.src = 'pixel_test_video.webm';
video.play()
.then(_ => { window.domAutomationController.send(true); })
.catch(e => { window.domAutomationController.send(false); });
}
</script> </script>
</html> </html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment