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/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 #endif | 36 #endif |
37 | 37 |
38 #if defined(USE_AURA) | 38 #if defined(USE_AURA) |
39 namespace aura { | 39 namespace aura { |
40 namespace test { | 40 namespace test { |
41 class AuraTestHelper; | 41 class AuraTestHelper; |
42 } | 42 } |
43 } | 43 } |
44 #endif | 44 #endif |
45 | 45 |
| 46 #if defined(TOOLKIT_VIEWS) |
| 47 namespace views { |
| 48 class ViewsDelegate; |
| 49 } |
| 50 #endif |
| 51 |
46 namespace content { | 52 namespace content { |
47 class NavigationController; | 53 class NavigationController; |
48 class WebContents; | 54 class WebContents; |
49 } | 55 } |
50 | 56 |
51 // Base class for browser based unit tests. BrowserWithTestWindowTest creates a | 57 // Base class for browser based unit tests. BrowserWithTestWindowTest creates a |
52 // Browser with a TestingProfile and TestBrowserWindow. To add a tab use | 58 // Browser with a TestingProfile and TestBrowserWindow. To add a tab use |
53 // AddTab. For example, the following adds a tab and navigates to | 59 // AddTab. For example, the following adds a tab and navigates to |
54 // two URLs that target the TestWebContents: | 60 // two URLs that target the TestWebContents: |
55 // | 61 // |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 // Creates the BrowserWindow used by this test. The caller owns the return | 146 // Creates the BrowserWindow used by this test. The caller owns the return |
141 // value. Can return NULL to use the default window created by Browser. | 147 // value. Can return NULL to use the default window created by Browser. |
142 virtual BrowserWindow* CreateBrowserWindow(); | 148 virtual BrowserWindow* CreateBrowserWindow(); |
143 | 149 |
144 // Creates the browser given |profile|, |host_desktop_type| and | 150 // Creates the browser given |profile|, |host_desktop_type| and |
145 // |browser_window|. The caller owns the return value. | 151 // |browser_window|. The caller owns the return value. |
146 virtual Browser* CreateBrowser(Profile* profile, | 152 virtual Browser* CreateBrowser(Profile* profile, |
147 chrome::HostDesktopType host_desktop_type, | 153 chrome::HostDesktopType host_desktop_type, |
148 BrowserWindow* browser_window); | 154 BrowserWindow* browser_window); |
149 | 155 |
| 156 #if defined(TOOLKIT_VIEWS) |
| 157 // Creates the ViewsDelegate to use, may be overriden to create a different |
| 158 // ViewsDelegate. |
| 159 virtual views::ViewsDelegate* CreateViewsDelegate(); |
| 160 #endif |
| 161 |
150 private: | 162 private: |
151 // We need to create a MessageLoop, otherwise a bunch of things fails. | 163 // We need to create a MessageLoop, otherwise a bunch of things fails. |
152 content::TestBrowserThreadBundle thread_bundle_; | 164 content::TestBrowserThreadBundle thread_bundle_; |
153 base::ShadowingAtExitManager at_exit_manager_; | 165 base::ShadowingAtExitManager at_exit_manager_; |
154 | 166 |
155 #if defined(OS_CHROMEOS) | 167 #if defined(OS_CHROMEOS) |
156 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 168 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
157 chromeos::ScopedTestCrosSettings test_cros_settings_; | 169 chromeos::ScopedTestCrosSettings test_cros_settings_; |
158 chromeos::ScopedTestUserManager test_user_manager_; | 170 chromeos::ScopedTestUserManager test_user_manager_; |
159 #endif | 171 #endif |
160 | 172 |
161 // The profile will automatically be destroyed by TearDown using the | 173 // The profile will automatically be destroyed by TearDown using the |
162 // |DestroyProfile()| function - which can be overwritten by derived testing | 174 // |DestroyProfile()| function - which can be overwritten by derived testing |
163 // frameworks. | 175 // frameworks. |
164 TestingProfile* profile_; | 176 TestingProfile* profile_; |
165 scoped_ptr<BrowserWindow> window_; // Usually a TestBrowserWindow. | 177 scoped_ptr<BrowserWindow> window_; // Usually a TestBrowserWindow. |
166 scoped_ptr<Browser> browser_; | 178 scoped_ptr<Browser> browser_; |
167 | 179 |
168 // The existence of this object enables tests via | 180 // The existence of this object enables tests via |
169 // RenderViewHostTester. | 181 // RenderViewHostTester. |
170 content::RenderViewHostTestEnabler rvh_test_enabler_; | 182 content::RenderViewHostTestEnabler rvh_test_enabler_; |
171 | 183 |
172 #if defined(USE_ASH) | 184 #if defined(USE_ASH) |
173 scoped_ptr<ash::test::AshTestHelper> ash_test_helper_; | 185 scoped_ptr<ash::test::AshTestHelper> ash_test_helper_; |
174 #endif | 186 #endif |
175 #if defined(USE_AURA) | 187 #if defined(USE_AURA) |
176 scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_; | 188 scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_; |
177 #endif | 189 #endif |
178 | 190 |
| 191 #if defined(TOOLKIT_VIEWS) |
| 192 scoped_ptr<views::ViewsDelegate> views_delegate_; |
| 193 #endif |
| 194 |
179 #if defined(OS_WIN) | 195 #if defined(OS_WIN) |
180 ui::ScopedOleInitializer ole_initializer_; | 196 ui::ScopedOleInitializer ole_initializer_; |
181 #endif | 197 #endif |
182 | 198 |
183 // The desktop to create the initial window on. | 199 // The desktop to create the initial window on. |
184 chrome::HostDesktopType host_desktop_type_; | 200 chrome::HostDesktopType host_desktop_type_; |
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 |