Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: chrome/browser/chromeos/accessibility/touch_exploration_controller_browsertest.cc

Issue 240333007: wip: Second crack at implementing the touch exploration mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding a flag to disable the touch exploration mode. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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/"),
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698