Home | History | Annotate | Download | only in base
      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
      3 // found in the LICENSE file.
      4 
      5 #include "base/files/file.h"
      6 #include "base/logging.h"
      7 #include "build/build_config.h"
      8 #include "media/base/media_file_checker.h"
      9 #include "media/base/test_data_util.h"
     10 #include "testing/gtest/include/gtest/gtest.h"
     11 
     12 namespace media {
     13 
     14 static void RunMediaFileChecker(const std::string& filename, bool expectation) {
     15   base::File file(GetTestDataFilePath(filename),
     16                   base::File::FLAG_OPEN | base::File::FLAG_READ);
     17   ASSERT_TRUE(file.IsValid());
     18 
     19   MediaFileChecker checker(file.Pass());
     20   const base::TimeDelta check_time = base::TimeDelta::FromMilliseconds(100);
     21   bool result = checker.Start(check_time);
     22   EXPECT_EQ(expectation, result);
     23 }
     24 
     25 TEST(MediaFileCheckerTest, InvalidFile) {
     26   RunMediaFileChecker("ten_byte_file", false);
     27 }
     28 
     29 TEST(MediaFileCheckerTest, Video) {
     30   RunMediaFileChecker("bear.ogv", true);
     31 }
     32 
     33 TEST(MediaFileCheckerTest, Audio) {
     34   RunMediaFileChecker("sfx.ogg", true);
     35 }
     36 
     37 #if defined(USE_PROPRIETARY_CODECS)
     38 TEST(MediaFileCheckerTest, MP3) {
     39   RunMediaFileChecker("sfx.mp3", true);
     40 }
     41 #endif
     42 
     43 }  // namespace media
     44