Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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->AppendSwitchASCII(switches::kDisableGpuEarlyInit, ""); | |
|
no sievers
2015/03/26 23:16:19
nit: AppendSwitch(switches::kDisableGpuEarlyInit)
halliwell
2015/03/26 23:25:00
Done.
| |
| 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 23 matching lines...) Expand all Loading... | |
| 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 // Fails since UI Compositor establishes a GpuChannel. |
| 137 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest, DISABLED_Basic) { | 143 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest, Basic) { |
| 138 DCHECK(!IsChannelEstablished()); | 144 DCHECK(!IsChannelEstablished()); |
| 139 EstablishAndWait(); | 145 EstablishAndWait(); |
| 140 EXPECT_TRUE(GetGpuChannel() != NULL); | 146 EXPECT_TRUE(GetGpuChannel() != NULL); |
| 141 } | 147 } |
| 142 | 148 |
| 143 // Fails since UI Compositor establishes a GpuChannel. | 149 // Fails since UI Compositor establishes a GpuChannel. |
| 144 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest, | 150 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest, |
| 145 DISABLED_EstablishAndTerminate) { | 151 EstablishAndTerminate) { |
| 146 DCHECK(!IsChannelEstablished()); | 152 DCHECK(!IsChannelEstablished()); |
| 147 base::RunLoop run_loop; | 153 base::RunLoop run_loop; |
| 148 GetFactory()->EstablishGpuChannel(kInitCause, run_loop.QuitClosure()); | 154 GetFactory()->EstablishGpuChannel(kInitCause, run_loop.QuitClosure()); |
| 149 GetFactory()->Terminate(); | 155 GetFactory()->Terminate(); |
| 150 | 156 |
| 151 // The callback should still trigger. | 157 // The callback should still trigger. |
| 152 run_loop.Run(); | 158 run_loop.Run(); |
| 153 } | 159 } |
| 154 | 160 |
| 155 #if !defined(OS_ANDROID) | 161 #if !defined(OS_ANDROID) |
| 156 // Fails since UI Compositor establishes a GpuChannel. | 162 // Fails since UI Compositor establishes a GpuChannel. |
| 157 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest, | 163 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest, |
| 158 DISABLED_AlreadyEstablished) { | 164 AlreadyEstablished) { |
| 159 DCHECK(!IsChannelEstablished()); | 165 DCHECK(!IsChannelEstablished()); |
| 160 scoped_refptr<GpuChannelHost> gpu_channel = | 166 scoped_refptr<GpuChannelHost> gpu_channel = |
| 161 GetFactory()->EstablishGpuChannelSync(kInitCause); | 167 GetFactory()->EstablishGpuChannelSync(kInitCause); |
| 162 | 168 |
| 163 // Expect established callback immediately. | 169 // Expect established callback immediately. |
| 164 bool event = false; | 170 bool event = false; |
| 165 GetFactory()->EstablishGpuChannel( | 171 GetFactory()->EstablishGpuChannel( |
| 166 kInitCause, | 172 kInitCause, |
| 167 base::Bind(&BrowserGpuChannelHostFactoryTest::Signal, &event)); | 173 base::Bind(&BrowserGpuChannelHostFactoryTest::Signal, &event)); |
| 168 EXPECT_TRUE(event); | 174 EXPECT_TRUE(event); |
| 169 EXPECT_EQ(gpu_channel.get(), GetGpuChannel()); | 175 EXPECT_EQ(gpu_channel.get(), GetGpuChannel()); |
| 170 } | 176 } |
| 171 #endif | 177 #endif |
| 172 | 178 |
| 173 // Fails since UI Compositor establishes a GpuChannel. | 179 // Fails since UI Compositor establishes a GpuChannel. |
| 174 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest, | 180 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest, |
| 175 DISABLED_CrashAndRecover) { | 181 CrashAndRecover) { |
| 176 DCHECK(!IsChannelEstablished()); | 182 DCHECK(!IsChannelEstablished()); |
| 177 EstablishAndWait(); | 183 EstablishAndWait(); |
| 178 scoped_refptr<GpuChannelHost> host = GetGpuChannel(); | 184 scoped_refptr<GpuChannelHost> host = GetGpuChannel(); |
| 179 | 185 |
| 180 scoped_refptr<ContextProviderCommandBuffer> provider = | 186 scoped_refptr<ContextProviderCommandBuffer> provider = |
| 181 ContextProviderCommandBuffer::Create(CreateContext(), | 187 ContextProviderCommandBuffer::Create(CreateContext(), |
| 182 "BrowserGpuChannelHostFactoryTest"); | 188 "BrowserGpuChannelHostFactoryTest"); |
| 183 base::RunLoop run_loop; | 189 base::RunLoop run_loop; |
| 184 int counter = 0; | 190 int counter = 0; |
| 185 provider->SetLostContextCallback( | 191 provider->SetLostContextCallback( |
| 186 base::Bind(&BrowserGpuChannelHostFactoryTest::OnContextLost, | 192 base::Bind(&BrowserGpuChannelHostFactoryTest::OnContextLost, |
| 187 base::Unretained(this), run_loop.QuitClosure(), &counter)); | 193 base::Unretained(this), run_loop.QuitClosure(), &counter)); |
| 188 EXPECT_TRUE(provider->BindToCurrentThread()); | 194 EXPECT_TRUE(provider->BindToCurrentThread()); |
| 189 GpuProcessHostUIShim* shim = | 195 GpuProcessHostUIShim* shim = |
| 190 GpuProcessHostUIShim::FromID(GetFactory()->GpuProcessHostId()); | 196 GpuProcessHostUIShim::FromID(GetFactory()->GpuProcessHostId()); |
| 191 EXPECT_TRUE(shim != NULL); | 197 EXPECT_TRUE(shim != NULL); |
| 192 shim->SimulateCrash(); | 198 shim->SimulateCrash(); |
| 193 run_loop.Run(); | 199 run_loop.Run(); |
| 194 | 200 |
| 195 EXPECT_EQ(1, counter); | 201 EXPECT_EQ(1, counter); |
| 196 EXPECT_FALSE(IsChannelEstablished()); | 202 EXPECT_FALSE(IsChannelEstablished()); |
| 197 EstablishAndWait(); | 203 EstablishAndWait(); |
| 198 EXPECT_TRUE(IsChannelEstablished()); | 204 EXPECT_TRUE(IsChannelEstablished()); |
| 199 } | 205 } |
| 200 | 206 |
| 201 } // namespace content | 207 } // namespace content |
| OLD | NEW |