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

Unified Diff: cc/animation/scrollbar_animation_controller_linear_fade_unittest.cc

Issue 640063002: Hide scrollbars when their dimensions are not scrollable. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added unit tests Created 6 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 side-by-side diff with in-line comments
Download patch
Index: cc/animation/scrollbar_animation_controller_linear_fade_unittest.cc
diff --git a/cc/animation/scrollbar_animation_controller_linear_fade_unittest.cc b/cc/animation/scrollbar_animation_controller_linear_fade_unittest.cc
index 99b45b35052a8eda18f025bb28b81e9e13435a4a..2d18953069c3a2b9d552210f60b2421761ec3979 100644
--- a/cc/animation/scrollbar_animation_controller_linear_fade_unittest.cc
+++ b/cc/animation/scrollbar_animation_controller_linear_fade_unittest.cc
@@ -7,7 +7,9 @@
#include "cc/layers/solid_color_scrollbar_layer_impl.h"
#include "cc/test/fake_impl_proxy.h"
#include "cc/test/fake_layer_tree_host_impl.h"
+#include "cc/test/geometry_test_utils.h"
#include "cc/test/test_shared_bitmap_manager.h"
+#include "cc/trees/layer_tree_impl.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace cc {
@@ -41,7 +43,7 @@ class ScrollbarAnimationControllerLinearFadeTest
scrollbar_layer_ =
SolidColorScrollbarLayerImpl::Create(host_impl_.active_tree(),
2,
- HORIZONTAL,
+ orientation(),
kThumbThickness,
kTrackStart,
kIsLeftSideVerticalScrollbar,
@@ -54,7 +56,7 @@ class ScrollbarAnimationControllerLinearFadeTest
scrollbar_layer_->SetScrollLayerAndClipLayerByIds(scroll_layer_ptr->id(),
clip_layer_->id());
clip_layer_->SetBounds(gfx::Size(100, 100));
- scroll_layer_ptr->SetBounds(gfx::Size(50, 50));
+ scroll_layer_ptr->SetBounds(gfx::Size(200, 200));
scrollbar_controller_ = ScrollbarAnimationControllerLinearFade::Create(
scroll_layer_ptr,
@@ -64,6 +66,8 @@ class ScrollbarAnimationControllerLinearFadeTest
base::TimeDelta::FromSeconds(3));
}
+ virtual ScrollbarOrientation orientation() const { return HORIZONTAL; }
+
FakeImplProxy proxy_;
TestSharedBitmapManager shared_bitmap_manager_;
FakeLayerTreeHostImpl host_impl_;
@@ -76,6 +80,12 @@ class ScrollbarAnimationControllerLinearFadeTest
int needs_frame_count_;
};
+class VerticalScrollbarAnimationControllerLinearFadeTest
+ : public ScrollbarAnimationControllerLinearFadeTest {
+ protected:
+ virtual ScrollbarOrientation orientation() const override { return VERTICAL; }
+};
+
TEST_F(ScrollbarAnimationControllerLinearFadeTest, DelayAnimationOnResize) {
scrollbar_layer_->SetOpacity(0.0f);
scrollbar_controller_->DidScrollBegin();
@@ -119,6 +129,144 @@ TEST_F(ScrollbarAnimationControllerLinearFadeTest,
EXPECT_EQ(0, needs_frame_count_);
}
+TEST_F(ScrollbarAnimationControllerLinearFadeTest, HideOnResize) {
+ LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1);
+ ASSERT_TRUE(scroll_layer);
+ EXPECT_SIZE_EQ(gfx::Size(200, 200), scroll_layer->bounds());
+
+ EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation());
+
+ clip_layer_->SetBounds(gfx::Size(100, 200));
+ EXPECT_SIZE_EQ(gfx::Size(100, 200), clip_layer_->bounds());
+
+ base::TimeTicks time;
aelias_OOO_until_Jul13 2014/10/14 23:23:41 You're not doing anything with this time variable?
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->DidScrollBegin();
+
+ scrollbar_controller_->DidScrollUpdate(false);
+ EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity());
+
+ scrollbar_controller_->DidScrollEnd();
+
+ clip_layer_->SetBounds(gfx::Size(200, 100));
+ EXPECT_SIZE_EQ(gfx::Size(200, 100), clip_layer_->bounds());
+
+ time = base::TimeTicks();
+
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->DidScrollBegin();
+
+ scrollbar_controller_->DidScrollUpdate(false);
+ EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity());
+
+ scrollbar_controller_->DidScrollEnd();
+}
+
+TEST_F(VerticalScrollbarAnimationControllerLinearFadeTest, HideOnResize) {
+ LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1);
+ ASSERT_TRUE(scroll_layer);
+ EXPECT_SIZE_EQ(gfx::Size(200, 200), scroll_layer->bounds());
+
+ EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation());
+
+ clip_layer_->SetBounds(gfx::Size(100, 200));
+ EXPECT_SIZE_EQ(gfx::Size(100, 200), clip_layer_->bounds());
+
+ base::TimeTicks time;
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->DidScrollBegin();
+
+ scrollbar_controller_->DidScrollUpdate(false);
+ EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity());
+
+ scrollbar_controller_->DidScrollEnd();
+
+ clip_layer_->SetBounds(gfx::Size(200, 100));
+ EXPECT_SIZE_EQ(gfx::Size(200, 100), clip_layer_->bounds());
+
+ time = base::TimeTicks();
+
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->DidScrollBegin();
+
+ scrollbar_controller_->DidScrollUpdate(false);
+ EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity());
+
+ scrollbar_controller_->DidScrollEnd();
+}
+
+TEST_F(ScrollbarAnimationControllerLinearFadeTest,
+ HideOnUserNonScrollableHorz) {
+ EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation());
+
+ LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1);
+ ASSERT_TRUE(scroll_layer);
+ scroll_layer->set_user_scrollable_horizontal(false);
+
+ base::TimeTicks time;
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->DidScrollBegin();
+
+ scrollbar_controller_->DidScrollUpdate(false);
+ EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity());
+
+ scrollbar_controller_->DidScrollEnd();
+}
+
+TEST_F(ScrollbarAnimationControllerLinearFadeTest,
+ ShowOnUserNonScrollableVert) {
+ EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation());
+
+ LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1);
+ ASSERT_TRUE(scroll_layer);
+ scroll_layer->set_user_scrollable_vertical(false);
+
+ base::TimeTicks time;
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->DidScrollBegin();
+
+ scrollbar_controller_->DidScrollUpdate(false);
+ EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity());
+
+ scrollbar_controller_->DidScrollEnd();
+}
+
+TEST_F(VerticalScrollbarAnimationControllerLinearFadeTest,
+ HideOnUserNonScrollableVert) {
+ EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation());
+
+ LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1);
+ ASSERT_TRUE(scroll_layer);
+ scroll_layer->set_user_scrollable_vertical(false);
+
+ base::TimeTicks time;
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->DidScrollBegin();
+
+ scrollbar_controller_->DidScrollUpdate(false);
+ EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity());
+
+ scrollbar_controller_->DidScrollEnd();
+}
+
+TEST_F(VerticalScrollbarAnimationControllerLinearFadeTest,
+ ShowOnUserNonScrollableHorz) {
+ EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation());
+
+ LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1);
+ ASSERT_TRUE(scroll_layer);
+ scroll_layer->set_user_scrollable_horizontal(false);
+
+ base::TimeTicks time;
+ time += base::TimeDelta::FromSeconds(1);
+ scrollbar_controller_->DidScrollBegin();
+
+ scrollbar_controller_->DidScrollUpdate(false);
+ EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity());
+
+ scrollbar_controller_->DidScrollEnd();
+}
+
TEST_F(ScrollbarAnimationControllerLinearFadeTest, AwakenByScrollingGesture) {
base::TimeTicks time;
time += base::TimeDelta::FromSeconds(1);
« no previous file with comments | « cc/animation/scrollbar_animation_controller_linear_fade.cc ('k') | cc/animation/scrollbar_animation_controller_thinning.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698