| OLD | NEW |
| 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/client/window_tree_client.h" | 7 #include "ui/aura/client/window_tree_client.h" |
| 8 #include "ui/aura/test/aura_test_helper.h" | 8 #include "ui/aura/test/aura_test_helper.h" |
| 9 #include "ui/aura/test/test_window_delegate.h" | 9 #include "ui/aura/test/test_window_delegate.h" |
| 10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
| 11 #include "ui/base/ime/input_method_initializer.h" | 11 #include "ui/base/ime/input_method_initializer.h" |
| 12 #include "ui/compositor/test/context_factories_for_test.h" | 12 #include "ui/compositor/test/context_factories_for_test.h" |
| 13 #include "ui/events/event_dispatcher.h" | 13 #include "ui/events/event_dispatcher.h" |
| 14 #include "ui/events/event_processor.h" | 14 #include "ui/events/event_processor.h" |
| 15 #include "ui/events/gestures/gesture_configuration.h" | 15 #include "ui/events/gesture_detection/gesture_configuration.h" |
| 16 | 16 |
| 17 namespace aura { | 17 namespace aura { |
| 18 namespace test { | 18 namespace test { |
| 19 | 19 |
| 20 AuraTestBase::AuraTestBase() | 20 AuraTestBase::AuraTestBase() |
| 21 : setup_called_(false), | 21 : setup_called_(false), |
| 22 teardown_called_(false) { | 22 teardown_called_(false) { |
| 23 } | 23 } |
| 24 | 24 |
| 25 AuraTestBase::~AuraTestBase() { | 25 AuraTestBase::~AuraTestBase() { |
| 26 CHECK(setup_called_) | 26 CHECK(setup_called_) |
| 27 << "You have overridden SetUp but never called super class's SetUp"; | 27 << "You have overridden SetUp but never called super class's SetUp"; |
| 28 CHECK(teardown_called_) | 28 CHECK(teardown_called_) |
| 29 << "You have overridden TearDown but never called super class's TearDown"; | 29 << "You have overridden TearDown but never called super class's TearDown"; |
| 30 } | 30 } |
| 31 | 31 |
| 32 void AuraTestBase::SetUp() { | 32 void AuraTestBase::SetUp() { |
| 33 setup_called_ = true; | 33 setup_called_ = true; |
| 34 testing::Test::SetUp(); | 34 testing::Test::SetUp(); |
| 35 ui::InitializeInputMethodForTesting(); | 35 ui::InitializeInputMethodForTesting(); |
| 36 | 36 |
| 37 // Changing the parameters for gesture recognition shouldn't cause | 37 // Changing the parameters for gesture recognition shouldn't cause |
| 38 // tests to fail, so we use a separate set of parameters for unit | 38 // tests to fail, so we use a separate set of parameters for unit |
| 39 // testing. | 39 // testing. |
| 40 ui::GestureConfiguration::set_long_press_time_in_ms(1000); | 40 ui::GestureConfiguration::GetInstance()->set_long_press_time_in_ms(1000); |
| 41 ui::GestureConfiguration::set_semi_long_press_time_in_ms(400); | 41 ui::GestureConfiguration::GetInstance()->set_semi_long_press_time_in_ms(400); |
| 42 ui::GestureConfiguration::set_show_press_delay_in_ms(5); | 42 ui::GestureConfiguration::GetInstance()->set_show_press_delay_in_ms(5); |
| 43 ui::GestureConfiguration::set_max_distance_for_two_finger_tap_in_pixels(300); | 43 ui::GestureConfiguration::GetInstance() |
| 44 ui::GestureConfiguration::set_max_time_between_double_click_in_ms(700); | 44 ->set_max_distance_for_two_finger_tap_in_pixels(300); |
| 45 ui::GestureConfiguration:: | 45 ui::GestureConfiguration::GetInstance() |
| 46 set_max_separation_for_gesture_touches_in_pixels(150); | 46 ->set_max_time_between_double_click_in_ms(700); |
| 47 ui::GestureConfiguration::set_max_touch_down_duration_for_click_in_ms(800); | 47 ui::GestureConfiguration::GetInstance() |
| 48 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(5); | 48 ->set_max_separation_for_gesture_touches_in_pixels(150); |
| 49 ui::GestureConfiguration::set_max_distance_between_taps_for_double_tap(20); | 49 ui::GestureConfiguration::GetInstance() |
| 50 ui::GestureConfiguration::set_min_distance_for_pinch_scroll_in_pixels(20); | 50 ->set_max_touch_down_duration_for_click_in_ms(800); |
| 51 ui::GestureConfiguration::set_min_pinch_update_distance_in_pixels(5); | 51 ui::GestureConfiguration::GetInstance() |
| 52 ui::GestureConfiguration::set_default_radius(0); | 52 ->set_max_touch_move_in_pixels_for_click(5); |
| 53 ui::GestureConfiguration::set_fling_velocity_cap(15000); | 53 ui::GestureConfiguration::GetInstance() |
| 54 ui::GestureConfiguration::set_min_swipe_speed(10); | 54 ->set_max_distance_between_taps_for_double_tap(20); |
| 55 | 55 ui::GestureConfiguration::GetInstance() |
| 56 ->set_min_distance_for_pinch_scroll_in_pixels(20); |
| 57 ui::GestureConfiguration::GetInstance() |
| 58 ->set_min_pinch_update_distance_in_pixels(5); |
| 59 ui::GestureConfiguration::GetInstance()->set_default_radius(0); |
| 60 ui::GestureConfiguration::GetInstance()->set_fling_velocity_cap(15000); |
| 61 ui::GestureConfiguration::GetInstance()->set_min_swipe_speed(10); |
| 56 // The ContextFactory must exist before any Compositors are created. | 62 // The ContextFactory must exist before any Compositors are created. |
| 57 bool enable_pixel_output = false; | 63 bool enable_pixel_output = false; |
| 58 ui::ContextFactory* context_factory = | 64 ui::ContextFactory* context_factory = |
| 59 ui::InitializeContextFactoryForTests(enable_pixel_output); | 65 ui::InitializeContextFactoryForTests(enable_pixel_output); |
| 60 | 66 |
| 61 helper_.reset(new AuraTestHelper(&message_loop_)); | 67 helper_.reset(new AuraTestHelper(&message_loop_)); |
| 62 helper_->SetUp(context_factory); | 68 helper_->SetUp(context_factory); |
| 63 } | 69 } |
| 64 | 70 |
| 65 void AuraTestBase::TearDown() { | 71 void AuraTestBase::TearDown() { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 104 |
| 99 bool AuraTestBase::DispatchEventUsingWindowDispatcher(ui::Event* event) { | 105 bool AuraTestBase::DispatchEventUsingWindowDispatcher(ui::Event* event) { |
| 100 ui::EventDispatchDetails details = | 106 ui::EventDispatchDetails details = |
| 101 event_processor()->OnEventFromSource(event); | 107 event_processor()->OnEventFromSource(event); |
| 102 CHECK(!details.dispatcher_destroyed); | 108 CHECK(!details.dispatcher_destroyed); |
| 103 return event->handled(); | 109 return event->handled(); |
| 104 } | 110 } |
| 105 | 111 |
| 106 } // namespace test | 112 } // namespace test |
| 107 } // namespace aura | 113 } // namespace aura |
| OLD | NEW |