OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/file_util.h" | 5 #include "base/file_util.h" |
6 #include "media/base/container_names.h" | 6 #include "media/base/container_names.h" |
7 #include "media/base/test_data_util.h" | 7 #include "media/base/test_data_util.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace media { | 10 namespace media { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 if (file_util::GetFileSize(filename, &actual_size) && actual_size < read_size) | 104 if (file_util::GetFileSize(filename, &actual_size) && actual_size < read_size) |
105 read_size = actual_size; | 105 read_size = actual_size; |
106 int read = file_util::ReadFile(filename, buffer, read_size); | 106 int read = file_util::ReadFile(filename, buffer, read_size); |
107 | 107 |
108 // Now verify the type. | 108 // Now verify the type. |
109 EXPECT_EQ(expected, | 109 EXPECT_EQ(expected, |
110 DetermineContainer(reinterpret_cast<const uint8*>(buffer), read)) | 110 DetermineContainer(reinterpret_cast<const uint8*>(buffer), read)) |
111 << "Failure with file " << filename.value(); | 111 << "Failure with file " << filename.value(); |
112 } | 112 } |
113 | 113 |
114 // Test several OGG files to ensure that the container is detected properly. | |
115 TEST(ContainerNamesTest, FileCheckOGG) { | 114 TEST(ContainerNamesTest, FileCheckOGG) { |
116 TestFile(CONTAINER_OGG, GetTestDataFilePath("bear.ogv")); | 115 TestFile(CONTAINER_OGG, GetTestDataFilePath("bear.ogv")); |
117 TestFile(CONTAINER_OGG, GetTestDataFilePath("9ch.ogg")); | 116 TestFile(CONTAINER_OGG, GetTestDataFilePath("9ch.ogg")); |
118 } | 117 } |
119 | 118 |
120 // Test several WAV files to ensure that the container is detected properly. | |
121 TEST(ContainerNamesTest, FileCheckWAV) { | 119 TEST(ContainerNamesTest, FileCheckWAV) { |
122 TestFile(CONTAINER_WAV, GetTestDataFilePath("4ch.wav")); | 120 TestFile(CONTAINER_WAV, GetTestDataFilePath("4ch.wav")); |
123 TestFile(CONTAINER_WAV, GetTestDataFilePath("sfx_f32le.wav")); | 121 TestFile(CONTAINER_WAV, GetTestDataFilePath("sfx_f32le.wav")); |
124 TestFile(CONTAINER_WAV, GetTestDataFilePath("sfx_s16le.wav")); | 122 TestFile(CONTAINER_WAV, GetTestDataFilePath("sfx_s16le.wav")); |
125 } | 123 } |
126 | 124 |
127 // Test several MOV files to ensure that the container is detected properly. | |
128 TEST(ContainerNamesTest, FileCheckMOV) { | 125 TEST(ContainerNamesTest, FileCheckMOV) { |
129 TestFile(CONTAINER_MOV, GetTestDataFilePath("bear-1280x720.mp4")); | 126 TestFile(CONTAINER_MOV, GetTestDataFilePath("bear-1280x720.mp4")); |
130 TestFile(CONTAINER_MOV, GetTestDataFilePath("sfx.m4a")); | 127 TestFile(CONTAINER_MOV, GetTestDataFilePath("sfx.m4a")); |
131 } | 128 } |
132 | 129 |
133 // Test several WEBM files to ensure that the container is detected properly. | |
134 TEST(ContainerNamesTest, FileCheckWEBM) { | 130 TEST(ContainerNamesTest, FileCheckWEBM) { |
135 TestFile(CONTAINER_WEBM, GetTestDataFilePath("bear-320x240.webm")); | 131 TestFile(CONTAINER_WEBM, GetTestDataFilePath("bear-320x240.webm")); |
136 TestFile(CONTAINER_WEBM, GetTestDataFilePath("no_streams.webm")); | 132 TestFile(CONTAINER_WEBM, GetTestDataFilePath("no_streams.webm")); |
137 TestFile(CONTAINER_WEBM, GetTestDataFilePath("webm_ebml_element")); | 133 TestFile(CONTAINER_WEBM, GetTestDataFilePath("webm_ebml_element")); |
138 } | 134 } |
139 | 135 |
140 // Test several MP3 files to ensure that the container is detected properly. | |
141 TEST(ContainerNamesTest, FileCheckMP3) { | 136 TEST(ContainerNamesTest, FileCheckMP3) { |
142 TestFile(CONTAINER_MP3, GetTestDataFilePath("id3_test.mp3")); | 137 TestFile(CONTAINER_MP3, GetTestDataFilePath("id3_test.mp3")); |
143 TestFile(CONTAINER_MP3, GetTestDataFilePath("sfx.mp3")); | 138 TestFile(CONTAINER_MP3, GetTestDataFilePath("sfx.mp3")); |
144 } | 139 } |
145 | 140 |
| 141 TEST(ContainerNamesTest, FileCheckAC3) { |
| 142 TestFile(CONTAINER_AC3, GetTestDataFilePath("bear.ac3")); |
| 143 } |
| 144 |
| 145 TEST(ContainerNamesTest, FileCheckAAC) { |
| 146 TestFile(CONTAINER_AAC, GetTestDataFilePath("bear.adts")); |
| 147 } |
| 148 |
| 149 TEST(ContainerNamesTest, FileCheckAIFF) { |
| 150 TestFile(CONTAINER_AIFF, GetTestDataFilePath("bear.aiff")); |
| 151 } |
| 152 |
| 153 TEST(ContainerNamesTest, FileCheckASF) { |
| 154 TestFile(CONTAINER_ASF, GetTestDataFilePath("bear.asf")); |
| 155 } |
| 156 |
| 157 TEST(ContainerNamesTest, FileCheckAVI) { |
| 158 TestFile(CONTAINER_AVI, GetTestDataFilePath("bear.avi")); |
| 159 } |
| 160 |
| 161 TEST(ContainerNamesTest, FileCheckEAC3) { |
| 162 TestFile(CONTAINER_EAC3, GetTestDataFilePath("bear.eac3")); |
| 163 } |
| 164 |
| 165 TEST(ContainerNamesTest, FileCheckFLAC) { |
| 166 TestFile(CONTAINER_FLAC, GetTestDataFilePath("bear.flac")); |
| 167 } |
| 168 |
| 169 TEST(ContainerNamesTest, FileCheckFLV) { |
| 170 TestFile(CONTAINER_FLV, GetTestDataFilePath("bear.flv")); |
| 171 } |
| 172 |
| 173 TEST(ContainerNamesTest, FileCheckH261) { |
| 174 TestFile(CONTAINER_H261, GetTestDataFilePath("bear.h261")); |
| 175 } |
| 176 |
| 177 TEST(ContainerNamesTest, FileCheckH263) { |
| 178 TestFile(CONTAINER_H263, GetTestDataFilePath("bear.h263")); |
| 179 } |
| 180 |
| 181 TEST(ContainerNamesTest, FileCheckMJPEG) { |
| 182 TestFile(CONTAINER_MJPEG, GetTestDataFilePath("bear.mjpeg")); |
| 183 } |
| 184 |
| 185 TEST(ContainerNamesTest, FileCheckMPEG2PS) { |
| 186 TestFile(CONTAINER_MPEG2PS, GetTestDataFilePath("bear.mpeg")); |
| 187 } |
| 188 |
| 189 TEST(ContainerNamesTest, FileCheckMPEG2TS) { |
| 190 TestFile(CONTAINER_MPEG2TS, GetTestDataFilePath("bear.m2ts")); |
| 191 } |
| 192 |
| 193 TEST(ContainerNamesTest, FileCheckRM) { |
| 194 TestFile(CONTAINER_RM, GetTestDataFilePath("bear.rm")); |
| 195 } |
| 196 |
| 197 TEST(ContainerNamesTest, FileCheckSWF) { |
| 198 TestFile(CONTAINER_SWF, GetTestDataFilePath("bear.swf")); |
| 199 } |
| 200 |
146 // Try a few non containers. | 201 // Try a few non containers. |
147 TEST(ContainerNamesTest, FileCheckUNKNOWN) { | 202 TEST(ContainerNamesTest, FileCheckUNKNOWN) { |
148 TestFile(CONTAINER_UNKNOWN, GetTestDataFilePath("ten_byte_file")); | 203 TestFile(CONTAINER_UNKNOWN, GetTestDataFilePath("ten_byte_file")); |
149 TestFile(CONTAINER_UNKNOWN, GetTestDataFilePath("README")); | 204 TestFile(CONTAINER_UNKNOWN, GetTestDataFilePath("README")); |
150 TestFile(CONTAINER_UNKNOWN, GetTestDataFilePath("bali_640x360_P422.yuv")); | 205 TestFile(CONTAINER_UNKNOWN, GetTestDataFilePath("bali_640x360_P422.yuv")); |
151 TestFile(CONTAINER_UNKNOWN, GetTestDataFilePath("bali_640x360_RGB24.rgb")); | 206 TestFile(CONTAINER_UNKNOWN, GetTestDataFilePath("bali_640x360_RGB24.rgb")); |
152 TestFile(CONTAINER_UNKNOWN, GetTestDataFilePath("webm_vp8_track_entry")); | 207 TestFile(CONTAINER_UNKNOWN, GetTestDataFilePath("webm_vp8_track_entry")); |
153 } | 208 } |
154 | 209 |
155 } // namespace container_names | 210 } // namespace container_names |
156 | 211 |
157 } // namespace media | 212 } // namespace media |
OLD | NEW |