| 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_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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   53 //   state changes you'll need to run the message loop from your test method. |   53 //   state changes you'll need to run the message loop from your test method. | 
|   54 //   For example, if you need to wait till a find bar has completely been shown |   54 //   For example, if you need to wait till a find bar has completely been shown | 
|   55 //   you'll need to invoke content::RunMessageLoop. When the message bar is |   55 //   you'll need to invoke content::RunMessageLoop. When the message bar is | 
|   56 //   shown, invoke MessageLoop::current()->QuitWhenIdle() to return control back |   56 //   shown, invoke MessageLoop::current()->QuitWhenIdle() to return control back | 
|   57 //   to your test method. |   57 //   to your test method. | 
|   58 // . If you subclass and override SetUp, be sure and invoke |   58 // . If you subclass and override SetUp, be sure and invoke | 
|   59 //   InProcessBrowserTest::SetUp. (But see also SetUpOnMainThread, |   59 //   InProcessBrowserTest::SetUp. (But see also SetUpOnMainThread, | 
|   60 //   SetUpInProcessBrowserTestFixture and other related hook methods for a |   60 //   SetUpInProcessBrowserTestFixture and other related hook methods for a | 
|   61 //   cleaner alternative). |   61 //   cleaner alternative). | 
|   62 // |   62 // | 
|   63 // Following three hook methods are called in sequence before calling |   63 // The following four hook methods are called in sequence before calling | 
|   64 // BrowserMain(), thus no browser has been created yet. They are mainly for |   64 // BrowserMain(), thus no browser has been created yet. They are mainly for | 
|   65 // setting up the environment for running the browser. |   65 // setting up the environment for running the browser. | 
|   66 // . SetUpUserDataDirectory() |   66 // . SetUpUserDataDirectory() | 
|   67 // . SetUpCommandLine() |   67 // . SetUpCommandLine() | 
 |   68 // . SetUpDefaultCommandLine() | 
|   68 // . SetUpInProcessBrowserTestFixture() |   69 // . SetUpInProcessBrowserTestFixture() | 
|   69 // |   70 // | 
 |   71 // Default command line switches are added in the default implementation of | 
 |   72 // SetUpDefaultCommandLine(). Addtional command line switches can be simply | 
 |   73 // appended in SetUpCommandLine() without the need to invoke | 
 |   74 // InProcessBrowserTest::SetUpCommandLine(). If a test needs to change the | 
 |   75 // default command line, it can override SetUpDefaultCommandLine(), where it | 
 |   76 // should invoke InProcessBrowserTest::SetUpDefaultCommandLine() to get the | 
 |   77 // default swtiches, and modify them as needed. | 
 |   78 // | 
|   70 // SetUpOnMainThread() is called just after creating the default browser object |   79 // SetUpOnMainThread() is called just after creating the default browser object | 
|   71 // and before executing the real test code. It's mainly for setting up things |   80 // and before executing the real test code. It's mainly for setting up things | 
|   72 // related to the browser object and associated window, like opening a new Tab |   81 // related to the browser object and associated window, like opening a new Tab | 
|   73 // with a testing page loaded. |   82 // with a testing page loaded. | 
|   74 // |   83 // | 
|   75 // TearDownOnMainThread() is called just after executing the real test code to |   84 // TearDownOnMainThread() is called just after executing the real test code to | 
|   76 // do necessary cleanup before the browser is torn down. |   85 // do necessary cleanup before the browser is torn down. | 
|   77 // |   86 // | 
|   78 // TearDownInProcessBrowserTestFixture() is called after BrowserMain() exits to |   87 // TearDownInProcessBrowserTestFixture() is called after BrowserMain() exits to | 
|   79 // cleanup things setup for running the browser. |   88 // cleanup things setup for running the browser. | 
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  128   // Convenience methods for adding tabs to a Browser. |  137   // Convenience methods for adding tabs to a Browser. | 
|  129   void AddTabAtIndexToBrowser(Browser* browser, |  138   void AddTabAtIndexToBrowser(Browser* browser, | 
|  130                               int index, |  139                               int index, | 
|  131                               const GURL& url, |  140                               const GURL& url, | 
|  132                               ui::PageTransition transition, |  141                               ui::PageTransition transition, | 
|  133                               bool check_navigation_success); |  142                               bool check_navigation_success); | 
|  134   void AddTabAtIndex(int index, |  143   void AddTabAtIndex(int index, | 
|  135                      const GURL& url, |  144                      const GURL& url, | 
|  136                      ui::PageTransition transition); |  145                      ui::PageTransition transition); | 
|  137  |  146  | 
 |  147   // Setups default command line that will be used to launch the child browser | 
 |  148   // process with an in-process test. Called by SetUp() after SetupCommandLine() | 
 |  149   // to add default commandline switches. A default implementation is provided | 
 |  150   // in this class. If a test does not want to use the default implementation, | 
 |  151   // it should override this method. | 
 |  152   virtual void SetUpDefaultCommandLine(base::CommandLine* command_line); | 
 |  153  | 
