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

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

Issue 2285023003: Ensures the first browser in each interactive_ui_test is in the foreground (Closed)
Patch Set: feedback Created 4 years, 3 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
« no previous file with comments | « no previous file | chrome/test/base/in_process_browser_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_IN_PROCESS_BROWSER_TEST_H_ 5 #ifndef CHROME_TEST_BASE_IN_PROCESS_BROWSER_TEST_H_
6 #define CHROME_TEST_BASE_IN_PROCESS_BROWSER_TEST_H_ 6 #define CHROME_TEST_BASE_IN_PROCESS_BROWSER_TEST_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 InProcessBrowserTest(); 111 InProcessBrowserTest();
112 ~InProcessBrowserTest() override; 112 ~InProcessBrowserTest() override;
113 113
114 // Configures everything for an in process browser test, then invokes 114 // Configures everything for an in process browser test, then invokes
115 // BrowserMain. BrowserMain ends up invoking RunTestOnMainThreadLoop. 115 // BrowserMain. BrowserMain ends up invoking RunTestOnMainThreadLoop.
116 void SetUp() override; 116 void SetUp() override;
117 117
118 // Restores state configured in SetUp. 118 // Restores state configured in SetUp.
119 void TearDown() override; 119 void TearDown() override;
120 120
121 using SetUpBrowserFunction = bool(const Browser*);
122
123 // Sets a function that is called from InProcessBrowserTest::SetUp() with the
124 // first browser. This is intended to set up state applicable to all tests
125 // in the suite. For example, interactive_ui_tests installs a function that
126 // ensures the first browser is in the foreground, active and has focus.
127 static void set_global_browser_set_up_function(
128 SetUpBrowserFunction* set_up_function) {
129 global_browser_set_up_function_ = set_up_function;
130 }
131
121 protected: 132 protected:
122 // Returns the browser created by CreateBrowser. 133 // Returns the browser created by CreateBrowser.
123 Browser* browser() const { return browser_; } 134 Browser* browser() const { return browser_; }
124 135
125 // Closes the given browser and waits for it to release all its resources. 136 // Closes the given browser and waits for it to release all its resources.
126 void CloseBrowserSynchronously(Browser* browser); 137 void CloseBrowserSynchronously(Browser* browser);
127 138
128 // Closes the browser without waiting for it to release all its resources. 139 // Closes the browser without waiting for it to release all its resources.
129 // WARNING: This may leave tasks posted, but not yet run, in the message 140 // WARNING: This may leave tasks posted, but not yet run, in the message
130 // loops. Prefer CloseBrowserSynchronously over this method. 141 // loops. Prefer CloseBrowserSynchronously over this method.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 bool RunAccessibilityChecks(std::string* error_message); 238 bool RunAccessibilityChecks(std::string* error_message);
228 239
229 private: 240 private:
230 // Creates a user data directory for the test if one is needed. Returns true 241 // Creates a user data directory for the test if one is needed. Returns true
231 // if successful. 242 // if successful.
232 virtual bool CreateUserDataDirectory() WARN_UNUSED_RESULT; 243 virtual bool CreateUserDataDirectory() WARN_UNUSED_RESULT;
233 244
234 // Quits all open browsers and waits until there are no more browsers. 245 // Quits all open browsers and waits until there are no more browsers.
235 void QuitBrowsers(); 246 void QuitBrowsers();
236 247
248 static SetUpBrowserFunction* global_browser_set_up_function_;
249
237 // Browser created from CreateBrowser. 250 // Browser created from CreateBrowser.
238 Browser* browser_; 251 Browser* browser_;
239 252
240 // Temporary user data directory. Used only when a user data directory is not 253 // Temporary user data directory. Used only when a user data directory is not
241 // specified in the command line. 254 // specified in the command line.
242 base::ScopedTempDir temp_user_data_dir_; 255 base::ScopedTempDir temp_user_data_dir_;
243 256
244 // True if we should exit the tests after the last browser instance closes. 257 // True if we should exit the tests after the last browser instance closes.
245 bool exit_when_last_browser_closes_; 258 bool exit_when_last_browser_closes_;
246 259
247 // True if the about:blank tab should be opened when the browser is launched. 260 // True if the about:blank tab should be opened when the browser is launched.
248 bool open_about_blank_on_browser_launch_; 261 bool open_about_blank_on_browser_launch_;
249 262
250 // True if the accessibility test should run for a particular test case. 263 // True if the accessibility test should run for a particular test case.
251 // This is reset for every test case. 264 // This is reset for every test case.
252 bool run_accessibility_checks_for_test_case_; 265 bool run_accessibility_checks_for_test_case_;
253 266
254 #if defined(OS_MACOSX) 267 #if defined(OS_MACOSX)
255 base::mac::ScopedNSAutoreleasePool* autorelease_pool_; 268 base::mac::ScopedNSAutoreleasePool* autorelease_pool_;
256 std::unique_ptr<ScopedBundleSwizzlerMac> bundle_swizzler_; 269 std::unique_ptr<ScopedBundleSwizzlerMac> bundle_swizzler_;
257 #endif // OS_MACOSX 270 #endif // OS_MACOSX
258 271
259 #if defined(OS_WIN) 272 #if defined(OS_WIN)
260 std::unique_ptr<base::win::ScopedCOMInitializer> com_initializer_; 273 std::unique_ptr<base::win::ScopedCOMInitializer> com_initializer_;
261 #endif 274 #endif
262 }; 275 };
263 276
264 #endif // CHROME_TEST_BASE_IN_PROCESS_BROWSER_TEST_H_ 277 #endif // CHROME_TEST_BASE_IN_PROCESS_BROWSER_TEST_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/test/base/in_process_browser_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698