Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Unified Diff: media/cast/net/rtcp/rtcp_utility_unittest.cc

Issue 1521173002: Improve RTCP unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@rtcp_cleanup
Patch Set: Rebased Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/cast/net/rtcp/rtcp_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cast/net/rtcp/rtcp_utility_unittest.cc
diff --git a/media/cast/net/rtcp/rtcp_utility_unittest.cc b/media/cast/net/rtcp/rtcp_utility_unittest.cc
index 0f9e4c4e74a7f38652c080cb0efdcd4a7c31e832..f3777e966f147d10c7817337109cd63ab3577528 100644
--- a/media/cast/net/rtcp/rtcp_utility_unittest.cc
+++ b/media/cast/net/rtcp/rtcp_utility_unittest.cc
@@ -127,6 +127,7 @@ class RtcpParserTest : public ::testing::Test {
scoped_ptr<base::SimpleTestTickClock> testing_clock_;
scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_;
+ private:
DISALLOW_COPY_AND_ASSIGN(RtcpParserTest);
};
@@ -404,5 +405,51 @@ TEST_F(RtcpParserTest, InjectReceiverReportWithReceiverLogVerificationMulti) {
ExpectReceiverLog(parser, receiver_log);
}
+TEST(RtcpUtilityTest, NtpAndTime) {
+ const int64_t kSecondsbetweenYear1900and2010 = INT64_C(40176 * 24 * 60 * 60);
+ const int64_t kSecondsbetweenYear1900and2030 = INT64_C(47481 * 24 * 60 * 60);
+
+ uint32_t ntp_seconds_1 = 0;
+ uint32_t ntp_fraction_1 = 0;
+ base::TimeTicks input_time = base::TimeTicks::Now();
+ ConvertTimeTicksToNtp(input_time, &ntp_seconds_1, &ntp_fraction_1);
+
+ // Verify absolute value.
+ EXPECT_GT(ntp_seconds_1, kSecondsbetweenYear1900and2010);
+ EXPECT_LT(ntp_seconds_1, kSecondsbetweenYear1900and2030);
+
+ base::TimeTicks out_1 = ConvertNtpToTimeTicks(ntp_seconds_1, ntp_fraction_1);
+ EXPECT_EQ(input_time, out_1); // Verify inverse.
+
+ base::TimeDelta time_delta = base::TimeDelta::FromMilliseconds(1000);
+ input_time += time_delta;
+
+ uint32_t ntp_seconds_2 = 0;
+ uint32_t ntp_fraction_2 = 0;
+
+ ConvertTimeTicksToNtp(input_time, &ntp_seconds_2, &ntp_fraction_2);
+ base::TimeTicks out_2 = ConvertNtpToTimeTicks(ntp_seconds_2, ntp_fraction_2);
+ EXPECT_EQ(input_time, out_2); // Verify inverse.
+
+ // Verify delta.
+ EXPECT_EQ((out_2 - out_1), time_delta);
+ EXPECT_EQ((ntp_seconds_2 - ntp_seconds_1), UINT32_C(1));
+ EXPECT_NEAR(ntp_fraction_2, ntp_fraction_1, 1);
+
+ time_delta = base::TimeDelta::FromMilliseconds(500);
+ input_time += time_delta;
+
+ uint32_t ntp_seconds_3 = 0;
+ uint32_t ntp_fraction_3 = 0;
+
+ ConvertTimeTicksToNtp(input_time, &ntp_seconds_3, &ntp_fraction_3);
+ base::TimeTicks out_3 = ConvertNtpToTimeTicks(ntp_seconds_3, ntp_fraction_3);
+ EXPECT_EQ(input_time, out_3); // Verify inverse.
+
+ // Verify delta.
+ EXPECT_EQ((out_3 - out_2), time_delta);
+ EXPECT_NEAR((ntp_fraction_3 - ntp_fraction_2), 0xffffffff / 2, 1);
+}
+
} // namespace cast
} // namespace media
« no previous file with comments | « media/cast/net/rtcp/rtcp_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698