OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chromecast/browser/test/chromecast_browser_test_helper.h" |
| 6 |
| 7 #include "base/memory/ptr_util.h" |
| 8 #include "chromecast/browser/cast_browser_context.h" |
| 9 #include "chromecast/browser/cast_browser_process.h" |
| 10 #include "chromecast/browser/cast_content_window.h" |
| 11 #include "content/public/browser/web_contents.h" |
| 12 #include "content/public/test/browser_test_utils.h" |
| 13 #include "content/public/test/test_navigation_observer.h" |
| 14 |
| 15 namespace chromecast { |
| 16 namespace shell { |
| 17 namespace { |
| 18 |
| 19 class DefaultHelper : public ChromecastBrowserTestHelper { |
| 20 public: |
| 21 ~DefaultHelper() override {} |
| 22 |
| 23 content::WebContents* NavigateToURL(const GURL& url) override { |
| 24 window_.reset(new CastContentWindow); |
| 25 gfx::Size initial_size(1280, 720); |
| 26 |
| 27 web_contents_ = window_->CreateWebContents( |
| 28 initial_size, CastBrowserProcess::GetInstance()->browser_context()); |
| 29 window_->CreateWindowTree(initial_size, web_contents_.get()); |
| 30 |
| 31 content::WaitForLoadStop(web_contents_.get()); |
| 32 content::TestNavigationObserver same_tab_observer(web_contents_.get(), 1); |
| 33 content::NavigationController::LoadURLParams params(url); |
| 34 params.transition_type = ui::PageTransitionFromInt( |
| 35 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR); |
| 36 web_contents_->GetController().LoadURLWithParams(params); |
| 37 same_tab_observer.Wait(); |
| 38 |
| 39 return web_contents_.get(); |
| 40 } |
| 41 |
| 42 private: |
| 43 std::unique_ptr<CastContentWindow> window_; |
| 44 std::unique_ptr<content::WebContents> web_contents_; |
| 45 }; |
| 46 |
| 47 } // namespace |
| 48 |
| 49 std::unique_ptr<ChromecastBrowserTestHelper> |
| 50 ChromecastBrowserTestHelper::Create() { |
| 51 return base::WrapUnique(new DefaultHelper()); |
| 52 } |
| 53 |
| 54 } // namespace shell |
| 55 } // namespace chromecast |
OLD | NEW |