dts_unittest.cc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright 2021 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. #include <stdint.h>
  5. #include <string>
  6. #include "media/base/mock_media_log.h"
  7. #include "media/formats/mp4/dts.h"
  8. #include "testing/gmock/include/gmock/gmock.h"
  9. #include "testing/gtest/include/gtest/gtest.h"
  10. using ::testing::AllOf;
  11. using ::testing::HasSubstr;
  12. using ::testing::InSequence;
  13. using ::testing::StrictMock;
  14. namespace media {
  15. namespace mp4 {
  16. class DTSTest : public testing::Test {
  17. public:
  18. DTSTest() = default;
  19. bool Parse(const std::vector<uint8_t>& data) {
  20. return dts_.Parse(data, &media_log_);
  21. }
  22. StrictMock<MockMediaLog> media_log_;
  23. DTS dts_;
  24. };
  25. TEST_F(DTSTest, NoInputTest) {
  26. std::vector<uint8_t> data;
  27. EXPECT_FALSE(Parse(data));
  28. }
  29. TEST_F(DTSTest, ShortInvalidInputTest) {
  30. std::vector<uint8_t> data({0x32, 0x44});
  31. EXPECT_FALSE(Parse(data));
  32. }
  33. TEST_F(DTSTest, NormalInputTest) {
  34. std::vector<uint8_t> data({0x00, 0x00, 0xbb, 0x80, 0x00, 0x0b, 0xb8, 0x00,
  35. 0x00, 0x0b, 0xb8, 0x00, 0x18, 0x03, 0x24, 0x40});
  36. EXPECT_TRUE(Parse(data));
  37. EXPECT_EQ(dts_.GetDtsSamplingFrequency(), 48000u);
  38. EXPECT_EQ(dts_.GetMaxBitrate(), 768000u);
  39. EXPECT_EQ(dts_.GetAvgBitrate(), 768000u);
  40. EXPECT_EQ(dts_.GetPcmSampleDepth(), 24u);
  41. EXPECT_EQ(dts_.GetFrameDuration(), 512);
  42. }
  43. } // namespace mp4
  44. } // namespace media