OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ui/chromeos/touch_exploration_controller.h" | |
6 | |
7 #include "ash/accessibility_delegate.h" | |
8 #include "ash/ash_switches.h" | |
9 #include "ash/shell.h" | |
10 #include "ash/test/ash_test_base.h" | |
11 #include "base/command_line.h" | |
12 #include "chrome/test/base/in_process_browser_test.h" | |
13 #include "chrome/test/base/ui_test_utils.h" | |
14 #include "ui/aura/test/event_generator.h" | |
15 #include "ui/aura/window_tree_host.h" | |
16 #include "ui/compositor/compositor.h" | |
17 #include "ui/compositor/test/draw_waiter_for_test.h" | |
18 #include "ui/events/test/test_event_handler.h" | |
19 | |
20 namespace ui { | |
21 | |
22 class TouchExplorationTest : public InProcessBrowserTest { | |
23 public: | |
24 TouchExplorationTest() { | |
25 CommandLine::ForCurrentProcess()->AppendSwitch( | |
26 ash::switches::kAshEnableTouchExplorationMode); | |
oshima
2014/05/02 20:04:24
Can you do this in SetUpCommandLine?
mfomitchev
2014/05/02 21:01:00
Done.
| |
27 } | |
28 virtual ~TouchExplorationTest() {} | |
29 | |
30 protected: | |
31 void SwitchTouchExplorationMode(bool on) { | |
32 ash::AccessibilityDelegate* ad = | |
33 ash::Shell::GetInstance()->accessibility_delegate(); | |
34 if (on != ad->IsSpokenFeedbackEnabled()) | |
35 ad->ToggleSpokenFeedback(ash::A11Y_NOTIFICATION_NONE); | |
36 } | |
37 | |
38 private: | |
39 DISALLOW_COPY_AND_ASSIGN(TouchExplorationTest); | |
40 }; | |
41 | |
42 IN_PROC_BROWSER_TEST_F(TouchExplorationTest, PRE_ToggleOnOff) { | |
43 // TODO (mfomitchev): If the test is run by itself, there is a resize at the | |
44 // very beginning. An in-progress resize creates a "resize lock" in | |
45 // RenderWidgetHostViewAura, which calls | |
46 // WindowEventDispatcher::HoldPointerMoves(), which prevents mouse events from | |
47 // coming through. Adding a PRE_ test ensures the resize completes before the | |
48 // actual test is executed. sadrul@ says the resize shouldn't be even | |
49 // happening, so this needs to be looked at further. | |
50 } | |
51 | |
52 // This test turns the touch exploration mode on/off and confirms that events | |
53 // get rewritten when the touch exploration mode is on, and aren't affected | |
54 // after the touch exploration mode is turned off. | |
55 IN_PROC_BROWSER_TEST_F(TouchExplorationTest, ToggleOnOff) { | |
56 aura::Window* root_window = ash::Shell::GetInstance()->GetPrimaryRootWindow(); | |
57 scoped_ptr<ui::test::TestEventHandler> | |
58 event_handler(new ui::test::TestEventHandler()); | |
59 root_window->AddPreTargetHandler(event_handler.get()); | |
60 SwitchTouchExplorationMode(true); | |
61 aura::test::EventGenerator generator(root_window); | |
62 | |
63 generator.PressTouchId(1); | |
64 // Number of mouse events may be greater than 1 because of ET_MOUSE_ENTERED. | |
65 EXPECT_GT(event_handler->num_mouse_events(), 0); | |
66 EXPECT_EQ(0, event_handler->num_touch_events()); | |
67 event_handler->Reset(); | |
68 | |
69 SwitchTouchExplorationMode(false); | |
70 generator.MoveTouchId(gfx::Point(11, 12), 1); | |
71 EXPECT_EQ(0, event_handler->num_mouse_events()); | |
72 EXPECT_EQ(1, event_handler->num_touch_events()); | |
73 event_handler->Reset(); | |
74 | |
75 SwitchTouchExplorationMode(true); | |
76 generator.PressTouchId(2); | |
77 EXPECT_GT(event_handler->num_mouse_events(), 0); | |
78 EXPECT_EQ(0, event_handler->num_touch_events()); | |
79 | |
80 SwitchTouchExplorationMode(false); | |
81 root_window->RemovePreTargetHandler(event_handler.get()); | |
82 } | |
83 | |
84 } // namespace ui | |
OLD | NEW |