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

Side by Side Diff: chromecast/browser/test/chromecast_browser_test_helper_default.cc

Issue 2345053002: Revert of Add CastMediaBlocker and BrowserTest (Closed)
Patch Set: Created 4 years, 3 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
OLDNEW
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 "chromecast/browser/test/chromecast_browser_test_helper.h" 5 #include "chromecast/browser/test/chromecast_browser_test_helper.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "chromecast/browser/cast_browser_context.h" 8 #include "chromecast/browser/cast_browser_context.h"
9 #include "chromecast/browser/cast_browser_process.h" 9 #include "chromecast/browser/cast_browser_process.h"
10 #include "chromecast/browser/cast_content_window.h" 10 #include "chromecast/browser/cast_content_window.h"
11 #include "chromecast/browser/cast_media_blocker.h"
12 #include "content/public/browser/web_contents.h" 11 #include "content/public/browser/web_contents.h"
13 #include "content/public/test/browser_test_utils.h" 12 #include "content/public/test/browser_test_utils.h"
14 #include "content/public/test/test_navigation_observer.h" 13 #include "content/public/test/test_navigation_observer.h"
15 14
16 namespace chromecast { 15 namespace chromecast {
17 namespace shell { 16 namespace shell {
18 namespace { 17 namespace {
19 18
20 class DefaultHelper : public ChromecastBrowserTestHelper { 19 class DefaultHelper : public ChromecastBrowserTestHelper {
21 public: 20 public:
22 ~DefaultHelper() override {} 21 ~DefaultHelper() override {}
23 22
24 content::WebContents* NavigateToURL(const GURL& url) override { 23 content::WebContents* NavigateToURL(const GURL& url) override {
25 window_.reset(new CastContentWindow); 24 window_.reset(new CastContentWindow);
26 25
27 web_contents_ = window_->CreateWebContents( 26 web_contents_ = window_->CreateWebContents(
28 CastBrowserProcess::GetInstance()->browser_context()); 27 CastBrowserProcess::GetInstance()->browser_context());
29 window_->CreateWindowTree(web_contents_.get()); 28 window_->CreateWindowTree(web_contents_.get());
30 blocker_.reset(new CastMediaBlocker(web_contents_.get()));
31 29
32 content::WaitForLoadStop(web_contents_.get()); 30 content::WaitForLoadStop(web_contents_.get());
33 content::TestNavigationObserver same_tab_observer(web_contents_.get(), 1); 31 content::TestNavigationObserver same_tab_observer(web_contents_.get(), 1);
34 content::NavigationController::LoadURLParams params(url); 32 content::NavigationController::LoadURLParams params(url);
35 params.transition_type = ui::PageTransitionFromInt( 33 params.transition_type = ui::PageTransitionFromInt(
36 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR); 34 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR);
37 web_contents_->GetController().LoadURLWithParams(params); 35 web_contents_->GetController().LoadURLWithParams(params);
38 same_tab_observer.Wait(); 36 same_tab_observer.Wait();
39 37
40 return web_contents_.get(); 38 return web_contents_.get();
41 } 39 }
42 40
43 void BlockMediaLoading(bool block) override {
44 blocker_->BlockMediaLoading(block);
45 }
46
47 private: 41 private:
48 std::unique_ptr<CastContentWindow> window_; 42 std::unique_ptr<CastContentWindow> window_;
49 std::unique_ptr<content::WebContents> web_contents_; 43 std::unique_ptr<content::WebContents> web_contents_;
50 std::unique_ptr<CastMediaBlocker> blocker_;
51 }; 44 };
52 45
53 } // namespace 46 } // namespace
54 47
55 std::unique_ptr<ChromecastBrowserTestHelper> 48 std::unique_ptr<ChromecastBrowserTestHelper>
56 ChromecastBrowserTestHelper::Create() { 49 ChromecastBrowserTestHelper::Create() {
57 return base::MakeUnique<DefaultHelper>(); 50 return base::MakeUnique<DefaultHelper>();
58 } 51 }
59 52
60 } // namespace shell 53 } // namespace shell
61 } // namespace chromecast 54 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698