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

Side by Side Diff: content/test/browser_test_base.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "content/test/browser_test_base.h" 5 #include "content/test/browser_test_base.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/task.h" 8 #include "base/task.h"
9 #include "content/common/main_function_params.h" 9 #include "content/common/main_function_params.h"
10 #include "sandbox/src/dep.h" 10 #include "sandbox/src/dep.h"
11 #include "ui/gfx/gl/gl_switches.h"
11 12
12 #if defined(OS_MACOSX) 13 #if defined(OS_MACOSX)
13 #include "base/mac/mac_util.h" 14 #include "base/mac/mac_util.h"
14 #include "base/system_monitor/system_monitor.h" 15 #include "base/system_monitor/system_monitor.h"
15 #endif 16 #endif
16 17
18 #if defined(VIEWS_COMPOSITOR)
19 #include "ui/gfx/compositor/compositor.h"
20 #include "ui/gfx/compositor/test_compositor.h"
21 #endif
22
17 extern int BrowserMain(const MainFunctionParams&); 23 extern int BrowserMain(const MainFunctionParams&);
18 24
25 #if defined(VIEWS_COMPOSITOR)
26 static ui::Compositor* TestCreateCompositor(ui::CompositorDelegate* owner) {
27 return new ui::TestCompositor(owner);
28 }
29 #endif
30
19 BrowserTestBase::BrowserTestBase() { 31 BrowserTestBase::BrowserTestBase() {
20 #if defined(OS_MACOSX) 32 #if defined(OS_MACOSX)
21 base::mac::SetOverrideAmIBundled(true); 33 base::mac::SetOverrideAmIBundled(true);
22 base::SystemMonitor::AllocateSystemIOPorts(); 34 base::SystemMonitor::AllocateSystemIOPorts();
23 #endif 35 #endif
24 } 36 }
25 37
26 BrowserTestBase::~BrowserTestBase() { 38 BrowserTestBase::~BrowserTestBase() {
27 } 39 }
28 40
29 void BrowserTestBase::SetUp() { 41 void BrowserTestBase::SetUp() {
42 CommandLine* command_line = CommandLine::ForCurrentProcess();
43
44 // Use MesaGL as the GL implementation, as desktopgl/egl is not present on
45 // test bots yet.
46 EXPECT_TRUE(!command_line->HasSwitch(switches::kUseGL));
47 command_line->AppendSwitchASCII(switches::kUseGL,
48 gfx::kGLImplementationOSMesaName);
49
30 SandboxInitWrapper sandbox_wrapper; 50 SandboxInitWrapper sandbox_wrapper;
31 MainFunctionParams params(*CommandLine::ForCurrentProcess(), 51 MainFunctionParams params(*command_line, sandbox_wrapper, NULL);
32 sandbox_wrapper,
33 NULL);
34 params.ui_task = 52 params.ui_task =
35 NewRunnableMethod(this, &BrowserTestBase::ProxyRunTestOnMainThreadLoop); 53 NewRunnableMethod(this, &BrowserTestBase::ProxyRunTestOnMainThreadLoop);
36 54
55 #if defined(VIEWS_COMPOSITOR)
56 // Use a mock compositor that noops draws.
57 ui::Compositor::set_compositor_factory_for_testing(&TestCreateCompositor);
58 #endif
59
37 SetUpInProcessBrowserTestFixture(); 60 SetUpInProcessBrowserTestFixture();
38 BrowserMain(params); 61 BrowserMain(params);
39 TearDownInProcessBrowserTestFixture(); 62 TearDownInProcessBrowserTestFixture();
40 } 63 }
41 64
42 void BrowserTestBase::TearDown() { 65 void BrowserTestBase::TearDown() {
66 #if defined(VIEWS_COMPOSITOR)
67 ui::Compositor::set_compositor_factory_for_testing(NULL);
68 #endif
43 } 69 }
44 70
45 void BrowserTestBase::ProxyRunTestOnMainThreadLoop() { 71 void BrowserTestBase::ProxyRunTestOnMainThreadLoop() {
46 RunTestOnMainThreadLoop(); 72 RunTestOnMainThreadLoop();
47 } 73 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698