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

Unified Diff: cc/resources/texture_mailbox_deleter_unittest.cc

Issue 23454014: cc: Drop ContextProvider references on the impl thread before quitting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: callbackcontrolcenter: rebase Created 7 years, 3 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 | « cc/resources/texture_mailbox_deleter.cc ('k') | cc/test/pixel_test.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/texture_mailbox_deleter_unittest.cc
diff --git a/cc/resources/texture_mailbox_deleter_unittest.cc b/cc/resources/texture_mailbox_deleter_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e08984e7583268b3a48e64e0723e3c62af7f1c5f
--- /dev/null
+++ b/cc/resources/texture_mailbox_deleter_unittest.cc
@@ -0,0 +1,39 @@
+// 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 "cc/resources/texture_mailbox_deleter.h"
+
+#include "cc/debug/test_context_provider.h"
+#include "cc/debug/test_web_graphics_context_3d.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace cc {
+namespace {
+
+TEST(TextureMailboxDeleterTest, Destroy) {
+ scoped_ptr<TextureMailboxDeleter> deleter(new TextureMailboxDeleter);
+
+ scoped_refptr<TestContextProvider> context_provider =
+ TestContextProvider::Create();
+ context_provider->BindToCurrentThread();
+
+ unsigned texture_id = context_provider->Context3d()->createTexture();
+
+ EXPECT_TRUE(context_provider->HasOneRef());
+ EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures());
+
+ TextureMailbox::ReleaseCallback cb =
+ deleter->GetReleaseCallback(context_provider, texture_id);
+ EXPECT_FALSE(context_provider->HasOneRef());
+ EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures());
+
+ // When the deleter is destroyed, it immediately drops its ref on the
+ // ContextProvider, and deletes the texture.
+ deleter.reset();
+ EXPECT_TRUE(context_provider->HasOneRef());
+ EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures());
+}
+
+} // namespace
+} // namespace cc
« no previous file with comments | « cc/resources/texture_mailbox_deleter.cc ('k') | cc/test/pixel_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698