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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « cc/input/top_controls_manager.cc ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/input/top_controls_manager.h" 5 #include "cc/input/top_controls_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath>
8 9
10 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
10 #include "base/time/time.h" 12 #include "base/time/time.h"
11 #include "cc/input/top_controls_manager_client.h" 13 #include "cc/input/top_controls_manager_client.h"
12 #include "cc/layers/layer_impl.h" 14 #include "cc/layers/layer_impl.h"
13 #include "cc/test/fake_impl_proxy.h" 15 #include "cc/test/fake_impl_proxy.h"
14 #include "cc/test/fake_layer_tree_host_impl.h" 16 #include "cc/test/fake_layer_tree_host_impl.h"
15 #include "cc/test/test_shared_bitmap_manager.h" 17 #include "cc/test/test_shared_bitmap_manager.h"
16 #include "cc/trees/layer_tree_impl.h" 18 #include "cc/trees/layer_tree_impl.h"
17 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
18 #include "ui/gfx/frame_time.h" 20 #include "ui/gfx/frame_time.h"
(...skipping 25 matching lines...) Expand all
44 void DidChangeTopControlsPosition() override { 46 void DidChangeTopControlsPosition() override {
45 redraw_needed_ = true; 47 redraw_needed_ = true;
46 update_draw_properties_needed_ = true; 48 update_draw_properties_needed_ = true;
47 } 49 }
48 50
49 bool HaveRootScrollLayer() const override { return true; } 51 bool HaveRootScrollLayer() const override { return true; }
50 52
51 float TopControlsHeight() const override { return top_controls_height_; } 53 float TopControlsHeight() const override { return top_controls_height_; }
52 54
53 void SetCurrentTopControlsShownRatio(float ratio) override { 55 void SetCurrentTopControlsShownRatio(float ratio) override {
56 ASSERT_FALSE(std::isnan(ratio));
57 ASSERT_FALSE(ratio == std::numeric_limits<float>::infinity());
58 ASSERT_FALSE(ratio == -std::numeric_limits<float>::infinity());
54 ratio = std::max(ratio, 0.f); 59 ratio = std::max(ratio, 0.f);
55 ratio = std::min(ratio, 1.f); 60 ratio = std::min(ratio, 1.f);
56 top_controls_shown_ratio_ = ratio; 61 top_controls_shown_ratio_ = ratio;
57 } 62 }
58 63
59 float CurrentTopControlsShownRatio() const override { 64 float CurrentTopControlsShownRatio() const override {
60 return top_controls_shown_ratio_; 65 return top_controls_shown_ratio_;
61 } 66 }
62 67
63 LayerImpl* rootScrollLayer() { 68 LayerImpl* rootScrollLayer() {
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 EXPECT_FALSE(manager->animation()); 443 EXPECT_FALSE(manager->animation());
439 EXPECT_FLOAT_EQ(-50.f, manager->ControlsTopOffset()); 444 EXPECT_FLOAT_EQ(-50.f, manager->ControlsTopOffset());
440 EXPECT_FLOAT_EQ(0.f, manager->ContentTopOffset()); 445 EXPECT_FLOAT_EQ(0.f, manager->ContentTopOffset());
441 446
442 client.SetTopControlsHeight(0.f); 447 client.SetTopControlsHeight(0.f);
443 EXPECT_FALSE(manager->animation()); 448 EXPECT_FALSE(manager->animation());
444 EXPECT_FLOAT_EQ(0.f, manager->ControlsTopOffset()); 449 EXPECT_FLOAT_EQ(0.f, manager->ControlsTopOffset());
445 EXPECT_FLOAT_EQ(0.f, manager->ContentTopOffset()); 450 EXPECT_FLOAT_EQ(0.f, manager->ContentTopOffset());
446 } 451 }
447 452
453 TEST(TopControlsManagerTest, ScrollByWithZeroHeightControlsIsNoop) {
454 MockTopControlsManagerClient client(0.f, 0.5f, 0.5f);
455 TopControlsManager* manager = client.manager();
456 manager->UpdateTopControlsState(BOTH, BOTH, false);
457
458 manager->ScrollBegin();
459 gfx::Vector2dF pending = manager->ScrollBy(gfx::Vector2dF(0.f, 20.f));
460 EXPECT_FLOAT_EQ(20.f, pending.y());
461 EXPECT_FLOAT_EQ(0.f, manager->ControlsTopOffset());
462 EXPECT_FLOAT_EQ(0.f, manager->ContentTopOffset());
463 EXPECT_FLOAT_EQ(1.f, client.CurrentTopControlsShownRatio());
464 manager->ScrollEnd();
465 }
466
467
448 } // namespace 468 } // namespace
449 } // namespace cc 469 } // namespace cc
OLDNEW
« 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