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

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: Stylization 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..c7a3f0bad90cfef852a24aeccc9f618031330205
--- /dev/null
+++ b/media/base/encoded_bitstream_buffer_unittest.cc
@@ -0,0 +1,66 @@
+// 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) {
+ scoped_refptr<StrictMock<MockEncodedBitstreamBuffer> > a =
+ new StrictMock<MockEncodedBitstreamBuffer>();
+ EXPECT_EQ(a->key_frame(), false);
tommi (sloooow) - chröme 2013/03/01 16:03:43 EXPECT_FALSE(a->key_frame()) ?
Ville-Mikko Rautio 2013/03/04 14:02:25 Done.
+ 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);
tommi (sloooow) - chröme 2013/03/01 16:03:43 EXPECT_TRUE()?
Ville-Mikko Rautio 2013/03/04 14:02:25 Done.
+ 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
Ami GONE FROM CHROMIUM 2013/03/02 10:47:16 Time to rethink this file's existence?
Ville-Mikko Rautio 2013/03/04 14:02:25 I'm open to removing this as well. On the other ha
+

Powered by Google App Engine
This is Rietveld 408576698