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

Side by Side Diff: content/browser/frame_host/render_widget_host_view_guest_unittest.cc

Issue 2633303003: Clean up RenderWidgetHostView(ChildFrame and Guest) compositing code (Closed)
Patch Set: c Created 3 years, 11 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/browser/frame_host/render_widget_host_view_guest.h" 5 #include "content/browser/frame_host/render_widget_host_view_guest.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 ASSERT_TRUE(view_->IsShowing()); 119 ASSERT_TRUE(view_->IsShowing());
120 120
121 view_->Hide(); 121 view_->Hide();
122 ASSERT_FALSE(view_->IsShowing()); 122 ASSERT_FALSE(view_->IsShowing());
123 } 123 }
124 124
125 class TestBrowserPluginGuest : public BrowserPluginGuest { 125 class TestBrowserPluginGuest : public BrowserPluginGuest {
126 public: 126 public:
127 TestBrowserPluginGuest(WebContentsImpl* web_contents, 127 TestBrowserPluginGuest(WebContentsImpl* web_contents,
128 BrowserPluginGuestDelegate* delegate) 128 BrowserPluginGuestDelegate* delegate)
129 : BrowserPluginGuest(web_contents->HasOpener(), web_contents, delegate), 129 : BrowserPluginGuest(web_contents->HasOpener(), web_contents, delegate) {}
130 last_scale_factor_received_(0.f) {} 130
131 ~TestBrowserPluginGuest() override {} 131 ~TestBrowserPluginGuest() override {}
132 132
133 void ResetTestData() { 133 void ResetTestData() { last_surface_info_ = cc::SurfaceInfo(); }
134 last_surface_id_received_ = cc::SurfaceId();
135 last_frame_size_received_ = gfx::Size();
136 last_scale_factor_received_ = 0.f;
137 }
138 134
139 void set_has_attached_since_surface_set(bool has_attached_since_surface_set) { 135 void set_has_attached_since_surface_set(bool has_attached_since_surface_set) {
140 BrowserPluginGuest::set_has_attached_since_surface_set_for_test( 136 BrowserPluginGuest::set_has_attached_since_surface_set_for_test(
141 has_attached_since_surface_set); 137 has_attached_since_surface_set);
142 } 138 }
143 139
144 void set_attached(bool attached) { 140 void set_attached(bool attached) {
145 BrowserPluginGuest::set_attached_for_test(attached); 141 BrowserPluginGuest::set_attached_for_test(attached);
146 } 142 }
147 143
148 void SetChildFrameSurface(const cc::SurfaceId& surface_id, 144 void SetChildFrameSurface(const cc::SurfaceInfo& surface_info,
149 const gfx::Size& frame_size,
150 float scale_factor,
151 const cc::SurfaceSequence& sequence) override { 145 const cc::SurfaceSequence& sequence) override {
152 last_surface_id_received_ = surface_id; 146 last_surface_info_ = surface_info;
153 last_frame_size_received_ = frame_size;
154 last_scale_factor_received_ = scale_factor;
155 } 147 }
156 148
157 cc::SurfaceId last_surface_id_received_; 149 cc::SurfaceInfo last_surface_info_;
158 gfx::Size last_frame_size_received_;
159 float last_scale_factor_received_;
160 }; 150 };
161 151
162 // TODO(wjmaclean): we should restructure RenderWidgetHostViewChildFrameTest to 152 // TODO(wjmaclean): we should restructure RenderWidgetHostViewChildFrameTest to
163 // look more like this one, and then this one could be derived from it. Also, 153 // look more like this one, and then this one could be derived from it. Also,
164 // include CreateDelegatedFrame as part of the test class so we don't have to 154 // include CreateDelegatedFrame as part of the test class so we don't have to
165 // repeat it here. 155 // repeat it here.
166 class RenderWidgetHostViewGuestSurfaceTest 156 class RenderWidgetHostViewGuestSurfaceTest
167 : public testing::Test { 157 : public testing::Test {
168 public: 158 public:
169 RenderWidgetHostViewGuestSurfaceTest() 159 RenderWidgetHostViewGuestSurfaceTest()
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 267 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
278 cc::SurfaceManager* manager = 268 cc::SurfaceManager* manager =
279 factory->GetContextFactoryPrivate()->GetSurfaceManager(); 269 factory->GetContextFactoryPrivate()->GetSurfaceManager();
280 cc::Surface* surface = manager->GetSurfaceForId(id); 270 cc::Surface* surface = manager->GetSurfaceForId(id);
281 EXPECT_TRUE(surface); 271 EXPECT_TRUE(surface);
282 // There should be a SurfaceSequence created by the RWHVGuest. 272 // There should be a SurfaceSequence created by the RWHVGuest.
283 EXPECT_EQ(1u, surface->GetDestructionDependencyCount()); 273 EXPECT_EQ(1u, surface->GetDestructionDependencyCount());
284 #endif 274 #endif
285 // Surface ID should have been passed to BrowserPluginGuest to 275 // Surface ID should have been passed to BrowserPluginGuest to
286 // be sent to the embedding renderer. 276 // be sent to the embedding renderer.
287 EXPECT_EQ(id, browser_plugin_guest_->last_surface_id_received_); 277 EXPECT_EQ(cc::SurfaceInfo(id, scale_factor, view_size),
288 EXPECT_EQ(view_size, browser_plugin_guest_->last_frame_size_received_); 278 browser_plugin_guest_->last_surface_info_);
289 EXPECT_EQ(scale_factor, browser_plugin_guest_->last_scale_factor_received_);
290 } 279 }
291 280
292 browser_plugin_guest_->ResetTestData(); 281 browser_plugin_guest_->ResetTestData();
293 browser_plugin_guest_->set_has_attached_since_surface_set(true); 282 browser_plugin_guest_->set_has_attached_since_surface_set(true);
294 283
295 view_->OnSwapCompositorFrame( 284 view_->OnSwapCompositorFrame(
296 0, CreateDelegatedFrame(scale_factor, view_size, view_rect)); 285 0, CreateDelegatedFrame(scale_factor, view_size, view_rect));
297 286
298 id = GetSurfaceId(); 287 id = GetSurfaceId();
299 if (id.is_valid()) { 288 if (id.is_valid()) {
300 #if !defined(OS_ANDROID) 289 #if !defined(OS_ANDROID)
301 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 290 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
302 cc::SurfaceManager* manager = 291 cc::SurfaceManager* manager =
303 factory->GetContextFactoryPrivate()->GetSurfaceManager(); 292 factory->GetContextFactoryPrivate()->GetSurfaceManager();
304 cc::Surface* surface = manager->GetSurfaceForId(id); 293 cc::Surface* surface = manager->GetSurfaceForId(id);
305 EXPECT_TRUE(surface); 294 EXPECT_TRUE(surface);
306 // There should be a SurfaceSequence created by the RWHVGuest. 295 // There should be a SurfaceSequence created by the RWHVGuest.
307 EXPECT_EQ(1u, surface->GetDestructionDependencyCount()); 296 EXPECT_EQ(1u, surface->GetDestructionDependencyCount());
308 #endif 297 #endif
309 // Surface ID should have been passed to BrowserPluginGuest to 298 // Surface ID should have been passed to BrowserPluginGuest to
310 // be sent to the embedding renderer. 299 // be sent to the embedding renderer.
311 EXPECT_EQ(id, browser_plugin_guest_->last_surface_id_received_); 300 EXPECT_EQ(cc::SurfaceInfo(id, scale_factor, view_size),
312 EXPECT_EQ(view_size, browser_plugin_guest_->last_frame_size_received_); 301 browser_plugin_guest_->last_surface_info_);
313 EXPECT_EQ(scale_factor,
314 browser_plugin_guest_->last_scale_factor_received_);
315 } 302 }
316 303
317 browser_plugin_guest_->set_attached(false); 304 browser_plugin_guest_->set_attached(false);
318 browser_plugin_guest_->ResetTestData(); 305 browser_plugin_guest_->ResetTestData();
319 306
320 view_->OnSwapCompositorFrame( 307 view_->OnSwapCompositorFrame(
321 0, CreateDelegatedFrame(scale_factor, view_size, view_rect)); 308 0, CreateDelegatedFrame(scale_factor, view_size, view_rect));
322 EXPECT_FALSE(GetSurfaceId().is_valid()); 309 EXPECT_FALSE(GetSurfaceId().is_valid());
323 } 310 }
324 311
325 } // namespace content 312 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_widget_host_view_guest.cc ('k') | content/common/browser_plugin/browser_plugin_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698