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

Unified Diff: components/exo/buffer_unittest.cc

Issue 1412093006: components: Add Exosphere component. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove some ifdefs Created 5 years, 1 month 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 | « components/exo/buffer.cc ('k') | components/exo/display.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/exo/buffer_unittest.cc
diff --git a/components/exo/buffer_unittest.cc b/components/exo/buffer_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4da72f4e55438f70ce90305ab8f244d29e5582d8
--- /dev/null
+++ b/components/exo/buffer_unittest.cc
@@ -0,0 +1,52 @@
+// Copyright 2015 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/bind.h"
+#include "cc/resources/single_release_callback.h"
+#include "components/exo/buffer.h"
+#include "components/exo/surface.h"
+#include "components/exo/test/exo_test_base.h"
+#include "components/exo/test/exo_test_helper.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/khronos/GLES2/gl2.h"
+#include "ui/gfx/gpu_memory_buffer.h"
+
+namespace exo {
+namespace {
+
+using BufferTest = test::ExoTestBase;
+
+void Release(int* release_call_count) {
+ (*release_call_count)++;
+}
+
+TEST_F(BufferTest, ReleaseCallback) {
+ gfx::Size buffer_size(256, 256);
+ scoped_ptr<Buffer> buffer(
+ new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size).Pass(),
+ GL_TEXTURE_2D));
+
+ // Set the release callback.
+ int release_call_count = 0;
+ buffer->set_release_callback(
+ base::Bind(&Release, base::Unretained(&release_call_count)));
+
+ // Acquire a texture mailbox for the contents of the buffer.
+ cc::TextureMailbox texture_mailbox;
+ scoped_ptr<cc::SingleReleaseCallback> buffer_release_callback =
+ buffer->AcquireTextureMailbox(&texture_mailbox);
+ ASSERT_TRUE(buffer_release_callback);
+
+ // Trying to acquire an already in-use buffer should fail.
+ EXPECT_FALSE(buffer->AcquireTextureMailbox(&texture_mailbox));
+
+ // Release buffer.
+ buffer_release_callback->Run(gpu::SyncToken(), false);
+
+ // Release() should have been called exactly once.
+ ASSERT_EQ(release_call_count, 1);
+}
+
+} // namespace
+} // namespace exo
« no previous file with comments | « components/exo/buffer.cc ('k') | components/exo/display.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698