Chromium Code Reviews| 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. | 114 // Test several OGG files to ensure that the container is detected properly. |
|
xhwang
2013/05/29 18:43:22
These comments don't add much value as the tests t
jrummell
2013/05/29 20:46:39
Done.
| |
| 115 TEST(ContainerNamesTest, FileCheckOGG) { | 115 TEST(ContainerNamesTest, FileCheckOGG) { |
| 116 TestFile(CONTAINER_OGG, GetTestDataFilePath("bear.ogv")); | 116 TestFile(CONTAINER_OGG, GetTestDataFilePath("bear.ogv")); |
| 117 TestFile(CONTAINER_OGG, GetTestDataFilePath("9ch.ogg")); | 117 TestFile(CONTAINER_OGG, GetTestDataFilePath("9ch.ogg")); |
| 118 } | 118 } |
| 119 | 119 |
| 120 // Test several WAV files to ensure that the container is detected properly. | 120 // Test several WAV files to ensure that the container is detected properly. |
| 121 TEST(ContainerNamesTest, FileCheckWAV) { | 121 TEST(ContainerNamesTest, FileCheckWAV) { |
| 122 TestFile(CONTAINER_WAV, GetTestDataFilePath("4ch.wav")); | 122 TestFile(CONTAINER_WAV, GetTestDataFilePath("4ch.wav")); |
| 123 TestFile(CONTAINER_WAV, GetTestDataFilePath("sfx_f32le.wav")); | 123 TestFile(CONTAINER_WAV, GetTestDataFilePath("sfx_f32le.wav")); |
| 124 TestFile(CONTAINER_WAV, GetTestDataFilePath("sfx_s16le.wav")); | 124 TestFile(CONTAINER_WAV, GetTestDataFilePath("sfx_s16le.wav")); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 136 TestFile(CONTAINER_WEBM, GetTestDataFilePath("no_streams.webm")); | 136 TestFile(CONTAINER_WEBM, GetTestDataFilePath("no_streams.webm")); |
| 137 TestFile(CONTAINER_WEBM, GetTestDataFilePath("webm_ebml_element")); | 137 TestFile(CONTAINER_WEBM, GetTestDataFilePath("webm_ebml_element")); |
| 138 } | 138 } |
| 139 | 139 |
| 140 // Test several MP3 files to ensure that the container is detected properly. | 140 // Test several MP3 files to ensure that the container is detected properly. |
| 141 TEST(ContainerNamesTest, FileCheckMP3) { | 141 TEST(ContainerNamesTest, FileCheckMP3) { |
| 142 TestFile(CONTAINER_MP3, GetTestDataFilePath("id3_test.mp3")); | 142 TestFile(CONTAINER_MP3, GetTestDataFilePath("id3_test.mp3")); |
| 143 TestFile(CONTAINER_MP3, GetTestDataFilePath("sfx.mp3")); | 143 TestFile(CONTAINER_MP3, GetTestDataFilePath("sfx.mp3")); |
| 144 } | 144 } |
| 145 | 145 |
| 146 // Test AC3 files to ensure that the container is detected properly. | |
| 147 TEST(ContainerNamesTest, FileCheckAC3) { | |
| 148 TestFile(CONTAINER_AC3, GetTestDataFilePath("bear.ac3")); | |
| 149 } | |
| 150 | |
| 151 // Test AAC files to ensure that the container is detected properly. | |
| 152 TEST(ContainerNamesTest, FileCheckAAC) { | |
| 153 TestFile(CONTAINER_AAC, GetTestDataFilePath("bear.adts")); | |
| 154 } | |
| 155 | |
| 156 // Test AIFF files to ensure that the container is detected properly. | |
| 157 TEST(ContainerNamesTest, FileCheckAIFF) { | |
| 158 TestFile(CONTAINER_AIFF, GetTestDataFilePath("bear.aiff")); | |
| 159 } | |
| 160 | |
| 161 // Test ASF files to ensure that the container is detected properly. | |
| 162 TEST(ContainerNamesTest, FileCheckASF) { | |
| 163 TestFile(CONTAINER_ASF, GetTestDataFilePath("bear.asf")); | |
| 164 } | |
| 165 | |
| 166 // Test AVI files to ensure that the container is detected properly. | |
| 167 TEST(ContainerNamesTest, FileCheckAVI) { | |
| 168 TestFile(CONTAINER_AVI, GetTestDataFilePath("bear.avi")); | |
| 169 } | |
| 170 | |
| 171 // Test EAC3 files to ensure that the container is detected properly. | |
| 172 TEST(ContainerNamesTest, FileCheckEAC3) { | |
| 173 TestFile(CONTAINER_EAC3, GetTestDataFilePath("bear.eac3")); | |
| 174 } | |
| 175 | |
| 176 // Test FLAC files to ensure that the container is detected properly. | |
| 177 TEST(ContainerNamesTest, FileCheckFLAC) { | |
| 178 TestFile(CONTAINER_FLAC, GetTestDataFilePath("bear.flac")); | |
| 179 } | |
| 180 | |
| 181 // Test FLV files to ensure that the container is detected properly. | |
| 182 TEST(ContainerNamesTest, FileCheckFLV) { | |
| 183 TestFile(CONTAINER_FLV, GetTestDataFilePath("bear.flv")); | |
| 184 } | |
| 185 | |
| 186 // Test H261 files to ensure that the container is detected properly. | |
| 187 TEST(ContainerNamesTest, FileCheckH261) { | |
| 188 TestFile(CONTAINER_H261, GetTestDataFilePath("bear.h261")); | |
| 189 } | |
| 190 | |
| 191 // Test H263 files to ensure that the container is detected properly. | |
| 192 TEST(ContainerNamesTest, FileCheckH263) { | |
| 193 TestFile(CONTAINER_H263, GetTestDataFilePath("bear.h263")); | |
| 194 } | |
| 195 | |
| 196 // Test MJPEG files to ensure that the container is detected properly. | |
| 197 TEST(ContainerNamesTest, FileCheckMJPEG) { | |
| 198 TestFile(CONTAINER_MJPEG, GetTestDataFilePath("bear.mjpeg")); | |
| 199 } | |
| 200 | |
| 201 // Test MPEG2PS files to ensure that the container is detected properly. | |
| 202 TEST(ContainerNamesTest, FileCheckMPEG2PS) { | |
| 203 TestFile(CONTAINER_MPEG2PS, GetTestDataFilePath("bear.mpeg")); | |
| 204 } | |
| 205 | |
| 206 // Test MPEG2TS files to ensure that the container is detected properly. | |
| 207 TEST(ContainerNamesTest, FileCheckMPEG2TS) { | |
| 208 TestFile(CONTAINER_MPEG2TS, GetTestDataFilePath("bear.m2ts")); | |
| 209 } | |
| 210 | |
| 211 // Test RM files to ensure that the container is detected properly. | |
| 212 TEST(ContainerNamesTest, FileCheckRM) { | |
| 213 TestFile(CONTAINER_RM, GetTestDataFilePath("bear.rm")); | |
| 214 } | |
| 215 | |
| 216 // Test SWF files to ensure that the container is detected properly. | |
| 217 TEST(ContainerNamesTest, FileCheckSWF) { | |
| 218 TestFile(CONTAINER_SWF, GetTestDataFilePath("bear.swf")); | |
| 219 } | |
| 220 | |
| 146 // Try a few non containers. | 221 // Try a few non containers. |
| 147 TEST(ContainerNamesTest, FileCheckUNKNOWN) { | 222 TEST(ContainerNamesTest, FileCheckUNKNOWN) { |
| 148 TestFile(CONTAINER_UNKNOWN, GetTestDataFilePath("ten_byte_file")); | 223 TestFile(CONTAINER_UNKNOWN, GetTestDataFilePath("ten_byte_file")); |
| 149 TestFile(CONTAINER_UNKNOWN, GetTestDataFilePath("README")); | 224 TestFile(CONTAINER_UNKNOWN, GetTestDataFilePath("README")); |
| 150 TestFile(CONTAINER_UNKNOWN, GetTestDataFilePath("bali_640x360_P422.yuv")); | 225 TestFile(CONTAINER_UNKNOWN, GetTestDataFilePath("bali_640x360_P422.yuv")); |
| 151 TestFile(CONTAINER_UNKNOWN, GetTestDataFilePath("bali_640x360_RGB24.rgb")); | 226 TestFile(CONTAINER_UNKNOWN, GetTestDataFilePath("bali_640x360_RGB24.rgb")); |
| 152 TestFile(CONTAINER_UNKNOWN, GetTestDataFilePath("webm_vp8_track_entry")); | 227 TestFile(CONTAINER_UNKNOWN, GetTestDataFilePath("webm_vp8_track_entry")); |
| 153 } | 228 } |
| 154 | 229 |
| 155 } // namespace container_names | 230 } // namespace container_names |
| 156 | 231 |
| 157 } // namespace media | 232 } // namespace media |
| OLD | NEW |