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

Unified Diff: media/base/audio_video_metadata_extractor_unittest.cc

Issue 121383002: Media Galleries API Metadata: Add audio video metadata extractor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address thestig comments Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
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..c55cd5df3b2c1bcee4da9748c188e66dde1ab317
--- /dev/null
+++ b/media/base/audio_video_metadata_extractor_unittest.cc
@@ -0,0 +1,78 @@
+// Copyright 2014 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 "base/memory/scoped_ptr.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 {
+
+scoped_ptr<AudioVideoMetadataExtractor> GetExtractor(
+ const std::string& filename,
+ bool expected_result,
+ double expected_duration,
+ int expected_width,
+ int expected_height) {
+ FileDataSource source;
+ EXPECT_TRUE(source.Initialize(GetTestDataFilePath(filename)));
+
+ scoped_ptr<AudioVideoMetadataExtractor> extractor(
+ new AudioVideoMetadataExtractor);
+ bool extracted = extractor->Extract(&source);
+ EXPECT_EQ(expected_result, extracted);
+
+ if (!extracted)
+ return extractor.Pass();
+
+ EXPECT_EQ(expected_duration, extractor->duration());
+
+ EXPECT_EQ(expected_width, extractor->width());
+ EXPECT_EQ(expected_height, extractor->height());
+
+ return extractor.Pass();
+}
+
+TEST(AudioVideoMetadataExtractorTest, InvalidFile) {
+ GetExtractor("ten_byte_file", false, 0, -1, -1);
+}
+
+TEST(AudioVideoMetadataExtractorTest, AudioOGG) {
+ scoped_ptr<AudioVideoMetadataExtractor> extractor =
+ GetExtractor("9ch.ogg", true, 0, -1, -1);
+ EXPECT_EQ("Processed by SoX", extractor->comment());
+}
+
+TEST(AudioVideoMetadataExtractorTest, AudioWAV) {
+ scoped_ptr<AudioVideoMetadataExtractor> extractor =
+ GetExtractor("sfx_u8.wav", true, 0, -1, -1);
+ EXPECT_EQ("Lavf54.37.100", extractor->encoder());
+ EXPECT_EQ("Amadeus Pro", extractor->encoded_by());
+}
+
+TEST(AudioVideoMetadataExtractorTest, VideoWebM) {
+ scoped_ptr<AudioVideoMetadataExtractor> extractor =
+ GetExtractor("bear-320x240-multitrack.webm", true, 2, 320, 240);
+ EXPECT_EQ("Lavf53.9.0", extractor->encoder());
+}
+
+#if defined(USE_PROPRIETARY_CODECS)
+TEST(AudioVideoMetadataExtractorTest, AudioMP3) {
+ scoped_ptr<AudioVideoMetadataExtractor> extractor =
+ GetExtractor("id3_png_test.mp3", true, 1, -1, -1);
+
+ EXPECT_EQ("Airbag", extractor->title());
+ EXPECT_EQ("Radiohead", extractor->artist());
+ EXPECT_EQ("OK Computer", extractor->album());
+ EXPECT_EQ(1, extractor->track());
+ EXPECT_EQ("Alternative", extractor->genre());
+ EXPECT_EQ("1997", extractor->date());
+ EXPECT_EQ("Lavf54.4.100", extractor->encoder());
+}
+#endif
+
+} // namespace media

Powered by Google App Engine
This is Rietveld 408576698