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

Side by Side Diff: net/tools/quic/quic_epoll_clock_test.cc

Issue 2125303002: Use overloaded operators with QuicTime for addition, subtraction and scalar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@126402784
Patch Set: Created 4 years, 5 months 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 unified diff | Download patch
« no previous file with comments | « net/tools/quic/quic_epoll_clock.cc ('k') | net/tools/quic/quic_epoll_connection_helper_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/tools/quic/quic_epoll_clock.h" 5 #include "net/tools/quic/quic_epoll_clock.h"
6 6
7 #include "net/tools/quic/test_tools/mock_epoll_server.h" 7 #include "net/tools/quic/test_tools/mock_epoll_server.h"
8 #include "testing/gmock/include/gmock/gmock.h" 8 #include "testing/gmock/include/gmock/gmock.h"
9 9
10 namespace net { 10 namespace net {
11 namespace test { 11 namespace test {
12 12
13 TEST(QuicEpollClockTest, ApproximateNowInUsec) { 13 TEST(QuicEpollClockTest, ApproximateNowInUsec) {
14 MockEpollServer epoll_server; 14 MockEpollServer epoll_server;
15 QuicEpollClock clock(&epoll_server); 15 QuicEpollClock clock(&epoll_server);
16 16
17 epoll_server.set_now_in_usec(1000000); 17 epoll_server.set_now_in_usec(1000000);
18 EXPECT_EQ(1000000, 18 EXPECT_EQ(1000000,
19 clock.ApproximateNow().Subtract(QuicTime::Zero()).ToMicroseconds()); 19 (clock.ApproximateNow() - QuicTime::Zero()).ToMicroseconds());
20 EXPECT_EQ(1u, clock.WallNow().ToUNIXSeconds()); 20 EXPECT_EQ(1u, clock.WallNow().ToUNIXSeconds());
21 EXPECT_EQ(1000000u, clock.WallNow().ToUNIXMicroseconds()); 21 EXPECT_EQ(1000000u, clock.WallNow().ToUNIXMicroseconds());
22 22
23 epoll_server.AdvanceBy(5); 23 epoll_server.AdvanceBy(5);
24 EXPECT_EQ(1000005, 24 EXPECT_EQ(1000005,
25 clock.ApproximateNow().Subtract(QuicTime::Zero()).ToMicroseconds()); 25 (clock.ApproximateNow() - QuicTime::Zero()).ToMicroseconds());
26 EXPECT_EQ(1u, clock.WallNow().ToUNIXSeconds()); 26 EXPECT_EQ(1u, clock.WallNow().ToUNIXSeconds());
27 EXPECT_EQ(1000005u, clock.WallNow().ToUNIXMicroseconds()); 27 EXPECT_EQ(1000005u, clock.WallNow().ToUNIXMicroseconds());
28 28
29 epoll_server.AdvanceBy(10 * 1000000); 29 epoll_server.AdvanceBy(10 * 1000000);
30 EXPECT_EQ(11u, clock.WallNow().ToUNIXSeconds()); 30 EXPECT_EQ(11u, clock.WallNow().ToUNIXSeconds());
31 EXPECT_EQ(11000005u, clock.WallNow().ToUNIXMicroseconds()); 31 EXPECT_EQ(11000005u, clock.WallNow().ToUNIXMicroseconds());
32 } 32 }
33 33
34 TEST(QuicEpollClockTest, NowInUsec) { 34 TEST(QuicEpollClockTest, NowInUsec) {
35 MockEpollServer epoll_server; 35 MockEpollServer epoll_server;
36 QuicEpollClock clock(&epoll_server); 36 QuicEpollClock clock(&epoll_server);
37 37
38 epoll_server.set_now_in_usec(1000000); 38 epoll_server.set_now_in_usec(1000000);
39 EXPECT_EQ(1000000, clock.Now().Subtract(QuicTime::Zero()).ToMicroseconds()); 39 EXPECT_EQ(1000000, (clock.Now() - QuicTime::Zero()).ToMicroseconds());
40 40
41 epoll_server.AdvanceBy(5); 41 epoll_server.AdvanceBy(5);
42 EXPECT_EQ(1000005, clock.Now().Subtract(QuicTime::Zero()).ToMicroseconds()); 42 EXPECT_EQ(1000005, (clock.Now() - QuicTime::Zero()).ToMicroseconds());
43 } 43 }
44 44
45 } // namespace test 45 } // namespace test
46 } // namespace net 46 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_epoll_clock.cc ('k') | net/tools/quic/quic_epoll_connection_helper_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698