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 CONTENT_TEST_BROWSER_TEST_BASE_H_ | 5 #ifndef CONTENT_TEST_BROWSER_TEST_BASE_H_ |
6 #define CONTENT_TEST_BROWSER_TEST_BASE_H_ | 6 #define CONTENT_TEST_BROWSER_TEST_BASE_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
| 11 class CommandLine; |
| 12 |
11 class BrowserTestBase : public testing::Test { | 13 class BrowserTestBase : public testing::Test { |
12 public: | 14 public: |
13 BrowserTestBase(); | 15 BrowserTestBase(); |
14 virtual ~BrowserTestBase(); | 16 virtual ~BrowserTestBase(); |
15 | 17 |
16 // We do this so we can be used in a Task. | 18 // We do this so we can be used in a Task. |
17 void AddRef() {} | 19 void AddRef() {} |
18 void Release() {} | 20 void Release() {} |
19 static bool ImplementsThreadSafeReferenceCounting() { return false; } | 21 static bool ImplementsThreadSafeReferenceCounting() { return false; } |
20 | 22 |
21 // Configures everything for an in process browser test, then invokes | 23 // Configures everything for an in process browser test, then invokes |
22 // BrowserMain. BrowserMain ends up invoking RunTestOnMainThreadLoop. | 24 // BrowserMain. BrowserMain ends up invoking RunTestOnMainThreadLoop. |
23 virtual void SetUp() OVERRIDE; | 25 virtual void SetUp() OVERRIDE; |
24 | 26 |
25 // Restores state configured in SetUp. | 27 // Restores state configured in SetUp. |
26 virtual void TearDown() OVERRIDE; | 28 virtual void TearDown() OVERRIDE; |
27 | 29 |
| 30 // Override this to add any custom setup code that needs to be done on the |
| 31 // main thread after the browser is created and just before calling |
| 32 // RunTestOnMainThread(). |
| 33 virtual void SetUpOnMainThread() {} |
| 34 |
| 35 // Override this to add command line flags specific to your test. |
| 36 virtual void SetUpCommandLine(CommandLine* command_line) {} |
| 37 |
28 protected: | 38 protected: |
29 // We need these special methods because SetUp is the bottom of the stack | 39 // We need these special methods because SetUp is the bottom of the stack |
30 // that winds up calling your test method, so it is not always an option | 40 // that winds up calling your test method, so it is not always an option |
31 // to do what you want by overriding it and calling the superclass version. | 41 // to do what you want by overriding it and calling the superclass version. |
32 // | 42 // |
33 // Override this for things you would normally override SetUp for. It will be | 43 // Override this for things you would normally override SetUp for. It will be |
34 // called before your individual test fixture method is run, but after most | 44 // called before your individual test fixture method is run, but after most |
35 // of the overhead initialization has occured. | 45 // of the overhead initialization has occured. |
36 virtual void SetUpInProcessBrowserTestFixture() {} | 46 virtual void SetUpInProcessBrowserTestFixture() {} |
37 | 47 |
38 // Override this for things you would normally override TearDown for. | 48 // Override this for things you would normally override TearDown for. |
39 virtual void TearDownInProcessBrowserTestFixture() {} | 49 virtual void TearDownInProcessBrowserTestFixture() {} |
40 | 50 |
41 // Override this rather than TestBody. | 51 // Override this rather than TestBody. |
42 virtual void RunTestOnMainThread() = 0; | 52 virtual void RunTestOnMainThread() = 0; |
43 | 53 |
44 // This is invoked from main after browser_init/browser_main have completed. | 54 // This is invoked from main after browser_init/browser_main have completed. |
45 // This prepares for the test by creating a new browser, runs the test | 55 // This prepares for the test by creating a new browser, runs the test |
46 // (RunTestOnMainThread), quits the browsers and returns. | 56 // (RunTestOnMainThread), quits the browsers and returns. |
47 virtual void RunTestOnMainThreadLoop() = 0; | 57 virtual void RunTestOnMainThreadLoop() = 0; |
48 | 58 |
49 private: | 59 private: |
50 void ProxyRunTestOnMainThreadLoop(); | 60 void ProxyRunTestOnMainThreadLoop(); |
51 }; | 61 }; |
52 | 62 |
53 #endif // CONTENT_TEST_BROWSER_TEST_BASE_H_ | 63 #endif // CONTENT_TEST_BROWSER_TEST_BASE_H_ |
OLD | NEW |