Index: media/formats/mp4/aac_unittest.cc |
diff --git a/media/formats/mp4/aac_unittest.cc b/media/formats/mp4/aac_unittest.cc |
index df1b596873161533a10705458c7b8d6066f7ddc9..a7df37961bd30c3616b8f203816e8754a40dc454 100644 |
--- a/media/formats/mp4/aac_unittest.cc |
+++ b/media/formats/mp4/aac_unittest.cc |
@@ -2,20 +2,35 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "media/formats/mp4/aac.h" |
+#include <string> |
+#include "media/base/mock_media_log.h" |
+#include "media/formats/mp4/aac.h" |
+#include "testing/gmock/include/gmock/gmock.h" |
#include "testing/gtest/include/gtest/gtest.h" |
+using ::testing::InSequence; |
+using ::testing::StrictMock; |
+ |
namespace media { |
namespace mp4 { |
+#define CONTAINS_STRING(arg, x) (std::string::npos != (arg).find(x)) |
chcunningham
2015/08/19 19:36:18
We define this 3 places now (including sbs tests).
wolenetz
2015/08/24 20:13:52
Done (here and in prerequisite CL, since it had so
|
+ |
+MATCHER_P(AudioCodecLog, codec_string, "") { |
+ return CONTAINS_STRING(arg, "Audio codec: " + std::string(codec_string)); |
+} |
+ |
class AACTest : public testing::Test { |
public: |
+ AACTest() : media_log_(new StrictMock<MockMediaLog>()) {} |
+ |
bool Parse(const std::vector<uint8>& data) { |
- return aac_.Parse(data, new MediaLog()); |
+ return aac_.Parse(data, media_log_); |
} |
+ scoped_refptr<StrictMock<MockMediaLog>> media_log_; |
AAC aac_; |
}; |
@@ -25,6 +40,8 @@ TEST_F(AACTest, BasicProfileTest) { |
data.assign(buffer, buffer + sizeof(buffer)); |
+ EXPECT_MEDIA_LOG_STRING(AudioCodecLog("mp4a.40.2")); |
+ |
EXPECT_TRUE(Parse(data)); |
EXPECT_EQ(aac_.GetOutputSamplesPerSecond(false), 44100); |
EXPECT_EQ(aac_.GetChannelLayout(false), CHANNEL_LAYOUT_STEREO); |
@@ -36,6 +53,8 @@ TEST_F(AACTest, ExtensionTest) { |
data.assign(buffer, buffer + sizeof(buffer)); |
+ EXPECT_MEDIA_LOG_STRING(AudioCodecLog("mp4a.40.2")); |
+ |
EXPECT_TRUE(Parse(data)); |
EXPECT_EQ(aac_.GetOutputSamplesPerSecond(false), 48000); |
EXPECT_EQ(aac_.GetOutputSamplesPerSecond(true), 48000); |
@@ -52,6 +71,8 @@ TEST_F(AACTest, ImplicitSBR_ChannelConfig0) { |
data.assign(buffer, buffer + sizeof(buffer)); |
+ EXPECT_MEDIA_LOG_STRING(AudioCodecLog("mp4a.40.2")); |
+ |
EXPECT_TRUE(Parse(data)); |
// Test w/o implict SBR. |
@@ -70,6 +91,8 @@ TEST_F(AACTest, ImplicitSBR_ChannelConfig1) { |
data.assign(buffer, buffer + sizeof(buffer)); |
+ EXPECT_MEDIA_LOG_STRING(AudioCodecLog("mp4a.40.2")); |
+ |
EXPECT_TRUE(Parse(data)); |
// Test w/o implict SBR. |
@@ -87,6 +110,8 @@ TEST_F(AACTest, SixChannelTest) { |
data.assign(buffer, buffer + sizeof(buffer)); |
+ EXPECT_MEDIA_LOG_STRING(AudioCodecLog("mp4a.40.2")); |
+ |
EXPECT_TRUE(Parse(data)); |
EXPECT_EQ(aac_.GetOutputSamplesPerSecond(false), 48000); |
EXPECT_EQ(aac_.GetChannelLayout(false), CHANNEL_LAYOUT_5_1_BACK); |
@@ -102,17 +127,22 @@ TEST_F(AACTest, DataTooShortTest) { |
} |
TEST_F(AACTest, IncorrectProfileTest) { |
+ InSequence s; |
uint8 buffer[] = {0x0, 0x08}; |
std::vector<uint8> data; |
data.assign(buffer, buffer + sizeof(buffer)); |
+ EXPECT_MEDIA_LOG_STRING(AudioCodecLog("mp4a.40.0")); |
EXPECT_FALSE(Parse(data)); |
data[0] = 0x08; |
+ EXPECT_MEDIA_LOG_STRING(AudioCodecLog("mp4a.40.1")); |
EXPECT_TRUE(Parse(data)); |
data[0] = 0x28; |
+ // No media log for this profile 5, since not enough bits are in |data| to |
+ // first parse profile 5's extension frequency index. |
EXPECT_FALSE(Parse(data)); |
} |
@@ -126,6 +156,7 @@ TEST_F(AACTest, IncorrectFrequencyTest) { |
data[0] = 0x0e; |
data[1] = 0x08; |
+ EXPECT_MEDIA_LOG_STRING(AudioCodecLog("mp4a.40.1")); |
EXPECT_TRUE(Parse(data)); |
} |
@@ -135,6 +166,8 @@ TEST_F(AACTest, IncorrectChannelTest) { |
data.assign(buffer, buffer + sizeof(buffer)); |
+ EXPECT_MEDIA_LOG_STRING(AudioCodecLog("mp4a.40.1")).Times(2); |
chcunningham
2015/08/19 19:36:18
Do you know why we do it twice here? Not your faul
wolenetz
2015/08/24 20:13:52
The intrinsic parse sequence emits the AudioCodecL
|
+ |
EXPECT_FALSE(Parse(data)); |
data[1] = 0x08; |