| 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" |
| 11 #include "content/public/common/page_transition_types.h" | 11 #include "content/public/common/page_transition_types.h" |
| 12 #include "content/public/test/test_browser_thread_bundle.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 14 |
| 14 #if defined(USE_AURA) | 15 #if defined(USE_AURA) |
| 15 #include "ui/aura/test/aura_test_helper.h" | 16 #include "ui/aura/test/aura_test_helper.h" |
| 16 #endif | 17 #endif |
| 17 | 18 |
| 18 namespace aura { | 19 namespace aura { |
| 19 namespace test { | 20 namespace test { |
| 20 class AuraTestHelper; | 21 class AuraTestHelper; |
| 21 } | 22 } |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 149 |
| 149 // Simulates a reload of the current page. | 150 // Simulates a reload of the current page. |
| 150 void Reload(); | 151 void Reload(); |
| 151 void FailedReload(); | 152 void FailedReload(); |
| 152 | 153 |
| 153 protected: | 154 protected: |
| 154 // testing::Test | 155 // testing::Test |
| 155 virtual void SetUp() OVERRIDE; | 156 virtual void SetUp() OVERRIDE; |
| 156 virtual void TearDown() OVERRIDE; | 157 virtual void TearDown() OVERRIDE; |
| 157 | 158 |
| 159 // Configures which when to use real thraeads inside |thread_bundle|. |
| 160 // Must be called before CreateThreadBundle(). |
| 161 void SetRealThreadMask(int real_threads_mask) { |
| 162 DCHECK(thread_bundle_.get() == NULL); |
| 163 real_threads_mask_ = real_threads_mask; |
| 164 } |
| 165 |
| 166 // Creates |thread_bundle|. This is normally called by SetUp(). However, |
| 167 // Some tests have initialzation code that depend on BrowserThreads but |
| 168 // must also be run before SetUp() is called because the test needs to |
| 169 // override global objects that SetUp() uses. This method allows such |
| 170 // tests to early-create the threads. |
| 171 void CreateThreadBundle(); |
| 172 |
| 173 TestBrowserThreadBundle* thread_bundle() { return thread_bundle_.get(); } |
| 174 |
| 158 #if defined(USE_AURA) | 175 #if defined(USE_AURA) |
| 159 aura::RootWindow* root_window() { return aura_test_helper_->root_window(); } | 176 aura::RootWindow* root_window() { return aura_test_helper_->root_window(); } |
| 160 #endif | 177 #endif |
| 161 | 178 |
| 162 // Replaces the RPH being used. | 179 // Replaces the RPH being used. |
| 163 void SetRenderProcessHostFactory(RenderProcessHostFactory* factory); | 180 void SetRenderProcessHostFactory(RenderProcessHostFactory* factory); |
| 164 | 181 |
| 165 // This browser context will be created in SetUp if it has not already been | 182 // This browser context will be created in SetUp if it has not already been |
| 166 // created. This allows tests to override the browser context if they so | 183 // created. This allows tests to override the browser context if they so |
| 167 // choose in their own SetUp function before calling the base class's (us) | 184 // choose in their own SetUp function before calling the base class's (us) |
| 168 // SetUp(). | 185 // SetUp(). |
| 169 scoped_ptr<BrowserContext> browser_context_; | 186 scoped_ptr<BrowserContext> browser_context_; |
| 170 | 187 |
| 171 base::MessageLoopForUI message_loop_; | |
| 172 | |
| 173 private: | 188 private: |
| 174 // It is important not to use this directly in the implementation as | 189 // It is important not to use this directly in the implementation as |
| 175 // web_contents() and SetContents() are virtual and may be | 190 // web_contents() and SetContents() are virtual and may be |
| 176 // overridden by subclasses. | 191 // overridden by subclasses. |
| 177 scoped_ptr<WebContents> contents_; | 192 scoped_ptr<WebContents> contents_; |
| 178 #if defined(OS_WIN) | 193 #if defined(OS_WIN) |
| 179 scoped_ptr<ui::ScopedOleInitializer> ole_initializer_; | 194 scoped_ptr<ui::ScopedOleInitializer> ole_initializer_; |
| 180 #endif | 195 #endif |
| 181 #if defined(USE_AURA) | 196 #if defined(USE_AURA) |
| 182 scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_; | 197 scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_; |
| 183 #endif | 198 #endif |
| 184 RenderViewHostTestEnabler rvh_test_enabler_; | 199 RenderViewHostTestEnabler rvh_test_enabler_; |
| 185 | 200 |
| 201 int real_threads_mask_; |
| 202 scoped_ptr<TestBrowserThreadBundle> thread_bundle_; |
| 203 |
| 186 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTestHarness); | 204 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTestHarness); |
| 187 }; | 205 }; |
| 188 | 206 |
| 189 } // namespace content | 207 } // namespace content |
| 190 | 208 |
| 191 #endif // CONTENT_PUBLIC_TEST_TEST_RENDERER_HOST_H_ | 209 #endif // CONTENT_PUBLIC_TEST_TEST_RENDERER_HOST_H_ |
| OLD | NEW |