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..6124bad060d3d75db0cc7063e107651c8b4be9b6 |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/accessibility/touch_exploration_controller_browsertest.cc |
| @@ -0,0 +1,90 @@ |
| +// 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/ash_switches.h" |
| +#include "ash/shell.h" |
| +#include "ash/test/ash_test_base.h" |
| +#include "base/command_line.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/aura/window_tree_host.h" |
| +#include "ui/compositor/compositor.h" |
| +#include "ui/compositor/test/draw_waiter_for_test.h" |
| +#include "ui/events/test/test_event_handler.h" |
| + |
| +namespace ui { |
| + |
| +class TouchExplorationTest : public InProcessBrowserTest { |
| + public: |
| + TouchExplorationTest() { |
| + CommandLine::ForCurrentProcess()->AppendSwitch( |
| + ash::switches::kAshEnableTouchExplorationMode); |
| + } |
| + 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) { |
| + aura::Window* root_window = ash::Shell::GetInstance()->GetPrimaryRootWindow(); |
| + |
| + // TODO (mfomitchev): If the test is run by itself, there is a resize at the |
| + // very beginning. An in-progress resize creates a "resize lock" in |
| + // RenderWidgetHostViewAura, which calls |
| + // WindowEventDispatcher::HoldPointerMoves(), which prevents mouse events from |
| + // coming through. The below ensures the resize completes before the test is |
| + // executed, but sadrul@ says the resize shouldn't be event happening, so |
| + // this needs to be looked at further. |
| + ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( |
| + browser(), |
| + GURL("chrome://version"), |
|
sadrul
2014/05/02 15:47:24
This still looks bad. We have a lot of browser-tes
mfomitchev
2014/05/02 17:33:57
Navigating to a URL is just a hack to have the res
dmazzoni
2014/05/02 18:28:30
Does the window size actually change? Could you ju
mfomitchev
2014/05/02 19:22:53
Yes, it does. I am not sure why - sadrul@ seems to
|
| + 1); |
| + ui::Compositor* compositor = root_window->GetHost()->compositor(); |
| + compositor->ScheduleDraw(); |
| + ui::DrawWaiterForTest::WaitForCommit(compositor); |
| + |
| + scoped_ptr<ui::test::TestEventHandler> |
| + event_handler(new ui::test::TestEventHandler()); |
| + root_window->AddPreTargetHandler(event_handler.get()); |
| + SwitchTouchExplorationMode(true); |
| + aura::test::EventGenerator generator(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(0, event_handler->num_touch_events()); |
| + event_handler->Reset(); |
| + |
| + SwitchTouchExplorationMode(false); |
| + generator.MoveTouchId(gfx::Point(11, 12), 1); |
| + EXPECT_EQ(0, event_handler->num_mouse_events()); |
| + EXPECT_EQ(1, event_handler->num_touch_events()); |
| + event_handler->Reset(); |
| + |
| + SwitchTouchExplorationMode(true); |
| + generator.PressTouchId(2); |
| + EXPECT_GT(event_handler->num_mouse_events(), 0); |
| + EXPECT_EQ(0, event_handler->num_touch_events()); |
| + |
| + SwitchTouchExplorationMode(false); |
| + root_window->RemovePreTargetHandler(event_handler.get()); |
| +} |
| + |
| +} // namespace ui |