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/shell.h" | |
9 #include "ash/test/ash_test_base.h" | |
10 #include "base/time/time.h" | |
11 #include "chrome/test/base/in_process_browser_test.h" | |
12 #include "chrome/test/base/ui_test_utils.h" | |
13 #include "ui/aura/test/event_generator.h" | |
14 #include "ui/events/event.h" | |
15 #include "ui/events/event_utils.h" | |
16 #include "ui/events/test/test_event_handler.h" | |
17 #include "ui/gfx/geometry/point.h" | |
18 | |
19 namespace ui { | |
20 | |
21 class TouchExplorationTest : public InProcessBrowserTest { | |
22 public: | |
23 TouchExplorationTest() {} | |
24 virtual ~TouchExplorationTest() {} | |
25 | |
26 protected: | |
27 void SwitchTouchExplorationMode(bool on) { | |
28 ash::AccessibilityDelegate* ad = | |
29 ash::Shell::GetInstance()->accessibility_delegate(); | |
30 if (on != ad->IsSpokenFeedbackEnabled()) | |
31 ad->ToggleSpokenFeedback(ash::A11Y_NOTIFICATION_NONE); | |
32 } | |
33 | |
34 private: | |
35 DISALLOW_COPY_AND_ASSIGN(TouchExplorationTest); | |
36 }; | |
37 | |
38 // This test turns the touch exploration mode on/off and confirms that events | |
39 // get rewritten when the touch exploration mode is on, and aren't affected | |
40 // after the touch exploration mode is turned off. | |
41 IN_PROC_BROWSER_TEST_F(TouchExplorationTest, ToggleOnOff) { | |
42 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( | |
43 browser(), | |
44 GURL("http://www.google.com/"), | |
dmazzoni
2014/04/30 06:08:35
I don't think we want browser tests navigating to
mfomitchev
2014/04/30 17:06:19
What I am actually trying to do here is wait for t
dmazzoni
2014/04/30 17:45:07
Does it work if you navigate to about:blank or chr
mfomitchev
2014/04/30 19:19:30
Looks like it's flaky with chrome://version. This
sadrul
2014/04/30 21:12:02
You can just load a data url (e.g. 'data:text/html
mfomitchev
2014/04/30 21:33:53
Will it always work though? I am concerned it coul
| |
45 1); | |
46 scoped_ptr<ui::test::TestEventHandler> | |
47 event_handler(new ui::test::TestEventHandler()); | |
48 aura::Window* root_window = ash::Shell::GetInstance()->GetPrimaryRootWindow(); | |
49 root_window->AddPreTargetHandler(event_handler.get()); | |
50 SwitchTouchExplorationMode(true); | |
51 aura::test::EventGenerator generator(root_window); | |
52 aura::client::CursorClient* cursor_client = | |
53 aura::client::GetCursorClient(root_window); | |
54 | |
55 generator.PressTouchId(1); | |
56 // Number of mouse events may be greater than 1 because of ET_MOUSE_ENTERED. | |
57 EXPECT_GT(event_handler->num_mouse_events(), 0); | |
58 EXPECT_EQ(event_handler->num_touch_events(), 0); | |
59 EXPECT_FALSE(cursor_client->IsCursorVisible()); | |
60 event_handler->Reset(); | |
61 | |
62 SwitchTouchExplorationMode(false); | |
63 generator.MoveTouchId(gfx::Point(11, 12), 1); | |
64 EXPECT_EQ(event_handler->num_mouse_events(), 0); | |
65 EXPECT_EQ(event_handler->num_touch_events(), 1); | |
66 event_handler->Reset(); | |
67 | |
68 SwitchTouchExplorationMode(true); | |
69 generator.PressTouchId(2); | |
70 EXPECT_GT(event_handler->num_mouse_events(), 0); | |
71 EXPECT_EQ(event_handler->num_touch_events(), 0); | |
72 | |
73 SwitchTouchExplorationMode(false); | |
74 root_window->RemovePreTargetHandler(event_handler.get()); | |
75 } | |
76 | |
77 } // namespace ui | |
OLD | NEW |