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 |