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

Side by Side Diff: cc/scrollbar_animation_controller_linear_fade_unittest.cc

Issue 11366089: cc: Remove all remaining use of WebCore Rect/Point/Size types from the compositor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove gyp entries for stubs Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « cc/scrollbar_animation_controller_linear_fade.cc ('k') | cc/scrollbar_geometry_fixed_thumb.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "config.h" 5 #include "config.h"
6 6
7 #include "cc/scrollbar_animation_controller_linear_fade.h" 7 #include "cc/scrollbar_animation_controller_linear_fade.h"
8 8
9 #include "cc/scrollbar_layer_impl.h" 9 #include "cc/scrollbar_layer_impl.h"
10 #include "cc/single_thread_proxy.h" 10 #include "cc/single_thread_proxy.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 using namespace cc; 13 using namespace cc;
14 14
15 namespace { 15 namespace {
16 16
17 class ScrollbarAnimationControllerLinearFadeTest : public testing::Test { 17 class ScrollbarAnimationControllerLinearFadeTest : public testing::Test {
18 protected: 18 protected:
19 virtual void SetUp() 19 virtual void SetUp()
20 { 20 {
21 m_scrollLayer = LayerImpl::create(1); 21 m_scrollLayer = LayerImpl::create(1);
22 m_scrollLayer->addChild(LayerImpl::create(2)); 22 m_scrollLayer->addChild(LayerImpl::create(2));
23 m_contentLayer = m_scrollLayer->children()[0]; 23 m_contentLayer = m_scrollLayer->children()[0];
24 m_scrollbarLayer = ScrollbarLayerImpl::create(3); 24 m_scrollbarLayer = ScrollbarLayerImpl::create(3);
25 25
26 m_scrollLayer->setMaxScrollPosition(IntSize(50, 50)); 26 m_scrollLayer->setMaxScrollOffset(gfx::Vector2d(50, 50));
27 m_contentLayer->setBounds(IntSize(50, 50)); 27 m_contentLayer->setBounds(gfx::Size(50, 50));
28 28
29 m_scrollbarController = ScrollbarAnimationControllerLinearFade::create(m _scrollLayer.get(), 2, 3); 29 m_scrollbarController = ScrollbarAnimationControllerLinearFade::create(m _scrollLayer.get(), 2, 3);
30 m_scrollbarController->setHorizontalScrollbarLayer(m_scrollbarLayer.get( )); 30 m_scrollbarController->setHorizontalScrollbarLayer(m_scrollbarLayer.get( ));
31 } 31 }
32 32
33 DebugScopedSetImplThread implThread; 33 DebugScopedSetImplThread implThread;
34 34
35 scoped_ptr<ScrollbarAnimationControllerLinearFade> m_scrollbarController; 35 scoped_ptr<ScrollbarAnimationControllerLinearFade> m_scrollbarController;
36 scoped_ptr<LayerImpl> m_scrollLayer; 36 scoped_ptr<LayerImpl> m_scrollLayer;
37 LayerImpl* m_contentLayer; 37 LayerImpl* m_contentLayer;
38 scoped_ptr<ScrollbarLayerImpl> m_scrollbarLayer; 38 scoped_ptr<ScrollbarLayerImpl> m_scrollbarLayer;
39 39
40 }; 40 };
41 41
42 TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyHiddenInBegin) 42 TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyHiddenInBegin)
43 { 43 {
44 m_scrollbarController->animate(0); 44 m_scrollbarController->animate(0);
45 EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity()); 45 EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity());
46 m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 0); 46 m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 0);
47 m_scrollbarController->animate(0); 47 m_scrollbarController->animate(0);
48 EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity()); 48 EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity());
49 } 49 }
50 50
51 TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyAwakenByScroll) 51 TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyAwakenByScroll)
52 { 52 {
53 m_scrollLayer->setScrollDelta(IntSize(1, 1)); 53 m_scrollLayer->setScrollDelta(gfx::Vector2d(1, 1));
54 m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 0); 54 m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 0);
55 m_scrollbarController->animate(0); 55 m_scrollbarController->animate(0);
56 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); 56 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
57 m_scrollbarController->animate(1); 57 m_scrollbarController->animate(1);
58 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); 58 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
59 m_scrollLayer->setScrollDelta(IntSize(2, 2)); 59 m_scrollLayer->setScrollDelta(gfx::Vector2d(2, 2));
60 m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 1); 60 m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 1);
61 m_scrollbarController->animate(2); 61 m_scrollbarController->animate(2);
62 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); 62 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
63 m_scrollbarController->animate(3); 63 m_scrollbarController->animate(3);
64 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); 64 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
65 m_scrollbarController->animate(4); 65 m_scrollbarController->animate(4);
66 // Note that we use 3.0f to avoid "argument is truncated from 'double' to 66 // Note that we use 3.0f to avoid "argument is truncated from 'double' to
67 // 'float'" warnings on Windows. 67 // 'float'" warnings on Windows.
68 EXPECT_FLOAT_EQ(2 / 3.0f, m_scrollbarLayer->opacity()); 68 EXPECT_FLOAT_EQ(2 / 3.0f, m_scrollbarLayer->opacity());
69 m_scrollbarController->animate(5); 69 m_scrollbarController->animate(5);
70 EXPECT_FLOAT_EQ(1 / 3.0f, m_scrollbarLayer->opacity()); 70 EXPECT_FLOAT_EQ(1 / 3.0f, m_scrollbarLayer->opacity());
71 m_scrollLayer->setScrollDelta(IntSize(3, 3)); 71 m_scrollLayer->setScrollDelta(gfx::Vector2d(3, 3));
72 m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 5); 72 m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 5);
73 m_scrollbarController->animate(6); 73 m_scrollbarController->animate(6);
74 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); 74 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
75 m_scrollbarController->animate(7); 75 m_scrollbarController->animate(7);
76 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); 76 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
77 m_scrollbarController->animate(8); 77 m_scrollbarController->animate(8);
78 EXPECT_FLOAT_EQ(2 / 3.0f, m_scrollbarLayer->opacity()); 78 EXPECT_FLOAT_EQ(2 / 3.0f, m_scrollbarLayer->opacity());
79 m_scrollbarController->animate(9); 79 m_scrollbarController->animate(9);
80 EXPECT_FLOAT_EQ(1 / 3.0f, m_scrollbarLayer->opacity()); 80 EXPECT_FLOAT_EQ(1 / 3.0f, m_scrollbarLayer->opacity());
81 m_scrollbarController->animate(10); 81 m_scrollbarController->animate(10);
82 EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity()); 82 EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity());
83 } 83 }
84 84
85 TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyForceAwakenByPinch) 85 TEST_F(ScrollbarAnimationControllerLinearFadeTest, verifyForceAwakenByPinch)
86 { 86 {
87 m_scrollbarController->didPinchGestureBeginAtTime(0); 87 m_scrollbarController->didPinchGestureBeginAtTime(0);
88 m_scrollbarController->didPinchGestureUpdateAtTime(0); 88 m_scrollbarController->didPinchGestureUpdateAtTime(0);
89 m_scrollbarController->animate(0); 89 m_scrollbarController->animate(0);
90 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); 90 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
91 m_scrollbarController->animate(1); 91 m_scrollbarController->animate(1);
92 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); 92 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
93 m_scrollLayer->setScrollDelta(IntSize(1, 1)); 93 m_scrollLayer->setScrollDelta(gfx::Vector2d(1, 1));
94 m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 1); 94 m_scrollbarController->updateScrollOffsetAtTime(m_scrollLayer.get(), 1);
95 m_scrollbarController->animate(2); 95 m_scrollbarController->animate(2);
96 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); 96 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
97 m_scrollbarController->animate(3); 97 m_scrollbarController->animate(3);
98 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); 98 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
99 m_scrollbarController->animate(4); 99 m_scrollbarController->animate(4);
100 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); 100 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
101 m_scrollbarController->animate(5); 101 m_scrollbarController->animate(5);
102 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); 102 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
103 m_scrollbarController->animate(6); 103 m_scrollbarController->animate(6);
104 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); 104 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
105 m_scrollbarController->didPinchGestureEndAtTime(6); 105 m_scrollbarController->didPinchGestureEndAtTime(6);
106 m_scrollbarController->animate(7); 106 m_scrollbarController->animate(7);
107 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); 107 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
108 m_scrollbarController->animate(8); 108 m_scrollbarController->animate(8);
109 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity()); 109 EXPECT_FLOAT_EQ(1, m_scrollbarLayer->opacity());
110 m_scrollbarController->animate(9); 110 m_scrollbarController->animate(9);
111 EXPECT_FLOAT_EQ(2 / 3.0f, m_scrollbarLayer->opacity()); 111 EXPECT_FLOAT_EQ(2 / 3.0f, m_scrollbarLayer->opacity());
112 m_scrollbarController->animate(10); 112 m_scrollbarController->animate(10);
113 EXPECT_FLOAT_EQ(1 / 3.0f, m_scrollbarLayer->opacity()); 113 EXPECT_FLOAT_EQ(1 / 3.0f, m_scrollbarLayer->opacity());
114 m_scrollbarController->animate(11); 114 m_scrollbarController->animate(11);
115 EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity()); 115 EXPECT_FLOAT_EQ(0, m_scrollbarLayer->opacity());
116 116
117 } 117 }
118 118
119 } 119 }
OLDNEW
« no previous file with comments | « cc/scrollbar_animation_controller_linear_fade.cc ('k') | cc/scrollbar_geometry_fixed_thumb.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698