| 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 "content/public/test/render_view_test.h" | 5 #include "content/public/test/render_view_test.h" |
| 6 | 6 |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "content/common/dom_storage/dom_storage_types.h" | 8 #include "content/common/dom_storage/dom_storage_types.h" |
| 9 #include "content/common/frame_messages.h" | 9 #include "content/common/frame_messages.h" |
| 10 #include "content/common/input_messages.h" | 10 #include "content/common/input_messages.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 kMainFrameRouteId, | 197 kMainFrameRouteId, |
| 198 kSurfaceId, | 198 kSurfaceId, |
| 199 kInvalidSessionStorageNamespaceId, | 199 kInvalidSessionStorageNamespaceId, |
| 200 base::string16(), | 200 base::string16(), |
| 201 false, // is_renderer_created | 201 false, // is_renderer_created |
| 202 false, // swapped_out | 202 false, // swapped_out |
| 203 MSG_ROUTING_NONE, // proxy_routing_id | 203 MSG_ROUTING_NONE, // proxy_routing_id |
| 204 false, // hidden | 204 false, // hidden |
| 205 false, // never_visible | 205 false, // never_visible |
| 206 1, // next_page_id | 206 1, // next_page_id |
| 207 blink::WebScreenInfo()); | 207 *InitialSizeParams(), |
| 208 false, // enable_auto_resize |
| 209 gfx::Size(), // min_size |
| 210 gfx::Size() // max_size |
| 211 ); |
| 208 view->AddRef(); | 212 view->AddRef(); |
| 209 view_ = view; | 213 view_ = view; |
| 210 } | 214 } |
| 211 | 215 |
| 212 void RenderViewTest::TearDown() { | 216 void RenderViewTest::TearDown() { |
| 213 // Try very hard to collect garbage before shutting down. | 217 // Try very hard to collect garbage before shutting down. |
| 214 // "5" was chosen following http://crbug.com/46571#c9 | 218 // "5" was chosen following http://crbug.com/46571#c9 |
| 215 const int kGCIterations = 5; | 219 const int kGCIterations = 5; |
| 216 for (int i = 0; i < kGCIterations; i++) | 220 for (int i = 0; i < kGCIterations; i++) |
| 217 GetMainFrame()->collectGarbage(); | 221 GetMainFrame()->collectGarbage(); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 } | 404 } |
| 401 | 405 |
| 402 ContentBrowserClient* RenderViewTest::CreateContentBrowserClient() { | 406 ContentBrowserClient* RenderViewTest::CreateContentBrowserClient() { |
| 403 return new ContentBrowserClient; | 407 return new ContentBrowserClient; |
| 404 } | 408 } |
| 405 | 409 |
| 406 ContentRendererClient* RenderViewTest::CreateContentRendererClient() { | 410 ContentRendererClient* RenderViewTest::CreateContentRendererClient() { |
| 407 return new ContentRendererClient; | 411 return new ContentRendererClient; |
| 408 } | 412 } |
| 409 | 413 |
| 414 scoped_ptr<ViewMsg_Resize_Params> RenderViewTest::InitialSizeParams() { |
| 415 return make_scoped_ptr(new ViewMsg_Resize_Params()); |
| 416 } |
| 417 |
| 410 void RenderViewTest::GoToOffset(int offset, const PageState& state) { | 418 void RenderViewTest::GoToOffset(int offset, const PageState& state) { |
| 411 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); | 419 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); |
| 412 | 420 |
| 413 int history_list_length = impl->historyBackListCount() + | 421 int history_list_length = impl->historyBackListCount() + |
| 414 impl->historyForwardListCount() + 1; | 422 impl->historyForwardListCount() + 1; |
| 415 int pending_offset = offset + impl->history_list_offset(); | 423 int pending_offset = offset + impl->history_list_offset(); |
| 416 | 424 |
| 417 FrameMsg_Navigate_Params navigate_params; | 425 FrameMsg_Navigate_Params navigate_params; |
| 418 navigate_params.common_params.navigation_type = | 426 navigate_params.common_params.navigation_type = |
| 419 FrameMsg_Navigate_Type::NORMAL; | 427 FrameMsg_Navigate_Type::NORMAL; |
| 420 navigate_params.common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; | 428 navigate_params.common_params.transition = ui::PAGE_TRANSITION_FORWARD_BACK; |
| 421 navigate_params.current_history_list_length = history_list_length; | 429 navigate_params.current_history_list_length = history_list_length; |
| 422 navigate_params.current_history_list_offset = impl->history_list_offset(); | 430 navigate_params.current_history_list_offset = impl->history_list_offset(); |
| 423 navigate_params.pending_history_list_offset = pending_offset; | 431 navigate_params.pending_history_list_offset = pending_offset; |
| 424 navigate_params.page_id = impl->page_id_ + offset; | 432 navigate_params.page_id = impl->page_id_ + offset; |
| 425 navigate_params.commit_params.page_state = state; | 433 navigate_params.commit_params.page_state = state; |
| 426 navigate_params.request_time = base::Time::Now(); | 434 navigate_params.request_time = base::Time::Now(); |
| 427 | 435 |
| 428 FrameMsg_Navigate navigate_message(impl->GetMainRenderFrame()->GetRoutingID(), | 436 FrameMsg_Navigate navigate_message(impl->GetMainRenderFrame()->GetRoutingID(), |
| 429 navigate_params); | 437 navigate_params); |
| 430 impl->GetMainRenderFrame()->OnMessageReceived(navigate_message); | 438 impl->GetMainRenderFrame()->OnMessageReceived(navigate_message); |
| 431 | 439 |
| 432 // The load actually happens asynchronously, so we pump messages to process | 440 // The load actually happens asynchronously, so we pump messages to process |
| 433 // the pending continuation. | 441 // the pending continuation. |
| 434 FrameLoadWaiter(view_->GetMainRenderFrame()).Wait(); | 442 FrameLoadWaiter(view_->GetMainRenderFrame()).Wait(); |
| 435 } | 443 } |
| 436 | 444 |
| 437 } // namespace content | 445 } // namespace content |
| OLD | NEW |