| 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 "content/browser/compositor/image_transport_factory.h" |
| 6 |
| 5 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 6 #include "cc/output/context_provider.h" | 8 #include "cc/output/context_provider.h" |
| 7 #include "content/browser/compositor/image_transport_factory.h" | |
| 8 #include "content/browser/compositor/owned_mailbox.h" | 9 #include "content/browser/compositor/owned_mailbox.h" |
| 9 #include "content/public/browser/gpu_data_manager.h" | 10 #include "content/public/browser/gpu_data_manager.h" |
| 10 #include "content/public/test/content_browser_test.h" | 11 #include "content/public/test/content_browser_test.h" |
| 11 #include "gpu/GLES2/gl2extchromium.h" | 12 #include "gpu/GLES2/gl2extchromium.h" |
| 12 #include "gpu/command_buffer/client/gles2_interface.h" | 13 #include "gpu/command_buffer/client/gles2_interface.h" |
| 13 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
| 14 #include "ui/compositor/compositor.h" | 15 #include "ui/compositor/compositor.h" |
| 15 | 16 |
| 16 namespace content { | 17 namespace content { |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 class ImageTransportFactoryBrowserTest : public ContentBrowserTest {}; | 20 typedef ContentBrowserTest ImageTransportFactoryBrowserTest; |
| 20 | 21 |
| 21 class MockImageTransportFactoryObserver : public ImageTransportFactoryObserver { | 22 class MockImageTransportFactoryObserver : public ImageTransportFactoryObserver { |
| 22 public: | 23 public: |
| 23 MOCK_METHOD0(OnLostResources, void()); | 24 MOCK_METHOD0(OnLostResources, void()); |
| 24 }; | 25 }; |
| 25 | 26 |
| 26 // This crashes on Mac ASAN | 27 // This crashes on Mac ASAN |
| 27 // http://crbug.com/335083 | 28 // http://crbug.com/335083 |
| 28 #if defined(OS_MACOSX) | 29 #if defined(OS_MACOSX) |
| 29 #define MAYBE_TestLostContext DISABLED_TestLostContext | 30 #define MAYBE_TestLostContext DISABLED_TestLostContext |
| (...skipping 14 matching lines...) Expand all Loading... |
| 44 new OwnedMailbox(factory->GetGLHelper()); | 45 new OwnedMailbox(factory->GetGLHelper()); |
| 45 EXPECT_FALSE(mailbox->mailbox().IsZero()); | 46 EXPECT_FALSE(mailbox->mailbox().IsZero()); |
| 46 | 47 |
| 47 MockImageTransportFactoryObserver observer; | 48 MockImageTransportFactoryObserver observer; |
| 48 factory->AddObserver(&observer); | 49 factory->AddObserver(&observer); |
| 49 | 50 |
| 50 base::RunLoop run_loop; | 51 base::RunLoop run_loop; |
| 51 EXPECT_CALL(observer, OnLostResources()) | 52 EXPECT_CALL(observer, OnLostResources()) |
| 52 .WillOnce(testing::InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); | 53 .WillOnce(testing::InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); |
| 53 | 54 |
| 54 ui::ContextFactory* context_factory = ui::ContextFactory::GetInstance(); | 55 ui::ContextFactory* context_factory = factory->GetContextFactory(); |
| 55 gpu::gles2::GLES2Interface* gl = | 56 gpu::gles2::GLES2Interface* gl = |
| 56 context_factory->SharedMainThreadContextProvider()->ContextGL(); | 57 context_factory->SharedMainThreadContextProvider()->ContextGL(); |
| 57 gl->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, | 58 gl->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
| 58 GL_INNOCENT_CONTEXT_RESET_ARB); | 59 GL_INNOCENT_CONTEXT_RESET_ARB); |
| 59 | 60 |
| 60 // 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 |
| 61 // the context is gone. | 62 // the context is gone. |
| 62 gl->Flush(); | 63 gl->Flush(); |
| 63 | 64 |
| 64 run_loop.Run(); | 65 run_loop.Run(); |
| 65 EXPECT_TRUE(mailbox->mailbox().IsZero()); | 66 EXPECT_TRUE(mailbox->mailbox().IsZero()); |
| 66 | 67 |
| 67 factory->RemoveObserver(&observer); | 68 factory->RemoveObserver(&observer); |
| 68 } | 69 } |
| 69 | 70 |
| 70 } // anonymous namespace | 71 } // anonymous namespace |
| 71 } // namespace content | 72 } // namespace content |
| OLD | NEW |