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

Side by Side Diff: webkit/glue/weburlloader_impl_unittest.cc

Issue 7602023: Use a monotonic clock (TimeTicks) to report network times to WebCore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix skew in webkit_glue. Created 9 years, 2 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
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 "base/time.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLLoadTiming.h"
8 #include "webkit/glue/resource_loader_bridge.h"
9 #include "webkit/glue/weburlloader_impl.h"
10
11 using base::TimeTicks;
12 using WebKit::WebURLLoadTiming;
13
14 namespace webkit_glue {
15
16 WebURLLoadTiming RunTest(int64 initiation_time,
17 int64 start_time,
18 int64 end_time,
19 int64 callback_time,
20 int64 base_time,
21 int64 delta) {
22 ResourceLoadTimingInfo timing_info;
23 timing_info.base_ticks = TimeTicks::FromInternalValue(base_time);
24 timing_info.proxy_start = delta;
25 timing_info.proxy_end = 0;
26 timing_info.dns_start = 0;
27 timing_info.dns_end = 0;
28 timing_info.connect_start = 0;
29 timing_info.connect_end = 0;
30 timing_info.ssl_start = 0;
31 timing_info.ssl_end = 0;
32 timing_info.send_start = 0;
33 timing_info.send_end = 0;
34 timing_info.receive_headers_end = 0;
35
36 return PopulateWebURLLoadTiming(
37 timing_info,
38 TimeTicks::FromInternalValue(initiation_time),
39 TimeTicks::FromInternalValue(start_time),
40 TimeTicks::FromInternalValue(end_time),
41 TimeTicks::FromInternalValue(callback_time));
42 }
43
44 TEST(PopulateWebURLLoadTiming, NoSkew) {
45 WebURLLoadTiming timing = RunTest(0, 1, 4, 5, 2, 1);
jar (doing other things) 2011/10/12 01:07:38 At a minimum, please define constants rather than
James Simonsen 2011/10/12 02:57:46 Done.
46 EXPECT_EQ(2.0e-6, timing.requestTime());
47 EXPECT_EQ(1, timing.proxyStart());
48 }
49
50 TEST(PopulateWebURLLoadTiming, DoubleEndedSkew) {
jar (doing other things) 2011/10/12 01:07:38 These test names are not enough to explain what ea
James Simonsen 2011/10/12 02:57:46 Done.
51 WebURLLoadTiming timing = RunTest(2, 0, 8, 6, 4, 2);
52 EXPECT_EQ(4.0e-6, timing.requestTime());
53 EXPECT_EQ(1, timing.proxyStart());
54 }
55
56 TEST(PopulateWebURLLoadTiming, FrontEndSkew) {
57 WebURLLoadTiming timing = RunTest(2, 0, 6, 6, 2, 2);
58 EXPECT_EQ(3.0e-6, timing.requestTime());
59 EXPECT_EQ(1, timing.proxyStart());
60 }
61
62 TEST(PopulateWebURLLoadTiming, BackEndSkew) {
63 WebURLLoadTiming timing = RunTest(0, 0, 6, 4, 2, 2);
64 EXPECT_EQ(1.0e-6, timing.requestTime());
65 EXPECT_EQ(1, timing.proxyStart());
66 }
67
68 TEST(PopulateWebURLLoadTiming, Instantaneous) {
69 WebURLLoadTiming timing = RunTest(0, 1, 1, 2, 1, 0);
70 EXPECT_EQ(1.0e-6, timing.requestTime());
71 EXPECT_EQ(0, timing.proxyStart());
72 }
73
74 TEST(PopulateWebURLLoadTiming, DisjointInstantaneous) {
75 WebURLLoadTiming timing = RunTest(1, 2, 2, 1, 2, 1);
76 EXPECT_EQ(1.0e-6, timing.requestTime());
77 EXPECT_EQ(0, timing.proxyStart());
78 }
79
80 } // namespace webkit_glue
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698