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

Unified Diff: chrome/browser/chromeos/accessibility/touch_exploration_controller_browsertest.cc

Issue 359453003: Added accurate TouchToMouseMode testing to SplitTap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
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 2eaf3c7105c762b390caecab60893a86efd665c8..f19f5593d74a257ea4adeeedde1fa5df560f35ea 100644
--- a/chrome/browser/chromeos/accessibility/touch_exploration_controller_browsertest.cc
+++ b/chrome/browser/chromeos/accessibility/touch_exploration_controller_browsertest.cc
@@ -14,6 +14,7 @@
#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"
@@ -75,21 +76,20 @@ IN_PROC_BROWSER_TEST_F(TouchExplorationTest, ToggleOnOff) {
base::TimeDelta initial_time = Now();
ui::TouchEvent initial_press(
ui::ET_TOUCH_PRESSED, gfx::Point(100, 200), 1, initial_time);
+ generator.Dispatch(&initial_press);
+
+ // Since the touch exploration controller doesn't know if the user is
+ // double-tapping or not, touch exploration is only initiated if the
+ // user moves more than 8 pixels away from the initial location (the "slop"),
+ // or after 300 ms has elapsed if the finger does not move fast enough.
float delta_time =
- (initial_press.location() - gfx::Point(109,209)).Length() /
+ (initial_press.location() - gfx::Point(109, 209)).Length() /
gesture_detector_config_.minimum_swipe_velocity;
ui::TouchEvent touch_move(
ui::ET_TOUCH_MOVED,
gfx::Point(109, 209),
1,
initial_time + base::TimeDelta::FromSecondsD(delta_time));
-
- generator.Dispatch(&initial_press);
-
- // Since the touch exploration controller doesn't know if the user is
- // double-tapping or not, touch exploration is only initiated if the
- // user moves more than 8 pixels away from the initial location (the "slop"),
- // or after 300 ms has elapsed if the finger does not move fast enough.
generator.Dispatch(&touch_move);
// Number of mouse events may be greater than 1 because of ET_MOUSE_ENTERED.
@@ -125,4 +125,73 @@ 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);
mfomitchev 2014/07/09 13:26:01 Can you please put this setup logic into SetupOnMa
evy 2014/07/09 18:20:19 Done.
+ 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,
mfomitchev 2014/07/09 13:26:02 This comment needs fixing
evy 2014/07/09 18:20:19 Done.
+ // hidden after move.
+ base::TimeDelta initial_time = Now();
+ ui::TouchEvent initial_press(
+ ui::ET_TOUCH_PRESSED, gfx::Point(100, 200), 1, initial_time);
+ generator.Dispatch(&initial_press);
+ EXPECT_TRUE(cursor_client->IsMouseEventsEnabled());
+ EXPECT_TRUE(cursor_client->IsCursorVisible());
+
+ // Initiate touch explore by moving out of the slop slowly.
+ float delta_time =
+ (initial_press.location() - gfx::Point(109, 209)).Length() /
mfomitchev 2014/07/09 13:26:01 If you want to move slower that min swipe velocity
evy 2014/07/09 18:20:19 I changed this to wait for the timeout instead. I
+ gesture_detector_config_.minimum_swipe_velocity;
+ ui::TouchEvent touch_move(
+ ui::ET_TOUCH_MOVED,
+ gfx::Point(109, 209),
+ 1,
+ initial_time + base::TimeDelta::FromSecondsD(delta_time));
+ generator.Dispatch(&touch_move);
+ 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());
+}
+
} // namespace ui
« no previous file with comments | « no previous file | ui/chromeos/touch_exploration_controller.cc » ('j') | ui/chromeos/touch_exploration_controller_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698