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, if you need | |
36 // to set up something because of this API. | |
37 class Admixture { | |
38 public: | |
39 Admixture() {} | |
40 virtual ~Admixture() {} | |
41 virtual void SetUpCommandLine(base::CommandLine* command_line) {} | |
42 virtual void SetUpOnMainThread() {} | |
43 virtual void SetUpInProcessBrowserTestFixture() = 0; | |
dzhioev (left Google)
2014/08/15 14:37:14
Add a default implementation for this method.
Lisa Ignatyeva
2014/08/15 16:12:37
Done.
| |
44 virtual bool SetUpUserDataDirectory(); | |
dzhioev (left Google)
2014/08/15 14:37:14
I doubt this method will be really needed in admix
Lisa Ignatyeva
2014/08/15 16:12:37
Done.
| |
45 }; | |
dzhioev (left Google)
2014/08/15 14:37:14
We need TearDown* methods here as well.
Lisa Ignatyeva
2014/08/15 16:12:37
Done.
| |
46 | |
31 BrowserTestBase(); | 47 BrowserTestBase(); |
32 virtual ~BrowserTestBase(); | 48 virtual ~BrowserTestBase(); |
33 | 49 |
34 // We do this so we can be used in a Task. | 50 // We do this so we can be used in a Task. |
35 void AddRef() {} | 51 void AddRef() {} |
36 void Release() {} | 52 void Release() {} |
37 | 53 |
38 // Configures everything for an in process browser test, then invokes | 54 // Configures everything for an in process browser test, then invokes |
39 // BrowserMain. BrowserMain ends up invoking RunTestOnMainThreadLoop. | 55 // BrowserMain. BrowserMain ends up invoking RunTestOnMainThreadLoop. |
40 virtual void SetUp() OVERRIDE; | 56 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. | 139 // Call this before SetUp() to cause the test to generate pixel output. |
124 void EnablePixelOutput(); | 140 void EnablePixelOutput(); |
125 | 141 |
126 // Call this before SetUp() to not use GL, but use software compositing | 142 // Call this before SetUp() to not use GL, but use software compositing |
127 // instead. | 143 // instead. |
128 void UseSoftwareCompositing(); | 144 void UseSoftwareCompositing(); |
129 | 145 |
130 // Returns true if the test will be using GL acceleration via OSMesa. | 146 // Returns true if the test will be using GL acceleration via OSMesa. |
131 bool UsingOSMesa() const; | 147 bool UsingOSMesa() const; |
132 | 148 |
149 // Adds |admixture| as an admixture for this test. | |
150 void AddAdmixture(Admixture* admixture); | |
dzhioev (left Google)
2014/08/15 14:37:14
Please add comment that this method should only be
Lisa Ignatyeva
2014/08/15 16:12:37
Done.
| |
151 | |
152 // Returns admixtures for this test. | |
153 ScopedVector<Admixture> GetAdmixtures(); | |
dzhioev (left Google)
2014/08/15 14:37:14
It's a bad idea to pass ownership to caller. You c
Lisa Ignatyeva
2014/08/15 16:12:37
Done.
| |
154 | |
155 // Passes admixtures ownership back. | |
156 void ReturnAdmixtures(ScopedVector<BrowserTestBase::Admixture> arg); | |
157 | |
158 // Holds admixtures for this test. | |
159 ScopedVector<Admixture> admixtures_; | |
dzhioev (left Google)
2014/08/15 14:37:14
Put this declaration into private section.
Lisa Ignatyeva
2014/08/15 16:12:37
Done.
| |
133 private: | 160 private: |
134 void ProxyRunTestOnMainThreadLoop(); | 161 void ProxyRunTestOnMainThreadLoop(); |
135 | 162 |
136 // Testing server, started on demand. | 163 // Testing server, started on demand. |
137 scoped_ptr<net::SpawnedTestServer> test_server_; | 164 scoped_ptr<net::SpawnedTestServer> test_server_; |
138 | 165 |
139 // Embedded test server, cheap to create, started on demand. | 166 // Embedded test server, cheap to create, started on demand. |
140 scoped_ptr<net::test_server::EmbeddedTestServer> embedded_test_server_; | 167 scoped_ptr<net::test_server::EmbeddedTestServer> embedded_test_server_; |
141 | 168 |
142 // Host resolver used during tests. | 169 // Host resolver used during tests. |
(...skipping 10 matching lines...) Expand all Loading... | |
153 bool use_software_compositing_; | 180 bool use_software_compositing_; |
154 | 181 |
155 #if defined(OS_POSIX) | 182 #if defined(OS_POSIX) |
156 bool handle_sigterm_; | 183 bool handle_sigterm_; |
157 #endif | 184 #endif |
158 }; | 185 }; |
159 | 186 |
160 } // namespace content | 187 } // namespace content |
161 | 188 |
162 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_BASE_H_ | 189 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_BASE_H_ |
OLD | NEW |