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

Side by Side Diff: media/base/audio_video_metadata_extractor_unittest.cc

Issue 1643633005: Avoid dereferencing find() without checking for == end() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/sha1.h" 7 #include "base/sha1.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "media/base/audio_video_metadata_extractor.h" 9 #include "media/base/audio_video_metadata_extractor.h"
10 #include "media/base/test_data_util.h" 10 #include "media/base/test_data_util.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 EXPECT_EQ(0u, extractor->stream_infos()[0].tags.size()); 54 EXPECT_EQ(0u, extractor->stream_infos()[0].tags.size());
55 55
56 EXPECT_EQ(1u, extractor->stream_infos()[1].tags.size()); 56 EXPECT_EQ(1u, extractor->stream_infos()[1].tags.size());
57 EXPECT_EQ("vorbis", extractor->stream_infos()[1].type); 57 EXPECT_EQ("vorbis", extractor->stream_infos()[1].type);
58 EXPECT_EQ("Processed by SoX", 58 EXPECT_EQ("Processed by SoX",
59 extractor->stream_infos()[1].tags.find("COMMENT")->second); 59 extractor->stream_infos()[1].tags.find("COMMENT")->second);
60 60
61 EXPECT_EQ(0u, extractor->attached_images_bytes().size()); 61 EXPECT_EQ(0u, extractor->attached_images_bytes().size());
62 } 62 }
63 63
64 const std::string GetTagValue(
65 const media::AudioVideoMetadataExtractor::TagDictionary& tags,
66 const char* tag_name) {
67 auto tag_data = tags.find(tag_name);
68 EXPECT_NE(tag_data, tags.end());
DaleCurtis 2016/01/28 21:54:47 I'd just drop this since it's just noise in the te
brucedawson 2016/01/28 22:17:26 Sounds good. The original advice was to use ASSER
69 if (tag_data == tags.end())
70 return "";
71 return tag_data->second;
72 }
73
64 TEST(AudioVideoMetadataExtractorTest, AudioWAV) { 74 TEST(AudioVideoMetadataExtractorTest, AudioWAV) {
65 scoped_ptr<AudioVideoMetadataExtractor> extractor = 75 scoped_ptr<AudioVideoMetadataExtractor> extractor =
66 GetExtractor("sfx_u8.wav", true, true, 0, -1, -1); 76 GetExtractor("sfx_u8.wav", true, true, 0, -1, -1);
67 EXPECT_EQ("Lavf54.37.100", extractor->encoder()); 77 EXPECT_EQ("Lavf54.37.100", extractor->encoder());
68 EXPECT_EQ("Amadeus Pro", extractor->encoded_by()); 78 EXPECT_EQ("Amadeus Pro", extractor->encoded_by());
69 79
70 EXPECT_EQ("wav", extractor->stream_infos()[0].type); 80 EXPECT_EQ("wav", extractor->stream_infos()[0].type);
71 EXPECT_EQ(2u, extractor->stream_infos().size()); 81 EXPECT_EQ(2u, extractor->stream_infos().size());
72 82
73 EXPECT_EQ(2u, extractor->stream_infos()[0].tags.size()); 83 EXPECT_EQ(2u, extractor->stream_infos()[0].tags.size());
74 EXPECT_EQ("Lavf54.37.100", 84 EXPECT_EQ("Lavf54.37.100",
75 extractor->stream_infos()[0].tags.find("encoder")->second); 85 GetTagValue(extractor->stream_infos()[0].tags, "encoder"));
76 EXPECT_EQ("Amadeus Pro", 86 EXPECT_EQ("Amadeus Pro",
77 extractor->stream_infos()[0].tags.find("encoded_by")->second); 87 GetTagValue(extractor->stream_infos()[0].tags, "encoded_by"));
78 88
79 EXPECT_EQ("pcm_u8", extractor->stream_infos()[1].type); 89 EXPECT_EQ("pcm_u8", extractor->stream_infos()[1].type);
80 EXPECT_EQ(0u, extractor->stream_infos()[1].tags.size()); 90 EXPECT_EQ(0u, extractor->stream_infos()[1].tags.size());
81 91
82 EXPECT_EQ(0u, extractor->attached_images_bytes().size()); 92 EXPECT_EQ(0u, extractor->attached_images_bytes().size());
83 } 93 }
84 94
85 TEST(AudioVideoMetadataExtractorTest, VideoWebM) { 95 TEST(AudioVideoMetadataExtractorTest, VideoWebM) {
86 scoped_ptr<AudioVideoMetadataExtractor> extractor = 96 scoped_ptr<AudioVideoMetadataExtractor> extractor =
87 GetExtractor("bear-320x240-multitrack.webm", true, true, 2, 320, 240); 97 GetExtractor("bear-320x240-multitrack.webm", true, true, 2, 320, 240);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 extractor->attached_images_bytes()[0].substr(0, 8)); 208 extractor->attached_images_bytes()[0].substr(0, 8));
199 EXPECT_EQ("IEND\xae\x42\x60\x82", 209 EXPECT_EQ("IEND\xae\x42\x60\x82",
200 extractor->attached_images_bytes()[0].substr( 210 extractor->attached_images_bytes()[0].substr(
201 extractor->attached_images_bytes()[0].size() - 8, 8)); 211 extractor->attached_images_bytes()[0].size() - 8, 8));
202 EXPECT_EQ("\xF3\xED\x8F\xC7\xC7\x98\xB9V|p\xC0u!\xB5\x82\xCF\x95\xF0\xCD\xCE", 212 EXPECT_EQ("\xF3\xED\x8F\xC7\xC7\x98\xB9V|p\xC0u!\xB5\x82\xCF\x95\xF0\xCD\xCE",
203 base::SHA1HashString(extractor->attached_images_bytes()[0])); 213 base::SHA1HashString(extractor->attached_images_bytes()[0]));
204 } 214 }
205 #endif 215 #endif
206 216
207 } // namespace media 217 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698