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

Unified Diff: media/base/encoded_bitstream_buffer_unittest.cc

Issue 12379011: Interfaces for encoded video sources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed Client to be accessed through WeakPtr Created 7 years, 10 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
Index: media/base/encoded_bitstream_buffer_unittest.cc
diff --git a/media/base/encoded_bitstream_buffer_unittest.cc b/media/base/encoded_bitstream_buffer_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d94fa75ff28c685f8ef51bd7ab3e5917f02f6133
--- /dev/null
+++ b/media/base/encoded_bitstream_buffer_unittest.cc
@@ -0,0 +1,68 @@
+// 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/bind.h"
+#include "base/memory/ref_counted.h"
+#include "base/message_loop.h"
+#include "media/base/encoded_bitstream_buffer.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using ::testing::StrictMock;
+
+namespace media {
+
+class MockEncodedBitstreamBuffer : public EncodedBitstreamBuffer {
+ public:
+ MockEncodedBitstreamBuffer()
+ : EncodedBitstreamBuffer(0, base::Time::Now(), 0) {}
+ MOCK_METHOD0(Die, void());
+ virtual ~MockEncodedBitstreamBuffer() {
+ Die();
+ }
+};
+
+static void TestTask(scoped_refptr<EncodedBitstreamBuffer> b) {
+ ASSERT_TRUE(b.get() != NULL);
+ // Just let die and scoped_refptr should go.
+}
+
+TEST(EncodedBitstreamBufferTests, BasicTest) {
+ {
wjia(left Chromium) 2013/02/28 18:46:26 It seems this extra pair of braces is not needed.
vmr 2013/03/01 14:24:00 Done.
+ scoped_refptr<StrictMock<MockEncodedBitstreamBuffer> > a =
+ new StrictMock<MockEncodedBitstreamBuffer>();
+ EXPECT_EQ(a->key_frame(), false);
+ EXPECT_EQ(a->altref_frame(), false);
+ EXPECT_EQ(a->golden_frame(), false);
+ EXPECT_EQ(a->droppable(), false);
+ EXPECT_EQ(a->layer_sync(), false);
+ a->MarkKeyFrame();
+ a->MarkAltRef();
+ a->MarkGolden();
+ a->MarkDroppable();
+ a->MarkLayerSync();
+ EXPECT_EQ(a->key_frame(), true);
+ EXPECT_EQ(a->altref_frame(), true);
+ EXPECT_EQ(a->golden_frame(), true);
+ EXPECT_EQ(a->droppable(), true);
+ EXPECT_EQ(a->layer_sync(), true);
+ EXPECT_CALL(*a.get(), Die());
+ }
+}
+
+TEST(EncodedBitstreamBufferTests, CrossThreadTest) {
+ MessageLoop message_loop;
+ {
+ scoped_refptr<StrictMock<MockEncodedBitstreamBuffer> > a =
+ new StrictMock<MockEncodedBitstreamBuffer>();
+ base::Closure task = base::Bind(&TestTask, a);
+ message_loop.PostTask(FROM_HERE, task);
+ EXPECT_CALL(*a.get(), Die());
+ } // Now our reference should be gone.
+ // When TestTask finishes, destructor should be called.
+ message_loop.RunUntilIdle();
+}
+
+} // namespace media
+

Powered by Google App Engine
This is Rietveld 408576698