| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/macros.h" | 5 #include "base/macros.h" |
| 6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
| 7 #include "base/threading/platform_thread.h" | 7 #include "base/threading/platform_thread.h" |
| 8 #include "base/threading/thread_task_runner_handle.h" | 8 #include "base/threading/thread_task_runner_handle.h" |
| 9 #include "chromecast/browser/cast_media_blocker.h" | 9 #include "chromecast/browser/cast_media_blocker.h" |
| 10 #include "chromecast/browser/test/cast_browser_test.h" | 10 #include "chromecast/browser/test/cast_browser_test.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 query_params.push_back(std::make_pair("loop", "true")); | 37 query_params.push_back(std::make_pair("loop", "true")); |
| 38 | 38 |
| 39 std::string query = media::GetURLQueryString(query_params); | 39 std::string query = media::GetURLQueryString(query_params); |
| 40 GURL gurl = content::GetFileUrlWithQuery( | 40 GURL gurl = content::GetFileUrlWithQuery( |
| 41 media::GetTestDataFilePath("player.html"), query); | 41 media::GetTestDataFilePath("player.html"), query); |
| 42 | 42 |
| 43 web_contents_ = NavigateToURL(gurl); | 43 web_contents_ = NavigateToURL(gurl); |
| 44 WaitForLoadStop(web_contents_); | 44 WaitForLoadStop(web_contents_); |
| 45 | 45 |
| 46 blocker_ = base::MakeUnique<CastMediaBlocker>( | 46 blocker_ = base::MakeUnique<CastMediaBlocker>( |
| 47 content::MediaSession::Get(web_contents_), web_contents_); | 47 content::MediaSession::Get(web_contents_)); |
| 48 } | 48 } |
| 49 | 49 |
| 50 void BlockAndTestPlayerState(const std::string& media_type, bool blocked) { | 50 void BlockAndTestPlayerState(const std::string& media_type, bool blocked) { |
| 51 blocker_->BlockMediaLoading(blocked); | 51 blocker_->BlockMediaLoading(blocked); |
| 52 | 52 |
| 53 // Changing states is not instant, but should be timely (< 0.5s). | 53 // Changing states is not instant, but should be timely (< 0.5s). |
| 54 for (size_t i = 0; i < 5; i++) { | 54 for (size_t i = 0; i < 5; i++) { |
| 55 base::RunLoop run_loop; | 55 base::RunLoop run_loop; |
| 56 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 56 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 57 FROM_HERE, run_loop.QuitClosure(), | 57 FROM_HERE, run_loop.QuitClosure(), |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 IN_PROC_BROWSER_TEST_F(CastMediaBlockerBrowserTest, Video_BlockUnblock) { | 97 IN_PROC_BROWSER_TEST_F(CastMediaBlockerBrowserTest, Video_BlockUnblock) { |
| 98 PlayMedia("video", "tulip2.webm"); | 98 PlayMedia("video", "tulip2.webm"); |
| 99 | 99 |
| 100 BlockAndTestPlayerState("video", true); | 100 BlockAndTestPlayerState("video", true); |
| 101 BlockAndTestPlayerState("video", false); | 101 BlockAndTestPlayerState("video", false); |
| 102 } | 102 } |
| 103 #endif | 103 #endif |
| 104 | 104 |
| 105 } // namespace shell | 105 } // namespace shell |
| 106 } // namespace chromecast | 106 } // namespace chromecast |
| OLD | NEW |