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

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

Issue 1043603002: Revert of Add switch (for cast_shell) to defer creation of GPU process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
100 void OnContextLost(const base::Closure callback, int* counter) { 94 void OnContextLost(const base::Closure callback, int* counter) {
101 (*counter)++; 95 (*counter)++;
102 callback.Run(); 96 callback.Run();
103 } 97 }
104 98
105 protected: 99 protected:
106 BrowserGpuChannelHostFactory* GetFactory() { 100 BrowserGpuChannelHostFactory* GetFactory() {
107 return BrowserGpuChannelHostFactory::instance(); 101 return BrowserGpuChannelHostFactory::instance();
108 } 102 }
109 103
(...skipping 22 matching lines...) Expand all
132 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( 126 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
133 GetGpuChannel(), 127 GetGpuChannel(),
134 blink::WebGraphicsContext3D::Attributes(), 128 blink::WebGraphicsContext3D::Attributes(),
135 lose_context_when_out_of_memory, 129 lose_context_when_out_of_memory,
136 GURL(), 130 GURL(),
137 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), 131 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(),
138 NULL)); 132 NULL));
139 } 133 }
140 }; 134 };
141 135
142 // These tests are flaky on Windows. 136 // Fails since UI Compositor establishes a GpuChannel.
143 #if !defined(OS_WIN) 137 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest, DISABLED_Basic) {
144 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest, Basic) {
145 DCHECK(!IsChannelEstablished()); 138 DCHECK(!IsChannelEstablished());
146 EstablishAndWait(); 139 EstablishAndWait();
147 EXPECT_TRUE(GetGpuChannel() != NULL); 140 EXPECT_TRUE(GetGpuChannel() != NULL);
148 } 141 }
149 #endif
150 142
151 // Fails on chromeos since Shell::PlatformInitialize instantiates 143 // Fails since UI Compositor establishes a GpuChannel.
152 // wm::WMTestHelper leading to the compositor establishing a GPU
153 // channel.
154 #if !defined(OS_CHROMEOS) && !defined(OS_WIN)
155 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest, 144 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest,
156 EstablishAndTerminate) { 145 DISABLED_EstablishAndTerminate) {
157 DCHECK(!IsChannelEstablished()); 146 DCHECK(!IsChannelEstablished());
158 base::RunLoop run_loop; 147 base::RunLoop run_loop;
159 GetFactory()->EstablishGpuChannel(kInitCause, run_loop.QuitClosure()); 148 GetFactory()->EstablishGpuChannel(kInitCause, run_loop.QuitClosure());
160 GetFactory()->Terminate(); 149 GetFactory()->Terminate();
161 150
162 // The callback should still trigger. 151 // The callback should still trigger.
163 run_loop.Run(); 152 run_loop.Run();
164 } 153 }
165 #endif
166 154
167 #if !defined(OS_ANDROID) && !defined(OS_WIN) 155 #if !defined(OS_ANDROID)
156 // Fails since UI Compositor establishes a GpuChannel.
168 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest, 157 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest,
169 AlreadyEstablished) { 158 DISABLED_AlreadyEstablished) {
170 DCHECK(!IsChannelEstablished()); 159 DCHECK(!IsChannelEstablished());
171 scoped_refptr<GpuChannelHost> gpu_channel = 160 scoped_refptr<GpuChannelHost> gpu_channel =
172 GetFactory()->EstablishGpuChannelSync(kInitCause); 161 GetFactory()->EstablishGpuChannelSync(kInitCause);
173 162
174 // Expect established callback immediately. 163 // Expect established callback immediately.
175 bool event = false; 164 bool event = false;
176 GetFactory()->EstablishGpuChannel( 165 GetFactory()->EstablishGpuChannel(
177 kInitCause, 166 kInitCause,
178 base::Bind(&BrowserGpuChannelHostFactoryTest::Signal, &event)); 167 base::Bind(&BrowserGpuChannelHostFactoryTest::Signal, &event));
179 EXPECT_TRUE(event); 168 EXPECT_TRUE(event);
180 EXPECT_EQ(gpu_channel.get(), GetGpuChannel()); 169 EXPECT_EQ(gpu_channel.get(), GetGpuChannel());
181 } 170 }
182 #endif 171 #endif
183 172
184 #if !defined(OS_WIN) 173 // Fails since UI Compositor establishes a GpuChannel.
185 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest, 174 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest,
186 CrashAndRecover) { 175 DISABLED_CrashAndRecover) {
187 DCHECK(!IsChannelEstablished()); 176 DCHECK(!IsChannelEstablished());
188 EstablishAndWait(); 177 EstablishAndWait();
189 scoped_refptr<GpuChannelHost> host = GetGpuChannel(); 178 scoped_refptr<GpuChannelHost> host = GetGpuChannel();
190 179
191 scoped_refptr<ContextProviderCommandBuffer> provider = 180 scoped_refptr<ContextProviderCommandBuffer> provider =
192 ContextProviderCommandBuffer::Create(CreateContext(), 181 ContextProviderCommandBuffer::Create(CreateContext(),
193 "BrowserGpuChannelHostFactoryTest"); 182 "BrowserGpuChannelHostFactoryTest");
194 base::RunLoop run_loop; 183 base::RunLoop run_loop;
195 int counter = 0; 184 int counter = 0;
196 provider->SetLostContextCallback( 185 provider->SetLostContextCallback(
197 base::Bind(&BrowserGpuChannelHostFactoryTest::OnContextLost, 186 base::Bind(&BrowserGpuChannelHostFactoryTest::OnContextLost,
198 base::Unretained(this), run_loop.QuitClosure(), &counter)); 187 base::Unretained(this), run_loop.QuitClosure(), &counter));
199 EXPECT_TRUE(provider->BindToCurrentThread()); 188 EXPECT_TRUE(provider->BindToCurrentThread());
200 GpuProcessHostUIShim* shim = 189 GpuProcessHostUIShim* shim =
201 GpuProcessHostUIShim::FromID(GetFactory()->GpuProcessHostId()); 190 GpuProcessHostUIShim::FromID(GetFactory()->GpuProcessHostId());
202 EXPECT_TRUE(shim != NULL); 191 EXPECT_TRUE(shim != NULL);
203 shim->SimulateCrash(); 192 shim->SimulateCrash();
204 run_loop.Run(); 193 run_loop.Run();
205 194
206 EXPECT_EQ(1, counter); 195 EXPECT_EQ(1, counter);
207 EXPECT_FALSE(IsChannelEstablished()); 196 EXPECT_FALSE(IsChannelEstablished());
208 EstablishAndWait(); 197 EstablishAndWait();
209 EXPECT_TRUE(IsChannelEstablished()); 198 EXPECT_TRUE(IsChannelEstablished());
210 } 199 }
211 #endif
212 200
213 } // namespace content 201 } // 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