Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/test/base/browser_with_test_window_test.h" | 5 #include "chrome/test/base/browser_with_test_window_test.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| 11 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "chrome/browser/profiles/profile_destroyer.h" | 13 #include "chrome/browser/profiles/profile_destroyer.h" |
| 14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/browser_navigator.h" | 15 #include "chrome/browser/ui/browser_navigator.h" |
| 16 #include "chrome/browser/ui/browser_navigator_params.h" | 16 #include "chrome/browser/ui/browser_navigator_params.h" |
| 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 18 #include "chrome/browser/ui/views/harmony/chrome_layout_delegate.h" | |
|
Peter Kasting
2017/04/06 08:13:36
Can this test really be compiled without TOOLKIT_V
kylix_rd
2017/04/06 16:48:19
Done.
| |
| 18 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
| 19 #include "content/public/browser/navigation_controller.h" | 20 #include "content/public/browser/navigation_controller.h" |
| 20 #include "content/public/browser/navigation_entry.h" | 21 #include "content/public/browser/navigation_entry.h" |
| 21 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 22 #include "content/public/common/browser_side_navigation_policy.h" | 23 #include "content/public/common/browser_side_navigation_policy.h" |
| 23 #include "content/public/test/browser_side_navigation_test_utils.h" | 24 #include "content/public/test/browser_side_navigation_test_utils.h" |
| 24 #include "content/public/test/test_renderer_host.h" | 25 #include "content/public/test/test_renderer_host.h" |
| 25 #include "ui/base/page_transition_types.h" | 26 #include "ui/base/page_transition_types.h" |
| 27 #include "ui/views/test/test_views_delegate.h" | |
| 26 | 28 |
| 27 #if defined(OS_CHROMEOS) | 29 #if defined(OS_CHROMEOS) |
| 28 #include "ash/test/ash_test_helper.h" | 30 #include "ash/test/ash_test_helper.h" |
| 31 #include "ash/test/ash_test_views_delegate.h" | |
| 29 #include "chrome/test/base/ash_test_environment_chrome.h" | 32 #include "chrome/test/base/ash_test_environment_chrome.h" |
| 30 #elif defined(TOOLKIT_VIEWS) | 33 #elif defined(TOOLKIT_VIEWS) |
| 31 #include "ui/views/test/scoped_views_test_helper.h" | 34 #include "ui/views/test/scoped_views_test_helper.h" |
| 32 #endif | 35 #endif |
| 33 | 36 |
| 34 #if defined(TOOLKIT_VIEWS) | 37 #if defined(TOOLKIT_VIEWS) |
| 35 #include "chrome/browser/ui/views/chrome_constrained_window_views_client.h" | 38 #include "chrome/browser/ui/views/chrome_constrained_window_views_client.h" |
| 36 #include "components/constrained_window/constrained_window_views.h" | 39 #include "components/constrained_window/constrained_window_views.h" |
| 37 #endif | 40 #endif |
| 38 | 41 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 61 ash_test_helper_.reset( | 64 ash_test_helper_.reset( |
| 62 new ash::test::AshTestHelper(ash_test_environment_.get())); | 65 new ash::test::AshTestHelper(ash_test_environment_.get())); |
| 63 ash_test_helper_->SetUp(true); | 66 ash_test_helper_->SetUp(true); |
| 64 #elif defined(TOOLKIT_VIEWS) | 67 #elif defined(TOOLKIT_VIEWS) |
| 65 views_test_helper_.reset(new views::ScopedViewsTestHelper()); | 68 views_test_helper_.reset(new views::ScopedViewsTestHelper()); |
| 66 #endif | 69 #endif |
| 67 #if defined(TOOLKIT_VIEWS) | 70 #if defined(TOOLKIT_VIEWS) |
| 68 SetConstrainedWindowViewsClient(CreateChromeConstrainedWindowViewsClient()); | 71 SetConstrainedWindowViewsClient(CreateChromeConstrainedWindowViewsClient()); |
| 69 #endif | 72 #endif |
| 70 | 73 |
| 74 test_views_delegate()->set_layout_delegate( | |
| 75 base::MakeUnique<ChromeLayoutDelegate>()); | |
| 76 | |
| 71 if (content::IsBrowserSideNavigationEnabled()) | 77 if (content::IsBrowserSideNavigationEnabled()) |
| 72 content::BrowserSideNavigationSetUp(); | 78 content::BrowserSideNavigationSetUp(); |
| 73 | 79 |
| 74 // Subclasses can provide their own Profile. | 80 // Subclasses can provide their own Profile. |
| 75 profile_ = CreateProfile(); | 81 profile_ = CreateProfile(); |
| 76 // Subclasses can provide their own test BrowserWindow. If they return NULL | 82 // Subclasses can provide their own test BrowserWindow. If they return NULL |
| 77 // then Browser will create the a production BrowserWindow and the subclass | 83 // then Browser will create the a production BrowserWindow and the subclass |
| 78 // is responsible for cleaning it up (usually by NativeWidget destruction). | 84 // is responsible for cleaning it up (usually by NativeWidget destruction). |
| 79 window_.reset(CreateBrowserWindow()); | 85 window_.reset(CreateBrowserWindow()); |
| 80 | 86 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 201 Browser::CreateParams params(profile, true); | 207 Browser::CreateParams params(profile, true); |
| 202 if (hosted_app) { | 208 if (hosted_app) { |
| 203 params = Browser::CreateParams::CreateForApp( | 209 params = Browser::CreateParams::CreateForApp( |
| 204 "Test", true /* trusted_source */, gfx::Rect(), profile, true); | 210 "Test", true /* trusted_source */, gfx::Rect(), profile, true); |
| 205 } else { | 211 } else { |
| 206 params.type = browser_type; | 212 params.type = browser_type; |
| 207 } | 213 } |
| 208 params.window = browser_window; | 214 params.window = browser_window; |
| 209 return new Browser(params); | 215 return new Browser(params); |
| 210 } | 216 } |
| 217 | |
| 218 views::TestViewsDelegate* BrowserWithTestWindowTest::test_views_delegate() { | |
| 219 #if defined(OS_CHROMEOS) | |
| 220 return ash_test_helper_->test_views_delegate(); | |
| 221 #elif defined(TOOLKIT_VIEWS) | |
| 222 return views_test_helper_->test_views_delegate(); | |
| 223 #endif | |
| 224 } | |
| OLD | NEW |