Chromium Code Reviews| Index: chrome/browser/chromeos/accessibility/touch_exploration_controller_browsertest.cc |
| diff --git a/chrome/browser/chromeos/accessibility/touch_exploration_controller_browsertest.cc b/chrome/browser/chromeos/accessibility/touch_exploration_controller_browsertest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9739938c539aa37cc05275821335671e0df38360 |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/accessibility/touch_exploration_controller_browsertest.cc |
| @@ -0,0 +1,77 @@ |
| +// Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ui/chromeos/touch_exploration_controller.h" |
| + |
| +#include "ash/accessibility_delegate.h" |
| +#include "ash/shell.h" |
| +#include "ash/test/ash_test_base.h" |
| +#include "base/time/time.h" |
| +#include "chrome/test/base/in_process_browser_test.h" |
| +#include "chrome/test/base/ui_test_utils.h" |
| +#include "ui/aura/test/event_generator.h" |
| +#include "ui/events/event.h" |
| +#include "ui/events/event_utils.h" |
| +#include "ui/events/test/test_event_handler.h" |
| +#include "ui/gfx/geometry/point.h" |
| + |
| +namespace ui { |
| + |
| +class TouchExplorationTest : public InProcessBrowserTest { |
| + public: |
| + TouchExplorationTest() {} |
| + virtual ~TouchExplorationTest() {} |
| + |
| + protected: |
| + void SwitchTouchExplorationMode(bool on) { |
| + ash::AccessibilityDelegate* ad = |
| + ash::Shell::GetInstance()->accessibility_delegate(); |
| + if (on != ad->IsSpokenFeedbackEnabled()) |
| + ad->ToggleSpokenFeedback(ash::A11Y_NOTIFICATION_NONE); |
| + } |
| + |
| +private: |
| + DISALLOW_COPY_AND_ASSIGN(TouchExplorationTest); |
| +}; |
| + |
| +// This test turns the touch exploration mode on/off and confirms that events |
| +// get rewritten when the touch exploration mode is on, and aren't affected |
| +// after the touch exploration mode is turned off. |
| +IN_PROC_BROWSER_TEST_F(TouchExplorationTest, ToggleOnOff) { |
| + ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( |
| + browser(), |
| + 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
|
| + 1); |
| + scoped_ptr<ui::test::TestEventHandler> |
| + event_handler(new ui::test::TestEventHandler()); |
| + aura::Window* root_window = ash::Shell::GetInstance()->GetPrimaryRootWindow(); |
| + root_window->AddPreTargetHandler(event_handler.get()); |
| + SwitchTouchExplorationMode(true); |
| + aura::test::EventGenerator generator(root_window); |
| + aura::client::CursorClient* cursor_client = |
| + aura::client::GetCursorClient(root_window); |
| + |
| + generator.PressTouchId(1); |
| + // Number of mouse events may be greater than 1 because of ET_MOUSE_ENTERED. |
| + EXPECT_GT(event_handler->num_mouse_events(), 0); |
| + EXPECT_EQ(event_handler->num_touch_events(), 0); |
| + EXPECT_FALSE(cursor_client->IsCursorVisible()); |
| + event_handler->Reset(); |
| + |
| + SwitchTouchExplorationMode(false); |
| + generator.MoveTouchId(gfx::Point(11, 12), 1); |
| + EXPECT_EQ(event_handler->num_mouse_events(), 0); |
| + EXPECT_EQ(event_handler->num_touch_events(), 1); |
| + event_handler->Reset(); |
| + |
| + SwitchTouchExplorationMode(true); |
| + generator.PressTouchId(2); |
| + EXPECT_GT(event_handler->num_mouse_events(), 0); |
| + EXPECT_EQ(event_handler->num_touch_events(), 0); |
| + |
| + SwitchTouchExplorationMode(false); |
| + root_window->RemovePreTargetHandler(event_handler.get()); |
| +} |
| + |
| +} // namespace ui |