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

Unified Diff: content/browser/renderer_host/render_widget_host_unittest.cc

Issue 8240006: Use a mocked compositor for unit tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: missed views_test_base.cc Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_widget_host_unittest.cc
diff --git a/content/browser/renderer_host/render_widget_host_unittest.cc b/content/browser/renderer_host/render_widget_host_unittest.cc
index 7a8bea2a21f0d28679fee5a67cc504ab0539928d..03ce32ebeb5f5d47e1618e7a3dfcbc32c1ac3808 100644
--- a/content/browser/renderer_host/render_widget_host_unittest.cc
+++ b/content/browser/renderer_host/render_widget_host_unittest.cc
@@ -20,6 +20,11 @@
#include "ui/base/keycodes/keyboard_codes.h"
#include "ui/gfx/canvas_skia.h"
+#if defined(VIEWS_COMPOSITOR)
+#include "ui/gfx/compositor/compositor.h"
+#include "ui/gfx/compositor/test_compositor.h"
+#endif
+
using base::TimeDelta;
using WebKit::WebInputEvent;
@@ -237,6 +242,12 @@ class MockPaintingObserver : public NotificationObserver {
gfx::Size size_;
};
+#if defined(VIEWS_COMPOSITOR)
sky 2011/10/14 17:07:16 I was wrong in where I put some of this code. It s
danakj 2011/10/14 19:51:39 done. does it look right/did i get the relevant on
+// static
+static ui::Compositor* TestCreateCompositor(ui::CompositorDelegate* owner) {
+ return new ui::TestCompositor(owner);
+}
+#endif
// RenderWidgetHostTest --------------------------------------------------------
@@ -250,6 +261,10 @@ class RenderWidgetHostTest : public testing::Test {
protected:
// testing::Test
void SetUp() {
+#if defined(VIEWS_COMPOSITOR)
+ // Use a mock compositor that noops draws.
+ ui::Compositor::set_compositor_factory_for_testing(&TestCreateCompositor);
+#endif
browser_context_.reset(new TestBrowserContext());
process_ = new RenderWidgetHostProcess(browser_context_.get());
host_.reset(new MockRenderWidgetHost(process_, 1));
@@ -262,6 +277,9 @@ class RenderWidgetHostTest : public testing::Test {
host_.reset();
process_ = NULL;
browser_context_.reset();
+#if defined(VIEWS_COMPOSITOR)
+ ui::Compositor::set_compositor_factory_for_testing(NULL);
+#endif
// Process all pending tasks to avoid leaks.
MessageLoop::current()->RunAllPending();

Powered by Google App Engine
This is Rietveld 408576698