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

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: Comment+naming update, reenable tests 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 #include "content/common/gpu/client/gpu_context_tests.h" 74 #include "content/common/gpu/client/gpu_context_tests.h"
75 75
76 namespace content { 76 namespace content {
77 77
78 class BrowserGpuChannelHostFactoryTest : public ContentBrowserTest { 78 class BrowserGpuChannelHostFactoryTest : public ContentBrowserTest {
79 public: 79 public:
80 void SetUpOnMainThread() override { 80 void SetUpOnMainThread() override {
81 if (!BrowserGpuChannelHostFactory::CanUseForTesting()) 81 if (!BrowserGpuChannelHostFactory::CanUseForTesting())
82 return; 82 return;
83 83
84 // Start all tests without a gpu channel so that the tests exercise a
85 // consistent codepath.
86 if (!BrowserGpuChannelHostFactory::instance())
87 BrowserGpuChannelHostFactory::Initialize(false);
88
89 CHECK(GetFactory()); 84 CHECK(GetFactory());
no sievers 2015/03/26 22:05:29 Doesn't this fail? Don't you still have to call Br
halliwell 2015/03/26 22:16:52 Good point. The test was passing for me, but that
no sievers 2015/03/26 23:16:19 AURA || MAC || ANDROID might cover everything. But
90 85
91 ContentBrowserTest::SetUpOnMainThread(); 86 ContentBrowserTest::SetUpOnMainThread();
92 } 87 }
93 88
89 void SetUpCommandLine(base::CommandLine* command_line) override {
90 // Start all tests without a gpu channel so that the tests exercise a
91 // consistent codepath.
92 command_line->AppendSwitchASCII(switches::kDisableGpuEarlyInit, "");
93 }
94
94 void OnContextLost(const base::Closure callback, int* counter) { 95 void OnContextLost(const base::Closure callback, int* counter) {
95 (*counter)++; 96 (*counter)++;
96 callback.Run(); 97 callback.Run();
97 } 98 }
98 99
99 protected: 100 protected:
100 BrowserGpuChannelHostFactory* GetFactory() { 101 BrowserGpuChannelHostFactory* GetFactory() {
101 return BrowserGpuChannelHostFactory::instance(); 102 return BrowserGpuChannelHostFactory::instance();
102 } 103 }
103 104
(...skipping 23 matching lines...) Expand all
127 GetGpuChannel(), 128 GetGpuChannel(),
128 blink::WebGraphicsContext3D::Attributes(), 129 blink::WebGraphicsContext3D::Attributes(),
129 lose_context_when_out_of_memory, 130 lose_context_when_out_of_memory,
130 GURL(), 131 GURL(),
131 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), 132 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(),
132 NULL)); 133 NULL));
133 } 134 }
134 }; 135 };
135 136
136 // Fails since UI Compositor establishes a GpuChannel. 137 // Fails since UI Compositor establishes a GpuChannel.
137 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest, DISABLED_Basic) { 138 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest, Basic) {
138 DCHECK(!IsChannelEstablished()); 139 DCHECK(!IsChannelEstablished());
139 EstablishAndWait(); 140 EstablishAndWait();
140 EXPECT_TRUE(GetGpuChannel() != NULL); 141 EXPECT_TRUE(GetGpuChannel() != NULL);
141 } 142 }
142 143
143 // Fails since UI Compositor establishes a GpuChannel. 144 // Fails since UI Compositor establishes a GpuChannel.
144 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest, 145 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest,
145 DISABLED_EstablishAndTerminate) { 146 EstablishAndTerminate) {
146 DCHECK(!IsChannelEstablished()); 147 DCHECK(!IsChannelEstablished());
147 base::RunLoop run_loop; 148 base::RunLoop run_loop;
148 GetFactory()->EstablishGpuChannel(kInitCause, run_loop.QuitClosure()); 149 GetFactory()->EstablishGpuChannel(kInitCause, run_loop.QuitClosure());
149 GetFactory()->Terminate(); 150 GetFactory()->Terminate();
150 151
151 // The callback should still trigger. 152 // The callback should still trigger.
152 run_loop.Run(); 153 run_loop.Run();
153 } 154 }
154 155
155 #if !defined(OS_ANDROID) 156 #if !defined(OS_ANDROID)
156 // Fails since UI Compositor establishes a GpuChannel. 157 // Fails since UI Compositor establishes a GpuChannel.
157 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest, 158 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest,
158 DISABLED_AlreadyEstablished) { 159 AlreadyEstablished) {
159 DCHECK(!IsChannelEstablished()); 160 DCHECK(!IsChannelEstablished());
160 scoped_refptr<GpuChannelHost> gpu_channel = 161 scoped_refptr<GpuChannelHost> gpu_channel =
161 GetFactory()->EstablishGpuChannelSync(kInitCause); 162 GetFactory()->EstablishGpuChannelSync(kInitCause);
162 163
163 // Expect established callback immediately. 164 // Expect established callback immediately.
164 bool event = false; 165 bool event = false;
165 GetFactory()->EstablishGpuChannel( 166 GetFactory()->EstablishGpuChannel(
166 kInitCause, 167 kInitCause,
167 base::Bind(&BrowserGpuChannelHostFactoryTest::Signal, &event)); 168 base::Bind(&BrowserGpuChannelHostFactoryTest::Signal, &event));
168 EXPECT_TRUE(event); 169 EXPECT_TRUE(event);
169 EXPECT_EQ(gpu_channel.get(), GetGpuChannel()); 170 EXPECT_EQ(gpu_channel.get(), GetGpuChannel());
170 } 171 }
171 #endif 172 #endif
172 173
173 // Fails since UI Compositor establishes a GpuChannel. 174 // Fails since UI Compositor establishes a GpuChannel.
174 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest, 175 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest,
175 DISABLED_CrashAndRecover) { 176 CrashAndRecover) {
176 DCHECK(!IsChannelEstablished()); 177 DCHECK(!IsChannelEstablished());
177 EstablishAndWait(); 178 EstablishAndWait();
178 scoped_refptr<GpuChannelHost> host = GetGpuChannel(); 179 scoped_refptr<GpuChannelHost> host = GetGpuChannel();
179 180
180 scoped_refptr<ContextProviderCommandBuffer> provider = 181 scoped_refptr<ContextProviderCommandBuffer> provider =
181 ContextProviderCommandBuffer::Create(CreateContext(), 182 ContextProviderCommandBuffer::Create(CreateContext(),
182 "BrowserGpuChannelHostFactoryTest"); 183 "BrowserGpuChannelHostFactoryTest");
183 base::RunLoop run_loop; 184 base::RunLoop run_loop;
184 int counter = 0; 185 int counter = 0;
185 provider->SetLostContextCallback( 186 provider->SetLostContextCallback(
186 base::Bind(&BrowserGpuChannelHostFactoryTest::OnContextLost, 187 base::Bind(&BrowserGpuChannelHostFactoryTest::OnContextLost,
187 base::Unretained(this), run_loop.QuitClosure(), &counter)); 188 base::Unretained(this), run_loop.QuitClosure(), &counter));
188 EXPECT_TRUE(provider->BindToCurrentThread()); 189 EXPECT_TRUE(provider->BindToCurrentThread());
189 GpuProcessHostUIShim* shim = 190 GpuProcessHostUIShim* shim =
190 GpuProcessHostUIShim::FromID(GetFactory()->GpuProcessHostId()); 191 GpuProcessHostUIShim::FromID(GetFactory()->GpuProcessHostId());
191 EXPECT_TRUE(shim != NULL); 192 EXPECT_TRUE(shim != NULL);
192 shim->SimulateCrash(); 193 shim->SimulateCrash();
193 run_loop.Run(); 194 run_loop.Run();
194 195
195 EXPECT_EQ(1, counter); 196 EXPECT_EQ(1, counter);
196 EXPECT_FALSE(IsChannelEstablished()); 197 EXPECT_FALSE(IsChannelEstablished());
197 EstablishAndWait(); 198 EstablishAndWait();
198 EXPECT_TRUE(IsChannelEstablished()); 199 EXPECT_TRUE(IsChannelEstablished());
199 } 200 }
200 201
201 } // namespace content 202 } // 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