1 // Copyright (c) 2013 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.
5 #include "net/base/load_timing_info_test_util.h"
7 #include "net/base/load_timing_info.h"
8 #include "testing/gtest/include/gtest/gtest.h"
12 void ExpectConnectTimingHasNoTimes(
13 const LoadTimingInfo::ConnectTiming
& connect_timing
) {
14 EXPECT_TRUE(connect_timing
.dns_start
.is_null());
15 EXPECT_TRUE(connect_timing
.dns_end
.is_null());
16 EXPECT_TRUE(connect_timing
.connect_start
.is_null());
17 EXPECT_TRUE(connect_timing
.connect_end
.is_null());
18 EXPECT_TRUE(connect_timing
.ssl_start
.is_null());
19 EXPECT_TRUE(connect_timing
.ssl_end
.is_null());
22 void ExpectConnectTimingHasTimes(
23 const LoadTimingInfo::ConnectTiming
& connect_timing
,
24 int connect_timing_flags
) {
25 EXPECT_FALSE(connect_timing
.connect_start
.is_null());
26 EXPECT_LE(connect_timing
.connect_start
, connect_timing
.connect_end
);
28 if (!(connect_timing_flags
& CONNECT_TIMING_HAS_DNS_TIMES
)) {
29 EXPECT_TRUE(connect_timing
.dns_start
.is_null());
30 EXPECT_TRUE(connect_timing
.dns_end
.is_null());
32 EXPECT_FALSE(connect_timing
.dns_start
.is_null());
33 EXPECT_LE(connect_timing
.dns_start
, connect_timing
.dns_end
);
34 EXPECT_LE(connect_timing
.dns_end
, connect_timing
.connect_start
);
37 if (!(connect_timing_flags
& CONNECT_TIMING_HAS_SSL_TIMES
)) {
38 EXPECT_TRUE(connect_timing
.ssl_start
.is_null());
39 EXPECT_TRUE(connect_timing
.ssl_start
.is_null());
41 EXPECT_FALSE(connect_timing
.ssl_start
.is_null());
42 EXPECT_LE(connect_timing
.connect_start
, connect_timing
.ssl_start
);
43 EXPECT_LE(connect_timing
.ssl_start
, connect_timing
.ssl_end
);
44 EXPECT_LE(connect_timing
.ssl_end
, connect_timing
.connect_end
);
48 void ExpectLoadTimingHasOnlyConnectionTimes(
49 const LoadTimingInfo
& load_timing_info
) {
50 EXPECT_TRUE(load_timing_info
.request_start_time
.is_null());
51 EXPECT_TRUE(load_timing_info
.request_start
.is_null());
52 EXPECT_TRUE(load_timing_info
.proxy_resolve_start
.is_null());
53 EXPECT_TRUE(load_timing_info
.proxy_resolve_end
.is_null());
54 EXPECT_TRUE(load_timing_info
.send_start
.is_null());
55 EXPECT_TRUE(load_timing_info
.send_end
.is_null());
56 EXPECT_TRUE(load_timing_info
.receive_headers_end
.is_null());