| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 9 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 10 #include "chrome/test/base/in_process_browser_test.h" | 10 #include "chrome/test/base/in_process_browser_test.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 } | 22 } |
| 23 #endif | 23 #endif |
| 24 }; | 24 }; |
| 25 | 25 |
| 26 IN_PROC_BROWSER_TEST_F(DeferredMediaBrowserTest, BackgroundMediaIsDeferred) { | 26 IN_PROC_BROWSER_TEST_F(DeferredMediaBrowserTest, BackgroundMediaIsDeferred) { |
| 27 // Navigate to a video file, which would autoplay in the foreground, but won't | 27 // Navigate to a video file, which would autoplay in the foreground, but won't |
| 28 // in the background due to deferred media loading for hidden tabs. | 28 // in the background due to deferred media loading for hidden tabs. |
| 29 ui_test_utils::NavigateToURLWithDisposition( | 29 ui_test_utils::NavigateToURLWithDisposition( |
| 30 browser(), content::GetFileUrlWithQuery( | 30 browser(), content::GetFileUrlWithQuery( |
| 31 media::GetTestDataFilePath("bear-640x360.webm"), ""), | 31 media::GetTestDataFilePath("bear-640x360.webm"), ""), |
| 32 NEW_BACKGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 32 WindowOpenDisposition::NEW_BACKGROUND_TAB, |
| 33 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 33 | 34 |
| 34 ASSERT_EQ(2, browser()->tab_strip_model()->count()); | 35 ASSERT_EQ(2, browser()->tab_strip_model()->count()); |
| 35 content::WebContents* background_contents = | 36 content::WebContents* background_contents = |
| 36 browser()->tab_strip_model()->GetWebContentsAt(1); | 37 browser()->tab_strip_model()->GetWebContentsAt(1); |
| 37 EXPECT_TRUE( | 38 EXPECT_TRUE( |
| 38 content::WaitForRenderFrameReady(background_contents->GetMainFrame())); | 39 content::WaitForRenderFrameReady(background_contents->GetMainFrame())); |
| 39 EXPECT_NE(background_contents, | 40 EXPECT_NE(background_contents, |
| 40 browser()->tab_strip_model()->GetActiveWebContents()); | 41 browser()->tab_strip_model()->GetActiveWebContents()); |
| 41 | 42 |
| 42 // If autoplay for background tabs isn't deferred the play event listener will | 43 // If autoplay for background tabs isn't deferred the play event listener will |
| (...skipping 14 matching lines...) Expand all Loading... |
| 57 EXPECT_EQ(background_contents, | 58 EXPECT_EQ(background_contents, |
| 58 browser()->tab_strip_model()->GetActiveWebContents()); | 59 browser()->tab_strip_model()->GetActiveWebContents()); |
| 59 | 60 |
| 60 // If everything worked, we should see "playing" and not "ended". | 61 // If everything worked, we should see "playing" and not "ended". |
| 61 const base::string16 playing_str = base::UTF8ToUTF16("playing"); | 62 const base::string16 playing_str = base::UTF8ToUTF16("playing"); |
| 62 const base::string16 ended_str = base::UTF8ToUTF16("ended"); | 63 const base::string16 ended_str = base::UTF8ToUTF16("ended"); |
| 63 content::TitleWatcher watcher(background_contents, playing_str); | 64 content::TitleWatcher watcher(background_contents, playing_str); |
| 64 watcher.AlsoWaitForTitle(ended_str); | 65 watcher.AlsoWaitForTitle(ended_str); |
| 65 EXPECT_EQ(playing_str, watcher.WaitAndGetTitle()); | 66 EXPECT_EQ(playing_str, watcher.WaitAndGetTitle()); |
| 66 } | 67 } |
| OLD | NEW |