| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chromeos/touch_exploration_controller.h" | 5 #include "ui/chromeos/touch_exploration_controller.h" |
| 6 | 6 |
| 7 #include "ash/common/accessibility_delegate.h" | 7 #include "ash/common/accessibility_delegate.h" |
| 8 #include "ash/common/accessibility_types.h" | 8 #include "ash/common/accessibility_types.h" |
| 9 #include "ash/common/wm_shell.h" |
| 9 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 10 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/test/simple_test_tick_clock.h" | 13 #include "base/test/simple_test_tick_clock.h" |
| 13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 14 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 15 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 17 #include "chrome/test/base/in_process_browser_test.h" | 18 #include "chrome/test/base/in_process_browser_test.h" |
| 18 #include "content/public/test/browser_test_utils.h" | 19 #include "content/public/test/browser_test_utils.h" |
| 19 #include "ui/aura/client/cursor_client.h" | 20 #include "ui/aura/client/cursor_client.h" |
| 20 #include "ui/aura/window_tree_host.h" | 21 #include "ui/aura/window_tree_host.h" |
| 21 #include "ui/compositor/compositor.h" | 22 #include "ui/compositor/compositor.h" |
| 22 #include "ui/compositor/test/draw_waiter_for_test.h" | 23 #include "ui/compositor/test/draw_waiter_for_test.h" |
| 23 #include "ui/events/event.h" | 24 #include "ui/events/event.h" |
| 24 #include "ui/events/event_utils.h" | 25 #include "ui/events/event_utils.h" |
| 25 #include "ui/events/test/event_generator.h" | 26 #include "ui/events/test/event_generator.h" |
| 26 #include "ui/events/test/test_event_handler.h" | 27 #include "ui/events/test/test_event_handler.h" |
| 27 | 28 |
| 28 namespace ui { | |
| 29 | |
| 30 class TouchExplorationTest : public InProcessBrowserTest { | 29 class TouchExplorationTest : public InProcessBrowserTest { |
| 31 public: | 30 public: |
| 32 TouchExplorationTest() : simulated_clock_(new base::SimpleTestTickClock()) { | 31 TouchExplorationTest() : simulated_clock_(new base::SimpleTestTickClock()) { |
| 33 // Tests fail if time is ever 0. | 32 // Tests fail if time is ever 0. |
| 34 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10)); | 33 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10)); |
| 35 } | 34 } |
| 36 ~TouchExplorationTest() override {} | 35 ~TouchExplorationTest() override {} |
| 37 | 36 |
| 38 protected: | 37 protected: |
| 39 void SetUpOnMainThread() override { | 38 void SetUpOnMainThread() override { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 51 event_handler_.reset(new ui::test::TestEventHandler()); | 50 event_handler_.reset(new ui::test::TestEventHandler()); |
| 52 root_window_->AddPreTargetHandler(event_handler_.get()); | 51 root_window_->AddPreTargetHandler(event_handler_.get()); |
| 53 } | 52 } |
| 54 | 53 |
| 55 void TearDownOnMainThread() override { | 54 void TearDownOnMainThread() override { |
| 56 SwitchTouchExplorationMode(false); | 55 SwitchTouchExplorationMode(false); |
| 57 root_window_->RemovePreTargetHandler(event_handler_.get()); | 56 root_window_->RemovePreTargetHandler(event_handler_.get()); |
| 58 } | 57 } |
| 59 | 58 |
| 60 void SwitchTouchExplorationMode(bool on) { | 59 void SwitchTouchExplorationMode(bool on) { |
| 61 ash::AccessibilityDelegate* ad = | 60 ash::AccessibilityDelegate* delegate = |
| 62 ash::Shell::GetInstance()->accessibility_delegate(); | 61 ash::WmShell::Get()->GetAccessibilityDelegate(); |
| 63 if (on != ad->IsSpokenFeedbackEnabled()) | 62 if (on != delegate->IsSpokenFeedbackEnabled()) |
| 64 ad->ToggleSpokenFeedback(ash::A11Y_NOTIFICATION_NONE); | 63 delegate->ToggleSpokenFeedback(ash::A11Y_NOTIFICATION_NONE); |
| 65 } | 64 } |
| 66 | 65 |
| 67 base::TimeTicks Now() { return simulated_clock_->NowTicks(); } | 66 base::TimeTicks Now() { return simulated_clock_->NowTicks(); } |
| 68 | 67 |
| 69 ui::GestureDetector::Config gesture_detector_config_; | 68 ui::GestureDetector::Config gesture_detector_config_; |
| 70 base::SimpleTestTickClock* simulated_clock_; | 69 base::SimpleTestTickClock* simulated_clock_; |
| 71 aura::Window* root_window_; | 70 aura::Window* root_window_; |
| 72 std::unique_ptr<ui::test::TestEventHandler> event_handler_; | 71 std::unique_ptr<ui::test::TestEventHandler> event_handler_; |
| 73 | 72 |
| 74 private: | 73 private: |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 EXPECT_EQ(2, event_handler_->num_touch_events()); | 240 EXPECT_EQ(2, event_handler_->num_touch_events()); |
| 242 event_handler_->Reset(); | 241 event_handler_->Reset(); |
| 243 | 242 |
| 244 // Continuing to move the touch exploration finger should send more mouse | 243 // Continuing to move the touch exploration finger should send more mouse |
| 245 // events. | 244 // events. |
| 246 generator.MoveTouchId(gfx::Point(509, 609), 1); | 245 generator.MoveTouchId(gfx::Point(509, 609), 1); |
| 247 EXPECT_EQ(0, event_handler_->num_touch_events()); | 246 EXPECT_EQ(0, event_handler_->num_touch_events()); |
| 248 EXPECT_TRUE(cursor_client->IsMouseEventsEnabled()); | 247 EXPECT_TRUE(cursor_client->IsMouseEventsEnabled()); |
| 249 EXPECT_FALSE(cursor_client->IsCursorVisible()); | 248 EXPECT_FALSE(cursor_client->IsCursorVisible()); |
| 250 } | 249 } |
| 251 | |
| 252 } // namespace ui | |
| OLD | NEW |