diff options
-rw-r--r-- | content/browser/aura/gpu_process_transport_factory.cc | 21 | ||||
-rw-r--r-- | content/browser/aura/image_transport_factory_browsertest.cc | 56 | ||||
-rw-r--r-- | content/content_tests.gypi | 5 |
3 files changed, 69 insertions, 13 deletions
diff --git a/content/browser/aura/gpu_process_transport_factory.cc b/content/browser/aura/gpu_process_transport_factory.cc index e9080f0..2d09b24 100644 --- a/content/browser/aura/gpu_process_transport_factory.cc +++ b/content/browser/aura/gpu_process_transport_factory.cc @@ -407,16 +407,6 @@ GpuProcessTransportFactory::OffscreenCompositorContextProvider() { GpuProcessTransportFactory::CreateOffscreenCommandBufferContext(), "Compositor-Offscreen"); - if (!offscreen_compositor_contexts_.get()) - return NULL; - - if (!ui::Compositor::WasInitializedWithThread()) { - offscreen_compositor_contexts_->SetLostContextCallback(base::Bind( - &GpuProcessTransportFactory:: - OnLostMainThreadSharedContextInsideCallback, - callback_factory_.GetWeakPtr())); - } - return offscreen_compositor_contexts_; } @@ -440,9 +430,14 @@ GpuProcessTransportFactory::SharedMainThreadContextProvider() { OffscreenCompositorContextProvider().get()); } - if (shared_main_thread_contexts_ && - !shared_main_thread_contexts_->BindToCurrentThread()) - shared_main_thread_contexts_ = NULL; + if (shared_main_thread_contexts_) { + shared_main_thread_contexts_->SetLostContextCallback( + base::Bind(&GpuProcessTransportFactory:: + OnLostMainThreadSharedContextInsideCallback, + callback_factory_.GetWeakPtr())); + if (!shared_main_thread_contexts_->BindToCurrentThread()) + shared_main_thread_contexts_ = NULL; + } return shared_main_thread_contexts_; } diff --git a/content/browser/aura/image_transport_factory_browsertest.cc b/content/browser/aura/image_transport_factory_browsertest.cc new file mode 100644 index 0000000..233c06c --- /dev/null +++ b/content/browser/aura/image_transport_factory_browsertest.cc @@ -0,0 +1,56 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/run_loop.h" +#include "content/browser/aura/image_transport_factory.h" +#include "content/test/content_browser_test.h" +#include "gpu/GLES2/gl2extchromium.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" +#include "ui/compositor/compositor.h" + +namespace content { +namespace { + +class ImageTransportFactoryBrowserTest : public ContentBrowserTest { + public: + ImageTransportFactoryBrowserTest() {} + + virtual void SetUp() OVERRIDE { + UseRealGLContexts(); + ContentBrowserTest::SetUp(); + } +}; + +class MockImageTransportFactoryObserver : public ImageTransportFactoryObserver { + public: + MOCK_METHOD0(OnLostResources, void()); +}; + +// Checks that upon context loss, the observer is called and the created +// resources are reset. +IN_PROC_BROWSER_TEST_F(ImageTransportFactoryBrowserTest, TestLostContext) { + ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); + scoped_refptr<ui::Texture> texture = factory->CreateTransportClient(1.f); + + MockImageTransportFactoryObserver observer; + factory->AddObserver(&observer); + + base::RunLoop run_loop; + EXPECT_CALL(observer, OnLostResources()) + .WillOnce(testing::InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); + + WebKit::WebGraphicsContext3D* context = texture->HostContext3D(); + context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, + GL_INNOCENT_CONTEXT_RESET_ARB); + + run_loop.Run(); + EXPECT_FALSE(texture->HostContext3D()); + EXPECT_EQ(0u, texture->PrepareTexture()); + + factory->RemoveObserver(&observer); +} + +} // anonymous namespace +} // namespace content diff --git a/content/content_tests.gypi b/content/content_tests.gypi index 985e485..63e5e2b 100644 --- a/content/content_tests.gypi +++ b/content/content_tests.gypi @@ -854,6 +854,7 @@ 'browser/accessibility/accessibility_win_browsertest.cc', 'browser/accessibility/cross_platform_accessibility_browsertest.cc', 'browser/accessibility/dump_accessibility_tree_browsertest.cc', + 'browser/aura/image_transport_factory_browsertest.cc', 'browser/bookmarklet_browsertest.cc', 'browser/browser_plugin/browser_plugin_host_browsertest.cc', 'browser/browser_plugin/test_browser_plugin_embedder.cc', @@ -1025,6 +1026,10 @@ 'browser/plugin_browsertest.cc', 'browser/renderer_host/render_widget_host_view_win_browsertest.cc', ], + }, { + 'sources/': [ + ['exclude', '^browser/aura/'], + ], }], ['OS!="android" and OS!="ios"', { # npapi test plugin doesn't build on android or ios |