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/test/test_render_view_host.h" | 5 #include "content/test/test_render_view_host.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 params->searchable_form_encoding = std::string(); | 53 params->searchable_form_encoding = std::string(); |
54 params->did_create_new_entry = did_create_new_entry; | 54 params->did_create_new_entry = did_create_new_entry; |
55 params->gesture = NavigationGestureUser; | 55 params->gesture = NavigationGestureUser; |
56 params->was_within_same_page = false; | 56 params->was_within_same_page = false; |
57 params->method = "GET"; | 57 params->method = "GET"; |
58 params->page_state = PageState::CreateFromURL(url); | 58 params->page_state = PageState::CreateFromURL(url); |
59 } | 59 } |
60 | 60 |
61 TestRenderWidgetHostView::TestRenderWidgetHostView(RenderWidgetHost* rwh) | 61 TestRenderWidgetHostView::TestRenderWidgetHostView(RenderWidgetHost* rwh) |
62 : rwh_(RenderWidgetHostImpl::From(rwh)), | 62 : rwh_(RenderWidgetHostImpl::From(rwh)), |
| 63 is_showing_(false), |
63 is_occluded_(false), | 64 is_occluded_(false), |
64 did_swap_compositor_frame_(false) { | 65 did_swap_compositor_frame_(false) { |
65 #if defined(OS_ANDROID) | 66 #if defined(OS_ANDROID) |
66 // Not all tests initialize or need a context provider factory. | 67 // Not all tests initialize or need a context provider factory. |
67 if (ContextProviderFactoryImpl::GetInstance()) { | 68 if (ContextProviderFactoryImpl::GetInstance()) { |
68 frame_sink_id_ = AllocateFrameSinkId(); | 69 frame_sink_id_ = AllocateFrameSinkId(); |
69 GetSurfaceManager()->RegisterFrameSinkId(frame_sink_id_); | 70 GetSurfaceManager()->RegisterFrameSinkId(frame_sink_id_); |
70 } | 71 } |
71 #else | 72 #else |
72 // Not all tests initialize or need an image transport factory. | 73 // Not all tests initialize or need an image transport factory. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 115 |
115 bool TestRenderWidgetHostView::HasFocus() const { | 116 bool TestRenderWidgetHostView::HasFocus() const { |
116 return true; | 117 return true; |
117 } | 118 } |
118 | 119 |
119 bool TestRenderWidgetHostView::IsSurfaceAvailableForCopy() const { | 120 bool TestRenderWidgetHostView::IsSurfaceAvailableForCopy() const { |
120 return true; | 121 return true; |
121 } | 122 } |
122 | 123 |
123 void TestRenderWidgetHostView::Show() { | 124 void TestRenderWidgetHostView::Show() { |
| 125 is_showing_ = true; |
124 is_occluded_ = false; | 126 is_occluded_ = false; |
125 if (rwh_->is_hidden()) | |
126 rwh_->WasShown(ui::LatencyInfo()); | |
127 } | 127 } |
128 | 128 |
129 void TestRenderWidgetHostView::Hide() { | 129 void TestRenderWidgetHostView::Hide() { |
130 if (!rwh_->is_hidden()) | 130 is_showing_ = false; |
131 rwh_->WasHidden(); | |
132 } | 131 } |
133 | 132 |
134 bool TestRenderWidgetHostView::IsShowing() { | 133 bool TestRenderWidgetHostView::IsShowing() { |
135 return !rwh_->is_hidden(); | 134 return is_showing_; |
136 } | 135 } |
137 | 136 |
138 void TestRenderWidgetHostView::WasUnOccluded() { | 137 void TestRenderWidgetHostView::WasUnOccluded() { |
139 is_occluded_ = false; | 138 is_occluded_ = false; |
140 } | 139 } |
141 | 140 |
142 void TestRenderWidgetHostView::WasOccluded() { | 141 void TestRenderWidgetHostView::WasOccluded() { |
143 is_occluded_ = true; | 142 is_occluded_ = true; |
144 } | 143 } |
145 | 144 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 if (main_frame) | 264 if (main_frame) |
266 static_cast<RenderFrameHostImpl*>(main_frame)->SetRenderFrameCreated(true); | 265 static_cast<RenderFrameHostImpl*>(main_frame)->SetRenderFrameCreated(true); |
267 | 266 |
268 return true; | 267 return true; |
269 } | 268 } |
270 | 269 |
271 MockRenderProcessHost* TestRenderViewHost::GetProcess() const { | 270 MockRenderProcessHost* TestRenderViewHost::GetProcess() const { |
272 return static_cast<MockRenderProcessHost*>(RenderViewHostImpl::GetProcess()); | 271 return static_cast<MockRenderProcessHost*>(RenderViewHostImpl::GetProcess()); |
273 } | 272 } |
274 | 273 |
| 274 void TestRenderViewHost::SimulateWasHidden() { |
| 275 GetWidget()->WasHidden(); |
| 276 } |
| 277 |
| 278 void TestRenderViewHost::SimulateWasShown() { |
| 279 GetWidget()->WasShown(ui::LatencyInfo()); |
| 280 } |
| 281 |
275 WebPreferences TestRenderViewHost::TestComputeWebkitPrefs() { | 282 WebPreferences TestRenderViewHost::TestComputeWebkitPrefs() { |
276 return ComputeWebkitPrefs(); | 283 return ComputeWebkitPrefs(); |
277 } | 284 } |
278 | 285 |
279 void TestRenderViewHost::OnWebkitPreferencesChanged() { | 286 void TestRenderViewHost::OnWebkitPreferencesChanged() { |
280 RenderViewHostImpl::OnWebkitPreferencesChanged(); | 287 RenderViewHostImpl::OnWebkitPreferencesChanged(); |
281 if (webkit_preferences_changed_counter_) | 288 if (webkit_preferences_changed_counter_) |
282 ++*webkit_preferences_changed_counter_; | 289 ++*webkit_preferences_changed_counter_; |
283 } | 290 } |
284 | 291 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 | 330 |
324 TestRenderFrameHost* RenderViewHostImplTestHarness::main_test_rfh() { | 331 TestRenderFrameHost* RenderViewHostImplTestHarness::main_test_rfh() { |
325 return contents()->GetMainFrame(); | 332 return contents()->GetMainFrame(); |
326 } | 333 } |
327 | 334 |
328 TestWebContents* RenderViewHostImplTestHarness::contents() { | 335 TestWebContents* RenderViewHostImplTestHarness::contents() { |
329 return static_cast<TestWebContents*>(web_contents()); | 336 return static_cast<TestWebContents*>(web_contents()); |
330 } | 337 } |
331 | 338 |
332 } // namespace content | 339 } // namespace content |
OLD | NEW |