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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura_unittest.cc

Issue 2832043002: ui: Prevent DelegatedFrameHost from taking CompositorResizeLock forever (Closed)
Patch Set: resizelocknoframe: submitcomment Created 3 years, 8 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/browser/renderer_host/render_widget_host_view_aura.h ('k') | no next file » | 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/browser/renderer_host/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <tuple> 10 #include <tuple>
(...skipping 2595 matching lines...) Expand 10 before | Expand all | Expand 10 after
2606 2606
2607 // When the frame of the correct size is committed, the CompositorResizeLock 2607 // When the frame of the correct size is committed, the CompositorResizeLock
2608 // is released. 2608 // is released.
2609 view_->RunOnCompositingDidCommit(); 2609 view_->RunOnCompositingDidCommit();
2610 EXPECT_FALSE(view_->resize_locked()); 2610 EXPECT_FALSE(view_->resize_locked());
2611 EXPECT_FALSE(view_->compositor_locked()); 2611 EXPECT_FALSE(view_->compositor_locked());
2612 2612
2613 view_->window_->RemoveObserver(&observer); 2613 view_->window_->RemoveObserver(&observer);
2614 } 2614 }
2615 2615
2616 // When the DelegatedFrameHost does not have a frame from the renderer, it has
2617 // no reason to lock the compositor as there can't be guttering around a
2618 // renderer frame that doesn't exist.
2619 TEST_F(RenderWidgetHostViewAuraTest, MissingFramesDontLock) {
2620 gfx::Rect view_rect(100, 100);
2621 gfx::Size frame_size = view_rect.size();
2622
2623 view_->InitAsChild(nullptr);
2624 aura::client::ParentWindowWithContext(
2625 view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(),
2626 gfx::Rect());
2627
2628 // The view is resized before the first frame, which should not lock the
2629 // compositor as it's never received a frame to show yet.
2630 view_->SetSize(view_rect.size());
2631
2632 EXPECT_FALSE(view_->resize_locked());
2633 EXPECT_FALSE(view_->compositor_locked());
2634
2635 // Submit a frame of initial size to make a frame present in
2636 // DelegatedFrameHost, at which point locking becomes feasible if resized.
2637 view_->SubmitCompositorFrame(
2638 kArbitraryLocalSurfaceId,
2639 MakeDelegatedFrame(1.f, frame_size, gfx::Rect(frame_size)));
2640 view_->RunOnCompositingDidCommit();
2641
2642 EXPECT_FALSE(view_->resize_locked());
2643 EXPECT_FALSE(view_->compositor_locked());
2644
2645 // The view is resized and has its frame evicted, before a new frame arrives.
2646 // The resize will lock the compositor, but when evicted, it should no longer
2647 // be locked.
2648 view_rect.SetRect(0, 0, 150, 150);
2649 view_->SetSize(view_rect.size());
2650 EXPECT_TRUE(view_->resize_locked());
2651 EXPECT_TRUE(view_->compositor_locked());
2652
2653 view_->ClearCompositorFrame();
2654 EXPECT_FALSE(view_->resize_locked());
2655 EXPECT_FALSE(view_->compositor_locked());
2656
2657 // And future resizes after eviction should not lock the compositor since
2658 // there is no frame present.
2659 view_rect.SetRect(0, 0, 120, 120);
2660 view_->SetSize(view_rect.size());
2661 EXPECT_FALSE(view_->resize_locked());
2662 EXPECT_FALSE(view_->compositor_locked());
2663 }
2664
2616 TEST_F(RenderWidgetHostViewAuraTest, OutputSurfaceIdChange) { 2665 TEST_F(RenderWidgetHostViewAuraTest, OutputSurfaceIdChange) {
2617 gfx::Rect view_rect(100, 100); 2666 gfx::Rect view_rect(100, 100);
2618 gfx::Size frame_size = view_rect.size(); 2667 gfx::Size frame_size = view_rect.size();
2619 2668
2620 view_->InitAsChild(nullptr); 2669 view_->InitAsChild(nullptr);
2621 aura::client::ParentWindowWithContext( 2670 aura::client::ParentWindowWithContext(
2622 view_->GetNativeView(), 2671 view_->GetNativeView(),
2623 parent_view_->GetNativeView()->GetRootWindow(), 2672 parent_view_->GetNativeView()->GetRootWindow(),
2624 gfx::Rect()); 2673 gfx::Rect());
2625 view_->SetSize(view_rect.size()); 2674 view_->SetSize(view_rect.size());
(...skipping 2818 matching lines...) Expand 10 before | Expand all | Expand 10 after
5444 // There is no composition in the beginning. 5493 // There is no composition in the beginning.
5445 EXPECT_FALSE(has_composition_text()); 5494 EXPECT_FALSE(has_composition_text());
5446 SetHasCompositionTextToTrue(); 5495 SetHasCompositionTextToTrue();
5447 view->ImeCancelComposition(); 5496 view->ImeCancelComposition();
5448 // The composition must have been canceled. 5497 // The composition must have been canceled.
5449 EXPECT_FALSE(has_composition_text()); 5498 EXPECT_FALSE(has_composition_text());
5450 } 5499 }
5451 } 5500 }
5452 5501
5453 } // namespace content 5502 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698