OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 void Release() {} | 49 void Release() {} |
50 static bool ImplementsThreadSafeReferenceCounting() { return false; } | 50 static bool ImplementsThreadSafeReferenceCounting() { return false; } |
51 | 51 |
52 // Configures everything for an in process browser test, then invokes | 52 // Configures everything for an in process browser test, then invokes |
53 // BrowserMain. BrowserMain ends up invoking RunTestOnMainThreadLoop. | 53 // BrowserMain. BrowserMain ends up invoking RunTestOnMainThreadLoop. |
54 virtual void SetUp(); | 54 virtual void SetUp(); |
55 | 55 |
56 // Restores state configured in SetUp. | 56 // Restores state configured in SetUp. |
57 virtual void TearDown(); | 57 virtual void TearDown(); |
58 | 58 |
59 // This method is used to decide if user data dir | |
60 // needs to be deleted or not. | |
61 virtual bool ShouldDeleteProfile() { return true; } | |
62 | |
63 protected: | 59 protected: |
64 // Returns the browser created by CreateBrowser. | 60 // Returns the browser created by CreateBrowser. |
65 Browser* browser() const { return browser_; } | 61 Browser* browser() const { return browser_; } |
66 | 62 |
67 // Override this rather than TestBody. | 63 // Override this rather than TestBody. |
68 virtual void RunTestOnMainThread() = 0; | 64 virtual void RunTestOnMainThread() = 0; |
69 | 65 |
| 66 // Helper to initialize the user data directory. Called by SetUp() after |
| 67 // erasing the user data directory, but before any browser is launched. |
| 68 // If a test wishes to set up some initial non-empty state in the user |
| 69 // data directory before the browser starts up, it can do so here. |
| 70 virtual void SetUpUserDataDirectory() {}; |
| 71 |
70 // We need these special methods because InProcessBrowserTest::SetUp is the | 72 // We need these special methods because InProcessBrowserTest::SetUp is the |
71 // bottom of the stack that winds up calling your test method, so it is not | 73 // bottom of the stack that winds up calling your test method, so it is not |
72 // always an option to do what you want by overriding it and calling the | 74 // always an option to do what you want by overriding it and calling the |
73 // superclass version. | 75 // superclass version. |
74 // | 76 // |
75 // Override this for things you would normally override SetUp for. It will be | 77 // Override this for things you would normally override SetUp for. It will be |
76 // called before your individual test fixture method is run, but after most | 78 // called before your individual test fixture method is run, but after most |
77 // of the overhead initialization has occured. | 79 // of the overhead initialization has occured. |
78 virtual void SetUpInProcessBrowserTestFixture() {} | 80 virtual void SetUpInProcessBrowserTestFixture() {} |
79 | 81 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>);\ | 194 GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>);\ |
193 void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::RunTestOnMainThread() | 195 void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::RunTestOnMainThread() |
194 | 196 |
195 #define IN_PROC_BROWSER_TEST_F(test_fixture, test_name)\ | 197 #define IN_PROC_BROWSER_TEST_F(test_fixture, test_name)\ |
196 IN_PROC_BROWSER_TEST_(test_fixture, test_name, test_fixture,\ | 198 IN_PROC_BROWSER_TEST_(test_fixture, test_name, test_fixture,\ |
197 ::testing::internal::GetTypeId<test_fixture>()) | 199 ::testing::internal::GetTypeId<test_fixture>()) |
198 | 200 |
199 #endif // defined(ALLOW_IN_PROC_BROWSER_TEST) | 201 #endif // defined(ALLOW_IN_PROC_BROWSER_TEST) |
200 | 202 |
201 #endif // CHROME_TEST_IN_PROCESS_BROWSER_TEST_H_ | 203 #endif // CHROME_TEST_IN_PROCESS_BROWSER_TEST_H_ |
OLD | NEW |