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

Side by Side Diff: media/base/android/media_source_player_unittest.cc

Issue 239743005: Updates WebMediaPlayerAndroid and MediaSourceDelegate to respect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: const Created 6 years, 8 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
« no previous file with comments | « media/base/android/media_source_player.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 11 matching lines...) Expand all
22 22
23 // Helper macro to skip the test if MediaCodecBridge isn't available. 23 // Helper macro to skip the test if MediaCodecBridge isn't available.
24 #define SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE() \ 24 #define SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE() \
25 do { \ 25 do { \
26 if (!MediaCodecBridge::IsAvailable()) { \ 26 if (!MediaCodecBridge::IsAvailable()) { \
27 VLOG(0) << "Could not run test - not supported on device."; \ 27 VLOG(0) << "Could not run test - not supported on device."; \
28 return; \ 28 return; \
29 } \ 29 } \
30 } while (0) 30 } while (0)
31 31
32 const int kDefaultDurationInMs = 10000; 32 const base::TimeDelta kDefaultDuration =
33 base::TimeDelta::FromMilliseconds(10000);
33 34
34 // TODO(wolenetz/qinmin): Simplify tests with more effective mock usage, and 35 // TODO(wolenetz/qinmin): Simplify tests with more effective mock usage, and
35 // fix flaky pointer-based MDJ inequality testing. See http://crbug.com/327839. 36 // fix flaky pointer-based MDJ inequality testing. See http://crbug.com/327839.
36 37
37 // Mock of MediaPlayerManager for testing purpose. 38 // Mock of MediaPlayerManager for testing purpose.
38 class MockMediaPlayerManager : public MediaPlayerManager { 39 class MockMediaPlayerManager : public MediaPlayerManager {
39 public: 40 public:
40 explicit MockMediaPlayerManager(base::MessageLoop* message_loop) 41 explicit MockMediaPlayerManager(base::MessageLoop* message_loop)
41 : message_loop_(message_loop), 42 : message_loop_(message_loop),
42 playback_completed_(false), 43 playback_completed_(false),
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // use by tests, only where required. 245 // use by tests, only where required.
245 bool IsPendingSurfaceChange() { 246 bool IsPendingSurfaceChange() {
246 return player_.IsEventPending(player_.SURFACE_CHANGE_EVENT_PENDING); 247 return player_.IsEventPending(player_.SURFACE_CHANGE_EVENT_PENDING);
247 } 248 }
248 249
249 DemuxerConfigs CreateAudioDemuxerConfigs(AudioCodec audio_codec) { 250 DemuxerConfigs CreateAudioDemuxerConfigs(AudioCodec audio_codec) {
250 DemuxerConfigs configs; 251 DemuxerConfigs configs;
251 configs.audio_codec = audio_codec; 252 configs.audio_codec = audio_codec;
252 configs.audio_channels = 2; 253 configs.audio_channels = 2;
253 configs.is_audio_encrypted = false; 254 configs.is_audio_encrypted = false;
254 configs.duration_ms = kDefaultDurationInMs; 255 configs.duration = kDefaultDuration;
255 256
256 if (audio_codec == kCodecVorbis) { 257 if (audio_codec == kCodecVorbis) {
257 configs.audio_sampling_rate = 44100; 258 configs.audio_sampling_rate = 44100;
258 scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile( 259 scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile(
259 "vorbis-extradata"); 260 "vorbis-extradata");
260 configs.audio_extra_data = std::vector<uint8>( 261 configs.audio_extra_data = std::vector<uint8>(
261 buffer->data(), 262 buffer->data(),
262 buffer->data() + buffer->data_size()); 263 buffer->data() + buffer->data_size());
263 return configs; 264 return configs;
264 } 265 }
265 266
266 // Other codecs are not yet supported by this helper. 267 // Other codecs are not yet supported by this helper.
267 EXPECT_EQ(audio_codec, kCodecAAC); 268 EXPECT_EQ(audio_codec, kCodecAAC);
268 269
269 configs.audio_sampling_rate = 48000; 270 configs.audio_sampling_rate = 48000;
270 uint8 aac_extra_data[] = { 0x13, 0x10 }; 271 uint8 aac_extra_data[] = { 0x13, 0x10 };
271 configs.audio_extra_data = std::vector<uint8>( 272 configs.audio_extra_data = std::vector<uint8>(
272 aac_extra_data, 273 aac_extra_data,
273 aac_extra_data + 2); 274 aac_extra_data + 2);
274 return configs; 275 return configs;
275 } 276 }
276 277
277 DemuxerConfigs CreateVideoDemuxerConfigs() { 278 DemuxerConfigs CreateVideoDemuxerConfigs() {
278 DemuxerConfigs configs; 279 DemuxerConfigs configs;
279 configs.video_codec = kCodecVP8; 280 configs.video_codec = kCodecVP8;
280 configs.video_size = gfx::Size(320, 240); 281 configs.video_size = gfx::Size(320, 240);
281 configs.is_video_encrypted = false; 282 configs.is_video_encrypted = false;
282 configs.duration_ms = kDefaultDurationInMs; 283 configs.duration = kDefaultDuration;
283 return configs; 284 return configs;
284 } 285 }
285 286
286 DemuxerConfigs CreateAudioVideoDemuxerConfigs() { 287 DemuxerConfigs CreateAudioVideoDemuxerConfigs() {
287 DemuxerConfigs configs = CreateAudioDemuxerConfigs(kCodecVorbis); 288 DemuxerConfigs configs = CreateAudioDemuxerConfigs(kCodecVorbis);
288 configs.video_codec = kCodecVP8; 289 configs.video_codec = kCodecVP8;
289 configs.video_size = gfx::Size(320, 240); 290 configs.video_size = gfx::Size(320, 240);
290 configs.is_video_encrypted = false; 291 configs.is_video_encrypted = false;
291 return configs; 292 return configs;
292 } 293 }
(...skipping 1765 matching lines...) Expand 10 before | Expand all | Expand 10 after
2058 DemuxerConfigs configs = CreateVideoDemuxerConfigs(); 2059 DemuxerConfigs configs = CreateVideoDemuxerConfigs();
2059 configs.is_video_encrypted = true; 2060 configs.is_video_encrypted = true;
2060 2061
2061 player_.OnDemuxerConfigsAvailable(configs); 2062 player_.OnDemuxerConfigsAvailable(configs);
2062 CreateNextTextureAndSetVideoSurface(); 2063 CreateNextTextureAndSetVideoSurface();
2063 EXPECT_FALSE(IsPendingSurfaceChange()); 2064 EXPECT_FALSE(IsPendingSurfaceChange());
2064 EXPECT_FALSE(GetMediaDecoderJob(false)); 2065 EXPECT_FALSE(GetMediaDecoderJob(false));
2065 } 2066 }
2066 2067
2067 } // namespace media 2068 } // namespace media
OLDNEW
« no previous file with comments | « media/base/android/media_source_player.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698