OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/run_loop.h" |
| 6 #include "content/browser/aura/image_transport_factory.h" |
| 7 #include "content/test/content_browser_test.h" |
| 8 #include "gpu/GLES2/gl2extchromium.h" |
| 9 #include "testing/gmock/include/gmock/gmock.h" |
| 10 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
| 11 #include "ui/compositor/compositor.h" |
| 12 |
| 13 namespace content { |
| 14 namespace { |
| 15 |
| 16 class ImageTransportFactoryBrowserTest : public ContentBrowserTest { |
| 17 public: |
| 18 ImageTransportFactoryBrowserTest() {} |
| 19 |
| 20 virtual void SetUp() OVERRIDE { |
| 21 UseRealGLContexts(); |
| 22 ContentBrowserTest::SetUp(); |
| 23 } |
| 24 }; |
| 25 |
| 26 class MockImageTransportFactoryObserver : public ImageTransportFactoryObserver { |
| 27 public: |
| 28 MOCK_METHOD0(OnLostResources, void()); |
| 29 }; |
| 30 |
| 31 // Checks that upon context loss, the observer is called and the created |
| 32 // resources are reset. |
| 33 IN_PROC_BROWSER_TEST_F(ImageTransportFactoryBrowserTest, TestLostContext) { |
| 34 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 35 scoped_refptr<ui::Texture> texture = factory->CreateTransportClient(1.f); |
| 36 |
| 37 MockImageTransportFactoryObserver observer; |
| 38 factory->AddObserver(&observer); |
| 39 |
| 40 base::RunLoop run_loop; |
| 41 EXPECT_CALL(observer, OnLostResources()) |
| 42 .WillOnce(testing::InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); |
| 43 |
| 44 WebKit::WebGraphicsContext3D* context = texture->HostContext3D(); |
| 45 context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
| 46 GL_INNOCENT_CONTEXT_RESET_ARB); |
| 47 |
| 48 run_loop.Run(); |
| 49 EXPECT_FALSE(texture->HostContext3D()); |
| 50 EXPECT_EQ(0u, texture->PrepareTexture()); |
| 51 |
| 52 factory->RemoveObserver(&observer); |
| 53 } |
| 54 |
| 55 } // anonymous namespace |
| 56 } // namespace content |
OLD | NEW |