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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: webkit/glue/weburlloader_impl_unittest.cc
diff --git a/webkit/glue/weburlloader_impl_unittest.cc b/webkit/glue/weburlloader_impl_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7108ddb6f31d05d3b6e5d30dd05fc0da78dac8e5
--- /dev/null
+++ b/webkit/glue/weburlloader_impl_unittest.cc
@@ -0,0 +1,80 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/time.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebURLLoadTiming.h"
+#include "webkit/glue/resource_loader_bridge.h"
+#include "webkit/glue/weburlloader_impl.h"
+
+using base::TimeTicks;
+using WebKit::WebURLLoadTiming;
+
+namespace webkit_glue {
+
+WebURLLoadTiming RunTest(int64 initiation_time,
+ int64 start_time,
+ int64 end_time,
+ int64 callback_time,
+ int64 base_time,
+ int64 delta) {
+ ResourceLoadTimingInfo timing_info;
+ timing_info.base_ticks = TimeTicks::FromInternalValue(base_time);
+ timing_info.proxy_start = delta;
+ timing_info.proxy_end = 0;
+ timing_info.dns_start = 0;
+ timing_info.dns_end = 0;
+ timing_info.connect_start = 0;
+ timing_info.connect_end = 0;
+ timing_info.ssl_start = 0;
+ timing_info.ssl_end = 0;
+ timing_info.send_start = 0;
+ timing_info.send_end = 0;
+ timing_info.receive_headers_end = 0;
+
+ return PopulateWebURLLoadTiming(
+ timing_info,
+ TimeTicks::FromInternalValue(initiation_time),
+ TimeTicks::FromInternalValue(start_time),
+ TimeTicks::FromInternalValue(end_time),
+ TimeTicks::FromInternalValue(callback_time));
+}
+
+TEST(PopulateWebURLLoadTiming, NoSkew) {
+ 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.
+ EXPECT_EQ(2.0e-6, timing.requestTime());
+ EXPECT_EQ(1, timing.proxyStart());
+}
+
+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.
+ WebURLLoadTiming timing = RunTest(2, 0, 8, 6, 4, 2);
+ EXPECT_EQ(4.0e-6, timing.requestTime());
+ EXPECT_EQ(1, timing.proxyStart());
+}
+
+TEST(PopulateWebURLLoadTiming, FrontEndSkew) {
+ WebURLLoadTiming timing = RunTest(2, 0, 6, 6, 2, 2);
+ EXPECT_EQ(3.0e-6, timing.requestTime());
+ EXPECT_EQ(1, timing.proxyStart());
+}
+
+TEST(PopulateWebURLLoadTiming, BackEndSkew) {
+ WebURLLoadTiming timing = RunTest(0, 0, 6, 4, 2, 2);
+ EXPECT_EQ(1.0e-6, timing.requestTime());
+ EXPECT_EQ(1, timing.proxyStart());
+}
+
+TEST(PopulateWebURLLoadTiming, Instantaneous) {
+ WebURLLoadTiming timing = RunTest(0, 1, 1, 2, 1, 0);
+ EXPECT_EQ(1.0e-6, timing.requestTime());
+ EXPECT_EQ(0, timing.proxyStart());
+}
+
+TEST(PopulateWebURLLoadTiming, DisjointInstantaneous) {
+ WebURLLoadTiming timing = RunTest(1, 2, 2, 1, 2, 1);
+ EXPECT_EQ(1.0e-6, timing.requestTime());
+ EXPECT_EQ(0, timing.proxyStart());
+}
+
+} // namespace webkit_glue

Powered by Google App Engine
This is Rietveld 408576698