OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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. |
| 4 |
| 5 #include "base/bind.h" |
| 6 #include "cc/resources/single_release_callback.h" |
| 7 #include "components/exo/buffer.h" |
| 8 #include "components/exo/surface.h" |
| 9 #include "components/exo/test/exo_test_base.h" |
| 10 #include "components/exo/test/exo_test_helper.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "ui/gfx/gpu_memory_buffer.h" |
| 13 |
| 14 namespace exo { |
| 15 namespace { |
| 16 |
| 17 using BufferTest = test::ExoTestBase; |
| 18 |
| 19 void Release(int* release_call_count) { |
| 20 (*release_call_count)++; |
| 21 } |
| 22 |
| 23 TEST_F(BufferTest, ReleaseCallback) { |
| 24 gfx::Size buffer_size(256, 256); |
| 25 scoped_ptr<Buffer> buffer( |
| 26 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size).Pass())); |
| 27 |
| 28 // Set the release callback. |
| 29 int release_call_count = 0; |
| 30 buffer->set_release_callback( |
| 31 base::Bind(&Release, base::Unretained(&release_call_count))); |
| 32 |
| 33 // Acquire a texture mailbox for the contents of the buffer. |
| 34 cc::TextureMailbox texture_mailbox; |
| 35 scoped_ptr<cc::SingleReleaseCallback> buffer_release_callback = |
| 36 buffer->GetTextureMailbox(&texture_mailbox); |
| 37 ASSERT_TRUE(buffer_release_callback); |
| 38 |
| 39 // Trying to acquire an already in-use buffer should fail. |
| 40 EXPECT_FALSE(buffer->GetTextureMailbox(&texture_mailbox)); |
| 41 |
| 42 // Release buffer. |
| 43 buffer_release_callback->Run(gpu::SyncToken(), false); |
| 44 |
| 45 // Release() should have been called exactly once. |
| 46 ASSERT_EQ(release_call_count, 1); |
| 47 } |
| 48 |
| 49 } // namespace |
| 50 } // namespace exo |
OLD | NEW |