1 // Copyright 2014 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 "media/base/video_frame.h" 6 #include "media/cast/test/utility/audio_utility.h" 7 #include "testing/gtest/include/gtest/gtest.h" 8 9 namespace media { 10 namespace cast { 11 namespace test { 12 namespace { 13 14 TEST(AudioTimestampTest, Small) { 15 std::vector<float> samples(480); 16 for (int32 in_timestamp = 0; in_timestamp < 65536; in_timestamp += 177) { 17 EncodeTimestamp(in_timestamp, 0, samples.size(), &samples.front()); 18 uint16 out_timestamp; 19 EXPECT_TRUE( 20 DecodeTimestamp(&samples.front(), samples.size(), &out_timestamp)); 21 ASSERT_EQ(in_timestamp, out_timestamp); 22 } 23 } 24 25 TEST(AudioTimestampTest, Negative) { 26 std::vector<float> samples(480); 27 uint16 out_timestamp; 28 EXPECT_FALSE( 29 DecodeTimestamp(&samples.front(), samples.size(), &out_timestamp)); 30 } 31 32 TEST(AudioTimestampTest, CheckPhase) { 33 std::vector<float> samples(4800); 34 EncodeTimestamp(4711, 0, samples.size(), &samples.front()); 35 while (samples.size() > 240) { 36 uint16 out_timestamp; 37 EXPECT_TRUE( 38 DecodeTimestamp(&samples.front(), samples.size(), &out_timestamp)); 39 ASSERT_EQ(4711, out_timestamp); 40 41 samples.erase(samples.begin(), samples.begin() + 73); 42 } 43 } 44 45 } // namespace 46 } // namespace test 47 } // namespace cast 48 } // namespace media 49