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

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

Issue 582493002: Enable accessibility testing for the bookmark browser test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Apply Feedback Created 5 years, 10 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_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 "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "content/public/browser/web_contents.h"
12 #include "content/public/test/browser_test.h" 13 #include "content/public/test/browser_test.h"
13 #include "content/public/test/browser_test_base.h" 14 #include "content/public/test/browser_test_base.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 #include "ui/base/page_transition_types.h" 16 #include "ui/base/page_transition_types.h"
16 17
17 namespace base { 18 namespace base {
18 19
19 class CommandLine; 20 class CommandLine;
20 21
21 #if defined(OS_MACOSX) 22 #if defined(OS_MACOSX)
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 ~InProcessBrowserTest() override; 98 ~InProcessBrowserTest() override;
98 99
99 // Configures everything for an in process browser test, then invokes 100 // Configures everything for an in process browser test, then invokes
100 // BrowserMain. BrowserMain ends up invoking RunTestOnMainThreadLoop. 101 // BrowserMain. BrowserMain ends up invoking RunTestOnMainThreadLoop.
101 void SetUp() override; 102 void SetUp() override;
102 103
103 // Restores state configured in SetUp. 104 // Restores state configured in SetUp.
104 void TearDown() override; 105 void TearDown() override;
105 106
106 protected: 107 protected:
108 // Constant for accessibility audit.
109 static const std::string kExpectedAccessibilityResults;
Jay Civelli 2015/02/05 23:29:09 Does it need to be part of the class?
hcarmona 2015/02/06 22:50:53 With the other change to make the parameter for th
110
107 // Returns the browser created by CreateBrowser. 111 // Returns the browser created by CreateBrowser.
108 Browser* browser() const { return browser_; } 112 Browser* browser() const { return browser_; }
109 113
110 // Convenience methods for adding tabs to a Browser. 114 // Convenience methods for adding tabs to a Browser.
111 void AddTabAtIndexToBrowser(Browser* browser, 115 void AddTabAtIndexToBrowser(Browser* browser,
112 int index, 116 int index,
113 const GURL& url, 117 const GURL& url,
114 ui::PageTransition transition, 118 ui::PageTransition transition,
115 bool check_navigation_success); 119 bool check_navigation_success);
116 void AddTabAtIndex(int index, 120 void AddTabAtIndex(int index,
(...skipping 24 matching lines...) Expand all
141 Browser* CreateBrowserForPopup(Profile* profile); 145 Browser* CreateBrowserForPopup(Profile* profile);
142 146
143 // Creates a browser for an application and waits for it to load and shows 147 // Creates a browser for an application and waits for it to load and shows
144 // the browser. 148 // the browser.
145 Browser* CreateBrowserForApp(const std::string& app_name, Profile* profile); 149 Browser* CreateBrowserForApp(const std::string& app_name, Profile* profile);
146 150
147 // Called from the various CreateBrowser methods to add a blank tab, wait for 151 // Called from the various CreateBrowser methods to add a blank tab, wait for
148 // the navigation to complete, and show the browser's window. 152 // the navigation to complete, and show the browser's window.
149 void AddBlankTabAndShow(Browser* browser); 153 void AddBlankTabAndShow(Browser* browser);
150 154
155 // Disables running of accessibility tests for a particular test case. This is
156 // only meaningful when called from IN_PROC_BROWSER_TEST_F to override the
157 // value of run_accessibility_checks_.
158 void DisableAccessibilityChecks();
Jay Civelli 2015/02/05 23:29:09 How about having only 1 method? SetAccessibilityCh
hcarmona 2015/02/06 22:50:53 I think it makes sense. Collapsed both of these in
159
160 // Enables running of accessibility tests for a particular test case. This is
161 // only meaningful when called from IN_PROC_BROWSER_TEST_F to override the
162 // value of run_accessibility_checks_.
163 void EnableAccessibilityChecks();
164
151 #if !defined OS_MACOSX 165 #if !defined OS_MACOSX
152 // Return a CommandLine object that is used to relaunch the browser_test 166 // Return a CommandLine object that is used to relaunch the browser_test
153 // binary as a browser process. This function is deliberately not defined on 167 // binary as a browser process. This function is deliberately not defined on
154 // the Mac because re-using an existing browser process when launching from 168 // the Mac because re-using an existing browser process when launching from
155 // the command line isn't a concept that we support on the Mac; AppleEvents 169 // the command line isn't a concept that we support on the Mac; AppleEvents
156 // are the Mac solution for the same need. Any test based on these functions 170 // are the Mac solution for the same need. Any test based on these functions
157 // doesn't apply to the Mac. 171 // doesn't apply to the Mac.
158 base::CommandLine GetCommandLineForRelaunch(); 172 base::CommandLine GetCommandLineForRelaunch();
159 #endif 173 #endif
160 174
(...skipping 10 matching lines...) Expand all
171 185
172 void set_open_about_blank_on_browser_launch(bool value) { 186 void set_open_about_blank_on_browser_launch(bool value) {
173 open_about_blank_on_browser_launch_ = value; 187 open_about_blank_on_browser_launch_ = value;
174 } 188 }
175 189
176 // This must be called before RunTestOnMainThreadLoop() to have any effect. 190 // This must be called before RunTestOnMainThreadLoop() to have any effect.
177 void set_multi_desktop_test(bool multi_desktop_test) { 191 void set_multi_desktop_test(bool multi_desktop_test) {
178 multi_desktop_test_ = multi_desktop_test; 192 multi_desktop_test_ = multi_desktop_test;
179 } 193 }
180 194
195 // This should be called in a sub-class constructor to enable/disable
196 // accessibility testing for all test cases.
197 void set_run_accessibility_checks(bool run_accessibility_checks) {
Jay Civelli 2015/02/05 23:29:09 I am a bit confused by this. You can either enable
hcarmona 2015/02/06 22:50:53 I think you're right and this is too confusing. I'
Jay Civelli 2015/02/07 01:11:12 This looks much better, thanks!
198 run_accessibility_checks_ = run_accessibility_checks;
199 }
200
201 // Will run accessibility checks and fail the test if there are any issues.
202 void RunAccessibilityChecks(std::string *test_result);
Jay Civelli 2015/02/05 23:29:09 std::string*
hcarmona 2015/02/06 22:50:53 Done.
203
181 private: 204 private:
182 // Creates a user data directory for the test if one is needed. Returns true 205 // Creates a user data directory for the test if one is needed. Returns true
183 // if successful. 206 // if successful.
184 virtual bool CreateUserDataDirectory() WARN_UNUSED_RESULT; 207 virtual bool CreateUserDataDirectory() WARN_UNUSED_RESULT;
185 208
186 // Quits all open browsers and waits until there are no more browsers. 209 // Quits all open browsers and waits until there are no more browsers.
187 void QuitBrowsers(); 210 void QuitBrowsers();
188 211
189 // Prepare command line that will be used to launch the child browser process 212 // Prepare command line that will be used to launch the child browser process
190 // with an in-process test. 213 // with an in-process test.
191 void PrepareTestCommandLine(base::CommandLine* command_line); 214 void PrepareTestCommandLine(base::CommandLine* command_line);
192 215
216 // This method loads the javascript accessibility library.
217 // Returns false on loading error. Accessibility audit will fail if library is
Jay Civelli 2015/02/05 23:29:09 Should it just assert if it fails to load?
hcarmona 2015/02/06 22:50:53 Only called one place. Moved this method's content
218 // not loaded.
219 bool LoadAccessibilityLibrary(content::WebContents* web_contents)
220 WARN_UNUSED_RESULT;
221
193 // Browser created from CreateBrowser. 222 // Browser created from CreateBrowser.
194 Browser* browser_; 223 Browser* browser_;
195 224
196 // Temporary user data directory. Used only when a user data directory is not 225 // Temporary user data directory. Used only when a user data directory is not
197 // specified in the command line. 226 // specified in the command line.
198 base::ScopedTempDir temp_user_data_dir_; 227 base::ScopedTempDir temp_user_data_dir_;
199 228
200 // True if we should exit the tests after the last browser instance closes. 229 // True if we should exit the tests after the last browser instance closes.
201 bool exit_when_last_browser_closes_; 230 bool exit_when_last_browser_closes_;
202 231
203 // True if the about:blank tab should be opened when the browser is launched. 232 // True if the about:blank tab should be opened when the browser is launched.
204 bool open_about_blank_on_browser_launch_; 233 bool open_about_blank_on_browser_launch_;
205 234
206 // True if this is a multi-desktop test (in which case this browser test will 235 // True if this is a multi-desktop test (in which case this browser test will
207 // not ensure that Browsers are only created on the tested desktop). 236 // not ensure that Browsers are only created on the tested desktop).
208 bool multi_desktop_test_; 237 bool multi_desktop_test_;
209 238
239 // True if the accessibility tests should be run.
240 bool run_accessibility_checks_;
241
242 // True if the accessibility test should run for a particular test case.
243 // This is reset for every test case.
244 bool run_accessibility_checks_for_test_case_;
245
210 #if defined(OS_MACOSX) 246 #if defined(OS_MACOSX)
211 base::mac::ScopedNSAutoreleasePool* autorelease_pool_; 247 base::mac::ScopedNSAutoreleasePool* autorelease_pool_;
212 #endif // OS_MACOSX 248 #endif // OS_MACOSX
213 249
214 #if defined(OS_WIN) 250 #if defined(OS_WIN)
215 scoped_ptr<base::win::ScopedCOMInitializer> com_initializer_; 251 scoped_ptr<base::win::ScopedCOMInitializer> com_initializer_;
216 #endif 252 #endif
217 }; 253 };
218 254
219 #endif // CHROME_TEST_BASE_IN_PROCESS_BROWSER_TEST_H_ 255 #endif // CHROME_TEST_BASE_IN_PROCESS_BROWSER_TEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698