Index: media/base/audio_video_metadata_extractor_unittest.cc |
diff --git a/media/base/audio_video_metadata_extractor_unittest.cc b/media/base/audio_video_metadata_extractor_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..420d8bfcac9f9a785b9c1964f1bfa4cd3781b3eb |
--- /dev/null |
+++ b/media/base/audio_video_metadata_extractor_unittest.cc |
@@ -0,0 +1,85 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "base/logging.h" |
+#include "build/build_config.h" |
+#include "media/base/audio_video_metadata_extractor.h" |
+#include "media/base/test_data_util.h" |
+#include "media/filters/file_data_source.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace media { |
+ |
+void RunExtractor( |
+ const std::string& filename, |
+ bool expected_result, |
+ const std::string& expected_type, |
+ int expected_duration, |
+ int expected_width, |
+ int expected_height, |
+ std::map<std::string, std::string>* tags_result) { |
+ FileDataSource source; |
+ ASSERT_TRUE(source.Initialize(GetTestDataFilePath(filename))); |
+ |
+ AudioVideoMetadataExtractor extractor(&source); |
+ bool extracted = extractor.Extract(); |
+ ASSERT_EQ(expected_result, extracted); |
+ |
+ if (!extracted) |
+ return; |
+ |
+ EXPECT_EQ(expected_type, extractor.GetFormat()); |
+ EXPECT_EQ(expected_duration, extractor.GetDurationSeconds()); |
+ |
+ EXPECT_EQ(expected_width, extractor.GetWidth()); |
+ EXPECT_EQ(expected_height, extractor.GetHeight()); |
+ |
+ if (tags_result) |
+ *tags_result = extractor.GetTags(); |
+} |
+ |
+TEST(AudioVideoMetadataExtractorTest, InvalidFile) { |
+ RunExtractor("ten_byte_file", false, "", 0, 0, 0, NULL); |
+} |
+ |
+TEST(AudioVideoMetadataExtractorTest, AudioOGG) { |
+ std::map<std::string, std::string> tags; |
+ RunExtractor("9ch.ogg", true, "ogg", 0, 0, 0, &tags); |
+ ASSERT_EQ(1u, tags.size()); |
+ EXPECT_EQ("Processed by SoX", tags["comment"]); |
+} |
+ |
+TEST(AudioVideoMetadataExtractorTest, AudioWAV) { |
+ std::map<std::string, std::string> tags; |
+ RunExtractor("sfx_u8.wav", true, "wav", 0, 0, 0, &tags); |
+ ASSERT_EQ(2u, tags.size()); |
+ EXPECT_EQ("Lavf54.37.100", tags["encoder"]); |
+ EXPECT_EQ("Amadeus Pro", tags["encoded_by"]); |
+} |
+ |
+TEST(AudioVideoMetadataExtractorTest, VideoWebM) { |
+ std::map<std::string, std::string> tags; |
+ RunExtractor("bear-320x240-multitrack.webm", true, "matroska,webm", 2, |
+ 320, 240, &tags); |
+ ASSERT_EQ(1u, tags.size()); |
+ EXPECT_EQ("Lavf53.9.0", tags["encoder"]); |
+} |
+ |
+#if defined(USE_PROPRIETARY_CODECS) |
+TEST(AudioVideoMetadataExtractorTest, AudioMP3) { |
+ std::map<std::string, std::string> tags; |
+ RunExtractor("id3_png_test.mp3", true, "mp3", 1, 0, 0, &tags); |
+ |
+ ASSERT_EQ(7u, tags.size()); |
+ EXPECT_EQ("Airbag", tags["title"]); |
+ EXPECT_EQ("Radiohead", tags["artist"]); |
+ EXPECT_EQ("OK Computer", tags["album"]); |
+ EXPECT_EQ("1", tags["track"]); |
+ EXPECT_EQ("Alternative", tags["genre"]); |
+ EXPECT_EQ("1997", tags["date"]); |
+ EXPECT_EQ("Lavf54.4.100", tags["encoder"]); |
+} |
+#endif |
+ |
+} // namespace media |