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

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

Issue 261863002: Implementation of the Touch Exploration Mode - Part II (ash) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@touch_exploration_new_UI
Patch Set: Moving CrosAccessibilityObserver to anonymous namespace. 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
« no previous file with comments | « ash/root_window_controller.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 virtual ~TouchExplorationTest() {}
26
27 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
28 command_line->AppendSwitch(ash::switches::kAshEnableTouchExplorationMode);
29 }
30
31 protected:
32 void SwitchTouchExplorationMode(bool on) {
33 ash::AccessibilityDelegate* ad =
34 ash::Shell::GetInstance()->accessibility_delegate();
35 if (on != ad->IsSpokenFeedbackEnabled())
36 ad->ToggleSpokenFeedback(ash::A11Y_NOTIFICATION_NONE);
37 }
38
39 private:
40 DISALLOW_COPY_AND_ASSIGN(TouchExplorationTest);
41 };
42
43 IN_PROC_BROWSER_TEST_F(TouchExplorationTest, PRE_ToggleOnOff) {
44 // TODO (mfomitchev): If the test is run by itself, there is a resize at the
45 // very beginning. An in-progress resize creates a "resize lock" in
46 // RenderWidgetHostViewAura, which calls
47 // WindowEventDispatcher::HoldPointerMoves(), which prevents mouse events from
48 // coming through. Adding a PRE_ test ensures the resize completes before the
49 // actual test is executed. sadrul@ says the resize shouldn't be even
50 // happening, so this needs to be looked at further.
51 }
52
53 // This test turns the touch exploration mode on/off and confirms that events
54 // get rewritten when the touch exploration mode is on, and aren't affected
55 // after the touch exploration mode is turned off.
56 IN_PROC_BROWSER_TEST_F(TouchExplorationTest, ToggleOnOff) {
57 aura::Window* root_window = ash::Shell::GetInstance()->GetPrimaryRootWindow();
58 scoped_ptr<ui::test::TestEventHandler>
59 event_handler(new ui::test::TestEventHandler());
60 root_window->AddPreTargetHandler(event_handler.get());
61 SwitchTouchExplorationMode(true);
62 aura::test::EventGenerator generator(root_window);
63
64 generator.PressTouchId(1);
65 // Number of mouse events may be greater than 1 because of ET_MOUSE_ENTERED.
66 EXPECT_GT(event_handler->num_mouse_events(), 0);
67 EXPECT_EQ(0, event_handler->num_touch_events());
68 event_handler->Reset();
69
70 SwitchTouchExplorationMode(false);
71 generator.MoveTouchId(gfx::Point(11, 12), 1);
72 EXPECT_EQ(0, event_handler->num_mouse_events());
73 EXPECT_EQ(1, event_handler->num_touch_events());
74 event_handler->Reset();
75
76 SwitchTouchExplorationMode(true);
77 generator.PressTouchId(2);
78 EXPECT_GT(event_handler->num_mouse_events(), 0);
79 EXPECT_EQ(0, event_handler->num_touch_events());
80
81 SwitchTouchExplorationMode(false);
82 root_window->RemovePreTargetHandler(event_handler.get());
83 }
84
85 } // namespace ui
OLDNEW
« no previous file with comments | « ash/root_window_controller.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698