| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_IN_PROCESS_BROWSER_TEST_H_ | 5 #ifndef CHROME_TEST_IN_PROCESS_BROWSER_TEST_H_ |
| 6 #define CHROME_TEST_IN_PROCESS_BROWSER_TEST_H_ | 6 #define CHROME_TEST_IN_PROCESS_BROWSER_TEST_H_ |
| 7 | 7 |
| 8 #include "net/url_request/url_request_unittest.h" | 8 #include "net/url_request/url_request_unittest.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| 11 class Browser; | 11 class Browser; |
| 12 class Profile; | 12 class Profile; |
| 13 namespace net { | 13 namespace net { |
| 14 class RuleBasedHostMapper; | 14 class RuleBasedHostResolverProc; |
| 15 } | 15 } |
| 16 | 16 |
| 17 // Base class for tests wanting to bring up a browser in the unit test process. | 17 // Base class for tests wanting to bring up a browser in the unit test process. |
| 18 // Writing tests with InProcessBrowserTest is slightly different than that of | 18 // Writing tests with InProcessBrowserTest is slightly different than that of |
| 19 // other tests. This is necessitated by InProcessBrowserTest running a message | 19 // other tests. This is necessitated by InProcessBrowserTest running a message |
| 20 // loop. To use InProcessBrowserTest do the following: | 20 // loop. To use InProcessBrowserTest do the following: |
| 21 // . Use the macro IN_PROC_BROWSER_TEST_F to define your test. | 21 // . Use the macro IN_PROC_BROWSER_TEST_F to define your test. |
| 22 // . Your test method is invoked on the ui thread. If you need to block until | 22 // . Your test method is invoked on the ui thread. If you need to block until |
| 23 // state changes you'll need to run the message loop from your test method. | 23 // state changes you'll need to run the message loop from your test method. |
| 24 // For example, if you need to wait till a find bar has completely been shown | 24 // For example, if you need to wait till a find bar has completely been shown |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 // Override this rather than TestBody. | 59 // Override this rather than TestBody. |
| 60 virtual void RunTestOnMainThread() = 0; | 60 virtual void RunTestOnMainThread() = 0; |
| 61 | 61 |
| 62 // Override this to add command line flags specific to your test. | 62 // Override this to add command line flags specific to your test. |
| 63 virtual void SetUpCommandLine(CommandLine* command_line) {} | 63 virtual void SetUpCommandLine(CommandLine* command_line) {} |
| 64 | 64 |
| 65 // Override this to add any custom cleanup code that needs to be done on the | 65 // Override this to add any custom cleanup code that needs to be done on the |
| 66 // main thread before the browser is torn down. | 66 // main thread before the browser is torn down. |
| 67 virtual void CleanUpOnMainThread() {} | 67 virtual void CleanUpOnMainThread() {} |
| 68 | 68 |
| 69 // Allows subclasses to configure the host mapper. By default this blocks | 69 // Allows subclasses to configure the host resolver procedure. By default |
| 70 // requests to google.com as Chrome pings that on startup and we don't want to | 70 // this blocks requests to google.com as Chrome pings that on startup and we |
| 71 // do that during testing. | 71 // don't want to do that during testing. |
| 72 virtual void ConfigureHostMapper(net::RuleBasedHostMapper* host_mapper); | 72 virtual void ConfigureHostResolverProc(net::RuleBasedHostResolverProc* proc); |
| 73 | 73 |
| 74 // Invoked when a test is not finishing in a timely manner. | 74 // Invoked when a test is not finishing in a timely manner. |
| 75 void TimedOut(); | 75 void TimedOut(); |
| 76 | 76 |
| 77 // Sets Initial Timeout value. | 77 // Sets Initial Timeout value. |
| 78 void SetInitialTimeoutInMS(int initial_timeout); | 78 void SetInitialTimeoutInMS(int initial_timeout); |
| 79 | 79 |
| 80 // Starts an HTTP server. | 80 // Starts an HTTP server. |
| 81 HTTPTestServer* StartHTTPServer(); | 81 HTTPTestServer* StartHTTPServer(); |
| 82 | 82 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 parent_class::TearDownTestCase, \ | 150 parent_class::TearDownTestCase, \ |
| 151 new ::testing::internal::TestFactoryImpl<\ | 151 new ::testing::internal::TestFactoryImpl<\ |
| 152 GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>);\ | 152 GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>);\ |
| 153 void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::RunTestOnMainThread() | 153 void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::RunTestOnMainThread() |
| 154 | 154 |
| 155 #define IN_PROC_BROWSER_TEST_F(test_fixture, test_name)\ | 155 #define IN_PROC_BROWSER_TEST_F(test_fixture, test_name)\ |
| 156 IN_PROC_BROWSER_TEST_(test_fixture, test_name, test_fixture,\ | 156 IN_PROC_BROWSER_TEST_(test_fixture, test_name, test_fixture,\ |
| 157 ::testing::internal::GetTypeId<test_fixture>()) | 157 ::testing::internal::GetTypeId<test_fixture>()) |
| 158 | 158 |
| 159 #endif // CHROME_TEST_IN_PROCESS_BROWSER_TEST_H_ | 159 #endif // CHROME_TEST_IN_PROCESS_BROWSER_TEST_H_ |
| OLD | NEW |