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

Side by Side Diff: chrome/test/base/browser_with_test_window_test.h

Issue 1243033003: App Info: `View in Webstore` closes before navigating (not after) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Likely fix for CrOS Created 5 years, 4 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 (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"
11 #include "chrome/browser/ui/host_desktop.h" 11 #include "chrome/browser/ui/host_desktop.h"
12 #include "chrome/test/base/test_browser_window.h" 12 #include "chrome/test/base/test_browser_window.h"
13 #include "chrome/test/base/testing_profile.h" 13 #include "chrome/test/base/testing_profile.h"
14 #include "content/public/test/test_browser_thread_bundle.h" 14 #include "content/public/test/test_browser_thread_bundle.h"
15 #include "content/public/test/test_renderer_host.h" 15 #include "content/public/test/test_renderer_host.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 #if defined(OS_CHROMEOS) 18 #if defined(OS_CHROMEOS)
19 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h" 19 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h"
20 #include "chrome/browser/chromeos/settings/cros_settings.h" 20 #include "chrome/browser/chromeos/settings/cros_settings.h"
21 #include "chrome/browser/chromeos/settings/device_settings_service.h" 21 #include "chrome/browser/chromeos/settings/device_settings_service.h"
22 #endif 22 #endif
23 23
24 #if defined(OS_WIN) 24 #if defined(OS_WIN)
25 #include "ui/base/win/scoped_ole_initializer.h" 25 #include "ui/base/win/scoped_ole_initializer.h"
26 #endif 26 #endif
27 27
28 class GURL; 28 class GURL;
29 29
30 #if defined(USE_ASH) 30 #if defined(OS_CHROMEOS)
31 namespace ash { 31 namespace ash {
32 namespace test { 32 namespace test {
33 class AshTestHelper; 33 class AshTestHelper;
34 } 34 }
35 } 35 }
36 #endif 36 #elif defined(TOOLKIT_VIEWS)
37 37 namespace views {
38 #if defined(USE_AURA) 38 class ScopedViewsTestHelper;
39 namespace aura {
40 namespace test {
41 class AuraTestHelper;
42 }
43 } 39 }
44 #endif 40 #endif
45 41
46 #if defined(TOOLKIT_VIEWS)
47 namespace views {
48 class ViewsDelegate;
49 }
50 #endif
51
52 namespace content { 42 namespace content {
53 class NavigationController; 43 class NavigationController;
54 class WebContents; 44 class WebContents;
55 } 45 }
56 46
57 // Base class for browser based unit tests. BrowserWithTestWindowTest creates a 47 // Base class for browser based unit tests. BrowserWithTestWindowTest creates a
58 // Browser with a TestingProfile and TestBrowserWindow. To add a tab use 48 // Browser with a TestingProfile and TestBrowserWindow. To add a tab use
59 // AddTab. For example, the following adds a tab and navigates to 49 // AddTab. For example, the following adds a tab and navigates to
60 // two URLs that target the TestWebContents: 50 // two URLs that target the TestWebContents:
61 // 51 //
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 95 }
106 96
107 TestingProfile* profile() const { return profile_; } 97 TestingProfile* profile() const { return profile_; }
108 98
109 TestingProfile* GetProfile() { return profile_; } 99 TestingProfile* GetProfile() { return profile_; }
110 100
111 BrowserWindow* release_browser_window() WARN_UNUSED_RESULT { 101 BrowserWindow* release_browser_window() WARN_UNUSED_RESULT {
112 return window_.release(); 102 return window_.release();
113 } 103 }
114 104
105 // The context to help determine desktop type when creating new Widgets.
106 gfx::NativeWindow GetContext();
107
115 // Adds a tab to |browser| with the given URL and commits the load. 108 // Adds a tab to |browser| with the given URL and commits the load.
116 // This is a convenience function. The new tab will be added at index 0. 109 // This is a convenience function. The new tab will be added at index 0.
117 void AddTab(Browser* browser, const GURL& url); 110 void AddTab(Browser* browser, const GURL& url);
118 111
119 // Commits the pending load on the given controller. It will keep the 112 // Commits the pending load on the given controller. It will keep the
120 // URL of the pending load. If there is no pending load, this does nothing. 113 // URL of the pending load. If there is no pending load, this does nothing.
121 void CommitPendingLoad(content::NavigationController* controller); 114 void CommitPendingLoad(content::NavigationController* controller);
122 115
123 // Creates a pending navigation on the given navigation controller to the 116 // Creates a pending navigation on the given navigation controller to the
124 // given URL with the default parameters and the commits the load with a page 117 // given URL with the default parameters and the commits the load with a page
(...skipping 26 matching lines...) Expand all
151 144
152 // Creates the browser given |profile|, |browser_type|, |hosted_app|, 145 // Creates the browser given |profile|, |browser_type|, |hosted_app|,
153 // |host_desktop_type| and |browser_window|. The caller owns the return value. 146 // |host_desktop_type| and |browser_window|. The caller owns the return value.
154 virtual Browser* CreateBrowser(Profile* profile, 147 virtual Browser* CreateBrowser(Profile* profile,
155 Browser::Type browser_type, 148 Browser::Type browser_type,
156 bool hosted_app, 149 bool hosted_app,
157 chrome::HostDesktopType host_desktop_type, 150 chrome::HostDesktopType host_desktop_type,
158 BrowserWindow* browser_window); 151 BrowserWindow* browser_window);
159 152
160 private: 153 private:
161 #if !defined(OS_CHROMEOS) && defined(TOOLKIT_VIEWS)
162 // Creates the ViewsDelegate to use, may be overriden to create a different
163 // ViewsDelegate.
164 views::ViewsDelegate* CreateViewsDelegate();
165 #endif
166
167 // We need to create a MessageLoop, otherwise a bunch of things fails. 154 // We need to create a MessageLoop, otherwise a bunch of things fails.
168 content::TestBrowserThreadBundle thread_bundle_; 155 content::TestBrowserThreadBundle thread_bundle_;
169 base::ShadowingAtExitManager at_exit_manager_; 156 base::ShadowingAtExitManager at_exit_manager_;
170 157
171 #if defined(OS_CHROMEOS) 158 #if defined(OS_CHROMEOS)
172 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; 159 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_;
173 chromeos::ScopedTestCrosSettings test_cros_settings_; 160 chromeos::ScopedTestCrosSettings test_cros_settings_;
174 chromeos::ScopedTestUserManager test_user_manager_; 161 chromeos::ScopedTestUserManager test_user_manager_;
175 #endif 162 #endif
176 163
177 // The profile will automatically be destroyed by TearDown using the 164 // The profile will automatically be destroyed by TearDown using the
178 // |DestroyProfile()| function - which can be overwritten by derived testing 165 // |DestroyProfile()| function - which can be overwritten by derived testing
179 // frameworks. 166 // frameworks.
180 TestingProfile* profile_; 167 TestingProfile* profile_;
181 scoped_ptr<BrowserWindow> window_; // Usually a TestBrowserWindow. 168 scoped_ptr<BrowserWindow> window_; // Usually a TestBrowserWindow.
182 scoped_ptr<Browser> browser_; 169 scoped_ptr<Browser> browser_;
183 170
184 // The existence of this object enables tests via 171 // The existence of this object enables tests via
185 // RenderViewHostTester. 172 // RenderViewHostTester.
186 content::RenderViewHostTestEnabler rvh_test_enabler_; 173 content::RenderViewHostTestEnabler rvh_test_enabler_;
187 174
188 #if defined(USE_ASH) 175 #if defined(OS_CHROMEOS)
189 scoped_ptr<ash::test::AshTestHelper> ash_test_helper_; 176 scoped_ptr<ash::test::AshTestHelper> ash_test_helper_;
190 #endif 177 #elif defined(TOOLKIT_VIEWS)
191 #if defined(USE_AURA) 178 scoped_ptr<views::ScopedViewsTestHelper> views_test_helper_;
192 scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_;
193 #endif
194
195 #if defined(TOOLKIT_VIEWS)
196 scoped_ptr<views::ViewsDelegate> views_delegate_;
197 #endif 179 #endif
198 180
199 #if defined(OS_WIN) 181 #if defined(OS_WIN)
200 ui::ScopedOleInitializer ole_initializer_; 182 ui::ScopedOleInitializer ole_initializer_;
201 #endif 183 #endif
202 184
203 // The type of browser to create (tabbed or popup). 185 // The type of browser to create (tabbed or popup).
204 Browser::Type browser_type_; 186 Browser::Type browser_type_;
205 187
206 // The desktop to create the initial window on. 188 // The desktop to create the initial window on.
207 chrome::HostDesktopType host_desktop_type_; 189 chrome::HostDesktopType host_desktop_type_;
208 190
209 // Whether the browser is part of a hosted app. 191 // Whether the browser is part of a hosted app.
210 bool hosted_app_; 192 bool hosted_app_;
211 193
212 DISALLOW_COPY_AND_ASSIGN(BrowserWithTestWindowTest); 194 DISALLOW_COPY_AND_ASSIGN(BrowserWithTestWindowTest);
213 }; 195 };
214 196
215 #endif // CHROME_TEST_BASE_BROWSER_WITH_TEST_WINDOW_TEST_H_ 197 #endif // CHROME_TEST_BASE_BROWSER_WITH_TEST_WINDOW_TEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698