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

Side by Side Diff: ui/aura/test/aura_test_base.cc

Issue 9751011: Gesture recognition constants should all be stored in the GestureConfiguration object. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Protect unit tests from changes in GestureConfiguration. Created 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "ui/aura/test/aura_test_base.h" 5 #include "ui/aura/test/aura_test_base.h"
6 6
7 #include "ui/aura/env.h" 7 #include "ui/aura/env.h"
8 #include "ui/aura/gestures/gesture_configuration.h"
8 #include "ui/aura/monitor_manager.h" 9 #include "ui/aura/monitor_manager.h"
9 #include "ui/aura/single_monitor_manager.h" 10 #include "ui/aura/single_monitor_manager.h"
10 #include "ui/aura/root_window.h" 11 #include "ui/aura/root_window.h"
11 #include "ui/aura/test/test_screen.h" 12 #include "ui/aura/test/test_screen.h"
12 #include "ui/aura/test/test_stacking_client.h" 13 #include "ui/aura/test/test_stacking_client.h"
13 #include "ui/aura/ui_controls_aura.h" 14 #include "ui/aura/ui_controls_aura.h"
14 #include "ui/ui_controls/ui_controls.h" 15 #include "ui/ui_controls/ui_controls.h"
15 16
16 namespace aura { 17 namespace aura {
17 namespace test { 18 namespace test {
18 19
19 AuraTestBase::AuraTestBase() { 20 AuraTestBase::AuraTestBase() {
20 } 21 }
21 22
22 AuraTestBase::~AuraTestBase() { 23 AuraTestBase::~AuraTestBase() {
23 } 24 }
24 25
25 void AuraTestBase::SetUp() { 26 void AuraTestBase::SetUp() {
26 testing::Test::SetUp(); 27 testing::Test::SetUp();
28
29 // Changing the parameters for gesture recognition shouldn't cause
girard 2012/03/20 18:30:59 Is this necessary? Are the configured parameters u
tdresser 2012/03/20 19:34:10 It seems beneficial to isolate changes to GestureC
30 // tests to fail, so we use a separate set of parameters for unit
31 // testing.
32 GestureConfiguration::set_long_press_time_in_ms(500);
33 GestureConfiguration::set_max_seconds_between_double_click(0.7);
34 GestureConfiguration::set_max_touch_down_duration_in_seconds_for_click(0.8);
35 GestureConfiguration::set_max_touch_move_in_pixels_for_click(20);
36 GestureConfiguration::set_min_distance_for_pinch_scroll_in_pixels(20);
37 GestureConfiguration::set_min_flick_speed_squared(550.f * 550.f);
38 GestureConfiguration::set_min_pinch_update_distance_in_pixels(5);
39 GestureConfiguration::set_min_rail_break_velocity(200);
40 GestureConfiguration::set_min_scroll_delta_squared(5 * 5);
41 GestureConfiguration::set_min_touch_down_duration_in_seconds_for_click(0.01);
42 GestureConfiguration::set_points_buffered_for_velocity(10);
43 GestureConfiguration::set_rail_break_proportion(15);
44 GestureConfiguration::set_rail_start_proportion(2);
45
27 root_window_.reset(Env::GetInstance()->monitor_manager()-> 46 root_window_.reset(Env::GetInstance()->monitor_manager()->
28 CreateRootWindowForPrimaryMonitor()); 47 CreateRootWindowForPrimaryMonitor());
29 gfx::Screen::SetInstance(new aura::TestScreen(root_window_.get())); 48 gfx::Screen::SetInstance(new aura::TestScreen(root_window_.get()));
30 ui_controls::InstallUIControlsAura(CreateUIControlsAura(root_window_.get())); 49 ui_controls::InstallUIControlsAura(CreateUIControlsAura(root_window_.get()));
31 helper_.InitRootWindow(root_window()); 50 helper_.InitRootWindow(root_window());
32 helper_.SetUp(); 51 helper_.SetUp();
33 stacking_client_.reset(new TestStackingClient(root_window())); 52 stacking_client_.reset(new TestStackingClient(root_window()));
34 } 53 }
35 54
36 void AuraTestBase::TearDown() { 55 void AuraTestBase::TearDown() {
37 // Flush the message loop because we have pending release tasks 56 // Flush the message loop because we have pending release tasks
38 // and these tasks if un-executed would upset Valgrind. 57 // and these tasks if un-executed would upset Valgrind.
39 RunAllPendingInMessageLoop(); 58 RunAllPendingInMessageLoop();
40 59
41 stacking_client_.reset(); 60 stacking_client_.reset();
42 helper_.TearDown(); 61 helper_.TearDown();
43 root_window_.reset(); 62 root_window_.reset();
44 testing::Test::TearDown(); 63 testing::Test::TearDown();
45 } 64 }
46 65
47 void AuraTestBase::RunAllPendingInMessageLoop() { 66 void AuraTestBase::RunAllPendingInMessageLoop() {
48 helper_.RunAllPendingInMessageLoop(root_window()); 67 helper_.RunAllPendingInMessageLoop(root_window());
49 } 68 }
50 69
51 } // namespace test 70 } // namespace test
52 } // namespace aura 71 } // namespace aura
OLDNEW
« ui/aura/gestures/gesture_point.cc ('K') | « ui/aura/gestures/gesture_sequence.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698