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

Unified Diff: cc/input/scroll_state_unittest.cc

Issue 1215183004: Arrange compositor scrolling into scroll customization format (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nit. Created 5 years, 5 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
« no previous file with comments | « cc/input/scroll_state.cc ('k') | cc/layers/layer_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/input/scroll_state_unittest.cc
diff --git a/cc/input/scroll_state_unittest.cc b/cc/input/scroll_state_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5e091df685f2049b3e568fac17c73f7e6596c612
--- /dev/null
+++ b/cc/input/scroll_state_unittest.cc
@@ -0,0 +1,79 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/input/scroll_state.h"
+
+#include "cc/layers/layer_impl.h"
+#include "cc/test/fake_impl_proxy.h"
+#include "cc/test/fake_layer_tree_host_impl.h"
+#include "cc/test/test_shared_bitmap_manager.h"
+#include "cc/test/test_task_graph_runner.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace cc {
+
+class ScrollStateTest : public testing::Test {};
+
+TEST_F(ScrollStateTest, ConsumeDeltaNative) {
+ const float delta_x = 12.3f;
+ const float delta_y = 3.9f;
+
+ const float delta_x_to_consume = 1.2f;
+ const float delta_y_to_consume = 2.3f;
+
+ ScrollState scrollState(delta_x, delta_y, 0, 0, false /* should_propagate */,
+ false /* delta_consumed_for_scroll_sequence */,
+ false /* is_direct_manipulation */);
+ EXPECT_FLOAT_EQ(delta_x, scrollState.delta_x());
+ EXPECT_FLOAT_EQ(delta_y, scrollState.delta_y());
+ EXPECT_FALSE(scrollState.delta_consumed_for_scroll_sequence());
+ EXPECT_FALSE(scrollState.FullyConsumed());
+
+ scrollState.ConsumeDelta(0, 0);
+ EXPECT_FLOAT_EQ(delta_x, scrollState.delta_x());
+ EXPECT_FLOAT_EQ(delta_y, scrollState.delta_y());
+ EXPECT_FALSE(scrollState.delta_consumed_for_scroll_sequence());
+ EXPECT_FALSE(scrollState.FullyConsumed());
+
+ scrollState.ConsumeDelta(delta_x_to_consume, 0);
+ EXPECT_FLOAT_EQ(delta_x - delta_x_to_consume, scrollState.delta_x());
+ EXPECT_FLOAT_EQ(delta_y, scrollState.delta_y());
+ EXPECT_TRUE(scrollState.delta_consumed_for_scroll_sequence());
+ EXPECT_FALSE(scrollState.FullyConsumed());
+
+ scrollState.ConsumeDelta(0, delta_y_to_consume);
+ EXPECT_FLOAT_EQ(delta_x - delta_x_to_consume, scrollState.delta_x());
+ EXPECT_FLOAT_EQ(delta_y - delta_y_to_consume, scrollState.delta_y());
+ EXPECT_TRUE(scrollState.delta_consumed_for_scroll_sequence());
+ EXPECT_FALSE(scrollState.FullyConsumed());
+
+ scrollState.ConsumeDelta(scrollState.delta_x(), scrollState.delta_y());
+ EXPECT_TRUE(scrollState.delta_consumed_for_scroll_sequence());
+ EXPECT_TRUE(scrollState.FullyConsumed());
+}
+
+TEST_F(ScrollStateTest, CurrentNativeScrollingScrollable) {
+ ScrollState scrollState(0, 0, 0, 0, false, false, false);
+
+ FakeImplProxy proxy;
+ TestSharedBitmapManager shared_bitmap_manager;
+ TestTaskGraphRunner task_graph_runner;
+ FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager,
+ &task_graph_runner);
+
+ scoped_ptr<LayerImpl> layer_impl =
+ LayerImpl::Create(host_impl.active_tree(), 1);
+ scrollState.set_current_native_scrolling_layer(layer_impl.get());
+ EXPECT_EQ(layer_impl, scrollState.current_native_scrolling_layer());
+}
+
+TEST_F(ScrollStateTest, FullyConsumed) {
+ ScrollState scrollState(1, 3, 0, 0, 0, false, false);
+ EXPECT_FALSE(scrollState.FullyConsumed());
+
+ scrollState.ConsumeDelta(1, 3);
+ EXPECT_TRUE(scrollState.FullyConsumed());
+}
+} // namespace cc
« no previous file with comments | « cc/input/scroll_state.cc ('k') | cc/layers/layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698