Chromium Code Reviews| Index: media/base/media_file_checker_unittest.cc |
| diff --git a/media/base/media_file_checker_unittest.cc b/media/base/media_file_checker_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6e964f5c7f2a8b17d057eb9afd0ee619c1669bb4 |
| --- /dev/null |
| +++ b/media/base/media_file_checker_unittest.cc |
| @@ -0,0 +1,53 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "base/logging.h" |
| +#include "build/build_config.h" |
| +#include "media/base/media_file_checker.h" |
| +#include "media/base/test_data_util.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +namespace media { |
| + |
| +namespace { |
|
vandebo (ex-Chrome)
2013/08/09 04:26:14
Also killed this namespace.
|
| + |
| +const base::TimeDelta check_time = base::TimeDelta::FromMilliseconds(100); |
|
DaleCurtis
2013/08/09 00:58:04
Move inside function to avoid potential static ini
vandebo (ex-Chrome)
2013/08/09 04:26:14
Done.
|
| + |
| +void RunMediaFileChecker(const std::string& filename, bool expectation) { |
| + base::PlatformFileError error; |
| + base::PlatformFile file = base::CreatePlatformFile( |
| + GetTestDataFilePath(filename), |
| + base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, |
| + NULL, |
| + &error); |
| + ASSERT_EQ(base::PLATFORM_FILE_OK, error); |
| + |
| + MediaFileChecker checker(file); |
| + bool result = checker.Start(check_time); |
| + EXPECT_EQ(expectation, result); |
| + |
| + base::ClosePlatformFile(file); |
| +} |
| + |
| +} // namespace |
| + |
| +TEST(MediaFileCheckerTest, InvalidFile) { |
| + RunMediaFileChecker("ten_byte_file", false); |
| +} |
| + |
| +TEST(MediaFileCheckerTest, Video) { |
| + RunMediaFileChecker("bear.ogv", true); |
| +} |
| + |
| +TEST(MediaFileCheckerTest, Audio) { |
| + RunMediaFileChecker("sfx.ogg", true); |
| +} |
| + |
| +#if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) |
| +TEST(MediaFileCheckerTest, MP3) { |
| + RunMediaFileChecker("sfx.mp3", true); |
| +} |
| +#endif |
| + |
| +} // namespace media |