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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 std::string url_str = "data:text/html;charset=utf-8,"; | 138 std::string url_str = "data:text/html;charset=utf-8,"; |
139 url_str.append(html); | 139 url_str.append(html); |
140 GURL url(url_str); | 140 GURL url(url_str); |
141 FrameLoadWaiter waiter(view_, &msg_loop_); | 141 FrameLoadWaiter waiter(view_, &msg_loop_); |
142 GetMainFrame()->loadRequest(WebURLRequest(url)); | 142 GetMainFrame()->loadRequest(WebURLRequest(url)); |
143 // The load actually happens asynchronously, so we pump messages to process | 143 // The load actually happens asynchronously, so we pump messages to process |
144 // the pending continuation. | 144 // the pending continuation. |
145 waiter.Wait(); | 145 waiter.Wait(); |
146 } | 146 } |
147 | 147 |
148 void RenderViewTest::GoBack(const blink::WebHistoryItem& item) { | 148 void RenderViewTest::GoBack(const PageState& state) { |
149 GoToOffset(-1, item); | 149 GoToOffset(-1, state); |
150 } | 150 } |
151 | 151 |
152 void RenderViewTest::GoForward(const blink::WebHistoryItem& item) { | 152 void RenderViewTest::GoForward(const PageState& state) { |
153 GoToOffset(1, item); | 153 GoToOffset(1, state); |
154 } | 154 } |
155 | 155 |
156 void RenderViewTest::GoBackToPrevious() { | 156 void RenderViewTest::GoBackToPrevious() { |
157 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); | 157 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); |
158 GoBack(impl->history_controller()->GetPreviousItemForExport()); | 158 GoBack(HistoryEntryToPageState( |
| 159 impl->history_controller()->GetPreviousEntry())); |
159 } | 160 } |
160 | 161 |
161 void RenderViewTest::SetUp() { | 162 void RenderViewTest::SetUp() { |
162 content_client_.reset(CreateContentClient()); | 163 content_client_.reset(CreateContentClient()); |
163 content_browser_client_.reset(CreateContentBrowserClient()); | 164 content_browser_client_.reset(CreateContentBrowserClient()); |
164 content_renderer_client_.reset(CreateContentRendererClient()); | 165 content_renderer_client_.reset(CreateContentRendererClient()); |
165 SetContentClient(content_client_.get()); | 166 SetContentClient(content_client_.get()); |
166 SetBrowserClientForTesting(content_browser_client_.get()); | 167 SetBrowserClientForTesting(content_browser_client_.get()); |
167 SetRendererClientForTesting(content_renderer_client_.get()); | 168 SetRendererClientForTesting(content_renderer_client_.get()); |
168 | 169 |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 } | 414 } |
414 | 415 |
415 ContentBrowserClient* RenderViewTest::CreateContentBrowserClient() { | 416 ContentBrowserClient* RenderViewTest::CreateContentBrowserClient() { |
416 return new ContentBrowserClient; | 417 return new ContentBrowserClient; |
417 } | 418 } |
418 | 419 |
419 ContentRendererClient* RenderViewTest::CreateContentRendererClient() { | 420 ContentRendererClient* RenderViewTest::CreateContentRendererClient() { |
420 return new ContentRendererClient; | 421 return new ContentRendererClient; |
421 } | 422 } |
422 | 423 |
423 void RenderViewTest::GoToOffset(int offset, | 424 void RenderViewTest::GoToOffset(int offset, const PageState& state) { |
424 const blink::WebHistoryItem& history_item) { | |
425 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); | 425 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); |
426 | 426 |
427 int history_list_length = impl->historyBackListCount() + | 427 int history_list_length = impl->historyBackListCount() + |
428 impl->historyForwardListCount() + 1; | 428 impl->historyForwardListCount() + 1; |
429 int pending_offset = offset + impl->history_list_offset(); | 429 int pending_offset = offset + impl->history_list_offset(); |
430 | 430 |
431 FrameMsg_Navigate_Params navigate_params; | 431 FrameMsg_Navigate_Params navigate_params; |
432 navigate_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 432 navigate_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
433 navigate_params.transition = PAGE_TRANSITION_FORWARD_BACK; | 433 navigate_params.transition = PAGE_TRANSITION_FORWARD_BACK; |
434 navigate_params.current_history_list_length = history_list_length; | 434 navigate_params.current_history_list_length = history_list_length; |
435 navigate_params.current_history_list_offset = impl->history_list_offset(); | 435 navigate_params.current_history_list_offset = impl->history_list_offset(); |
436 navigate_params.pending_history_list_offset = pending_offset; | 436 navigate_params.pending_history_list_offset = pending_offset; |
437 navigate_params.page_id = impl->GetPageId() + offset; | 437 navigate_params.page_id = impl->GetPageId() + offset; |
438 navigate_params.page_state = HistoryItemToPageState(history_item); | 438 navigate_params.page_state = state; |
439 navigate_params.request_time = base::Time::Now(); | 439 navigate_params.request_time = base::Time::Now(); |
440 | 440 |
441 FrameMsg_Navigate navigate_message(impl->main_render_frame()->GetRoutingID(), | 441 FrameMsg_Navigate navigate_message(impl->main_render_frame()->GetRoutingID(), |
442 navigate_params); | 442 navigate_params); |
443 impl->main_render_frame()->OnMessageReceived(navigate_message); | 443 impl->main_render_frame()->OnMessageReceived(navigate_message); |
444 | 444 |
445 // The load actually happens asynchronously, so we pump messages to process | 445 // The load actually happens asynchronously, so we pump messages to process |
446 // the pending continuation. | 446 // the pending continuation. |
447 ProcessPendingMessages(); | 447 ProcessPendingMessages(); |
448 } | 448 } |
449 | 449 |
450 } // namespace content | 450 } // namespace content |
OLD | NEW |