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

Unified Diff: cc/input/top_controls_manager_unittest.cc

Issue 982333003: Don't calculate a shown ratio when top controls height is 0. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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/top_controls_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/input/top_controls_manager_unittest.cc
diff --git a/cc/input/top_controls_manager_unittest.cc b/cc/input/top_controls_manager_unittest.cc
index 16d0e5d21b1b32e45c5f733aa5fcf18daa804ac8..c78f5c0d316f3922e412a2e7e43e34d753137d52 100644
--- a/cc/input/top_controls_manager_unittest.cc
+++ b/cc/input/top_controls_manager_unittest.cc
@@ -5,7 +5,9 @@
#include "cc/input/top_controls_manager.h"
#include <algorithm>
+#include <cmath>
+#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
#include "cc/input/top_controls_manager_client.h"
@@ -51,6 +53,9 @@ class MockTopControlsManagerClient : public TopControlsManagerClient {
float TopControlsHeight() const override { return top_controls_height_; }
void SetCurrentTopControlsShownRatio(float ratio) override {
+ ASSERT_FALSE(std::isnan(ratio));
+ ASSERT_FALSE(ratio == std::numeric_limits<float>::infinity());
+ ASSERT_FALSE(ratio == -std::numeric_limits<float>::infinity());
ratio = std::max(ratio, 0.f);
ratio = std::min(ratio, 1.f);
top_controls_shown_ratio_ = ratio;
@@ -445,5 +450,20 @@ TEST(TopControlsManagerTest, ShrinkingHeightKeepsTopControlsHidden) {
EXPECT_FLOAT_EQ(0.f, manager->ContentTopOffset());
}
+TEST(TopControlsManagerTest, ScrollByWithZeroHeightControlsIsNoop) {
+ MockTopControlsManagerClient client(0.f, 0.5f, 0.5f);
+ TopControlsManager* manager = client.manager();
+ manager->UpdateTopControlsState(BOTH, BOTH, false);
+
+ manager->ScrollBegin();
+ gfx::Vector2dF pending = manager->ScrollBy(gfx::Vector2dF(0.f, 20.f));
+ EXPECT_FLOAT_EQ(20.f, pending.y());
+ EXPECT_FLOAT_EQ(0.f, manager->ControlsTopOffset());
+ EXPECT_FLOAT_EQ(0.f, manager->ContentTopOffset());
+ EXPECT_FLOAT_EQ(1.f, client.CurrentTopControlsShownRatio());
+ manager->ScrollEnd();
+}
+
+
} // namespace
} // namespace cc
« no previous file with comments | « cc/input/top_controls_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698