OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/web_contents/touch_editable_impl_aura.h" | 5 #include "content/browser/web_contents/touch_editable_impl_aura.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 aura::test::EventGenerator generator(content->GetRootWindow(), content); | 362 aura::test::EventGenerator generator(content->GetRootWindow(), content); |
363 gfx::Rect bounds = content->GetBoundsInRootWindow(); | 363 gfx::Rect bounds = content->GetBoundsInRootWindow(); |
364 EXPECT_EQ(GetRenderWidgetHostViewAura(touch_editable), rwhva); | 364 EXPECT_EQ(GetRenderWidgetHostViewAura(touch_editable), rwhva); |
365 | 365 |
366 ExecuteSyncJSFunction(main_frame, "focus_textfield()"); | 366 ExecuteSyncJSFunction(main_frame, "focus_textfield()"); |
367 touch_editable->WaitForSelectionChangeCallback(); | 367 touch_editable->WaitForSelectionChangeCallback(); |
368 | 368 |
369 // Tap textfield | 369 // Tap textfield |
370 touch_editable->Reset(); | 370 touch_editable->Reset(); |
371 generator.GestureTapAt(gfx::Point(bounds.x() + 50, bounds.y() + 40)); | 371 generator.GestureTapAt(gfx::Point(bounds.x() + 50, bounds.y() + 40)); |
372 // Tap Down and Tap acks are sent synchronously. | 372 // Tap Down acks are sent synchronously, while Tap acks are asynchronous. |
| 373 touch_editable->Reset(); |
| 374 touch_editable->WaitForGestureAck(); |
373 touch_editable->WaitForSelectionChangeCallback(); | 375 touch_editable->WaitForSelectionChangeCallback(); |
374 touch_editable->Reset(); | |
375 | 376 |
376 // Check if cursor handle is showing. | 377 // Check if cursor handle is showing. |
377 EXPECT_NE(ui::TEXT_INPUT_TYPE_NONE, GetTextInputType(touch_editable)); | 378 EXPECT_NE(ui::TEXT_INPUT_TYPE_NONE, GetTextInputType(touch_editable)); |
378 EXPECT_TRUE(GetTouchSelectionController(touch_editable)); | 379 EXPECT_TRUE(GetTouchSelectionController(touch_editable)); |
379 | 380 |
380 scoped_ptr<base::Value> value = | 381 scoped_ptr<base::Value> value = |
381 content::ExecuteScriptAndGetValue(main_frame, "get_cursor_position()"); | 382 content::ExecuteScriptAndGetValue(main_frame, "get_cursor_position()"); |
382 int cursor_pos = -1; | 383 int cursor_pos = -1; |
383 value->GetAsInteger(&cursor_pos); | 384 value->GetAsInteger(&cursor_pos); |
384 EXPECT_NE(-1, cursor_pos); | 385 EXPECT_NE(-1, cursor_pos); |
385 | 386 |
386 // Move the cursor handle. | 387 // Move the cursor handle. |
387 generator.GestureScrollSequence( | 388 generator.GestureScrollSequence( |
388 gfx::Point(50, 59), | 389 gfx::Point(50, 59), |
389 gfx::Point(10, 59), | 390 gfx::Point(10, 59), |
390 base::TimeDelta::FromMilliseconds(20), | 391 base::TimeDelta::FromMilliseconds(20), |
391 1); | 392 1); |
392 touch_editable->WaitForSelectionChangeCallback(); | 393 touch_editable->WaitForSelectionChangeCallback(); |
393 EXPECT_TRUE(GetTouchSelectionController(touch_editable)); | 394 EXPECT_TRUE(GetTouchSelectionController(touch_editable)); |
394 value = content::ExecuteScriptAndGetValue(main_frame, | 395 value = content::ExecuteScriptAndGetValue(main_frame, |
395 "get_cursor_position()"); | 396 "get_cursor_position()"); |
396 int new_cursor_pos = -1; | 397 int new_cursor_pos = -1; |
397 value->GetAsInteger(&new_cursor_pos); | 398 value->GetAsInteger(&new_cursor_pos); |
398 EXPECT_NE(-1, new_cursor_pos); | 399 EXPECT_NE(-1, new_cursor_pos); |
399 // Cursor should have moved. | 400 // Cursor should have moved. |
400 EXPECT_NE(new_cursor_pos, cursor_pos); | 401 EXPECT_NE(new_cursor_pos, cursor_pos); |
401 } | 402 } |
402 | 403 |
403 } // namespace content | 404 } // namespace content |
OLD | NEW |