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

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

Issue 14816006: Land Recent QUIC changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added missing NET_PRIVATE_EXPORT to QuicWallTime Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « net/tools/quic/quic_epoll_clock.cc ('k') | net/tools/quic/quic_server.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 tools { 11 namespace tools {
12 namespace test { 12 namespace test {
13 13
14 TEST(QuicEpollClockTest, ApproximateNowInUsec) { 14 TEST(QuicEpollClockTest, ApproximateNowInUsec) {
15 MockEpollServer epoll_server; 15 MockEpollServer epoll_server;
16 QuicEpollClock clock(&epoll_server); 16 QuicEpollClock clock(&epoll_server);
17 17
18 epoll_server.set_now_in_usec(1000000); 18 epoll_server.set_now_in_usec(1000000);
19 EXPECT_EQ(1000000, 19 EXPECT_EQ(1000000,
20 clock.ApproximateNow().Subtract(QuicTime::Zero()).ToMicroseconds()); 20 clock.ApproximateNow().Subtract(QuicTime::Zero()).ToMicroseconds());
21 EXPECT_EQ(QuicTime::Delta::FromMicroseconds(1000000), 21 EXPECT_EQ(1u, clock.WallNow().ToUNIXSeconds());
22 clock.NowAsDeltaSinceUnixEpoch());
23 22
24 epoll_server.AdvanceBy(5); 23 epoll_server.AdvanceBy(5);
25 EXPECT_EQ(1000005, 24 EXPECT_EQ(1000005,
26 clock.ApproximateNow().Subtract(QuicTime::Zero()).ToMicroseconds()); 25 clock.ApproximateNow().Subtract(QuicTime::Zero()).ToMicroseconds());
27 EXPECT_EQ(QuicTime::Delta::FromMicroseconds(1000005), 26 EXPECT_EQ(1u, clock.WallNow().ToUNIXSeconds());
28 clock.NowAsDeltaSinceUnixEpoch()); 27
28 epoll_server.AdvanceBy(10 * 1000000);
29 EXPECT_EQ(11u, clock.WallNow().ToUNIXSeconds());
29 } 30 }
30 31
31 TEST(QuicEpollClockTest, NowInUsec) { 32 TEST(QuicEpollClockTest, NowInUsec) {
32 MockEpollServer epoll_server; 33 MockEpollServer epoll_server;
33 QuicEpollClock clock(&epoll_server); 34 QuicEpollClock clock(&epoll_server);
34 35
35 epoll_server.set_now_in_usec(1000000); 36 epoll_server.set_now_in_usec(1000000);
36 EXPECT_EQ(1000000, 37 EXPECT_EQ(1000000,
37 clock.Now().Subtract(QuicTime::Zero()).ToMicroseconds()); 38 clock.Now().Subtract(QuicTime::Zero()).ToMicroseconds());
38 EXPECT_EQ(QuicTime::Delta::FromMicroseconds(1000000),
39 clock.NowAsDeltaSinceUnixEpoch());
40 39
41 epoll_server.AdvanceBy(5); 40 epoll_server.AdvanceBy(5);
42 EXPECT_EQ(1000005, 41 EXPECT_EQ(1000005,
43 clock.Now().Subtract(QuicTime::Zero()).ToMicroseconds()); 42 clock.Now().Subtract(QuicTime::Zero()).ToMicroseconds());
44 EXPECT_EQ(QuicTime::Delta::FromMicroseconds(1000005),
45 clock.NowAsDeltaSinceUnixEpoch());
46 } 43 }
47 44
48 } // namespace test 45 } // namespace test
49 } // namespace tools 46 } // namespace tools
50 } // namespace net 47 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_epoll_clock.cc ('k') | net/tools/quic/quic_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698