OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/basictypes.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 2292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2303 frame()->Navigate(late_common_params, late_start_params, late_request_params); | 2303 frame()->Navigate(late_common_params, late_start_params, late_request_params); |
2304 ProcessPendingMessages(); | 2304 ProcessPendingMessages(); |
2305 base::Time after_navigation = | 2305 base::Time after_navigation = |
2306 base::Time::Now() + base::TimeDelta::FromDays(1); | 2306 base::Time::Now() + base::TimeDelta::FromDays(1); |
2307 | 2307 |
2308 base::Time late_nav_reported_start = | 2308 base::Time late_nav_reported_start = |
2309 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); | 2309 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); |
2310 EXPECT_LE(late_nav_reported_start, after_navigation); | 2310 EXPECT_LE(late_nav_reported_start, after_navigation); |
2311 } | 2311 } |
2312 | 2312 |
2313 TEST_F(RenderViewImplTest, BrowserNavigationStartSuccessfullyTransmitted) { | |
clamy
2015/11/04 13:53:40
Should you also test for a renderer initiated navi
Charlie Harrison
2015/11/04 14:24:52
Yeah probably. Would you like me to write a bunch
clamy
2015/11/04 15:59:09
I think smaller independant test cases are easier
| |
2314 CommonNavigationParams common_params; | |
2315 StartNavigationParams start_params; | |
2316 RequestNavigationParams request_params; | |
clamy
2015/11/04 13:53:39
No need to declare this, just use the default cons
Charlie Harrison
2015/11/04 14:24:52
Acknowledged.
| |
2317 common_params.url = GURL("data:text/html,<div>Page</div>"); | |
2318 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | |
2319 common_params.transition = ui::PAGE_TRANSITION_TYPED; | |
2320 start_params.is_post = true; | |
2321 | |
2322 // Data munching to simulate what we do in blink: convert navigation_start to | |
2323 // a double for DocumentLoadTiming, then back to a TimeTicks to send back to | |
2324 // the browser in FrameHostMsg_DidStartProvisionalLoadForFrame. | |
2325 double navigation_start_seconds = | |
2326 (common_params.navigation_start - base::TimeTicks()).InSecondsF(); | |
2327 base::TimeTicks adjusted_navigation_start = | |
2328 base::TimeTicks::FromInternalValue(navigation_start_seconds * | |
2329 base::Time::kMicrosecondsPerSecond); | |
2330 | |
2331 frame()->Navigate(common_params, start_params, request_params); | |
2332 ProcessPendingMessages(); | |
2333 | |
2334 const IPC::Message* frame_navigate_msg = | |
2335 render_thread_->sink().GetUniqueMessageMatching( | |
2336 FrameHostMsg_DidStartProvisionalLoadForFrame::ID); | |
2337 FrameHostMsg_DidStartProvisionalLoadForFrame::Param host_nav_params; | |
2338 FrameHostMsg_DidStartProvisionalLoadForFrame::Read(frame_navigate_msg, | |
2339 &host_nav_params); | |
2340 EXPECT_EQ(base::get<1>(host_nav_params), adjusted_navigation_start); | |
2341 } | |
2342 | |
2313 TEST_F(RenderViewImplTest, PreferredSizeZoomed) { | 2343 TEST_F(RenderViewImplTest, PreferredSizeZoomed) { |
2314 LoadHTML("<body style='margin:0;'><div style='display:inline-block; " | 2344 LoadHTML("<body style='margin:0;'><div style='display:inline-block; " |
2315 "width:400px; height:400px;'/></body>"); | 2345 "width:400px; height:400px;'/></body>"); |
2316 view()->webview()->mainFrame()->setCanHaveScrollbars(false); | 2346 view()->webview()->mainFrame()->setCanHaveScrollbars(false); |
2317 EnablePreferredSizeMode(); | 2347 EnablePreferredSizeMode(); |
2318 | 2348 |
2319 gfx::Size size = GetPreferredSize(); | 2349 gfx::Size size = GetPreferredSize(); |
2320 EXPECT_EQ(gfx::Size(400, 400), size); | 2350 EXPECT_EQ(gfx::Size(400, 400), size); |
2321 | 2351 |
2322 SetZoomLevel(ZoomFactorToZoomLevel(2.0)); | 2352 SetZoomLevel(ZoomFactorToZoomLevel(2.0)); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2380 FROM_HERE, | 2410 FROM_HERE, |
2381 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); | 2411 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); |
2382 ExecuteJavaScriptForTests("debugger;"); | 2412 ExecuteJavaScriptForTests("debugger;"); |
2383 | 2413 |
2384 // CloseWhilePaused should resume execution and continue here. | 2414 // CloseWhilePaused should resume execution and continue here. |
2385 EXPECT_FALSE(IsPaused()); | 2415 EXPECT_FALSE(IsPaused()); |
2386 Detach(); | 2416 Detach(); |
2387 } | 2417 } |
2388 | 2418 |
2389 } // namespace content | 2419 } // namespace content |
OLD | NEW |