Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Side by Side Diff: content/test/test_render_view_host.cc

Issue 2861533003: Backfill some UI tests. (Closed)
Patch Set: test rwhv makes its own window Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/test/test_render_view_host.h ('k') | ui/views/window/dialog_client_view_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 12 matching lines...) Expand all
23 #include "content/public/browser/navigation_controller.h" 23 #include "content/public/browser/navigation_controller.h"
24 #include "content/public/browser/storage_partition.h" 24 #include "content/public/browser/storage_partition.h"
25 #include "content/public/common/content_client.h" 25 #include "content/public/common/content_client.h"
26 #include "content/public/common/page_state.h" 26 #include "content/public/common/page_state.h"
27 #include "content/public/common/web_preferences.h" 27 #include "content/public/common/web_preferences.h"
28 #include "content/test/test_render_frame_host.h" 28 #include "content/test/test_render_frame_host.h"
29 #include "content/test/test_web_contents.h" 29 #include "content/test/test_web_contents.h"
30 #include "media/base/video_frame.h" 30 #include "media/base/video_frame.h"
31 #include "ui/aura/env.h" 31 #include "ui/aura/env.h"
32 #include "ui/compositor/compositor.h" 32 #include "ui/compositor/compositor.h"
33 #include "ui/compositor/layer_type.h"
33 #include "ui/gfx/geometry/rect.h" 34 #include "ui/gfx/geometry/rect.h"
34 35
35 namespace content { 36 namespace content {
36 37
37 void InitNavigateParams(FrameHostMsg_DidCommitProvisionalLoad_Params* params, 38 void InitNavigateParams(FrameHostMsg_DidCommitProvisionalLoad_Params* params,
38 int nav_entry_id, 39 int nav_entry_id,
39 bool did_create_new_entry, 40 bool did_create_new_entry,
40 const GURL& url, 41 const GURL& url,
41 ui::PageTransition transition) { 42 ui::PageTransition transition) {
42 params->nav_entry_id = nav_entry_id; 43 params->nav_entry_id = nav_entry_id;
(...skipping 10 matching lines...) Expand all
53 params->was_within_same_document = false; 54 params->was_within_same_document = false;
54 params->method = "GET"; 55 params->method = "GET";
55 params->page_state = PageState::CreateFromURL(url); 56 params->page_state = PageState::CreateFromURL(url);
56 } 57 }
57 58
58 TestRenderWidgetHostView::TestRenderWidgetHostView(RenderWidgetHost* rwh) 59 TestRenderWidgetHostView::TestRenderWidgetHostView(RenderWidgetHost* rwh)
59 : rwh_(RenderWidgetHostImpl::From(rwh)), 60 : rwh_(RenderWidgetHostImpl::From(rwh)),
60 is_showing_(false), 61 is_showing_(false),
61 is_occluded_(false), 62 is_occluded_(false),
62 did_swap_compositor_frame_(false), 63 did_swap_compositor_frame_(false),
63 background_color_(SK_ColorWHITE) { 64 background_color_(SK_ColorWHITE),
65 window_(new aura::Window(this)) {
sky 2017/05/10 15:49:50 Call window_->set_owned_by_parent(false). That way
Bret 2017/05/10 21:18:39 All done.
64 #if defined(OS_ANDROID) 66 #if defined(OS_ANDROID)
65 frame_sink_id_ = AllocateFrameSinkId(); 67 frame_sink_id_ = AllocateFrameSinkId();
66 GetSurfaceManager()->RegisterFrameSinkId(frame_sink_id_); 68 GetSurfaceManager()->RegisterFrameSinkId(frame_sink_id_);
67 #else 69 #else
68 // Not all tests initialize or need an image transport factory. 70 // Not all tests initialize or need an image transport factory.
69 if (ImageTransportFactory::GetInstance()) { 71 if (ImageTransportFactory::GetInstance()) {
70 frame_sink_id_ = AllocateFrameSinkId(); 72 frame_sink_id_ = AllocateFrameSinkId();
71 GetSurfaceManager()->RegisterFrameSinkId(frame_sink_id_); 73 GetSurfaceManager()->RegisterFrameSinkId(frame_sink_id_);
72 } 74 }
73 #endif 75 #endif
74 76
75 rwh_->SetView(this); 77 rwh_->SetView(this);
78 window_->Init(ui::LayerType::LAYER_NOT_DRAWN);
76 } 79 }
77 80
78 TestRenderWidgetHostView::~TestRenderWidgetHostView() { 81 TestRenderWidgetHostView::~TestRenderWidgetHostView() {
79 cc::SurfaceManager* manager = GetSurfaceManager(); 82 cc::SurfaceManager* manager = GetSurfaceManager();
80 if (manager) { 83 if (manager) {
81 manager->InvalidateFrameSinkId(frame_sink_id_); 84 manager->InvalidateFrameSinkId(frame_sink_id_);
82 } 85 }
86 delete window_;
83 } 87 }
84 88
85 RenderWidgetHost* TestRenderWidgetHostView::GetRenderWidgetHost() const { 89 RenderWidgetHost* TestRenderWidgetHostView::GetRenderWidgetHost() const {
86 return rwh_; 90 return rwh_;
87 } 91 }
88 92
89 gfx::Vector2dF TestRenderWidgetHostView::GetLastScrollOffset() const { 93 gfx::Vector2dF TestRenderWidgetHostView::GetLastScrollOffset() const {
90 return gfx::Vector2dF(); 94 return gfx::Vector2dF();
91 } 95 }
92 96
93 gfx::NativeView TestRenderWidgetHostView::GetNativeView() const { 97 gfx::NativeView TestRenderWidgetHostView::GetNativeView() const {
94 return nullptr; 98 return window_;
95 } 99 }
96 100
97 gfx::NativeViewAccessible TestRenderWidgetHostView::GetNativeViewAccessible() { 101 gfx::NativeViewAccessible TestRenderWidgetHostView::GetNativeViewAccessible() {
98 return nullptr; 102 return nullptr;
99 } 103 }
100 104
101 ui::TextInputClient* TestRenderWidgetHostView::GetTextInputClient() { 105 ui::TextInputClient* TestRenderWidgetHostView::GetTextInputClient() {
102 return &text_input_client_; 106 return &text_input_client_;
103 } 107 }
104 108
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 return false; 200 return false;
197 } 201 }
198 202
199 void TestRenderWidgetHostView::UnlockMouse() { 203 void TestRenderWidgetHostView::UnlockMouse() {
200 } 204 }
201 205
202 cc::FrameSinkId TestRenderWidgetHostView::GetFrameSinkId() { 206 cc::FrameSinkId TestRenderWidgetHostView::GetFrameSinkId() {
203 return frame_sink_id_; 207 return frame_sink_id_;
204 } 208 }
205 209
210 gfx::Size TestRenderWidgetHostView::GetMinimumSize() const {
211 return gfx::Size();
212 }
213
214 gfx::Size TestRenderWidgetHostView::GetMaximumSize() const {
215 return gfx::Size();
216 }
217
218 gfx::NativeCursor TestRenderWidgetHostView::GetCursor(const gfx::Point& point) {
219 return ui::CursorType::kNone;
220 }
221
222 int TestRenderWidgetHostView::GetNonClientComponent(
223 const gfx::Point& point) const {
224 return 0;
225 }
226
227 bool TestRenderWidgetHostView::ShouldDescendIntoChildForEventHandling(
228 aura::Window* child,
229 const gfx::Point& location) {
230 return false;
231 }
232
233 bool TestRenderWidgetHostView::CanFocus() {
234 return false;
235 }
236
237 bool TestRenderWidgetHostView::HasHitTestMask() const {
238 return false;
239 }
240
241 void TestRenderWidgetHostView::GetHitTestMask(gfx::Path* mask) const {}
242
206 TestRenderViewHost::TestRenderViewHost( 243 TestRenderViewHost::TestRenderViewHost(
207 SiteInstance* instance, 244 SiteInstance* instance,
208 std::unique_ptr<RenderWidgetHostImpl> widget, 245 std::unique_ptr<RenderWidgetHostImpl> widget,
209 RenderViewHostDelegate* delegate, 246 RenderViewHostDelegate* delegate,
210 int32_t main_frame_routing_id, 247 int32_t main_frame_routing_id,
211 bool swapped_out) 248 bool swapped_out)
212 : RenderViewHostImpl(instance, 249 : RenderViewHostImpl(instance,
213 std::move(widget), 250 std::move(widget),
214 delegate, 251 delegate,
215 main_frame_routing_id, 252 main_frame_routing_id,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 356
320 TestRenderFrameHost* RenderViewHostImplTestHarness::main_test_rfh() { 357 TestRenderFrameHost* RenderViewHostImplTestHarness::main_test_rfh() {
321 return contents()->GetMainFrame(); 358 return contents()->GetMainFrame();
322 } 359 }
323 360
324 TestWebContents* RenderViewHostImplTestHarness::contents() { 361 TestWebContents* RenderViewHostImplTestHarness::contents() {
325 return static_cast<TestWebContents*>(web_contents()); 362 return static_cast<TestWebContents*>(web_contents());
326 } 363 }
327 364
328 } // namespace content 365 } // namespace content
OLDNEW
« no previous file with comments | « content/test/test_render_view_host.h ('k') | ui/views/window/dialog_client_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698