|  138   // Initializes the contents of the user data directory. Called by SetUp() |  154   // Initializes the contents of the user data directory. Called by SetUp() | 
|  139   // after creating the user data directory, but before any browser is launched. |  155   // after creating the user data directory, but before any browser is launched. | 
|  140   // If a test wishes to set up some initial non-empty state in the user data |  156   // If a test wishes to set up some initial non-empty state in the user data | 
|  141   // directory before the browser starts up, it can do so here. Returns true if |  157   // directory before the browser starts up, it can do so here. Returns true if | 
|  142   // successful. |  158   // successful. | 
|  143   virtual bool SetUpUserDataDirectory() WARN_UNUSED_RESULT; |  159   virtual bool SetUpUserDataDirectory() WARN_UNUSED_RESULT; | 
|  144  |  160  | 
|  145   // BrowserTestBase: |  161   // BrowserTestBase: | 
|  146   void RunTestOnMainThreadLoop() override; |  162   void RunTestOnMainThreadLoop() override; | 
|  147  |  163  | 
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  200 #endif  // OS_MACOSX |  216 #endif  // OS_MACOSX | 
|  201  |  217  | 
|  202   void set_exit_when_last_browser_closes(bool value) { |  218   void set_exit_when_last_browser_closes(bool value) { | 
|  203     exit_when_last_browser_closes_ = value; |  219     exit_when_last_browser_closes_ = value; | 
|  204   } |  220   } | 
|  205  |  221  | 
|  206   void set_open_about_blank_on_browser_launch(bool value) { |  222   void set_open_about_blank_on_browser_launch(bool value) { | 
|  207     open_about_blank_on_browser_launch_ = value; |  223     open_about_blank_on_browser_launch_ = value; | 
|  208   } |  224   } | 
|  209  |  225  | 
|  210   // This must be called before RunTestOnMainThreadLoop() to have any effect. |  | 
|  211   void set_multi_desktop_test(bool multi_desktop_test) { |  | 
|  212     multi_desktop_test_ = multi_desktop_test; |  | 
|  213   } |  | 
|  214  |  | 
|  215   // Runs accessibility checks and sets |error_message| if it fails. |  226   // Runs accessibility checks and sets |error_message| if it fails. | 
|  216   bool RunAccessibilityChecks(std::string* error_message); |  227   bool RunAccessibilityChecks(std::string* error_message); | 
|  217  |  228  | 
|  218  private: |  229  private: | 
|  219   // Creates a user data directory for the test if one is needed. Returns true |  230   // Creates a user data directory for the test if one is needed. Returns true | 
|  220   // if successful. |  231   // if successful. | 
|  221   virtual bool CreateUserDataDirectory() WARN_UNUSED_RESULT; |  232   virtual bool CreateUserDataDirectory() WARN_UNUSED_RESULT; | 
|  222  |  233  | 
|  223   // Quits all open browsers and waits until there are no more browsers. |  234   // Quits all open browsers and waits until there are no more browsers. | 
|  224   void QuitBrowsers(); |  235   void QuitBrowsers(); | 
|  225  |  236  | 
|  226   // Prepare command line that will be used to launch the child browser process |  | 
|  227   // with an in-process test. |  | 
|  228   void PrepareTestCommandLine(base::CommandLine* command_line); |  | 
|  229  |  | 
|  230   // Browser created from CreateBrowser. |  237   // Browser created from CreateBrowser. | 
|  231   Browser* browser_; |  238   Browser* browser_; | 
|  232  |  239  | 
|  233   // Temporary user data directory. Used only when a user data directory is not |  240   // Temporary user data directory. Used only when a user data directory is not | 
|  234   // specified in the command line. |  241   // specified in the command line. | 
|  235   base::ScopedTempDir temp_user_data_dir_; |  242   base::ScopedTempDir temp_user_data_dir_; | 
|  236  |  243  | 
|  237   // True if we should exit the tests after the last browser instance closes. |  244   // True if we should exit the tests after the last browser instance closes. | 
|  238   bool exit_when_last_browser_closes_; |  245   bool exit_when_last_browser_closes_; | 
|  239  |  246  | 
|  240   // True if the about:blank tab should be opened when the browser is launched. |  247   // True if the about:blank tab should be opened when the browser is launched. | 
|  241   bool open_about_blank_on_browser_launch_; |  248   bool open_about_blank_on_browser_launch_; | 
|  242  |  249  | 
|  243   // True if this is a multi-desktop test (in which case this browser test will |  | 
|  244   // not ensure that Browsers are only created on the tested desktop). |  | 
|  245   bool multi_desktop_test_; |  | 
|  246  |  | 
|  247   // True if the accessibility test should run for a particular test case. |  250   // True if the accessibility test should run for a particular test case. | 
|  248   // This is reset for every test case. |  251   // This is reset for every test case. | 
|  249   bool run_accessibility_checks_for_test_case_; |  252   bool run_accessibility_checks_for_test_case_; | 
|  250  |  253  | 
|  251 #if defined(OS_MACOSX) |  254 #if defined(OS_MACOSX) | 
|  252   base::mac::ScopedNSAutoreleasePool* autorelease_pool_; |  255   base::mac::ScopedNSAutoreleasePool* autorelease_pool_; | 
|  253   std::unique_ptr<ScopedBundleSwizzlerMac> bundle_swizzler_; |  256   std::unique_ptr<ScopedBundleSwizzlerMac> bundle_swizzler_; | 
|  254 #endif  // OS_MACOSX |  257 #endif  // OS_MACOSX | 
|  255  |  258  | 
|  256 #if defined(OS_WIN) |  259 #if defined(OS_WIN) | 
|  257   std::unique_ptr<base::win::ScopedCOMInitializer> com_initializer_; |  260   std::unique_ptr<base::win::ScopedCOMInitializer> com_initializer_; | 
|  258 #endif |  261 #endif | 
|  259 }; |  262 }; | 
|  260  |  263  | 
|  261 #endif  // CHROME_TEST_BASE_IN_PROCESS_BROWSER_TEST_H_ |  264 #endif  // CHROME_TEST_BASE_IN_PROCESS_BROWSER_TEST_H_ | 
| OLD | NEW |