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

Side by Side 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, 9 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 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.
4
5 #include "base/bind.h"
6 #include "base/memory/ref_counted.h"
7 #include "base/message_loop.h"
8 #include "media/base/encoded_bitstream_buffer.h"
9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 using ::testing::StrictMock;
13
14 namespace media {
15
16 class MockEncodedBitstreamBuffer : public EncodedBitstreamBuffer {
17 public:
18 MockEncodedBitstreamBuffer()
19 : EncodedBitstreamBuffer(0, base::Time::Now(), 0) {}
20 MOCK_METHOD0(Die, void());
21 virtual ~MockEncodedBitstreamBuffer() {
22 Die();
23 }
24 };
25
26 static void TestTask(scoped_refptr<EncodedBitstreamBuffer> b) {
27 ASSERT_TRUE(b.get() != NULL);
28 // Just let die and scoped_refptr should go.
29 }
30
31 TEST(EncodedBitstreamBufferTests, BasicTest) {
32 {
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.
33 scoped_refptr<StrictMock<MockEncodedBitstreamBuffer> > a =
34 new StrictMock<MockEncodedBitstreamBuffer>();
35 EXPECT_EQ(a->key_frame(), false);
36 EXPECT_EQ(a->altref_frame(), false);
37 EXPECT_EQ(a->golden_frame(), false);
38 EXPECT_EQ(a->droppable(), false);
39 EXPECT_EQ(a->layer_sync(), false);
40 a->MarkKeyFrame();
41 a->MarkAltRef();
42 a->MarkGolden();
43 a->MarkDroppable();
44 a->MarkLayerSync();
45 EXPECT_EQ(a->key_frame(), true);
46 EXPECT_EQ(a->altref_frame(), true);
47 EXPECT_EQ(a->golden_frame(), true);
48 EXPECT_EQ(a->droppable(), true);
49 EXPECT_EQ(a->layer_sync(), true);
50 EXPECT_CALL(*a.get(), Die());
51 }
52 }
53
54 TEST(EncodedBitstreamBufferTests, CrossThreadTest) {
55 MessageLoop message_loop;
56 {
57 scoped_refptr<StrictMock<MockEncodedBitstreamBuffer> > a =
58 new StrictMock<MockEncodedBitstreamBuffer>();
59 base::Closure task = base::Bind(&TestTask, a);
60 message_loop.PostTask(FROM_HERE, task);
61 EXPECT_CALL(*a.get(), Die());
62 } // Now our reference should be gone.
63 // When TestTask finishes, destructor should be called.
64 message_loop.RunUntilIdle();
65 }
66
67 } // namespace media
68
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698