Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(495)

Side by Side Diff: chrome/browser/media/defer_background_media_browsertest.cc

Issue 1293253003: Fix autoplay during prerendering for media elements on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@defer_media
Patch Set: Rename test class. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/renderer/media/android/webmediaplayer_android.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
6 #include "build/build_config.h" 7 #include "build/build_config.h"
7 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/tabs/tab_strip_model.h" 9 #include "chrome/browser/ui/tabs/tab_strip_model.h"
9 #include "chrome/test/base/in_process_browser_test.h" 10 #include "chrome/test/base/in_process_browser_test.h"
10 #include "chrome/test/base/ui_test_utils.h" 11 #include "chrome/test/base/ui_test_utils.h"
12 #include "content/public/common/content_switches.h"
11 #include "content/public/test/browser_test_utils.h" 13 #include "content/public/test/browser_test_utils.h"
12 #include "media/base/test_data_util.h" 14 #include "media/base/test_data_util.h"
13 15
14 // TODO(dalecurtis): Android does not correctly defer media today, fix and 16 class DeferredMediaBrowserTest : public InProcessBrowserTest {
15 // enable this test (needs disable of user gesture). http://crbug.com/522157 17 public:
16 #if !defined(OS_ANDROID) 18 #if defined(OS_ANDROID)
17 typedef InProcessBrowserTest MediaBrowserTest; 19 void SetUpCommandLine(base::CommandLine* command_line) override {
20 command_line->AppendSwitch(
21 switches::kDisableGestureRequirementForMediaPlayback);
22 }
23 #endif
24 };
18 25
19 IN_PROC_BROWSER_TEST_F(MediaBrowserTest, BackgroundMediaIsDeferred) { 26 IN_PROC_BROWSER_TEST_F(DeferredMediaBrowserTest, BackgroundMediaIsDeferred) {
20 // 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
21 // in the background due to deferred media loading for hidden tabs. 28 // in the background due to deferred media loading for hidden tabs.
22 ui_test_utils::NavigateToURLWithDisposition( 29 ui_test_utils::NavigateToURLWithDisposition(
23 browser(), content::GetFileUrlWithQuery( 30 browser(), content::GetFileUrlWithQuery(
24 media::GetTestDataFilePath("bear-640x360.webm"), ""), 31 media::GetTestDataFilePath("bear-640x360.webm"), ""),
25 NEW_BACKGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 32 NEW_BACKGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
26 33
27 ASSERT_EQ(2, browser()->tab_strip_model()->count()); 34 ASSERT_EQ(2, browser()->tab_strip_model()->count());
28 content::WebContents* background_contents = 35 content::WebContents* background_contents =
29 browser()->tab_strip_model()->GetWebContentsAt(1); 36 browser()->tab_strip_model()->GetWebContentsAt(1);
(...skipping 20 matching lines...) Expand all
50 EXPECT_EQ(background_contents, 57 EXPECT_EQ(background_contents,
51 browser()->tab_strip_model()->GetActiveWebContents()); 58 browser()->tab_strip_model()->GetActiveWebContents());
52 59
53 // If everything worked, we should see "playing" and not "ended". 60 // If everything worked, we should see "playing" and not "ended".
54 const base::string16 playing_str = base::UTF8ToUTF16("playing"); 61 const base::string16 playing_str = base::UTF8ToUTF16("playing");
55 const base::string16 ended_str = base::UTF8ToUTF16("ended"); 62 const base::string16 ended_str = base::UTF8ToUTF16("ended");
56 content::TitleWatcher watcher(background_contents, playing_str); 63 content::TitleWatcher watcher(background_contents, playing_str);
57 watcher.AlsoWaitForTitle(ended_str); 64 watcher.AlsoWaitForTitle(ended_str);
58 EXPECT_EQ(playing_str, watcher.WaitAndGetTitle()); 65 EXPECT_EQ(playing_str, watcher.WaitAndGetTitle());
59 } 66 }
60 #endif // !defined(OS_ANDROID)
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/android/webmediaplayer_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698