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

Side by Side 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: refine metadata extraction logic 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
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 "build/build_config.h"
7 #include "media/base/audio_video_metadata_extractor.h"
8 #include "media/base/test_data_util.h"
9 #include "media/filters/file_data_source.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace media {
13
14 void RunExtractor(
15 const std::string& filename,
16 bool expected_result,
17 const std::string& expected_type,
18 int expected_duration,
19 int expected_width,
20 int expected_height,
21 std::map<std::string, std::string>* tags_result) {
22 FileDataSource source;
23 ASSERT_TRUE(source.Initialize(GetTestDataFilePath(filename)));
24
25 AudioVideoMetadataExtractor extractor(&source);
26 bool extracted = extractor.Extract();
27 ASSERT_EQ(expected_result, extracted);
28
29 if (!extracted)
30 return;
31
32 EXPECT_EQ(expected_type, extractor.GetFormat());
33 EXPECT_EQ(expected_duration, extractor.GetDurationSeconds());
34
35 EXPECT_EQ(expected_width, extractor.GetWidth());
36 EXPECT_EQ(expected_height, extractor.GetHeight());
37
38 if (tags_result)
39 *tags_result = extractor.GetTags();
40 }
41
42 TEST(AudioVideoMetadataExtractorTest, InvalidFile) {
43 RunExtractor("ten_byte_file", false, "", 0, 0, 0, NULL);
44 }
45
46 TEST(AudioVideoMetadataExtractorTest, AudioOGG) {
47 std::map<std::string, std::string> tags;
48 RunExtractor("9ch.ogg", true, "ogg", 0, 0, 0, &tags);
49 ASSERT_EQ(1u, tags.size());
50 EXPECT_EQ("Processed by SoX", tags["comment"]);
51 }
52
53 TEST(AudioVideoMetadataExtractorTest, AudioWAV) {
54 std::map<std::string, std::string> tags;
55 RunExtractor("sfx_u8.wav", true, "wav", 0, 0, 0, &tags);
56 ASSERT_EQ(2u, tags.size());
57 EXPECT_EQ("Lavf54.37.100", tags["encoder"]);
58 EXPECT_EQ("Amadeus Pro", tags["encoded_by"]);
59 }
60
61 TEST(AudioVideoMetadataExtractorTest, VideoWebM) {
62 std::map<std::string, std::string> tags;
63 RunExtractor("bear-320x240-multitrack.webm", true, "matroska,webm", 2,
64 320, 240, &tags);
65 ASSERT_EQ(1u, tags.size());
66 EXPECT_EQ("Lavf53.9.0", tags["encoder"]);
67 }
68
69 #if defined(USE_PROPRIETARY_CODECS)
70 TEST(AudioVideoMetadataExtractorTest, AudioMP3) {
71 std::map<std::string, std::string> tags;
72 RunExtractor("id3_png_test.mp3", true, "mp3", 1, 0, 0, &tags);
73
74 ASSERT_EQ(7u, tags.size());
75 EXPECT_EQ("Airbag", tags["title"]);
76 EXPECT_EQ("Radiohead", tags["artist"]);
77 EXPECT_EQ("OK Computer", tags["album"]);
78 EXPECT_EQ("1", tags["track"]);
79 EXPECT_EQ("Alternative", tags["genre"]);
80 EXPECT_EQ("1997", tags["date"]);
81 EXPECT_EQ("Lavf54.4.100", tags["encoder"]);
82 }
83 #endif
84
85 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698