Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Side by Side Diff: content/public/test/browser_test_base.h

Issue 2832153003: Move calling of shared browser test methods like SetUpOnMainThread/TearDownOnMainThread/RunTestOn... (Closed)
Patch Set: sync Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromecast/browser/test/cast_browser_test.cc ('k') | content/public/test/browser_test_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/threading/thread.h" 10 #include "base/threading/thread.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 // to do what you want by overriding it and calling the superclass version. 60 // to do what you want by overriding it and calling the superclass version.
61 // 61 //
62 // Override this for things you would normally override SetUp for. It will be 62 // Override this for things you would normally override SetUp for. It will be
63 // called before your individual test fixture method is run, but after most 63 // called before your individual test fixture method is run, but after most
64 // of the overhead initialization has occured. 64 // of the overhead initialization has occured.
65 virtual void SetUpInProcessBrowserTestFixture() {} 65 virtual void SetUpInProcessBrowserTestFixture() {}
66 66
67 // Override this for things you would normally override TearDown for. 67 // Override this for things you would normally override TearDown for.
68 virtual void TearDownInProcessBrowserTestFixture() {} 68 virtual void TearDownInProcessBrowserTestFixture() {}
69 69
70 // This is invoked from main after browser_init/browser_main have completed.
71 // This prepares for the test by creating a new browser and doing any other
72 // initialization.
73 // This is meant to be inherited only by the test harness.
74 virtual void PreRunTestOnMainThread() = 0;
75
70 // Override this rather than TestBody. 76 // Override this rather than TestBody.
77 // Note this is internally called by the browser test macros.
71 virtual void RunTestOnMainThread() = 0; 78 virtual void RunTestOnMainThread() = 0;
72 79
73 // This is invoked from main after browser_init/browser_main have completed. 80 // This is invoked from main after RunTestOnMainThread has run, to give the
74 // This prepares for the test by creating a new browser, runs the test 81 // harness a chance for post-test cleanup.
75 // (RunTestOnMainThread), quits the browsers and returns. 82 // This is meant to be inherited only by the test harness.
76 virtual void RunTestOnMainThreadLoop() = 0; 83 virtual void PostRunTestOnMainThread() = 0;
77 84
78 // Sets expected browser exit code, in case it's different than 0 (success). 85 // Sets expected browser exit code, in case it's different than 0 (success).
79 void set_expected_exit_code(int code) { expected_exit_code_ = code; } 86 void set_expected_exit_code(int code) { expected_exit_code_ = code; }
80 87
81 const net::SpawnedTestServer* spawned_test_server() const { 88 const net::SpawnedTestServer* spawned_test_server() const {
82 return spawned_test_server_.get(); 89 return spawned_test_server_.get();
83 } 90 }
84 net::SpawnedTestServer* spawned_test_server() { 91 net::SpawnedTestServer* spawned_test_server() {
85 return spawned_test_server_.get(); 92 return spawned_test_server_.get();
86 } 93 }
(...skipping 30 matching lines...) Expand all
117 // Call this before SetUp() to cause the test to generate pixel output. 124 // Call this before SetUp() to cause the test to generate pixel output.
118 void EnablePixelOutput(); 125 void EnablePixelOutput();
119 126
120 // Call this before SetUp() to not use GL, but use software compositing 127 // Call this before SetUp() to not use GL, but use software compositing
121 // instead. 128 // instead.
122 void UseSoftwareCompositing(); 129 void UseSoftwareCompositing();
123 130
124 // Returns true if the test will be using GL acceleration via a software GL. 131 // Returns true if the test will be using GL acceleration via a software GL.
125 bool UsingSoftwareGL() const; 132 bool UsingSoftwareGL() const;
126 133
134 // Temporary
135 // TODO(jam): remove this.
136 void disable_io_checks() { disable_io_checks_ = true; }
137
127 private: 138 private:
128 void ProxyRunTestOnMainThreadLoop(); 139 void ProxyRunTestOnMainThreadLoop();
129 140
130 // Testing server, started on demand. 141 // Testing server, started on demand.
131 std::unique_ptr<net::SpawnedTestServer> spawned_test_server_; 142 std::unique_ptr<net::SpawnedTestServer> spawned_test_server_;
132 143
133 // Embedded test server, cheap to create, started on demand. 144 // Embedded test server, cheap to create, started on demand.
134 std::unique_ptr<net::EmbeddedTestServer> embedded_test_server_; 145 std::unique_ptr<net::EmbeddedTestServer> embedded_test_server_;
135 146
136 // Host resolver used during tests. 147 // Host resolver used during tests.
137 scoped_refptr<net::RuleBasedHostResolverProc> rule_based_resolver_; 148 scoped_refptr<net::RuleBasedHostResolverProc> rule_based_resolver_;
138 149
139 // Expected exit code (default is 0). 150 // Expected exit code (default is 0).
140 int expected_exit_code_; 151 int expected_exit_code_;
141 152
142 // When true, the compositor will produce pixel output that can be read back 153 // When true, the compositor will produce pixel output that can be read back
143 // for pixel tests. 154 // for pixel tests.
144 bool enable_pixel_output_; 155 bool enable_pixel_output_;
145 156
146 // When true, do compositing with the software backend instead of using GL. 157 // When true, do compositing with the software backend instead of using GL.
147 bool use_software_compositing_; 158 bool use_software_compositing_;
148 159
149 // Whether SetUp was called. This value is checked in the destructor of this 160 // Whether SetUp was called. This value is checked in the destructor of this
150 // class to ensure that SetUp was called. If it's not called, the test will 161 // class to ensure that SetUp was called. If it's not called, the test will
151 // not run and report a false positive result. 162 // not run and report a false positive result.
152 bool set_up_called_; 163 bool set_up_called_;
153 164
165 // Tests should keep on the IO thread checks to test that production code
166 // paths don't make file access. Keep this for now since src/chrome didn't
167 // check this.
168 bool disable_io_checks_;
169
154 #if defined(OS_POSIX) 170 #if defined(OS_POSIX)
155 bool handle_sigterm_; 171 bool handle_sigterm_;
156 #endif 172 #endif
157 }; 173 };
158 174
159 } // namespace content 175 } // namespace content
160 176
161 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_BASE_H_ 177 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_BASE_H_
OLDNEW
« no previous file with comments | « chromecast/browser/test/cast_browser_test.cc ('k') | content/public/test/browser_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698