OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 "media/base/media_file_checker.h" | 5 #include "media/base/media_file_checker.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 #include "media/base/test_data_util.h" | 12 #include "media/base/test_data_util.h" |
| 13 #include "media/media_features.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 | 15 |
15 namespace media { | 16 namespace media { |
16 | 17 |
17 static void RunMediaFileChecker(const std::string& filename, bool expectation) { | 18 static void RunMediaFileChecker(const std::string& filename, bool expectation) { |
18 base::File file(GetTestDataFilePath(filename), | 19 base::File file(GetTestDataFilePath(filename), |
19 base::File::FLAG_OPEN | base::File::FLAG_READ); | 20 base::File::FLAG_OPEN | base::File::FLAG_READ); |
20 ASSERT_TRUE(file.IsValid()); | 21 ASSERT_TRUE(file.IsValid()); |
21 | 22 |
22 MediaFileChecker checker(std::move(file)); | 23 MediaFileChecker checker(std::move(file)); |
23 const base::TimeDelta check_time = base::TimeDelta::FromMilliseconds(100); | 24 const base::TimeDelta check_time = base::TimeDelta::FromMilliseconds(100); |
24 bool result = checker.Start(check_time); | 25 bool result = checker.Start(check_time); |
25 EXPECT_EQ(expectation, result); | 26 EXPECT_EQ(expectation, result); |
26 } | 27 } |
27 | 28 |
28 TEST(MediaFileCheckerTest, InvalidFile) { | 29 TEST(MediaFileCheckerTest, InvalidFile) { |
29 RunMediaFileChecker("ten_byte_file", false); | 30 RunMediaFileChecker("ten_byte_file", false); |
30 } | 31 } |
31 | 32 |
32 TEST(MediaFileCheckerTest, Video) { | 33 TEST(MediaFileCheckerTest, Video) { |
33 RunMediaFileChecker("bear.ogv", true); | 34 RunMediaFileChecker("bear.ogv", true); |
34 } | 35 } |
35 | 36 |
36 TEST(MediaFileCheckerTest, Audio) { | 37 TEST(MediaFileCheckerTest, Audio) { |
37 RunMediaFileChecker("sfx.ogg", true); | 38 RunMediaFileChecker("sfx.ogg", true); |
38 } | 39 } |
39 | 40 |
40 #if defined(USE_PROPRIETARY_CODECS) | 41 #if BUILDFLAG(USE_PROPRIETARY_CODECS) |
41 TEST(MediaFileCheckerTest, MP3) { | 42 TEST(MediaFileCheckerTest, MP3) { |
42 RunMediaFileChecker("sfx.mp3", true); | 43 RunMediaFileChecker("sfx.mp3", true); |
43 } | 44 } |
44 #endif | 45 #endif |
45 | 46 |
46 } // namespace media | 47 } // namespace media |
OLD | NEW |