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_TEST_RENDERER_HOST_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_TEST_RENDERER_HOST_H_ |
6 #define CONTENT_PUBLIC_TEST_TEST_RENDERER_HOST_H_ | 6 #define CONTENT_PUBLIC_TEST_TEST_RENDERER_HOST_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "content/public/browser/render_view_host.h" | 10 #include "content/public/browser/render_view_host.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 | 149 |
150 // Simulates a reload of the current page. | 150 // Simulates a reload of the current page. |
151 void Reload(); | 151 void Reload(); |
152 void FailedReload(); | 152 void FailedReload(); |
153 | 153 |
154 protected: | 154 protected: |
155 // testing::Test | 155 // testing::Test |
156 virtual void SetUp() OVERRIDE; | 156 virtual void SetUp() OVERRIDE; |
157 virtual void TearDown() OVERRIDE; | 157 virtual void TearDown() OVERRIDE; |
158 | 158 |
| 159 // Derived classes should override this method to use a custom BrowserContext. |
| 160 // It is invoked by SetUp after threads were started. |
| 161 // RenderViewHostTestHarness will take ownership of the returned |
| 162 // BrowserContext. |
| 163 virtual BrowserContext* CreateBrowserContext(); |
| 164 |
159 // Configures which TestBrowserThreads inside |thread_bundle| are backed by | 165 // Configures which TestBrowserThreads inside |thread_bundle| are backed by |
160 // real threads. Must be called before SetUp(). | 166 // real threads. Must be called before SetUp(). |
161 void SetThreadBundleOptions(int options) { | 167 void SetThreadBundleOptions(int options) { |
162 DCHECK(thread_bundle_.get() == NULL); | 168 DCHECK(thread_bundle_.get() == NULL); |
163 thread_bundle_options_ = options; | 169 thread_bundle_options_ = options; |
164 } | 170 } |
165 | 171 |
166 TestBrowserThreadBundle* thread_bundle() { return thread_bundle_.get(); } | 172 TestBrowserThreadBundle* thread_bundle() { return thread_bundle_.get(); } |
167 | 173 |
168 #if defined(USE_AURA) | 174 #if defined(USE_AURA) |
169 aura::RootWindow* root_window() { return aura_test_helper_->root_window(); } | 175 aura::RootWindow* root_window() { return aura_test_helper_->root_window(); } |
170 #endif | 176 #endif |
171 | 177 |
172 // Replaces the RPH being used. | 178 // Replaces the RPH being used. |
173 void SetRenderProcessHostFactory(RenderProcessHostFactory* factory); | 179 void SetRenderProcessHostFactory(RenderProcessHostFactory* factory); |
174 | 180 |
175 // This browser context will be created in SetUp if it has not already been | 181 private: |
176 // created. This allows tests to override the browser context if they so | |
177 // choose in their own SetUp function before calling the base class's (us) | |
178 // SetUp(). | |
179 scoped_ptr<BrowserContext> browser_context_; | 182 scoped_ptr<BrowserContext> browser_context_; |
180 | 183 |
181 private: | |
182 // It is important not to use this directly in the implementation as | 184 // It is important not to use this directly in the implementation as |
183 // web_contents() and SetContents() are virtual and may be | 185 // web_contents() and SetContents() are virtual and may be |
184 // overridden by subclasses. | 186 // overridden by subclasses. |
185 scoped_ptr<WebContents> contents_; | 187 scoped_ptr<WebContents> contents_; |
186 #if defined(OS_WIN) | 188 #if defined(OS_WIN) |
187 scoped_ptr<ui::ScopedOleInitializer> ole_initializer_; | 189 scoped_ptr<ui::ScopedOleInitializer> ole_initializer_; |
188 #endif | 190 #endif |
189 #if defined(USE_AURA) | 191 #if defined(USE_AURA) |
190 scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_; | 192 scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_; |
191 #endif | 193 #endif |
192 RenderViewHostTestEnabler rvh_test_enabler_; | 194 RenderViewHostTestEnabler rvh_test_enabler_; |
193 | 195 |
194 int thread_bundle_options_; | 196 int thread_bundle_options_; |
195 scoped_ptr<TestBrowserThreadBundle> thread_bundle_; | 197 scoped_ptr<TestBrowserThreadBundle> thread_bundle_; |
196 | 198 |
197 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTestHarness); | 199 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTestHarness); |
198 }; | 200 }; |
199 | 201 |
200 } // namespace content | 202 } // namespace content |
201 | 203 |
202 #endif // CONTENT_PUBLIC_TEST_TEST_RENDERER_HOST_H_ | 204 #endif // CONTENT_PUBLIC_TEST_TEST_RENDERER_HOST_H_ |
OLD | NEW |