Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1166)

Unified Diff: content/browser/aura/image_transport_factory_browsertest.cc

Issue 25367003: aura: Attach lost context callback to the shared main thread context (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add test Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/aura/gpu_process_transport_factory.cc ('k') | content/content_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/aura/image_transport_factory_browsertest.cc
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 0000000000000000000000000000000000000000..81c74c789fbf2236742ffb0e8e3b6691fc2f86f4
--- /dev/null
+++ b/content/browser/aura/image_transport_factory_browsertest.cc
@@ -0,0 +1,56 @@
+// Copyright (c) 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
« no previous file with comments | « content/browser/aura/gpu_process_transport_factory.cc ('k') | content/content_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698