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

Side by Side Diff: content/browser/gpu/gpu_ipc_browsertests.cc

Issue 1038783002: Add switch (for cast_shell) to defer creation of GPU process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tests appear to be flaky on Windows, disabling there. Created 5 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 | « content/browser/browser_main_loop.cc ('k') | content/public/common/content_switches.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" 7 #include "content/browser/gpu/browser_gpu_channel_host_factory.h"
8 #include "content/browser/gpu/gpu_process_host_ui_shim.h" 8 #include "content/browser/gpu/gpu_process_host_ui_shim.h"
9 #include "content/common/gpu/client/context_provider_command_buffer.h" 9 #include "content/common/gpu/client/context_provider_command_buffer.h"
10 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 10 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // Start all tests without a gpu channel so that the tests exercise a 84 // Start all tests without a gpu channel so that the tests exercise a
85 // consistent codepath. 85 // consistent codepath.
86 if (!BrowserGpuChannelHostFactory::instance()) 86 if (!BrowserGpuChannelHostFactory::instance())
87 BrowserGpuChannelHostFactory::Initialize(false); 87 BrowserGpuChannelHostFactory::Initialize(false);
88 88
89 CHECK(GetFactory()); 89 CHECK(GetFactory());
90 90
91 ContentBrowserTest::SetUpOnMainThread(); 91 ContentBrowserTest::SetUpOnMainThread();
92 } 92 }
93 93
94 void SetUpCommandLine(base::CommandLine* command_line) override {
95 // Start all tests without a gpu channel so that the tests exercise a
96 // consistent codepath.
97 command_line->AppendSwitch(switches::kDisableGpuEarlyInit);
98 }
99
94 void OnContextLost(const base::Closure callback, int* counter) { 100 void OnContextLost(const base::Closure callback, int* counter) {
95 (*counter)++; 101 (*counter)++;
96 callback.Run(); 102 callback.Run();
97 } 103 }
98 104
99 protected: 105 protected:
100 BrowserGpuChannelHostFactory* GetFactory() { 106 BrowserGpuChannelHostFactory* GetFactory() {
101 return BrowserGpuChannelHostFactory::instance(); 107 return BrowserGpuChannelHostFactory::instance();
102 } 108 }
103 109
(...skipping 22 matching lines...) Expand all
126 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( 132 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
127 GetGpuChannel(), 133 GetGpuChannel(),
128 blink::WebGraphicsContext3D::Attributes(), 134 blink::WebGraphicsContext3D::Attributes(),
129 lose_context_when_out_of_memory, 135 lose_context_when_out_of_memory,
130 GURL(), 136 GURL(),
131 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), 137 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(),
132 NULL)); 138 NULL));
133 } 139 }
134 }; 140 };
135 141
136 // Fails since UI Compositor establishes a GpuChannel. 142 // These tests are flaky on Windows.
137 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest, DISABLED_Basic) { 143 #if !defined(OS_WIN)
144 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest, Basic) {
138 DCHECK(!IsChannelEstablished()); 145 DCHECK(!IsChannelEstablished());
139 EstablishAndWait(); 146 EstablishAndWait();
140 EXPECT_TRUE(GetGpuChannel() != NULL); 147 EXPECT_TRUE(GetGpuChannel() != NULL);
141 } 148 }
149 #endif
142 150
143 // Fails since UI Compositor establishes a GpuChannel. 151 // Fails on chromeos since Shell::PlatformInitialize instantiates
152 // wm::WMTestHelper leading to the compositor establishing a GPU
153 // channel.
154 #if !defined(OS_CHROMEOS) && !defined(OS_WIN)
144 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest, 155 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest,
145 DISABLED_EstablishAndTerminate) { 156 EstablishAndTerminate) {
146 DCHECK(!IsChannelEstablished()); 157 DCHECK(!IsChannelEstablished());
147 base::RunLoop run_loop; 158 base::RunLoop run_loop;
148 GetFactory()->EstablishGpuChannel(kInitCause, run_loop.QuitClosure()); 159 GetFactory()->EstablishGpuChannel(kInitCause, run_loop.QuitClosure());
149 GetFactory()->Terminate(); 160 GetFactory()->Terminate();
150 161
151 // The callback should still trigger. 162 // The callback should still trigger.
152 run_loop.Run(); 163 run_loop.Run();
153 } 164 }
165 #endif
154 166
155 #if !defined(OS_ANDROID) 167 #if !defined(OS_ANDROID) && !defined(OS_WIN)
156 // Fails since UI Compositor establishes a GpuChannel.
157 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest, 168 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest,
158 DISABLED_AlreadyEstablished) { 169 AlreadyEstablished) {
159 DCHECK(!IsChannelEstablished()); 170 DCHECK(!IsChannelEstablished());
160 scoped_refptr<GpuChannelHost> gpu_channel = 171 scoped_refptr<GpuChannelHost> gpu_channel =
161 GetFactory()->EstablishGpuChannelSync(kInitCause); 172 GetFactory()->EstablishGpuChannelSync(kInitCause);
162 173
163 // Expect established callback immediately. 174 // Expect established callback immediately.
164 bool event = false; 175 bool event = false;
165 GetFactory()->EstablishGpuChannel( 176 GetFactory()->EstablishGpuChannel(
166 kInitCause, 177 kInitCause,
167 base::Bind(&BrowserGpuChannelHostFactoryTest::Signal, &event)); 178 base::Bind(&BrowserGpuChannelHostFactoryTest::Signal, &event));
168 EXPECT_TRUE(event); 179 EXPECT_TRUE(event);
169 EXPECT_EQ(gpu_channel.get(), GetGpuChannel()); 180 EXPECT_EQ(gpu_channel.get(), GetGpuChannel());
170 } 181 }
171 #endif 182 #endif
172 183
173 // Fails since UI Compositor establishes a GpuChannel. 184 #if !defined(OS_WIN)
174 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest, 185 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest,
175 DISABLED_CrashAndRecover) { 186 CrashAndRecover) {
176 DCHECK(!IsChannelEstablished()); 187 DCHECK(!IsChannelEstablished());
177 EstablishAndWait(); 188 EstablishAndWait();
178 scoped_refptr<GpuChannelHost> host = GetGpuChannel(); 189 scoped_refptr<GpuChannelHost> host = GetGpuChannel();
179 190
180 scoped_refptr<ContextProviderCommandBuffer> provider = 191 scoped_refptr<ContextProviderCommandBuffer> provider =
181 ContextProviderCommandBuffer::Create(CreateContext(), 192 ContextProviderCommandBuffer::Create(CreateContext(),
182 "BrowserGpuChannelHostFactoryTest"); 193 "BrowserGpuChannelHostFactoryTest");
183 base::RunLoop run_loop; 194 base::RunLoop run_loop;
184 int counter = 0; 195 int counter = 0;
185 provider->SetLostContextCallback( 196 provider->SetLostContextCallback(
186 base::Bind(&BrowserGpuChannelHostFactoryTest::OnContextLost, 197 base::Bind(&BrowserGpuChannelHostFactoryTest::OnContextLost,
187 base::Unretained(this), run_loop.QuitClosure(), &counter)); 198 base::Unretained(this), run_loop.QuitClosure(), &counter));
188 EXPECT_TRUE(provider->BindToCurrentThread()); 199 EXPECT_TRUE(provider->BindToCurrentThread());
189 GpuProcessHostUIShim* shim = 200 GpuProcessHostUIShim* shim =
190 GpuProcessHostUIShim::FromID(GetFactory()->GpuProcessHostId()); 201 GpuProcessHostUIShim::FromID(GetFactory()->GpuProcessHostId());
191 EXPECT_TRUE(shim != NULL); 202 EXPECT_TRUE(shim != NULL);
192 shim->SimulateCrash(); 203 shim->SimulateCrash();
193 run_loop.Run(); 204 run_loop.Run();
194 205
195 EXPECT_EQ(1, counter); 206 EXPECT_EQ(1, counter);
196 EXPECT_FALSE(IsChannelEstablished()); 207 EXPECT_FALSE(IsChannelEstablished());
197 EstablishAndWait(); 208 EstablishAndWait();
198 EXPECT_TRUE(IsChannelEstablished()); 209 EXPECT_TRUE(IsChannelEstablished());
199 } 210 }
211 #endif
200 212
201 } // namespace content 213 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_main_loop.cc ('k') | content/public/common/content_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698