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