Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
|
acolwell GONE FROM CHROMIUM
2014/01/07 00:27:24
ditto
tommycli
2014/01/07 00:55:28
Done.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/logging.h" | |
| 6 #include "base/memory/scoped_ptr.h" | |
| 7 #include "build/build_config.h" | |
| 8 #include "media/base/audio_video_metadata_extractor.h" | |
| 9 #include "media/base/test_data_util.h" | |
| 10 #include "media/filters/file_data_source.h" | |
| 11 #include "testing/gtest/include/gtest/gtest.h" | |
| 12 | |
| 13 namespace media { | |
| 14 | |
| 15 scoped_ptr<AudioVideoMetadataExtractor> GetExtractor( | |
| 16 const std::string& filename, | |
| 17 bool expected_result, | |
| 18 double expected_duration, | |
| 19 int expected_width, | |
| 20 int expected_height) { | |
| 21 FileDataSource source; | |
| 22 EXPECT_TRUE(source.Initialize(GetTestDataFilePath(filename))); | |
| 23 | |
| 24 scoped_ptr<AudioVideoMetadataExtractor> extractor( | |
| 25 new AudioVideoMetadataExtractor); | |
| 26 bool extracted = extractor->Extract(&source); | |
| 27 EXPECT_EQ(expected_result, extracted); | |
| 28 | |
| 29 if (!extracted) | |
| 30 return extractor.Pass(); | |
| 31 | |
| 32 EXPECT_EQ(expected_duration, extractor->duration()); | |
| 33 | |
| 34 EXPECT_EQ(expected_width, extractor->width()); | |
| 35 EXPECT_EQ(expected_height, extractor->height()); | |
| 36 | |
| 37 return extractor.Pass(); | |
| 38 } | |
| 39 | |
| 40 TEST(AudioVideoMetadataExtractorTest, InvalidFile) { | |
| 41 GetExtractor("ten_byte_file", false, 0, -1, -1); | |
| 42 } | |
| 43 | |
| 44 TEST(AudioVideoMetadataExtractorTest, AudioOGG) { | |
| 45 scoped_ptr<AudioVideoMetadataExtractor> extractor = | |
| 46 GetExtractor("9ch.ogg", true, 0, -1, -1); | |
| 47 EXPECT_EQ("Processed by SoX", extractor->comment()); | |
| 48 } | |
| 49 | |
| 50 TEST(AudioVideoMetadataExtractorTest, AudioWAV) { | |
| 51 scoped_ptr<AudioVideoMetadataExtractor> extractor = | |
| 52 GetExtractor("sfx_u8.wav", true, 0, -1, -1); | |
| 53 EXPECT_EQ("Lavf54.37.100", extractor->encoder()); | |
| 54 EXPECT_EQ("Amadeus Pro", extractor->encoded_by()); | |
| 55 } | |
| 56 | |
| 57 TEST(AudioVideoMetadataExtractorTest, VideoWebM) { | |
| 58 scoped_ptr<AudioVideoMetadataExtractor> extractor = | |
| 59 GetExtractor("bear-320x240-multitrack.webm", true, 2, 320, 240); | |
| 60 EXPECT_EQ("Lavf53.9.0", extractor->encoder()); | |
| 61 } | |
| 62 | |
| 63 #if defined(USE_PROPRIETARY_CODECS) | |
| 64 TEST(AudioVideoMetadataExtractorTest, AudioMP3) { | |
| 65 scoped_ptr<AudioVideoMetadataExtractor> extractor = | |
| 66 GetExtractor("id3_png_test.mp3", true, 1, -1, -1); | |
| 67 | |
| 68 EXPECT_EQ("Airbag", extractor->title()); | |
| 69 EXPECT_EQ("Radiohead", extractor->artist()); | |
| 70 EXPECT_EQ("OK Computer", extractor->album()); | |
| 71 EXPECT_EQ(1, extractor->track()); | |
| 72 EXPECT_EQ("Alternative", extractor->genre()); | |
| 73 EXPECT_EQ("1997", extractor->date()); | |
| 74 EXPECT_EQ("Lavf54.4.100", extractor->encoder()); | |
| 75 } | |
| 76 #endif | |
| 77 | |
| 78 } // namespace media | |
| OLD | NEW |