OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/logging.h" | 5 #include "base/logging.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "media/base/media.h" | |
7 #include "media/ffmpeg/ffmpeg_common.h" | 8 #include "media/ffmpeg/ffmpeg_common.h" |
8 #include "media/filters/ffmpeg_glue.h" | 9 #include "media/filters/ffmpeg_glue.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
10 | 11 |
11 namespace media { | 12 namespace media { |
12 | 13 |
13 class FFmpegCommonTest : public testing::Test { | 14 class FFmpegCommonTest : public testing::Test { |
14 public: | 15 public: |
15 FFmpegCommonTest() { FFmpegGlue::InitializeFFmpeg(); } | 16 FFmpegCommonTest() { |
17 InitializeMediaLibrary(); | |
DaleCurtis
2015/06/02 18:21:07
Shouldn't be necessary?
chcunningham
2015/06/03 01:14:16
Done.
| |
18 FFmpegGlue::InitializeFFmpeg(); | |
19 } | |
16 ~FFmpegCommonTest() override{}; | 20 ~FFmpegCommonTest() override{}; |
17 }; | 21 }; |
18 | 22 |
19 TEST_F(FFmpegCommonTest, OpusAudioDecoderConfig) { | 23 TEST_F(FFmpegCommonTest, OpusAudioDecoderConfig) { |
20 AVCodecContext context = {0}; | 24 AVCodecContext context = {0}; |
21 context.codec_type = AVMEDIA_TYPE_AUDIO; | 25 context.codec_type = AVMEDIA_TYPE_AUDIO; |
22 context.codec_id = AV_CODEC_ID_OPUS; | 26 context.codec_id = AV_CODEC_ID_OPUS; |
23 context.channel_layout = CHANNEL_LAYOUT_STEREO; | 27 context.channel_layout = CHANNEL_LAYOUT_STEREO; |
24 context.channels = 2; | 28 context.channels = 2; |
25 context.sample_fmt = AV_SAMPLE_FMT_FLT; | 29 context.sample_fmt = AV_SAMPLE_FMT_FLT; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 EXPECT_EQ(2012, exploded.year); | 86 EXPECT_EQ(2012, exploded.year); |
83 EXPECT_EQ(11, exploded.month); | 87 EXPECT_EQ(11, exploded.month); |
84 EXPECT_EQ(6, exploded.day_of_week); | 88 EXPECT_EQ(6, exploded.day_of_week); |
85 EXPECT_EQ(10, exploded.day_of_month); | 89 EXPECT_EQ(10, exploded.day_of_month); |
86 EXPECT_EQ(12, exploded.hour); | 90 EXPECT_EQ(12, exploded.hour); |
87 EXPECT_EQ(34, exploded.minute); | 91 EXPECT_EQ(34, exploded.minute); |
88 EXPECT_EQ(56, exploded.second); | 92 EXPECT_EQ(56, exploded.second); |
89 EXPECT_EQ(0, exploded.millisecond); | 93 EXPECT_EQ(0, exploded.millisecond); |
90 } | 94 } |
91 | 95 |
92 #if defined(ALLOCATOR_SHIM) && defined(GTEST_HAS_DEATH_TEST) | |
93 TEST_F(FFmpegCommonTest, WinAllocatorShimDeathTest) { | |
94 scoped_ptr<char, base::FreeDeleter> ptr; | |
95 // INT_MAX - 128 is carefully chosen to be below the default limit for | |
96 // ffmpeg allocations, but above the maximum allowed limit by the allocator | |
97 // shim, so we can be certain the code is being hit. | |
98 EXPECT_DEATH(ptr.reset(static_cast<char*>(av_malloc(INT_MAX - 128))), ""); | |
99 ASSERT_TRUE(!ptr); | |
100 } | |
101 #endif | |
102 | |
103 TEST_F(FFmpegCommonTest, UTCDateToTime_Invalid) { | 96 TEST_F(FFmpegCommonTest, UTCDateToTime_Invalid) { |
104 const char* invalid_date_strings[] = { | 97 const char* invalid_date_strings[] = { |
105 "", | 98 "", |
106 "2012-11-10", | 99 "2012-11-10", |
107 "12:34:56", | 100 "12:34:56", |
108 "-- ::", | 101 "-- ::", |
109 "2012-11-10 12:34:", | 102 "2012-11-10 12:34:", |
110 "2012-11-10 12::56", | 103 "2012-11-10 12::56", |
111 "2012-11-10 :34:56", | 104 "2012-11-10 :34:56", |
112 "2012-11- 12:34:56", | 105 "2012-11- 12:34:56", |
(...skipping 17 matching lines...) Expand all Loading... | |
130 for (size_t i = 0; i < arraysize(invalid_date_strings); ++i) { | 123 for (size_t i = 0; i < arraysize(invalid_date_strings); ++i) { |
131 const char* date_string = invalid_date_strings[i]; | 124 const char* date_string = invalid_date_strings[i]; |
132 base::Time result; | 125 base::Time result; |
133 EXPECT_FALSE(FFmpegUTCDateToTime(date_string, &result)) | 126 EXPECT_FALSE(FFmpegUTCDateToTime(date_string, &result)) |
134 << "date_string '" << date_string << "'"; | 127 << "date_string '" << date_string << "'"; |
135 EXPECT_TRUE(result.is_null()); | 128 EXPECT_TRUE(result.is_null()); |
136 } | 129 } |
137 } | 130 } |
138 | 131 |
139 } // namespace media | 132 } // namespace media |
OLD | NEW |