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

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 814083004: Notify main-thread of top controls state changes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unused functions Created 5 years, 10 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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "cc/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 7682 matching lines...) Expand 10 before | Expand all | Expand 10 after
7693 7693
7694 float new_offset = 7694 float new_offset =
7695 host_impl_->top_controls_manager()->ControlsTopOffset(); 7695 host_impl_->top_controls_manager()->ControlsTopOffset();
7696 7696
7697 if (new_offset != old_offset) { 7697 if (new_offset != old_offset) {
7698 EXPECT_TRUE(did_request_redraw_); 7698 EXPECT_TRUE(did_request_redraw_);
7699 EXPECT_TRUE(did_request_commit_); 7699 EXPECT_TRUE(did_request_commit_);
7700 } 7700 }
7701 } 7701 }
7702 EXPECT_FALSE(host_impl_->top_controls_manager()->animation()); 7702 EXPECT_FALSE(host_impl_->top_controls_manager()->animation());
7703 EXPECT_EQ(-top_controls_height_,
7704 host_impl_->top_controls_manager()->ControlsTopOffset());
7703 } 7705 }
7704 7706
7705 TEST_F(LayerTreeHostImplWithTopControlsTest, 7707 TEST_F(LayerTreeHostImplWithTopControlsTest,
7708 TopControlsAnimationAfterMainThreadFlingStopped) {
7709 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200));
7710 host_impl_->SetViewportSize(gfx::Size(100, 100));
7711 host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN,
7712 false);
7713 float initial_scroll_offset = 50;
7714 scroll_layer->PushScrollOffsetFromMainThread(
7715 gfx::ScrollOffset(0, initial_scroll_offset));
7716 DrawFrame();
7717
7718 EXPECT_EQ(InputHandler::ScrollStarted,
7719 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture));
7720 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset());
7721 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(),
7722 scroll_layer->CurrentScrollOffset().ToString());
7723
7724 // Scroll the top controls partially.
7725 const float residue = 15;
7726 float offset = top_controls_height_ - residue;
7727 EXPECT_TRUE(
7728 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll);
7729 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset());
7730 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(),
7731 scroll_layer->CurrentScrollOffset().ToString());
7732
7733 did_request_redraw_ = false;
7734 did_request_animate_ = false;
7735 did_request_commit_ = false;
7736
7737 // End the fling while the controls are still offset from the limit.
7738 host_impl_->MainThreadHasStoppedFlinging();
7739 ASSERT_TRUE(host_impl_->top_controls_manager()->animation());
7740 EXPECT_TRUE(did_request_animate_);
7741 EXPECT_TRUE(did_request_redraw_);
7742 EXPECT_FALSE(did_request_commit_);
7743
7744 // Animate the top controls to the limit.
7745 base::TimeTicks animation_time = gfx::FrameTime::Now();
7746 while (did_request_animate_) {
7747 did_request_redraw_ = false;
7748 did_request_animate_ = false;
7749 did_request_commit_ = false;
7750
7751 float old_offset = host_impl_->top_controls_manager()->ControlsTopOffset();
7752
7753 animation_time += base::TimeDelta::FromMilliseconds(5);
7754 host_impl_->Animate(animation_time);
7755
7756 float new_offset = host_impl_->top_controls_manager()->ControlsTopOffset();
7757
7758 if (new_offset != old_offset) {
7759 EXPECT_TRUE(did_request_redraw_);
7760 EXPECT_TRUE(did_request_commit_);
7761 }
7762 }
7763 EXPECT_FALSE(host_impl_->top_controls_manager()->animation());
7764 EXPECT_EQ(-top_controls_height_,
7765 host_impl_->top_controls_manager()->ControlsTopOffset());
7766 }
7767
7768 TEST_F(LayerTreeHostImplWithTopControlsTest,
7706 TopControlsScrollDeltaInOverScroll) { 7769 TopControlsScrollDeltaInOverScroll) {
7707 // test varifies that the overscroll delta should not have accumulated in 7770 // test varifies that the overscroll delta should not have accumulated in
7708 // the top controls if we do a hide and show without releasing finger. 7771 // the top controls if we do a hide and show without releasing finger.
7709 7772
7710 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); 7773 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200));
7711 host_impl_->SetViewportSize(gfx::Size(100, 100)); 7774 host_impl_->SetViewportSize(gfx::Size(100, 100));
7712 host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN, 7775 host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN,
7713 false); 7776 false);
7714 DrawFrame(); 7777 DrawFrame();
7715 7778
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
8235 // surface. 8298 // surface.
8236 EXPECT_EQ(0, num_lost_surfaces_); 8299 EXPECT_EQ(0, num_lost_surfaces_);
8237 host_impl_->DidLoseOutputSurface(); 8300 host_impl_->DidLoseOutputSurface();
8238 EXPECT_EQ(1, num_lost_surfaces_); 8301 EXPECT_EQ(1, num_lost_surfaces_);
8239 host_impl_->DidLoseOutputSurface(); 8302 host_impl_->DidLoseOutputSurface();
8240 EXPECT_LE(1, num_lost_surfaces_); 8303 EXPECT_LE(1, num_lost_surfaces_);
8241 } 8304 }
8242 8305
8243 } // namespace 8306 } // namespace
8244 } // namespace cc 8307 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698