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

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: Stylization 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 scoped_refptr<StrictMock<MockEncodedBitstreamBuffer> > a =
33 new StrictMock<MockEncodedBitstreamBuffer>();
34 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.
35 EXPECT_EQ(a->altref_frame(), false);
36 EXPECT_EQ(a->golden_frame(), false);
37 EXPECT_EQ(a->droppable(), false);
38 EXPECT_EQ(a->layer_sync(), false);
39 a->MarkKeyFrame();
40 a->MarkAltRef();
41 a->MarkGolden();
42 a->MarkDroppable();
43 a->MarkLayerSync();
44 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.
45 EXPECT_EQ(a->altref_frame(), true);
46 EXPECT_EQ(a->golden_frame(), true);
47 EXPECT_EQ(a->droppable(), true);
48 EXPECT_EQ(a->layer_sync(), true);
49 EXPECT_CALL(*a.get(), Die());
50 }
51
52 TEST(EncodedBitstreamBufferTests, CrossThreadTest) {
53 MessageLoop message_loop;
54 {
55 scoped_refptr<StrictMock<MockEncodedBitstreamBuffer> > a =
56 new StrictMock<MockEncodedBitstreamBuffer>();
57 base::Closure task = base::Bind(&TestTask, a);
58 message_loop.PostTask(FROM_HERE, task);
59 EXPECT_CALL(*a.get(), Die());
60 } // Now our reference should be gone.
61 // When TestTask finishes, destructor should be called.
62 message_loop.RunUntilIdle();
63 }
64
65 } // 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
66
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698