1 // Copyright 2013 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "media/filters/media_file_checker.h"
9 #include "base/files/file.h"
10 #include "build/build_config.h"
11 #include "media/base/test_data_util.h"
12 #include "media/media_buildflags.h"
13 #include "testing/gtest/include/gtest/gtest.h"
17 static void RunMediaFileChecker(const std::string& filename, bool expectation) {
18 base::File file(GetTestDataFilePath(filename),
19 base::File::FLAG_OPEN | base::File::FLAG_READ);
20 ASSERT_TRUE(file.IsValid());
22 MediaFileChecker checker(std::move(file));
23 const base::TimeDelta check_time = base::Milliseconds(100);
24 bool result = checker.Start(check_time);
25 EXPECT_EQ(expectation, result);
28 TEST(MediaFileCheckerTest, InvalidFile) {
29 RunMediaFileChecker("ten_byte_file", false);
32 TEST(MediaFileCheckerTest, Video) {
33 RunMediaFileChecker("bear.ogv", true);
36 TEST(MediaFileCheckerTest, Audio) {
37 RunMediaFileChecker("sfx.ogg", true);
40 TEST(MediaFileCheckerTest, MP3) {
41 RunMediaFileChecker("sfx.mp3", true);