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 |
index 148f1f3845c312b3d1e44ef60270c76375da8da1..a5d5abe7adcefcd9c555156fbf0ac1752fa65d67 100644 |
--- a/chrome/browser/chromeos/accessibility/touch_exploration_controller_browsertest.cc |
+++ b/chrome/browser/chromeos/accessibility/touch_exploration_controller_browsertest.cc |
@@ -5,13 +5,16 @@ |
#include "ui/chromeos/touch_exploration_controller.h" |
#include "ash/accessibility_delegate.h" |
+#include "ash/root_window_controller.h" |
#include "ash/shell.h" |
#include "ash/test/ash_test_base.h" |
+#include "base/test/simple_test_tick_clock.h" |
#include "chrome/browser/ui/browser.h" |
#include "chrome/browser/ui/tabs/tab_strip_model.h" |
#include "chrome/test/base/in_process_browser_test.h" |
#include "chrome/test/base/ui_test_utils.h" |
#include "content/public/test/browser_test_utils.h" |
+#include "ui/aura/client/cursor_client.h" |
#include "ui/aura/test/event_generator.h" |
#include "ui/aura/window_tree_host.h" |
#include "ui/compositor/compositor.h" |
@@ -22,9 +25,9 @@ namespace ui { |
class TouchExplorationTest : public InProcessBrowserTest { |
public: |
- TouchExplorationTest() {} |
+ TouchExplorationTest() |
+ : simulated_clock_(new base::SimpleTestTickClock()) {} |
virtual ~TouchExplorationTest() {} |
- |
protected: |
void SwitchTouchExplorationMode(bool on) { |
ash::AccessibilityDelegate* ad = |
@@ -32,6 +35,9 @@ class TouchExplorationTest : public InProcessBrowserTest { |
if (on != ad->IsSpokenFeedbackEnabled()) |
ad->ToggleSpokenFeedback(ash::A11Y_NOTIFICATION_NONE); |
} |
+ ui::GestureDetector::Config gesture_detector_config_; |
+ // Owned by |generator|. |
+ base::SimpleTestTickClock* simulated_clock_; |
private: |
DISALLOW_COPY_AND_ASSIGN(TouchExplorationTest); |
@@ -46,13 +52,14 @@ IN_PROC_BROWSER_TEST_F(TouchExplorationTest, ToggleOnOff) { |
// involves sending a resize message to the renderer process. Here we wait |
// for the resize ack to be received, because currently WindowEventDispatcher |
// has code to hold touch and mouse move events until resize is complete |
+ |
// (crbug.com/384342) which interferes with this test. |
content::WebContents* web_contents = |
browser()->tab_strip_model()->GetActiveWebContents(); |
content::WaitForResizeComplete(web_contents); |
aura::Window* root_window = ash::Shell::GetInstance()->GetPrimaryRootWindow(); |
- scoped_ptr<ui::test::TestEventHandler> |
- event_handler(new ui::test::TestEventHandler()); |
+ 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); |
@@ -86,4 +93,100 @@ IN_PROC_BROWSER_TEST_F(TouchExplorationTest, ToggleOnOff) { |
root_window->RemovePreTargetHandler(event_handler.get()); |
} |
+ |
+// This test makes sure that after the user clicks with split tap, |
+// they continue to touch exploration mode if the original touch exploration |
+// finger is still on the screen. |
+IN_PROC_BROWSER_TEST_F(TouchExplorationTest, SplitTapExplore) { |
+ content::WebContents* web_contents = |
+ browser()->tab_strip_model()->GetActiveWebContents(); |
+ content::WaitForResizeComplete(web_contents); |
+ aura::Window* root_window = ash::Shell::GetInstance()->GetPrimaryRootWindow(); |
+ 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); |
+ aura::client::CursorClient* cursor_client = |
+ aura::client::GetCursorClient(root_window); |
+ |
+ // Mouse events should show the cursor. |
+ generator.MoveMouseTo(gfx::Point(30, 31)); |
+ EXPECT_TRUE(cursor_client->IsMouseEventsEnabled()); |
+ EXPECT_TRUE(cursor_client->IsCursorVisible()); |
+ |
+ // After a press the cursor should be shown after immediately after press, |
+ // hidden after move. |
+ generator.set_current_location(gfx::Point(100, 200)); |
+ generator.PressTouchId(1); |
+ EXPECT_TRUE(cursor_client->IsMouseEventsEnabled()); |
+ EXPECT_TRUE(cursor_client->IsCursorVisible()); |
+ // Initiate touch explore by moving out of the slop. |
+ generator.MoveTouchId(gfx::Point(109, 209), 1); |
+ EXPECT_TRUE(cursor_client->IsMouseEventsEnabled()); |
+ EXPECT_FALSE(cursor_client->IsCursorVisible()); |
+ event_handler->Reset(); |
+ |
+ // Press and release with a second finger for split tap. This should send |
+ // touch press and release events which should send a click press and release. |
+ // Once the press is passed through, mouse events should be disabled. |
+ // Mouse events are reenabled after the release. |
+ generator.set_current_location(gfx::Point(102, 202)); |
+ generator.PressTouchId(2); |
+ EXPECT_FALSE(cursor_client->IsMouseEventsEnabled()); |
+ EXPECT_FALSE(cursor_client->IsCursorVisible()); |
+ generator.ReleaseTouchId(2); |
+ EXPECT_TRUE(cursor_client->IsMouseEventsEnabled()); |
+ EXPECT_FALSE(cursor_client->IsCursorVisible()); |
+ EXPECT_EQ(2, event_handler->num_touch_events()); |
+ event_handler->Reset(); |
+ |
+ // Continuing to move the touch exploration finger should send more mouse |
+ // events. |
+ generator.MoveTouchId(gfx::Point(509, 609), 1); |
+ EXPECT_EQ(0, event_handler->num_touch_events()); |
+ EXPECT_TRUE(cursor_client->IsMouseEventsEnabled()); |
+ EXPECT_FALSE(cursor_client->IsCursorVisible()); |
+ |
+ SwitchTouchExplorationMode(false); |
+ root_window->RemovePreTargetHandler(event_handler.get()); |
+} |
+ |
+// This test checks that the cursor is hidden after a user presses and waits |
+// for 300ms, which generates a mouse move. |
+IN_PROC_BROWSER_TEST_F(TouchExplorationTest, PressMouseMove) { |
+ content::WebContents* web_contents = |
+ browser()->tab_strip_model()->GetActiveWebContents(); |
+ content::WaitForResizeComplete(web_contents); |
mfomitchev
2014/07/02 16:46:47
Can you please put this setup logic into SetupOnMa
|
+ aura::Window* root_window = ash::Shell::GetInstance()->GetPrimaryRootWindow(); |
+ scoped_ptr<ui::test::TestEventHandler> |
+ event_handler(new ui::test::TestEventHandler()); |
+ root_window->AddPreTargetHandler(event_handler.get()); |
+ SwitchTouchExplorationMode(true); |
+ ash::RootWindowController* root_window_controller = |
+ ash::GetRootWindowController(root_window); |
+ ui::TouchExplorationController* touch_exploration_controller = |
+ root_window_controller->GetTouchExplorationController(); |
+ aura::test::EventGenerator generator(root_window); |
+ aura::client::CursorClient* cursor_client = |
+ aura::client::GetCursorClient(root_window); |
+ generator.SetTickClock(scoped_ptr<base::TickClock>(simulated_clock_)); |
mfomitchev
2014/07/02 16:46:47
I'd just make simulated_clock_ into a local variab
|
+ |
+ |
+ |
+ generator.set_current_location(gfx::Point(100, 200)); |
+ generator.PressTouchId(1); |
+ simulated_clock_->Advance(gesture_detector_config_.double_tap_timeout); |
+ touch_exploration_controller->CallTapTimerNowForTesting(); |
+ |
+ // A single touch and release will send a mouse move to that location. |
+ EXPECT_EQ(0, event_handler->num_touch_events()); |
+ EXPECT_GT(event_handler->num_mouse_events(), 0); |
+ EXPECT_TRUE(cursor_client->IsMouseEventsEnabled()); |
+ EXPECT_FALSE(cursor_client->IsCursorVisible()); |
+ |
+ SwitchTouchExplorationMode(false); |
+ root_window->RemovePreTargetHandler(event_handler.get()); |
+} |
+ |
} // namespace ui |