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/accessibility_delegate.h" | 7 #include "ash/accessibility_delegate.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
10 #include "base/test/simple_test_tick_clock.h" | 10 #include "base/test/simple_test_tick_clock.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 class TouchExplorationTest : public InProcessBrowserTest { | 28 class TouchExplorationTest : public InProcessBrowserTest { |
29 public: | 29 public: |
30 TouchExplorationTest() : simulated_clock_(new base::SimpleTestTickClock()) { | 30 TouchExplorationTest() : simulated_clock_(new base::SimpleTestTickClock()) { |
31 // Tests fail if time is ever 0. | 31 // Tests fail if time is ever 0. |
32 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10)); | 32 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10)); |
33 } | 33 } |
34 virtual ~TouchExplorationTest() {} | 34 virtual ~TouchExplorationTest() {} |
35 | 35 |
36 protected: | 36 protected: |
37 virtual void SetUpOnMainThread() OVERRIDE { | 37 virtual void SetUpOnMainThread() override { |
38 // The RenderView for WebContents is created as a result of the | 38 // The RenderView for WebContents is created as a result of the |
39 // navigation to the New Tab page which is done as part of the test | 39 // navigation to the New Tab page which is done as part of the test |
40 // SetUp. The creation involves sending a resize message to the renderer | 40 // SetUp. The creation involves sending a resize message to the renderer |
41 // process. Here we wait for the resize ack to be received, because | 41 // process. Here we wait for the resize ack to be received, because |
42 // currently WindowEventDispatcher has code to hold touch and mouse | 42 // currently WindowEventDispatcher has code to hold touch and mouse |
43 // move events until resize is complete (crbug.com/384342) which | 43 // move events until resize is complete (crbug.com/384342) which |
44 // interferes with this test. | 44 // interferes with this test. |
45 content::WebContents* web_contents = | 45 content::WebContents* web_contents = |
46 browser()->tab_strip_model()->GetActiveWebContents(); | 46 browser()->tab_strip_model()->GetActiveWebContents(); |
47 content::WaitForResizeComplete(web_contents); | 47 content::WaitForResizeComplete(web_contents); |
48 root_window_ = ash::Shell::GetInstance()->GetPrimaryRootWindow(); | 48 root_window_ = ash::Shell::GetInstance()->GetPrimaryRootWindow(); |
49 event_handler_.reset(new ui::test::TestEventHandler()); | 49 event_handler_.reset(new ui::test::TestEventHandler()); |
50 root_window_->AddPreTargetHandler(event_handler_.get()); | 50 root_window_->AddPreTargetHandler(event_handler_.get()); |
51 } | 51 } |
52 | 52 |
53 virtual void TearDownOnMainThread() OVERRIDE { | 53 virtual void TearDownOnMainThread() override { |
54 SwitchTouchExplorationMode(false); | 54 SwitchTouchExplorationMode(false); |
55 root_window_->RemovePreTargetHandler(event_handler_.get()); | 55 root_window_->RemovePreTargetHandler(event_handler_.get()); |
56 } | 56 } |
57 | 57 |
58 void SwitchTouchExplorationMode(bool on) { | 58 void SwitchTouchExplorationMode(bool on) { |
59 ash::AccessibilityDelegate* ad = | 59 ash::AccessibilityDelegate* ad = |
60 ash::Shell::GetInstance()->accessibility_delegate(); | 60 ash::Shell::GetInstance()->accessibility_delegate(); |
61 if (on != ad->IsSpokenFeedbackEnabled()) | 61 if (on != ad->IsSpokenFeedbackEnabled()) |
62 ad->ToggleSpokenFeedback(ash::A11Y_NOTIFICATION_NONE); | 62 ad->ToggleSpokenFeedback(ash::A11Y_NOTIFICATION_NONE); |
63 } | 63 } |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 | 235 |
236 // Continuing to move the touch exploration finger should send more mouse | 236 // Continuing to move the touch exploration finger should send more mouse |
237 // events. | 237 // events. |
238 generator.MoveTouchId(gfx::Point(509, 609), 1); | 238 generator.MoveTouchId(gfx::Point(509, 609), 1); |
239 EXPECT_EQ(0, event_handler_->num_touch_events()); | 239 EXPECT_EQ(0, event_handler_->num_touch_events()); |
240 EXPECT_TRUE(cursor_client->IsMouseEventsEnabled()); | 240 EXPECT_TRUE(cursor_client->IsMouseEventsEnabled()); |
241 EXPECT_FALSE(cursor_client->IsCursorVisible()); | 241 EXPECT_FALSE(cursor_client->IsCursorVisible()); |
242 } | 242 } |
243 | 243 |
244 } // namespace ui | 244 } // namespace ui |
OLD | NEW |