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

Side by Side Diff: content/browser/web_contents/aura/overscroll_window_animation_unittest.cc

Issue 2698673006: Add User Actions and adding more details to UMA metrics for overscroll navigation (Closed)
Patch Set: Trailing period Created 3 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/browser/web_contents/aura/overscroll_window_animation.h" 5 #include "content/browser/web_contents/aura/overscroll_window_animation.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/aura/test/aura_test_base.h" 9 #include "ui/aura/test/aura_test_base.h"
10 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 120
121 // Tests a simple overscroll gesture. 121 // Tests a simple overscroll gesture.
122 TEST_F(OverscrollWindowAnimationTest, BasicOverscroll) { 122 TEST_F(OverscrollWindowAnimationTest, BasicOverscroll) {
123 EXPECT_FALSE(owa()->is_active()); 123 EXPECT_FALSE(owa()->is_active());
124 EXPECT_FALSE(overscroll_started()); 124 EXPECT_FALSE(overscroll_started());
125 EXPECT_FALSE(overscroll_completing()); 125 EXPECT_FALSE(overscroll_completing());
126 EXPECT_FALSE(overscroll_completed()); 126 EXPECT_FALSE(overscroll_completed());
127 EXPECT_FALSE(overscroll_aborted()); 127 EXPECT_FALSE(overscroll_aborted());
128 128
129 // Start an OVERSCROLL_EAST gesture. 129 // Start an OVERSCROLL_EAST gesture.
130 owa()->OnOverscrollModeChange(OVERSCROLL_NONE, OVERSCROLL_EAST); 130 owa()->OnOverscrollModeChange(OVERSCROLL_NONE, OVERSCROLL_EAST,
131 OverscrollSource::TOUCHPAD);
131 EXPECT_TRUE(owa()->is_active()); 132 EXPECT_TRUE(owa()->is_active());
133 EXPECT_EQ(OverscrollSource::TOUCHPAD, owa()->overscroll_source());
132 EXPECT_TRUE(overscroll_started()); 134 EXPECT_TRUE(overscroll_started());
133 EXPECT_FALSE(overscroll_completing()); 135 EXPECT_FALSE(overscroll_completing());
134 EXPECT_FALSE(overscroll_completed()); 136 EXPECT_FALSE(overscroll_completed());
135 EXPECT_FALSE(overscroll_aborted()); 137 EXPECT_FALSE(overscroll_aborted());
136 138
137 // Complete the overscroll. 139 // Complete the overscroll.
138 owa()->OnOverscrollComplete(OVERSCROLL_EAST); 140 owa()->OnOverscrollComplete(OVERSCROLL_EAST);
139 EXPECT_FALSE(owa()->is_active()); 141 EXPECT_FALSE(owa()->is_active());
140 EXPECT_TRUE(overscroll_started()); 142 EXPECT_TRUE(overscroll_started());
141 EXPECT_TRUE(overscroll_completing()); 143 EXPECT_TRUE(overscroll_completing());
142 EXPECT_TRUE(overscroll_completed()); 144 EXPECT_TRUE(overscroll_completed());
143 EXPECT_FALSE(overscroll_aborted()); 145 EXPECT_FALSE(overscroll_aborted());
144 } 146 }
145 147
146 // Tests aborting an overscroll gesture. 148 // Tests aborting an overscroll gesture.
147 TEST_F(OverscrollWindowAnimationTest, BasicAbort) { 149 TEST_F(OverscrollWindowAnimationTest, BasicAbort) {
148 // Start an OVERSCROLL_EAST gesture. 150 // Start an OVERSCROLL_EAST gesture.
149 owa()->OnOverscrollModeChange(OVERSCROLL_NONE, OVERSCROLL_EAST); 151 owa()->OnOverscrollModeChange(OVERSCROLL_NONE, OVERSCROLL_EAST,
152 OverscrollSource::TOUCHSCREEN);
153 EXPECT_EQ(OverscrollSource::TOUCHSCREEN, owa()->overscroll_source());
150 // Abort the overscroll. 154 // Abort the overscroll.
151 owa()->OnOverscrollModeChange(OVERSCROLL_EAST, OVERSCROLL_NONE); 155 owa()->OnOverscrollModeChange(OVERSCROLL_EAST, OVERSCROLL_NONE,
156 OverscrollSource::TOUCHSCREEN);
157 EXPECT_EQ(OverscrollSource::NONE, owa()->overscroll_source());
152 EXPECT_FALSE(owa()->is_active()); 158 EXPECT_FALSE(owa()->is_active());
153 EXPECT_TRUE(overscroll_started()); 159 EXPECT_TRUE(overscroll_started());
154 EXPECT_FALSE(overscroll_completing()); 160 EXPECT_FALSE(overscroll_completing());
155 EXPECT_FALSE(overscroll_completed()); 161 EXPECT_FALSE(overscroll_completed());
156 EXPECT_TRUE(overscroll_aborted()); 162 EXPECT_TRUE(overscroll_aborted());
157 } 163 }
158 164
159 // Tests starting an overscroll gesture when the slide window cannot be created. 165 // Tests starting an overscroll gesture when the slide window cannot be created.
160 TEST_F(OverscrollWindowAnimationTest, BasicCannotNavigate) { 166 TEST_F(OverscrollWindowAnimationTest, BasicCannotNavigate) {
161 set_create_window(false); 167 set_create_window(false);
162 // Start an OVERSCROLL_EAST gesture. 168 // Start an OVERSCROLL_EAST gesture.
163 owa()->OnOverscrollModeChange(OVERSCROLL_NONE, OVERSCROLL_EAST); 169 owa()->OnOverscrollModeChange(OVERSCROLL_NONE, OVERSCROLL_EAST,
170 OverscrollSource::TOUCHPAD);
164 EXPECT_FALSE(owa()->is_active()); 171 EXPECT_FALSE(owa()->is_active());
172 EXPECT_EQ(OverscrollSource::NONE, owa()->overscroll_source());
165 EXPECT_TRUE(overscroll_started()); 173 EXPECT_TRUE(overscroll_started());
166 EXPECT_FALSE(overscroll_completing()); 174 EXPECT_FALSE(overscroll_completing());
167 EXPECT_FALSE(overscroll_completed()); 175 EXPECT_FALSE(overscroll_completed());
168 EXPECT_FALSE(overscroll_aborted()); 176 EXPECT_FALSE(overscroll_aborted());
169 } 177 }
170 178
171 // Tests starting an overscroll gesture while another one was in progress 179 // Tests starting an overscroll gesture while another one was in progress
172 // completes the first one. 180 // completes the first one.
173 TEST_F(OverscrollWindowAnimationTest, NewOverscrollCompletesPreviousGesture) { 181 TEST_F(OverscrollWindowAnimationTest, NewOverscrollCompletesPreviousGesture) {
174 // This test requires a normal animation duration so that 182 // This test requires a normal animation duration so that
175 // OnImplicitAnimationsCancelled is not called as soon as the first overscroll 183 // OnImplicitAnimationsCancelled is not called as soon as the first overscroll
176 // finishes. 184 // finishes.
177 ui::ScopedAnimationDurationScaleMode normal_duration( 185 ui::ScopedAnimationDurationScaleMode normal_duration(
178 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); 186 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
179 ui::LayerAnimator* animator = GetMainWindow()->layer()->GetAnimator(); 187 ui::LayerAnimator* animator = GetMainWindow()->layer()->GetAnimator();
180 ui::ScopedLayerAnimationSettings settings(animator); 188 ui::ScopedLayerAnimationSettings settings(animator);
181 animator->set_disable_timer_for_test(true); 189 animator->set_disable_timer_for_test(true);
182 ui::LayerAnimatorTestController test_controller(animator); 190 ui::LayerAnimatorTestController test_controller(animator);
183 // Start an OVERSCROLL_EAST gesture. 191 // Start an OVERSCROLL_EAST gesture.
184 owa()->OnOverscrollModeChange(OVERSCROLL_NONE, OVERSCROLL_EAST); 192 owa()->OnOverscrollModeChange(OVERSCROLL_NONE, OVERSCROLL_EAST,
193 OverscrollSource::TOUCHPAD);
185 194
186 // Finishes the OVERSCROLL_EAST gesture. At this point the window should be 195 // Finishes the OVERSCROLL_EAST gesture. At this point the window should be
187 // being animated to its final position. 196 // being animated to its final position.
188 owa()->OnOverscrollComplete(OVERSCROLL_EAST); 197 owa()->OnOverscrollComplete(OVERSCROLL_EAST);
189 EXPECT_TRUE(owa()->is_active()); 198 EXPECT_TRUE(owa()->is_active());
199 EXPECT_EQ(OverscrollSource::TOUCHPAD, owa()->overscroll_source());
190 EXPECT_TRUE(overscroll_started()); 200 EXPECT_TRUE(overscroll_started());
191 EXPECT_TRUE(overscroll_completing()); 201 EXPECT_TRUE(overscroll_completing());
192 EXPECT_FALSE(overscroll_completed()); 202 EXPECT_FALSE(overscroll_completed());
193 EXPECT_FALSE(overscroll_aborted()); 203 EXPECT_FALSE(overscroll_aborted());
194 204
195 // Start another OVERSCROLL_EAST gesture. 205 // Start another OVERSCROLL_EAST gesture.
196 owa()->OnOverscrollModeChange(OVERSCROLL_NONE, OVERSCROLL_EAST); 206 owa()->OnOverscrollModeChange(OVERSCROLL_NONE, OVERSCROLL_EAST,
207 OverscrollSource::TOUCHSCREEN);
197 EXPECT_TRUE(owa()->is_active()); 208 EXPECT_TRUE(owa()->is_active());
209 EXPECT_EQ(OverscrollSource::TOUCHSCREEN, owa()->overscroll_source());
198 EXPECT_TRUE(overscroll_started()); 210 EXPECT_TRUE(overscroll_started());
199 EXPECT_TRUE(overscroll_completing()); 211 EXPECT_TRUE(overscroll_completing());
200 EXPECT_TRUE(overscroll_completed()); 212 EXPECT_TRUE(overscroll_completed());
201 EXPECT_FALSE(overscroll_aborted()); 213 EXPECT_FALSE(overscroll_aborted());
202 214
203 // Complete the overscroll gesture. 215 // Complete the overscroll gesture.
204 ResetFlags(); 216 ResetFlags();
205 owa()->OnOverscrollComplete(OVERSCROLL_EAST); 217 owa()->OnOverscrollComplete(OVERSCROLL_EAST);
206 218
207 base::TimeDelta duration = settings.GetTransitionDuration(); 219 base::TimeDelta duration = settings.GetTransitionDuration();
208 test_controller.StartThreadedAnimationsIfNeeded(); 220 test_controller.StartThreadedAnimationsIfNeeded();
209 base::TimeTicks start_time = base::TimeTicks::Now(); 221 base::TimeTicks start_time = base::TimeTicks::Now();
210 222
211 // Halfway through the animation, OverscrollCompleting should have been fired. 223 // Halfway through the animation, OverscrollCompleting should have been fired.
212 animator->Step(start_time + duration / 2); 224 animator->Step(start_time + duration / 2);
213 EXPECT_TRUE(owa()->is_active()); 225 EXPECT_TRUE(owa()->is_active());
226 EXPECT_EQ(OverscrollSource::TOUCHSCREEN, owa()->overscroll_source());
214 EXPECT_FALSE(overscroll_started()); 227 EXPECT_FALSE(overscroll_started());
215 EXPECT_TRUE(overscroll_completing()); 228 EXPECT_TRUE(overscroll_completing());
216 EXPECT_FALSE(overscroll_completed()); 229 EXPECT_FALSE(overscroll_completed());
217 EXPECT_FALSE(overscroll_aborted()); 230 EXPECT_FALSE(overscroll_aborted());
218 231
219 // The animation has finished, OverscrollCompleted should have been fired. 232 // The animation has finished, OverscrollCompleted should have been fired.
220 animator->Step(start_time + duration); 233 animator->Step(start_time + duration);
221 EXPECT_FALSE(owa()->is_active()); 234 EXPECT_FALSE(owa()->is_active());
235 EXPECT_EQ(OverscrollSource::NONE, owa()->overscroll_source());
222 EXPECT_FALSE(overscroll_started()); 236 EXPECT_FALSE(overscroll_started());
223 EXPECT_TRUE(overscroll_completing()); 237 EXPECT_TRUE(overscroll_completing());
224 EXPECT_TRUE(overscroll_completed()); 238 EXPECT_TRUE(overscroll_completed());
225 EXPECT_FALSE(overscroll_aborted()); 239 EXPECT_FALSE(overscroll_aborted());
226 } 240 }
227 241
228 } // namespace content 242 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698