OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/memory/scoped_ptr.h" |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "media/base/audio_video_metadata_extractor.h" | 8 #include "media/base/audio_video_metadata_extractor.h" |
9 #include "media/base/test_data_util.h" | 9 #include "media/base/test_data_util.h" |
10 #include "media/filters/file_data_source.h" | 10 #include "media/filters/file_data_source.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 namespace media { | 13 namespace media { |
14 | 14 |
15 scoped_ptr<AudioVideoMetadataExtractor> GetExtractor( | 15 scoped_ptr<AudioVideoMetadataExtractor> GetExtractor( |
16 const std::string& filename, | 16 const std::string& filename, |
17 bool expected_result, | 17 bool expected_result, |
18 double expected_duration, | 18 double expected_duration, |
19 int expected_width, | 19 int expected_width, |
20 int expected_height) { | 20 int expected_height) { |
21 FileDataSource source; | 21 FileDataSource source; |
22 EXPECT_TRUE(source.Initialize(GetTestDataFilePath(filename))); | 22 EXPECT_TRUE(source.Initialize(GetTestDataFilePath(filename))); |
23 | 23 |
24 scoped_ptr<AudioVideoMetadataExtractor> extractor( | 24 scoped_ptr<AudioVideoMetadataExtractor> extractor( |
25 new AudioVideoMetadataExtractor); | 25 new AudioVideoMetadataExtractor); |
26 bool extracted = extractor->Extract(&source); | 26 bool extracted = extractor->Extract(&source); |
27 EXPECT_EQ(expected_result, extracted); | 27 EXPECT_EQ(expected_result, extracted); |
28 | 28 |
29 if (!extracted) | 29 if (!extracted) |
30 return extractor.Pass(); | 30 return scoped_ptr<AudioVideoMetadataExtractor>(); |
Lei Zhang
2014/02/14 02:35:51
Isn't this going to case a crash when the caller c
tommycli
2014/02/14 17:06:48
Done.
| |
31 | 31 |
32 EXPECT_EQ(expected_duration, extractor->duration()); | 32 EXPECT_EQ(expected_duration, extractor->duration()); |
33 | 33 |
34 EXPECT_EQ(expected_width, extractor->width()); | 34 EXPECT_EQ(expected_width, extractor->width()); |
35 EXPECT_EQ(expected_height, extractor->height()); | 35 EXPECT_EQ(expected_height, extractor->height()); |
36 | 36 |
37 return extractor.Pass(); | 37 return extractor.Pass(); |
38 } | 38 } |
39 | 39 |
40 TEST(AudioVideoMetadataExtractorTest, InvalidFile) { | 40 TEST(AudioVideoMetadataExtractorTest, InvalidFile) { |
(...skipping 13 matching lines...) Expand all Loading... | |
54 EXPECT_EQ("Amadeus Pro", extractor->encoded_by()); | 54 EXPECT_EQ("Amadeus Pro", extractor->encoded_by()); |
55 } | 55 } |
56 | 56 |
57 TEST(AudioVideoMetadataExtractorTest, VideoWebM) { | 57 TEST(AudioVideoMetadataExtractorTest, VideoWebM) { |
58 scoped_ptr<AudioVideoMetadataExtractor> extractor = | 58 scoped_ptr<AudioVideoMetadataExtractor> extractor = |
59 GetExtractor("bear-320x240-multitrack.webm", true, 2, 320, 240); | 59 GetExtractor("bear-320x240-multitrack.webm", true, 2, 320, 240); |
60 EXPECT_EQ("Lavf53.9.0", extractor->encoder()); | 60 EXPECT_EQ("Lavf53.9.0", extractor->encoder()); |
61 } | 61 } |
62 | 62 |
63 #if defined(USE_PROPRIETARY_CODECS) | 63 #if defined(USE_PROPRIETARY_CODECS) |
64 TEST(AudioVideoMetadataExtractorTest, AndroidRotatedMP4Video) { | |
65 scoped_ptr<AudioVideoMetadataExtractor> extractor = | |
66 GetExtractor("90rotation.mp4", true, 0, 1920, 1080); | |
67 | |
68 EXPECT_EQ(90, extractor->rotation()); | |
69 } | |
70 | |
64 TEST(AudioVideoMetadataExtractorTest, AudioMP3) { | 71 TEST(AudioVideoMetadataExtractorTest, AudioMP3) { |
65 scoped_ptr<AudioVideoMetadataExtractor> extractor = | 72 scoped_ptr<AudioVideoMetadataExtractor> extractor = |
66 GetExtractor("id3_png_test.mp3", true, 1, -1, -1); | 73 GetExtractor("id3_png_test.mp3", true, 1, -1, -1); |
67 | 74 |
68 EXPECT_EQ("Airbag", extractor->title()); | 75 EXPECT_EQ("Airbag", extractor->title()); |
69 EXPECT_EQ("Radiohead", extractor->artist()); | 76 EXPECT_EQ("Radiohead", extractor->artist()); |
70 EXPECT_EQ("OK Computer", extractor->album()); | 77 EXPECT_EQ("OK Computer", extractor->album()); |
71 EXPECT_EQ(1, extractor->track()); | 78 EXPECT_EQ(1, extractor->track()); |
72 EXPECT_EQ("Alternative", extractor->genre()); | 79 EXPECT_EQ("Alternative", extractor->genre()); |
73 EXPECT_EQ("1997", extractor->date()); | 80 EXPECT_EQ("1997", extractor->date()); |
74 EXPECT_EQ("Lavf54.4.100", extractor->encoder()); | 81 EXPECT_EQ("Lavf54.4.100", extractor->encoder()); |
75 } | 82 } |
76 #endif | 83 #endif |
77 | 84 |
78 } // namespace media | 85 } // namespace media |
OLD | NEW |