| 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 #ifndef CHROME_TEST_BASE_BROWSER_WITH_TEST_WINDOW_TEST_H_ | 5 #ifndef CHROME_TEST_BASE_BROWSER_WITH_TEST_WINDOW_TEST_H_ |
| 6 #define CHROME_TEST_BASE_BROWSER_WITH_TEST_WINDOW_TEST_H_ | 6 #define CHROME_TEST_BASE_BROWSER_WITH_TEST_WINDOW_TEST_H_ |
| 7 | 7 |
| 8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/test/base/test_browser_window.h" | 13 #include "chrome/test/base/test_browser_window.h" |
| 14 #include "chrome/test/base/testing_profile.h" | 14 #include "chrome/test/base/testing_profile.h" |
| 15 #include "content/public/test/test_browser_thread_bundle.h" | 15 #include "content/public/test/test_browser_thread_bundle.h" |
| 16 #include "content/public/test/test_renderer_host.h" | 16 #include "content/public/test/test_renderer_host.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 18 |
| 19 #if defined(TOOLKIT_VIEWS) |
| 19 #if defined(OS_CHROMEOS) | 20 #if defined(OS_CHROMEOS) |
| 21 #include "ash/test/ash_test_helper.h" |
| 22 #include "ash/test/ash_test_views_delegate.h" |
| 20 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h" | 23 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h" |
| 21 #include "chrome/browser/chromeos/settings/cros_settings.h" | 24 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 22 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 25 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 26 #else |
| 27 #include "ui/views/test/scoped_views_test_helper.h" |
| 28 #endif |
| 23 #endif | 29 #endif |
| 24 | 30 |
| 25 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
| 26 #include "ui/base/win/scoped_ole_initializer.h" | 32 #include "ui/base/win/scoped_ole_initializer.h" |
| 27 #endif | 33 #endif |
| 28 | 34 |
| 29 class GURL; | 35 class GURL; |
| 30 | 36 |
| 37 #if defined(TOOLKIT_VIEWS) |
| 38 namespace views { |
| 39 class TestViewsDelegate; |
| 40 } |
| 31 #if defined(OS_CHROMEOS) | 41 #if defined(OS_CHROMEOS) |
| 32 namespace ash { | 42 namespace ash { |
| 33 namespace test { | 43 namespace test { |
| 34 class AshTestEnvironment; | 44 class AshTestEnvironment; |
| 35 class AshTestHelper; | |
| 36 } | 45 } |
| 37 } | 46 } |
| 38 #elif defined(TOOLKIT_VIEWS) | 47 #endif |
| 39 namespace views { | |
| 40 class ScopedViewsTestHelper; | |
| 41 } | |
| 42 #endif | 48 #endif |
| 43 | 49 |
| 44 namespace content { | 50 namespace content { |
| 45 class NavigationController; | 51 class NavigationController; |
| 46 } | 52 } |
| 47 | 53 |
| 48 // Base class for browser based unit tests. BrowserWithTestWindowTest creates a | 54 // Base class for browser based unit tests. BrowserWithTestWindowTest creates a |
| 49 // Browser with a TestingProfile and TestBrowserWindow. To add a tab use | 55 // Browser with a TestingProfile and TestBrowserWindow. To add a tab use |
| 50 // AddTab. For example, the following adds a tab and navigates to | 56 // AddTab. For example, the following adds a tab and navigates to |
| 51 // two URLs that target the TestWebContents: | 57 // two URLs that target the TestWebContents: |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 // value. Can return NULL to use the default window created by Browser. | 143 // value. Can return NULL to use the default window created by Browser. |
| 138 virtual BrowserWindow* CreateBrowserWindow(); | 144 virtual BrowserWindow* CreateBrowserWindow(); |
| 139 | 145 |
| 140 // Creates the browser given |profile|, |browser_type|, |hosted_app|, and | 146 // Creates the browser given |profile|, |browser_type|, |hosted_app|, and |
| 141 // |browser_window|. The caller owns the return value. | 147 // |browser_window|. The caller owns the return value. |
| 142 virtual Browser* CreateBrowser(Profile* profile, | 148 virtual Browser* CreateBrowser(Profile* profile, |
| 143 Browser::Type browser_type, | 149 Browser::Type browser_type, |
| 144 bool hosted_app, | 150 bool hosted_app, |
| 145 BrowserWindow* browser_window); | 151 BrowserWindow* browser_window); |
| 146 | 152 |
| 153 #if defined(TOOLKIT_VIEWS) |
| 154 views::TestViewsDelegate* test_views_delegate() { |
| 155 #if defined(OS_CHROMEOS) |
| 156 return ash_test_helper_->test_views_delegate(); |
| 157 #else |
| 158 return views_test_helper_->test_views_delegate(); |
| 159 #endif |
| 160 } |
| 161 #endif |
| 162 |
| 147 private: | 163 private: |
| 148 // We need to create a MessageLoop, otherwise a bunch of things fails. | 164 // We need to create a MessageLoop, otherwise a bunch of things fails. |
| 149 content::TestBrowserThreadBundle thread_bundle_; | 165 content::TestBrowserThreadBundle thread_bundle_; |
| 150 base::ShadowingAtExitManager at_exit_manager_; | 166 base::ShadowingAtExitManager at_exit_manager_; |
| 151 | 167 |
| 152 #if defined(OS_CHROMEOS) | 168 #if defined(OS_CHROMEOS) |
| 153 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 169 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
| 154 chromeos::ScopedTestCrosSettings test_cros_settings_; | 170 chromeos::ScopedTestCrosSettings test_cros_settings_; |
| 155 chromeos::ScopedTestUserManager test_user_manager_; | 171 chromeos::ScopedTestUserManager test_user_manager_; |
| 156 #endif | 172 #endif |
| (...skipping 23 matching lines...) Expand all Loading... |
| 180 // The type of browser to create (tabbed or popup). | 196 // The type of browser to create (tabbed or popup). |
| 181 Browser::Type browser_type_; | 197 Browser::Type browser_type_; |
| 182 | 198 |
| 183 // Whether the browser is part of a hosted app. | 199 // Whether the browser is part of a hosted app. |
| 184 bool hosted_app_; | 200 bool hosted_app_; |
| 185 | 201 |
| 186 DISALLOW_COPY_AND_ASSIGN(BrowserWithTestWindowTest); | 202 DISALLOW_COPY_AND_ASSIGN(BrowserWithTestWindowTest); |
| 187 }; | 203 }; |
| 188 | 204 |
| 189 #endif // CHROME_TEST_BASE_BROWSER_WITH_TEST_WINDOW_TEST_H_ | 205 #endif // CHROME_TEST_BASE_BROWSER_WITH_TEST_WINDOW_TEST_H_ |
| OLD | NEW |