OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/run_loop.h" | 5 #include "base/run_loop.h" |
6 #include "cc/output/context_provider.h" | 6 #include "cc/output/context_provider.h" |
7 #include "content/browser/compositor/image_transport_factory.h" | 7 #include "content/browser/compositor/image_transport_factory.h" |
8 #include "content/public/browser/gpu_data_manager.h" | 8 #include "content/public/browser/gpu_data_manager.h" |
9 #include "content/public/test/content_browser_test.h" | 9 #include "content/public/test/content_browser_test.h" |
10 #include "gpu/GLES2/gl2extchromium.h" | 10 #include "gpu/GLES2/gl2extchromium.h" |
(...skipping 20 matching lines...) Expand all Loading... | |
31 #endif | 31 #endif |
32 // Checks that upon context loss, the observer is called and the created | 32 // Checks that upon context loss, the observer is called and the created |
33 // resources are reset. | 33 // resources are reset. |
34 IN_PROC_BROWSER_TEST_F(ImageTransportFactoryBrowserTest, | 34 IN_PROC_BROWSER_TEST_F(ImageTransportFactoryBrowserTest, |
35 MAYBE_TestLostContext) { | 35 MAYBE_TestLostContext) { |
36 // This test doesn't make sense in software compositing mode. | 36 // This test doesn't make sense in software compositing mode. |
37 if (!GpuDataManager::GetInstance()->CanUseGpuBrowserCompositor()) | 37 if (!GpuDataManager::GetInstance()->CanUseGpuBrowserCompositor()) |
38 return; | 38 return; |
39 | 39 |
40 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 40 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
41 scoped_refptr<ui::Texture> texture = factory->CreateTransportClient(1.f); | 41 ui::ContextFactory* context_factory = ui::ContextFactory::GetInstance(); |
42 gpu::gles2::GLES2Interface* gl = | |
43 context_factory->SharedMainThreadContextProvider()->ContextGL(); | |
44 unsigned int texture_id = 0; | |
danakj
2014/04/08 14:34:18
nit: uint32?
piman
2014/04/08 17:34:22
Made it a GLuint, which is what GenTextures takes.
| |
45 gl->GenTextures(1, &texture_id); | |
46 | |
47 scoped_refptr<ui::Texture> texture = | |
48 factory->CreateOwnedTexture(gfx::Size(1, 1), 1.f, texture_id); | |
42 ASSERT_TRUE(texture.get()); | 49 ASSERT_TRUE(texture.get()); |
43 | 50 |
44 MockImageTransportFactoryObserver observer; | 51 MockImageTransportFactoryObserver observer; |
45 factory->AddObserver(&observer); | 52 factory->AddObserver(&observer); |
46 | 53 |
47 base::RunLoop run_loop; | 54 base::RunLoop run_loop; |
48 EXPECT_CALL(observer, OnLostResources()) | 55 EXPECT_CALL(observer, OnLostResources()) |
49 .WillOnce(testing::InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); | 56 .WillOnce(testing::InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); |
50 | 57 |
51 ui::ContextFactory* context_factory = ui::ContextFactory::GetInstance(); | |
52 | |
53 gpu::gles2::GLES2Interface* gl = | |
54 context_factory->SharedMainThreadContextProvider()->ContextGL(); | |
55 gl->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, | 58 gl->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
56 GL_INNOCENT_CONTEXT_RESET_ARB); | 59 GL_INNOCENT_CONTEXT_RESET_ARB); |
57 | 60 |
58 // We have to flush to make sure that the client side gets a chance to notice | 61 // We have to flush to make sure that the client side gets a chance to notice |
59 // the context is gone. | 62 // the context is gone. |
60 gl->Flush(); | 63 gl->Flush(); |
61 | 64 |
62 run_loop.Run(); | 65 run_loop.Run(); |
63 EXPECT_EQ(0u, texture->PrepareTexture()); | 66 EXPECT_EQ(0u, texture->PrepareTexture()); |
64 | 67 |
65 factory->RemoveObserver(&observer); | 68 factory->RemoveObserver(&observer); |
66 } | 69 } |
67 | 70 |
68 } // anonymous namespace | 71 } // anonymous namespace |
69 } // namespace content | 72 } // namespace content |
OLD | NEW |