cc: Adding DidFinishImplFrame to LTHI.
[chromium-blink-merge.git] / cc / resources / texture_mailbox_deleter_unittest.cc
blob15b425071327a8bee9e9403783ebd0e8628d1d9f
1 // Copyright 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.
5 #include "cc/resources/texture_mailbox_deleter.h"
7 #include "base/single_thread_task_runner.h"
8 #include "base/thread_task_runner_handle.h"
9 #include "cc/resources/single_release_callback.h"
10 #include "cc/test/test_context_provider.h"
11 #include "cc/test/test_web_graphics_context_3d.h"
12 #include "testing/gtest/include/gtest/gtest.h"
14 namespace cc {
15 namespace {
17 TEST(TextureMailboxDeleterTest, Destroy) {
18 scoped_ptr<TextureMailboxDeleter> deleter(
19 new TextureMailboxDeleter(base::ThreadTaskRunnerHandle::Get()));
21 scoped_refptr<TestContextProvider> context_provider =
22 TestContextProvider::Create();
23 context_provider->BindToCurrentThread();
25 GLuint texture_id = 0u;
26 context_provider->ContextGL()->GenTextures(1, &texture_id);
28 EXPECT_TRUE(context_provider->HasOneRef());
29 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures());
31 scoped_ptr<SingleReleaseCallback> cb =
32 deleter->GetReleaseCallback(context_provider, texture_id).Pass();
33 EXPECT_FALSE(context_provider->HasOneRef());
34 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures());
36 // When the deleter is destroyed, it immediately drops its ref on the
37 // ContextProvider, and deletes the texture.
38 deleter = nullptr;
39 EXPECT_TRUE(context_provider->HasOneRef());
40 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures());
42 // Run the scoped release callback before destroying it, but it won't do
43 // anything.
44 cb->Run(0, false);
47 } // namespace
48 } // namespace cc