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

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

Issue 2425923003: Replaced is_null() with is_valid in SurfaceId and related classes. (Closed)
Patch Set: Removed added printf statements; LocalFrameId::is_valid() no longer checks if nonce is 0. Created 4 years, 2 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 #else 209 #else
210 ui::ContextProviderFactory::SetInstance(nullptr); 210 ui::ContextProviderFactory::SetInstance(nullptr);
211 ContextProviderFactoryImpl::Terminate(); 211 ContextProviderFactoryImpl::Terminate();
212 #endif 212 #endif
213 } 213 }
214 214
215 cc::SurfaceId GetSurfaceId() const { 215 cc::SurfaceId GetSurfaceId() const {
216 DCHECK(view_); 216 DCHECK(view_);
217 RenderWidgetHostViewChildFrame* rwhvcf = 217 RenderWidgetHostViewChildFrame* rwhvcf =
218 static_cast<RenderWidgetHostViewChildFrame*>(view_); 218 static_cast<RenderWidgetHostViewChildFrame*>(view_);
219 if (rwhvcf->local_frame_id_.is_null()) 219 if (!rwhvcf->local_frame_id_.is_valid())
220 return cc::SurfaceId(); 220 return cc::SurfaceId();
221 return cc::SurfaceId(rwhvcf->frame_sink_id_, rwhvcf->local_frame_id_); 221 return cc::SurfaceId(rwhvcf->frame_sink_id_, rwhvcf->local_frame_id_);
222 } 222 }
223 223
224 protected: 224 protected:
225 TestBrowserThreadBundle thread_bundle_; 225 TestBrowserThreadBundle thread_bundle_;
226 std::unique_ptr<BrowserContext> browser_context_; 226 std::unique_ptr<BrowserContext> browser_context_;
227 MockRenderWidgetHostDelegate delegate_; 227 MockRenderWidgetHostDelegate delegate_;
228 BrowserPluginGuestDelegate browser_plugin_guest_delegate_; 228 BrowserPluginGuestDelegate browser_plugin_guest_delegate_;
229 std::unique_ptr<TestWebContents> web_contents_; 229 std::unique_ptr<TestWebContents> web_contents_;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 ASSERT_TRUE(browser_plugin_guest_); 266 ASSERT_TRUE(browser_plugin_guest_);
267 267
268 view_->SetSize(view_size); 268 view_->SetSize(view_size);
269 view_->Show(); 269 view_->Show();
270 270
271 browser_plugin_guest_->set_attached(true); 271 browser_plugin_guest_->set_attached(true);
272 view_->OnSwapCompositorFrame( 272 view_->OnSwapCompositorFrame(
273 0, CreateDelegatedFrame(scale_factor, view_size, view_rect)); 273 0, CreateDelegatedFrame(scale_factor, view_size, view_rect));
274 274
275 cc::SurfaceId id = GetSurfaceId(); 275 cc::SurfaceId id = GetSurfaceId();
276 if (!id.is_null()) { 276 if (id.is_valid()) {
277 #if !defined(OS_ANDROID) 277 #if !defined(OS_ANDROID)
278 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 278 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
279 cc::SurfaceManager* manager = factory->GetSurfaceManager(); 279 cc::SurfaceManager* manager = factory->GetSurfaceManager();
280 cc::Surface* surface = manager->GetSurfaceForId(id); 280 cc::Surface* surface = manager->GetSurfaceForId(id);
281 EXPECT_TRUE(surface); 281 EXPECT_TRUE(surface);
282 // There should be a SurfaceSequence created by the RWHVGuest. 282 // There should be a SurfaceSequence created by the RWHVGuest.
283 EXPECT_EQ(1u, surface->GetDestructionDependencyCount()); 283 EXPECT_EQ(1u, surface->GetDestructionDependencyCount());
284 #endif 284 #endif
285 // Surface ID should have been passed to BrowserPluginGuest to 285 // Surface ID should have been passed to BrowserPluginGuest to
286 // be sent to the embedding renderer. 286 // be sent to the embedding renderer.
287 EXPECT_EQ(id, browser_plugin_guest_->last_surface_id_received_); 287 EXPECT_EQ(id, browser_plugin_guest_->last_surface_id_received_);
288 EXPECT_EQ(view_size, browser_plugin_guest_->last_frame_size_received_); 288 EXPECT_EQ(view_size, browser_plugin_guest_->last_frame_size_received_);
289 EXPECT_EQ(scale_factor, browser_plugin_guest_->last_scale_factor_received_); 289 EXPECT_EQ(scale_factor, browser_plugin_guest_->last_scale_factor_received_);
290 } 290 }
291 291
292 browser_plugin_guest_->ResetTestData(); 292 browser_plugin_guest_->ResetTestData();
293 browser_plugin_guest_->set_has_attached_since_surface_set(true); 293 browser_plugin_guest_->set_has_attached_since_surface_set(true);
294 294
295 view_->OnSwapCompositorFrame( 295 view_->OnSwapCompositorFrame(
296 0, CreateDelegatedFrame(scale_factor, view_size, view_rect)); 296 0, CreateDelegatedFrame(scale_factor, view_size, view_rect));
297 297
298 id = GetSurfaceId(); 298 id = GetSurfaceId();
299 if (!id.is_null()) { 299 if (id.is_valid()) {
300 #if !defined(OS_ANDROID) 300 #if !defined(OS_ANDROID)
301 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 301 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
302 cc::SurfaceManager* manager = factory->GetSurfaceManager(); 302 cc::SurfaceManager* manager = factory->GetSurfaceManager();
303 cc::Surface* surface = manager->GetSurfaceForId(id); 303 cc::Surface* surface = manager->GetSurfaceForId(id);
304 EXPECT_TRUE(surface); 304 EXPECT_TRUE(surface);
305 // There should be a SurfaceSequence created by the RWHVGuest. 305 // There should be a SurfaceSequence created by the RWHVGuest.
306 EXPECT_EQ(1u, surface->GetDestructionDependencyCount()); 306 EXPECT_EQ(1u, surface->GetDestructionDependencyCount());
307 #endif 307 #endif
308 // Surface ID should have been passed to BrowserPluginGuest to 308 // Surface ID should have been passed to BrowserPluginGuest to
309 // be sent to the embedding renderer. 309 // be sent to the embedding renderer.
310 EXPECT_EQ(id, browser_plugin_guest_->last_surface_id_received_); 310 EXPECT_EQ(id, browser_plugin_guest_->last_surface_id_received_);
311 EXPECT_EQ(view_size, browser_plugin_guest_->last_frame_size_received_); 311 EXPECT_EQ(view_size, browser_plugin_guest_->last_frame_size_received_);
312 EXPECT_EQ(scale_factor, 312 EXPECT_EQ(scale_factor,
313 browser_plugin_guest_->last_scale_factor_received_); 313 browser_plugin_guest_->last_scale_factor_received_);
314 } 314 }
315 315
316 browser_plugin_guest_->set_attached(false); 316 browser_plugin_guest_->set_attached(false);
317 browser_plugin_guest_->ResetTestData(); 317 browser_plugin_guest_->ResetTestData();
318 318
319 view_->OnSwapCompositorFrame( 319 view_->OnSwapCompositorFrame(
320 0, CreateDelegatedFrame(scale_factor, view_size, view_rect)); 320 0, CreateDelegatedFrame(scale_factor, view_size, view_rect));
321 EXPECT_TRUE(GetSurfaceId().is_null()); 321 EXPECT_FALSE(GetSurfaceId().is_valid());
322 } 322 }
323 323
324 } // namespace content 324 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698