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

Side by Side Diff: media/filters/frame_processor_unittest.cc

Issue 2158923004: Convert media constants to constexpr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 public: 42 public:
43 FrameProcessorTestCallbackHelper() {} 43 FrameProcessorTestCallbackHelper() {}
44 virtual ~FrameProcessorTestCallbackHelper() {} 44 virtual ~FrameProcessorTestCallbackHelper() {}
45 45
46 MOCK_METHOD1(PossibleDurationIncrease, void(base::TimeDelta new_duration)); 46 MOCK_METHOD1(PossibleDurationIncrease, void(base::TimeDelta new_duration));
47 47
48 // Helper that calls the mock method as well as does basic sanity checks on 48 // Helper that calls the mock method as well as does basic sanity checks on
49 // |new_duration|. 49 // |new_duration|.
50 void OnPossibleDurationIncrease(base::TimeDelta new_duration) { 50 void OnPossibleDurationIncrease(base::TimeDelta new_duration) {
51 PossibleDurationIncrease(new_duration); 51 PossibleDurationIncrease(new_duration);
52 ASSERT_NE(kNoTimestamp(), new_duration); 52 ASSERT_NE(kNoTimestamp, new_duration);
53 ASSERT_NE(kInfiniteDuration(), new_duration); 53 ASSERT_NE(kInfiniteDuration, new_duration);
54 } 54 }
55 55
56 private: 56 private:
57 DISALLOW_COPY_AND_ASSIGN(FrameProcessorTestCallbackHelper); 57 DISALLOW_COPY_AND_ASSIGN(FrameProcessorTestCallbackHelper);
58 }; 58 };
59 59
60 // Test parameter determines indicates if the TEST_P instance is targeted for 60 // Test parameter determines indicates if the TEST_P instance is targeted for
61 // sequence mode (if true), or segments mode (if false). 61 // sequence mode (if true), or segments mode (if false).
62 class FrameProcessorTest : public testing::TestWithParam<bool> { 62 class FrameProcessorTest : public testing::TestWithParam<bool> {
63 protected: 63 protected:
64 FrameProcessorTest() 64 FrameProcessorTest()
65 : frame_processor_(new FrameProcessor( 65 : frame_processor_(new FrameProcessor(
66 base::Bind( 66 base::Bind(
67 &FrameProcessorTestCallbackHelper::OnPossibleDurationIncrease, 67 &FrameProcessorTestCallbackHelper::OnPossibleDurationIncrease,
68 base::Unretained(&callbacks_)), 68 base::Unretained(&callbacks_)),
69 new MediaLog())), 69 new MediaLog())),
70 append_window_end_(kInfiniteDuration()), 70 append_window_end_(kInfiniteDuration),
71 frame_duration_(base::TimeDelta::FromMilliseconds(10)), 71 frame_duration_(base::TimeDelta::FromMilliseconds(10)),
72 audio_id_(FrameProcessor::kAudioTrackId), 72 audio_id_(FrameProcessor::kAudioTrackId),
73 video_id_(FrameProcessor::kVideoTrackId) {} 73 video_id_(FrameProcessor::kVideoTrackId) {}
74 74
75 enum StreamFlags { 75 enum StreamFlags {
76 HAS_AUDIO = 1 << 0, 76 HAS_AUDIO = 1 << 0,
77 HAS_VIDEO = 1 << 1 77 HAS_VIDEO = 1 << 1
78 }; 78 };
79 79
80 void AddTestTracks(int stream_flags) { 80 void AddTestTracks(int stream_flags) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 ASSERT_TRUE(frame_processor_->ProcessFrames( 155 ASSERT_TRUE(frame_processor_->ProcessFrames(
156 StringToBufferQueue(audio_timestamps, audio_id_, DemuxerStream::AUDIO), 156 StringToBufferQueue(audio_timestamps, audio_id_, DemuxerStream::AUDIO),
157 StringToBufferQueue(video_timestamps, video_id_, DemuxerStream::VIDEO), 157 StringToBufferQueue(video_timestamps, video_id_, DemuxerStream::VIDEO),
158 empty_text_buffers_, append_window_start_, append_window_end_, 158 empty_text_buffers_, append_window_start_, append_window_end_,
159 &timestamp_offset_)); 159 &timestamp_offset_));
160 } 160 }
161 161
162 void CheckExpectedRangesByTimestamp(ChunkDemuxerStream* stream, 162 void CheckExpectedRangesByTimestamp(ChunkDemuxerStream* stream,
163 const std::string& expected) { 163 const std::string& expected) {
164 // Note, DemuxerStream::TEXT streams return [0,duration (==infinity here)) 164 // Note, DemuxerStream::TEXT streams return [0,duration (==infinity here))
165 Ranges<base::TimeDelta> r = stream->GetBufferedRanges(kInfiniteDuration()); 165 Ranges<base::TimeDelta> r = stream->GetBufferedRanges(kInfiniteDuration);
166 166
167 std::stringstream ss; 167 std::stringstream ss;
168 ss << "{ "; 168 ss << "{ ";
169 for (size_t i = 0; i < r.size(); ++i) { 169 for (size_t i = 0; i < r.size(); ++i) {
170 int64_t start = r.start(i).InMilliseconds(); 170 int64_t start = r.start(i).InMilliseconds();
171 int64_t end = r.end(i).InMilliseconds(); 171 int64_t end = r.end(i).InMilliseconds();
172 ss << "[" << start << "," << end << ") "; 172 ss << "[" << start << "," << end << ") ";
173 } 173 }
174 ss << "}"; 174 ss << "}";
175 EXPECT_EQ(expected, ss.str()); 175 EXPECT_EQ(expected, ss.str());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 226
227 // Decode the original_time_in_ms from the buffer's data. 227 // Decode the original_time_in_ms from the buffer's data.
228 double original_time_in_ms; 228 double original_time_in_ms;
229 ASSERT_EQ(sizeof(original_time_in_ms), last_read_buffer_->data_size()); 229 ASSERT_EQ(sizeof(original_time_in_ms), last_read_buffer_->data_size());
230 original_time_in_ms = *(reinterpret_cast<const double*>( 230 original_time_in_ms = *(reinterpret_cast<const double*>(
231 last_read_buffer_->data())); 231 last_read_buffer_->data()));
232 if (original_time_in_ms != time_in_ms) 232 if (original_time_in_ms != time_in_ms)
233 ss << ":" << original_time_in_ms; 233 ss << ":" << original_time_in_ms;
234 234
235 // Detect full-discard preroll buffer. 235 // Detect full-discard preroll buffer.
236 if (last_read_buffer_->discard_padding().first == kInfiniteDuration() && 236 if (last_read_buffer_->discard_padding().first == kInfiniteDuration &&
237 last_read_buffer_->discard_padding().second.is_zero()) { 237 last_read_buffer_->discard_padding().second.is_zero()) {
238 ss << "P"; 238 ss << "P";
239 } 239 }
240 } 240 }
241 241
242 EXPECT_EQ(expected, ss.str()); 242 EXPECT_EQ(expected, ss.str());
243 CheckReadStalls(stream); 243 CheckReadStalls(stream);
244 } 244 }
245 245
246 // TODO(wolenetz): Refactor to instead verify the expected signalling or lack 246 // TODO(wolenetz): Refactor to instead verify the expected signalling or lack
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 StreamParserBuffer* last_read_parser_buffer = 888 StreamParserBuffer* last_read_parser_buffer =
889 static_cast<StreamParserBuffer*>(last_read_buffer_.get()); 889 static_cast<StreamParserBuffer*>(last_read_buffer_.get());
890 ASSERT_EQ(base::TimeDelta::FromMilliseconds(0), 890 ASSERT_EQ(base::TimeDelta::FromMilliseconds(0),
891 last_read_parser_buffer->preroll_buffer()->duration()); 891 last_read_parser_buffer->preroll_buffer()->duration());
892 } 892 }
893 893
894 INSTANTIATE_TEST_CASE_P(SequenceMode, FrameProcessorTest, Values(true)); 894 INSTANTIATE_TEST_CASE_P(SequenceMode, FrameProcessorTest, Values(true));
895 INSTANTIATE_TEST_CASE_P(SegmentsMode, FrameProcessorTest, Values(false)); 895 INSTANTIATE_TEST_CASE_P(SegmentsMode, FrameProcessorTest, Values(false));
896 896
897 } // namespace media 897 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698