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 "media/ffmpeg/ffmpeg_common.h" | 7 #include "media/ffmpeg/ffmpeg_common.h" |
7 #include "media/filters/ffmpeg_glue.h" | 8 #include "media/filters/ffmpeg_glue.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
9 | 10 |
10 namespace media { | 11 namespace media { |
11 | 12 |
12 class FFmpegCommonTest : public testing::Test { | 13 class FFmpegCommonTest : public testing::Test { |
13 public: | 14 public: |
14 FFmpegCommonTest() { FFmpegGlue::InitializeFFmpeg(); } | 15 FFmpegCommonTest() { FFmpegGlue::InitializeFFmpeg(); } |
15 ~FFmpegCommonTest() override{}; | 16 ~FFmpegCommonTest() override{}; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 EXPECT_EQ(2012, exploded.year); | 82 EXPECT_EQ(2012, exploded.year); |
82 EXPECT_EQ(11, exploded.month); | 83 EXPECT_EQ(11, exploded.month); |
83 EXPECT_EQ(6, exploded.day_of_week); | 84 EXPECT_EQ(6, exploded.day_of_week); |
84 EXPECT_EQ(10, exploded.day_of_month); | 85 EXPECT_EQ(10, exploded.day_of_month); |
85 EXPECT_EQ(12, exploded.hour); | 86 EXPECT_EQ(12, exploded.hour); |
86 EXPECT_EQ(34, exploded.minute); | 87 EXPECT_EQ(34, exploded.minute); |
87 EXPECT_EQ(56, exploded.second); | 88 EXPECT_EQ(56, exploded.second); |
88 EXPECT_EQ(0, exploded.millisecond); | 89 EXPECT_EQ(0, exploded.millisecond); |
89 } | 90 } |
90 | 91 |
| 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 |
91 TEST_F(FFmpegCommonTest, UTCDateToTime_Invalid) { | 103 TEST_F(FFmpegCommonTest, UTCDateToTime_Invalid) { |
92 const char* invalid_date_strings[] = { | 104 const char* invalid_date_strings[] = { |
93 "", | 105 "", |
94 "2012-11-10", | 106 "2012-11-10", |
95 "12:34:56", | 107 "12:34:56", |
96 "-- ::", | 108 "-- ::", |
97 "2012-11-10 12:34:", | 109 "2012-11-10 12:34:", |
98 "2012-11-10 12::56", | 110 "2012-11-10 12::56", |
99 "2012-11-10 :34:56", | 111 "2012-11-10 :34:56", |
100 "2012-11- 12:34:56", | 112 "2012-11- 12:34:56", |
(...skipping 17 matching lines...) Expand all Loading... |
118 for (size_t i = 0; i < arraysize(invalid_date_strings); ++i) { | 130 for (size_t i = 0; i < arraysize(invalid_date_strings); ++i) { |
119 const char* date_string = invalid_date_strings[i]; | 131 const char* date_string = invalid_date_strings[i]; |
120 base::Time result; | 132 base::Time result; |
121 EXPECT_FALSE(FFmpegUTCDateToTime(date_string, &result)) | 133 EXPECT_FALSE(FFmpegUTCDateToTime(date_string, &result)) |
122 << "date_string '" << date_string << "'"; | 134 << "date_string '" << date_string << "'"; |
123 EXPECT_TRUE(result.is_null()); | 135 EXPECT_TRUE(result.is_null()); |
124 } | 136 } |
125 } | 137 } |
126 | 138 |
127 } // namespace media | 139 } // namespace media |
OLD | NEW |