OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <memory> | 5 #include <memory> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 DISALLOW_COPY_AND_ASSIGN(NullVideoSinkTest); | 66 DISALLOW_COPY_AND_ASSIGN(NullVideoSinkTest); |
67 }; | 67 }; |
68 | 68 |
69 TEST_F(NullVideoSinkTest, BasicFunctionality) { | 69 TEST_F(NullVideoSinkTest, BasicFunctionality) { |
70 const base::TimeDelta kInterval = base::TimeDelta::FromMilliseconds(25); | 70 const base::TimeDelta kInterval = base::TimeDelta::FromMilliseconds(25); |
71 | 71 |
72 std::unique_ptr<NullVideoSink> sink = ConstructSink(false, kInterval); | 72 std::unique_ptr<NullVideoSink> sink = ConstructSink(false, kInterval); |
73 scoped_refptr<VideoFrame> test_frame = CreateFrame(base::TimeDelta()); | 73 scoped_refptr<VideoFrame> test_frame = CreateFrame(base::TimeDelta()); |
74 | 74 |
75 // The sink shouldn't have to be started to use the paint method. | |
76 EXPECT_CALL(*this, FrameReceived(test_frame)); | |
77 sink->PaintSingleFrame(test_frame); | |
78 | |
79 { | 75 { |
80 SCOPED_TRACE("Waiting for sink startup."); | 76 SCOPED_TRACE("Waiting for sink startup."); |
81 sink->Start(this); | 77 sink->Start(this); |
82 const base::TimeTicks current_time = tick_clock_.NowTicks(); | 78 const base::TimeTicks current_time = tick_clock_.NowTicks(); |
83 const base::TimeTicks current_interval_end = current_time + kInterval; | 79 const base::TimeTicks current_interval_end = current_time + kInterval; |
84 EXPECT_CALL(*this, Render(current_time, current_interval_end, false)) | 80 EXPECT_CALL(*this, Render(current_time, current_interval_end, false)) |
85 .WillOnce(Return(test_frame)); | 81 .WillOnce(Return(test_frame)); |
86 WaitableMessageLoopEvent event; | 82 WaitableMessageLoopEvent event; |
87 EXPECT_CALL(*this, FrameReceived(test_frame)) | 83 EXPECT_CALL(*this, FrameReceived(test_frame)) |
88 .WillOnce(RunClosure(event.GetClosure())); | 84 .WillOnce(RunClosure(event.GetClosure())); |
(...skipping 19 matching lines...) Expand all Loading... |
108 event.RunAndWait(); | 104 event.RunAndWait(); |
109 } | 105 } |
110 | 106 |
111 { | 107 { |
112 SCOPED_TRACE("Waiting for stop event."); | 108 SCOPED_TRACE("Waiting for stop event."); |
113 WaitableMessageLoopEvent event; | 109 WaitableMessageLoopEvent event; |
114 sink->set_stop_cb(event.GetClosure()); | 110 sink->set_stop_cb(event.GetClosure()); |
115 sink->Stop(); | 111 sink->Stop(); |
116 event.RunAndWait(); | 112 event.RunAndWait(); |
117 } | 113 } |
| 114 |
| 115 // The sink shouldn't have to be started to use the paint method. |
| 116 EXPECT_CALL(*this, FrameReceived(test_frame)); |
| 117 sink->PaintSingleFrame(test_frame); |
118 } | 118 } |
119 | 119 |
120 TEST_F(NullVideoSinkTest, ClocklessFunctionality) { | 120 TEST_F(NullVideoSinkTest, ClocklessFunctionality) { |
121 // Construct the sink with a huge interval, it should still complete quickly. | 121 // Construct the sink with a huge interval, it should still complete quickly. |
122 const base::TimeDelta interval = base::TimeDelta::FromSeconds(10); | 122 const base::TimeDelta interval = base::TimeDelta::FromSeconds(10); |
123 std::unique_ptr<NullVideoSink> sink = ConstructSink(true, interval); | 123 std::unique_ptr<NullVideoSink> sink = ConstructSink(true, interval); |
124 | 124 |
125 scoped_refptr<VideoFrame> test_frame = CreateFrame(base::TimeDelta()); | 125 scoped_refptr<VideoFrame> test_frame = CreateFrame(base::TimeDelta()); |
126 scoped_refptr<VideoFrame> test_frame_2 = CreateFrame(interval); | 126 scoped_refptr<VideoFrame> test_frame_2 = CreateFrame(interval); |
127 sink->Start(this); | 127 sink->Start(this); |
(...skipping 18 matching lines...) Expand all Loading... |
146 .WillOnce( | 146 .WillOnce( |
147 DoAll(RunClosure(event.GetClosure()), Return(test_frame_2))); | 147 DoAll(RunClosure(event.GetClosure()), Return(test_frame_2))); |
148 } | 148 } |
149 } | 149 } |
150 event.RunAndWait(); | 150 event.RunAndWait(); |
151 ASSERT_LT(base::TimeTicks::Now() - now, kTestRuns * interval); | 151 ASSERT_LT(base::TimeTicks::Now() - now, kTestRuns * interval); |
152 sink->Stop(); | 152 sink->Stop(); |
153 } | 153 } |
154 | 154 |
155 } // namespace media | 155 } // namespace media |
OLD | NEW |