OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/basictypes.h" | 5 #include <stddef.h> |
| 6 #include <stdint.h> |
| 7 |
6 #include "base/bind.h" | 8 #include "base/bind.h" |
7 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/macros.h" |
8 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
9 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
10 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
11 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
12 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "build/build_config.h" |
13 #include "content/browser/frame_host/cross_site_transferring_request.h" | 17 #include "content/browser/frame_host/cross_site_transferring_request.h" |
14 #include "content/browser/frame_host/frame_navigation_entry.h" | 18 #include "content/browser/frame_host/frame_navigation_entry.h" |
15 #include "content/browser/frame_host/navigation_controller_impl.h" | 19 #include "content/browser/frame_host/navigation_controller_impl.h" |
16 #include "content/browser/frame_host/navigation_entry_impl.h" | 20 #include "content/browser/frame_host/navigation_entry_impl.h" |
17 #include "content/browser/frame_host/navigation_entry_screenshot_manager.h" | 21 #include "content/browser/frame_host/navigation_entry_screenshot_manager.h" |
18 #include "content/browser/frame_host/navigation_request.h" | 22 #include "content/browser/frame_host/navigation_request.h" |
19 #include "content/browser/frame_host/navigator.h" | 23 #include "content/browser/frame_host/navigator.h" |
20 #include "content/browser/frame_host/navigator_impl.h" | 24 #include "content/browser/frame_host/navigator_impl.h" |
21 #include "content/browser/site_instance_impl.h" | 25 #include "content/browser/site_instance_impl.h" |
22 #include "content/browser/web_contents/web_contents_impl.h" | 26 #include "content/browser/web_contents/web_contents_impl.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 } // namespace | 130 } // namespace |
127 | 131 |
128 namespace content { | 132 namespace content { |
129 | 133 |
130 // TimeSmoother tests ---------------------------------------------------------- | 134 // TimeSmoother tests ---------------------------------------------------------- |
131 | 135 |
132 // With no duplicates, GetSmoothedTime should be the identity | 136 // With no duplicates, GetSmoothedTime should be the identity |
133 // function. | 137 // function. |
134 TEST(TimeSmoother, Basic) { | 138 TEST(TimeSmoother, Basic) { |
135 NavigationControllerImpl::TimeSmoother smoother; | 139 NavigationControllerImpl::TimeSmoother smoother; |
136 for (int64 i = 1; i < 1000; ++i) { | 140 for (int64_t i = 1; i < 1000; ++i) { |
137 base::Time t = base::Time::FromInternalValue(i); | 141 base::Time t = base::Time::FromInternalValue(i); |
138 EXPECT_EQ(t, smoother.GetSmoothedTime(t)); | 142 EXPECT_EQ(t, smoother.GetSmoothedTime(t)); |
139 } | 143 } |
140 } | 144 } |
141 | 145 |
142 // With a single duplicate and timestamps thereafter increasing by one | 146 // With a single duplicate and timestamps thereafter increasing by one |
143 // microsecond, the smoothed time should always be one behind. | 147 // microsecond, the smoothed time should always be one behind. |
144 TEST(TimeSmoother, SingleDuplicate) { | 148 TEST(TimeSmoother, SingleDuplicate) { |
145 NavigationControllerImpl::TimeSmoother smoother; | 149 NavigationControllerImpl::TimeSmoother smoother; |
146 base::Time t = base::Time::FromInternalValue(1); | 150 base::Time t = base::Time::FromInternalValue(1); |
147 EXPECT_EQ(t, smoother.GetSmoothedTime(t)); | 151 EXPECT_EQ(t, smoother.GetSmoothedTime(t)); |
148 for (int64 i = 1; i < 1000; ++i) { | 152 for (int64_t i = 1; i < 1000; ++i) { |
149 base::Time expected_t = base::Time::FromInternalValue(i + 1); | 153 base::Time expected_t = base::Time::FromInternalValue(i + 1); |
150 t = base::Time::FromInternalValue(i); | 154 t = base::Time::FromInternalValue(i); |
151 EXPECT_EQ(expected_t, smoother.GetSmoothedTime(t)); | 155 EXPECT_EQ(expected_t, smoother.GetSmoothedTime(t)); |
152 } | 156 } |
153 } | 157 } |
154 | 158 |
155 // With k duplicates and timestamps thereafter increasing by one | 159 // With k duplicates and timestamps thereafter increasing by one |
156 // microsecond, the smoothed time should always be k behind. | 160 // microsecond, the smoothed time should always be k behind. |
157 TEST(TimeSmoother, ManyDuplicates) { | 161 TEST(TimeSmoother, ManyDuplicates) { |
158 const int64 kNumDuplicates = 100; | 162 const int64_t kNumDuplicates = 100; |
159 NavigationControllerImpl::TimeSmoother smoother; | 163 NavigationControllerImpl::TimeSmoother smoother; |
160 base::Time t = base::Time::FromInternalValue(1); | 164 base::Time t = base::Time::FromInternalValue(1); |
161 for (int64 i = 0; i < kNumDuplicates; ++i) { | 165 for (int64_t i = 0; i < kNumDuplicates; ++i) { |
162 base::Time expected_t = base::Time::FromInternalValue(i + 1); | 166 base::Time expected_t = base::Time::FromInternalValue(i + 1); |
163 EXPECT_EQ(expected_t, smoother.GetSmoothedTime(t)); | 167 EXPECT_EQ(expected_t, smoother.GetSmoothedTime(t)); |
164 } | 168 } |
165 for (int64 i = 1; i < 1000; ++i) { | 169 for (int64_t i = 1; i < 1000; ++i) { |
166 base::Time expected_t = | 170 base::Time expected_t = |
167 base::Time::FromInternalValue(i + kNumDuplicates); | 171 base::Time::FromInternalValue(i + kNumDuplicates); |
168 t = base::Time::FromInternalValue(i); | 172 t = base::Time::FromInternalValue(i); |
169 EXPECT_EQ(expected_t, smoother.GetSmoothedTime(t)); | 173 EXPECT_EQ(expected_t, smoother.GetSmoothedTime(t)); |
170 } | 174 } |
171 } | 175 } |
172 | 176 |
173 // If the clock jumps far back enough after a run of duplicates, it | 177 // If the clock jumps far back enough after a run of duplicates, it |
174 // should immediately jump to that value. | 178 // should immediately jump to that value. |
175 TEST(TimeSmoother, ClockBackwardsJump) { | 179 TEST(TimeSmoother, ClockBackwardsJump) { |
176 const int64 kNumDuplicates = 100; | 180 const int64_t kNumDuplicates = 100; |
177 NavigationControllerImpl::TimeSmoother smoother; | 181 NavigationControllerImpl::TimeSmoother smoother; |
178 base::Time t = base::Time::FromInternalValue(1000); | 182 base::Time t = base::Time::FromInternalValue(1000); |
179 for (int64 i = 0; i < kNumDuplicates; ++i) { | 183 for (int64_t i = 0; i < kNumDuplicates; ++i) { |
180 base::Time expected_t = base::Time::FromInternalValue(i + 1000); | 184 base::Time expected_t = base::Time::FromInternalValue(i + 1000); |
181 EXPECT_EQ(expected_t, smoother.GetSmoothedTime(t)); | 185 EXPECT_EQ(expected_t, smoother.GetSmoothedTime(t)); |
182 } | 186 } |
183 t = base::Time::FromInternalValue(500); | 187 t = base::Time::FromInternalValue(500); |
184 EXPECT_EQ(t, smoother.GetSmoothedTime(t)); | 188 EXPECT_EQ(t, smoother.GetSmoothedTime(t)); |
185 } | 189 } |
186 | 190 |
187 // NavigationControllerTest ---------------------------------------------------- | 191 // NavigationControllerTest ---------------------------------------------------- |
188 | 192 |
189 class NavigationControllerTest | 193 class NavigationControllerTest |
(...skipping 4925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5115 EXPECT_EQ(default_ssl_status.connection_status, | 5119 EXPECT_EQ(default_ssl_status.connection_status, |
5116 details.ssl_status.connection_status); | 5120 details.ssl_status.connection_status); |
5117 EXPECT_EQ(default_ssl_status.content_status, | 5121 EXPECT_EQ(default_ssl_status.content_status, |
5118 details.ssl_status.content_status); | 5122 details.ssl_status.content_status); |
5119 EXPECT_EQ(0u, details.ssl_status.signed_certificate_timestamp_ids.size()); | 5123 EXPECT_EQ(0u, details.ssl_status.signed_certificate_timestamp_ids.size()); |
5120 | 5124 |
5121 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count()); | 5125 EXPECT_EQ(1, main_test_rfh()->GetProcess()->bad_msg_count()); |
5122 } | 5126 } |
5123 | 5127 |
5124 } // namespace content | 5128 } // namespace content |
OLD | NEW |