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_PUBLIC_TEST_BROWSER_TEST_BASE_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_BROWSER_TEST_BASE_H_ |
6 #define CONTENT_PUBLIC_TEST_BROWSER_TEST_BASE_H_ | 6 #define CONTENT_PUBLIC_TEST_BROWSER_TEST_BASE_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/scoped_vector.h" | |
10 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
11 #include "net/test/spawned_test_server/spawned_test_server.h" | 12 #include "net/test/spawned_test_server/spawned_test_server.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
13 | 14 |
14 namespace base { | 15 namespace base { |
15 class CommandLine; | 16 class CommandLine; |
16 class FilePath; | 17 class FilePath; |
17 } | 18 } |
18 | 19 |
19 namespace net { | 20 namespace net { |
20 namespace test_server { | 21 namespace test_server { |
21 class EmbeddedTestServer; | 22 class EmbeddedTestServer; |
22 } | 23 } |
23 | 24 |
24 class RuleBasedHostResolverProc; | 25 class RuleBasedHostResolverProc; |
25 } // namespace net | 26 } // namespace net |
26 | 27 |
27 namespace content { | 28 namespace content { |
28 | 29 |
29 class BrowserTestBase : public testing::Test { | 30 class BrowserTestBase : public testing::Test { |
30 public: | 31 public: |
32 // Class that can be used to add some features not related directly | |
33 // to the testing process and do set ups needed for them in proper time. | |
34 // To do this you need to derive Admixture, implement | |
35 // all the methods you need there and (if needed) reload set ups and tear | |
36 // downs | |
37 // for things that you would usually do in those of the test, but which are | |
38 // connected | |
39 // to the admixture, not to the test itself. | |
40 // Finally, AddAdmixture() should be called in the test's constructor for each | |
41 // Admixture. | |
42 class Admixture { | |
43 public: | |
44 Admixture() {} | |
45 virtual ~Admixture() {} | |
46 virtual void SetUpCommandLine(base::CommandLine* command_line) {} | |
47 virtual void SetUpOnMainThread() {} | |
48 virtual void SetUpInProcessBrowserTestFixture() {} | |
49 virtual void TearDownOnMainThread() {} | |
50 virtual void TearDownInProcessBrowserTestFixture() {} | |
dzhioev (left Google)
2014/08/18 12:11:46
You forgot to add TearDown* calls in appropriate p
Lisa Ignatyeva
2014/08/18 12:20:41
Done.
| |
51 }; | |
52 | |
31 BrowserTestBase(); | 53 BrowserTestBase(); |
32 virtual ~BrowserTestBase(); | 54 virtual ~BrowserTestBase(); |
33 | 55 |
34 // We do this so we can be used in a Task. | 56 // We do this so we can be used in a Task. |
35 void AddRef() {} | 57 void AddRef() {} |
36 void Release() {} | 58 void Release() {} |
37 | 59 |
38 // Configures everything for an in process browser test, then invokes | 60 // Configures everything for an in process browser test, then invokes |
39 // BrowserMain. BrowserMain ends up invoking RunTestOnMainThreadLoop. | 61 // BrowserMain. BrowserMain ends up invoking RunTestOnMainThreadLoop. |
40 virtual void SetUp() OVERRIDE; | 62 virtual void SetUp() OVERRIDE; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 // Call this before SetUp() to cause the test to generate pixel output. | 145 // Call this before SetUp() to cause the test to generate pixel output. |
124 void EnablePixelOutput(); | 146 void EnablePixelOutput(); |
125 | 147 |
126 // Call this before SetUp() to not use GL, but use software compositing | 148 // Call this before SetUp() to not use GL, but use software compositing |
127 // instead. | 149 // instead. |
128 void UseSoftwareCompositing(); | 150 void UseSoftwareCompositing(); |
129 | 151 |
130 // Returns true if the test will be using GL acceleration via OSMesa. | 152 // Returns true if the test will be using GL acceleration via OSMesa. |
131 bool UsingOSMesa() const; | 153 bool UsingOSMesa() const; |
132 | 154 |
155 // Adds |admixture| as an admixture for this test, passing ownership | |
156 // for it to BrowserTestBase. | |
157 // Should be called in constructor of the test (should be already completed | |
158 // before running set ups). | |
159 void AddAdmixture(Admixture* admixture); | |
160 | |
161 // Returns admixtures for this test. | |
162 std::vector<BrowserTestBase::Admixture*> GetAdmixtures(); | |
163 | |
164 // Passes admixtures ownership back. | |
165 void ReturnAdmixtures(ScopedVector<BrowserTestBase::Admixture> arg); | |
dzhioev (left Google)
2014/08/18 12:11:46
Remove this declaration.
Lisa Ignatyeva
2014/08/18 12:20:41
Done.
| |
166 | |
133 private: | 167 private: |
134 void ProxyRunTestOnMainThreadLoop(); | 168 void ProxyRunTestOnMainThreadLoop(); |
135 | 169 |
136 // Testing server, started on demand. | 170 // Testing server, started on demand. |
137 scoped_ptr<net::SpawnedTestServer> test_server_; | 171 scoped_ptr<net::SpawnedTestServer> test_server_; |
138 | 172 |
139 // Embedded test server, cheap to create, started on demand. | 173 // Embedded test server, cheap to create, started on demand. |
140 scoped_ptr<net::test_server::EmbeddedTestServer> embedded_test_server_; | 174 scoped_ptr<net::test_server::EmbeddedTestServer> embedded_test_server_; |
141 | 175 |
142 // Host resolver used during tests. | 176 // Host resolver used during tests. |
143 scoped_refptr<net::RuleBasedHostResolverProc> rule_based_resolver_; | 177 scoped_refptr<net::RuleBasedHostResolverProc> rule_based_resolver_; |
144 | 178 |
179 // Holds admixtures for this test. | |
180 ScopedVector<Admixture> admixtures_; | |
181 | |
145 // Expected exit code (default is 0). | 182 // Expected exit code (default is 0). |
146 int expected_exit_code_; | 183 int expected_exit_code_; |
147 | 184 |
148 // When true, the compositor will produce pixel output that can be read back | 185 // When true, the compositor will produce pixel output that can be read back |
149 // for pixel tests. | 186 // for pixel tests. |
150 bool enable_pixel_output_; | 187 bool enable_pixel_output_; |
151 | 188 |
152 // When true, do compositing with the software backend instead of using GL. | 189 // When true, do compositing with the software backend instead of using GL. |
153 bool use_software_compositing_; | 190 bool use_software_compositing_; |
154 | 191 |
155 #if defined(OS_POSIX) | 192 #if defined(OS_POSIX) |
156 bool handle_sigterm_; | 193 bool handle_sigterm_; |
157 #endif | 194 #endif |
158 }; | 195 }; |
159 | 196 |
160 } // namespace content | 197 } // namespace content |
161 | 198 |
162 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_BASE_H_ | 199 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_BASE_H_ |
OLD | NEW |