OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef MEDIA_BASE_TEST_HELPERS_H_ | 5 #ifndef MEDIA_BASE_TEST_HELPERS_H_ |
6 #define MEDIA_BASE_TEST_HELPERS_H_ | 6 #define MEDIA_BASE_TEST_HELPERS_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/strings/string_number_conversions.h" |
14 #include "base/threading/non_thread_safe.h" | 15 #include "base/threading/non_thread_safe.h" |
15 #include "media/base/audio_parameters.h" | 16 #include "media/base/audio_parameters.h" |
16 #include "media/base/channel_layout.h" | 17 #include "media/base/channel_layout.h" |
17 #include "media/base/media_log.h" | 18 #include "media/base/media_log.h" |
18 #include "media/base/pipeline_status.h" | 19 #include "media/base/pipeline_status.h" |
19 #include "media/base/sample_format.h" | 20 #include "media/base/sample_format.h" |
20 #include "media/base/video_decoder_config.h" | 21 #include "media/base/video_decoder_config.h" |
21 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
22 #include "ui/gfx/geometry/size.h" | 23 #include "ui/gfx/geometry/size.h" |
23 | 24 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 // some sanity check. | 140 // some sanity check. |
140 scoped_refptr<DecoderBuffer> CreateFakeVideoBufferForTest( | 141 scoped_refptr<DecoderBuffer> CreateFakeVideoBufferForTest( |
141 const VideoDecoderConfig& config, | 142 const VideoDecoderConfig& config, |
142 base::TimeDelta timestamp, | 143 base::TimeDelta timestamp, |
143 base::TimeDelta duration); | 144 base::TimeDelta duration); |
144 | 145 |
145 // Verify if a fake video DecoderBuffer is valid. | 146 // Verify if a fake video DecoderBuffer is valid. |
146 bool VerifyFakeVideoBufferForTest(const scoped_refptr<DecoderBuffer>& buffer, | 147 bool VerifyFakeVideoBufferForTest(const scoped_refptr<DecoderBuffer>& buffer, |
147 const VideoDecoderConfig& config); | 148 const VideoDecoderConfig& config); |
148 | 149 |
| 150 MATCHER_P(HasTimestamp, timestamp_in_ms, "") { |
| 151 return arg.get() && !arg->end_of_stream() && |
| 152 arg->timestamp().InMilliseconds() == timestamp_in_ms; |
| 153 } |
| 154 |
| 155 MATCHER(IsEndOfStream, "") { |
| 156 return arg.get() && arg->end_of_stream(); |
| 157 } |
| 158 |
| 159 MATCHER_P(SegmentMissingFrames, track_id, "") { |
| 160 return CONTAINS_STRING( |
| 161 arg, "Media segment did not contain any coded frames for track " + |
| 162 std::string(track_id)); |
| 163 } |
| 164 |
| 165 MATCHER(StreamParsingFailed, "") { |
| 166 return CONTAINS_STRING(arg, "Append: stream parsing failed."); |
| 167 } |
| 168 |
| 169 MATCHER_P(FoundStream, stream_type_string, "") { |
| 170 return CONTAINS_STRING( |
| 171 arg, "found_" + std::string(stream_type_string) + "_stream") && |
| 172 CONTAINS_STRING(arg, "true"); |
| 173 } |
| 174 |
| 175 MATCHER_P2(CodecName, stream_type_string, codec_string, "") { |
| 176 return CONTAINS_STRING(arg, |
| 177 std::string(stream_type_string) + "_codec_name") && |
| 178 CONTAINS_STRING(arg, std::string(codec_string)); |
| 179 } |
| 180 |
| 181 MATCHER_P2(InitSegmentMismatchesMimeType, stream_type, codec_name, "") { |
| 182 return CONTAINS_STRING(arg, std::string(stream_type) + " stream codec " + |
| 183 std::string(codec_name) + |
| 184 " doesn't match SourceBuffer codecs."); |
| 185 } |
| 186 |
| 187 MATCHER_P(InitSegmentMissesExpectedTrack, missing_codec, "") { |
| 188 return CONTAINS_STRING(arg, "Initialization segment misses expected " + |
| 189 std::string(missing_codec) + " track."); |
| 190 } |
| 191 |
| 192 MATCHER_P2(UnexpectedTrack, track_type, id, "") { |
| 193 return CONTAINS_STRING(arg, std::string("Got unexpected ") + track_type + |
| 194 " track track_id=" + id); |
| 195 } |
| 196 |
| 197 MATCHER_P2(GeneratedSplice, duration_microseconds, time_microseconds, "") { |
| 198 return CONTAINS_STRING(arg, "Generated splice of overlap duration " + |
| 199 base::IntToString(duration_microseconds) + |
| 200 "us into new buffer at " + |
| 201 base::IntToString(time_microseconds) + "us."); |
| 202 } |
| 203 |
| 204 MATCHER_P2(SkippingSpliceAtOrBefore, |
| 205 new_microseconds, |
| 206 existing_microseconds, |
| 207 "") { |
| 208 return CONTAINS_STRING( |
| 209 arg, "Skipping splice frame generation: first new buffer at " + |
| 210 base::IntToString(new_microseconds) + |
| 211 "us begins at or before existing buffer at " + |
| 212 base::IntToString(existing_microseconds) + "us."); |
| 213 } |
| 214 |
| 215 MATCHER_P(SkippingSpliceAlreadySpliced, time_microseconds, "") { |
| 216 return CONTAINS_STRING( |
| 217 arg, "Skipping splice frame generation: overlapped buffers at " + |
| 218 base::IntToString(time_microseconds) + |
| 219 "us are in a previously buffered splice."); |
| 220 } |
| 221 |
| 222 MATCHER_P(WebMSimpleBlockDurationEstimated, estimated_duration_ms, "") { |
| 223 return CONTAINS_STRING(arg, "Estimating WebM block duration to be " + |
| 224 base::IntToString(estimated_duration_ms) + |
| 225 "ms for the last (Simple)Block in the " |
| 226 "Cluster for this Track. Use BlockGroups " |
| 227 "with BlockDurations at the end of each " |
| 228 "Track in a Cluster to avoid estimation."); |
| 229 } |
| 230 |
| 231 MATCHER_P(WebMNegativeTimecodeOffset, timecode_string, "") { |
| 232 return CONTAINS_STRING(arg, "Got a block with negative timecode offset " + |
| 233 std::string(timecode_string)); |
| 234 } |
| 235 |
| 236 MATCHER(WebMOutOfOrderTimecode, "") { |
| 237 return CONTAINS_STRING( |
| 238 arg, "Got a block with a timecode before the previous block."); |
| 239 } |
| 240 |
| 241 MATCHER(WebMClusterBeforeFirstInfo, "") { |
| 242 return CONTAINS_STRING(arg, "Found Cluster element before Info."); |
| 243 } |
| 244 |
149 } // namespace media | 245 } // namespace media |
150 | 246 |
151 #endif // MEDIA_BASE_TEST_HELPERS_H_ | 247 #endif // MEDIA_BASE_TEST_HELPERS_H_ |
OLD | NEW |