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 acks are sent synchronously, while Tap acks are asynchronous. | 372 // Tap Down and Tap acks are sent synchronously. |
| 373 touch_editable->WaitForSelectionChangeCallback(); |
373 touch_editable->Reset(); | 374 touch_editable->Reset(); |
374 touch_editable->WaitForGestureAck(); | |
375 touch_editable->WaitForSelectionChangeCallback(); | |
376 | 375 |
377 // Check if cursor handle is showing. | 376 // Check if cursor handle is showing. |
378 EXPECT_NE(ui::TEXT_INPUT_TYPE_NONE, GetTextInputType(touch_editable)); | 377 EXPECT_NE(ui::TEXT_INPUT_TYPE_NONE, GetTextInputType(touch_editable)); |
379 EXPECT_TRUE(GetTouchSelectionController(touch_editable)); | 378 EXPECT_TRUE(GetTouchSelectionController(touch_editable)); |
380 | 379 |
381 scoped_ptr<base::Value> value = | 380 scoped_ptr<base::Value> value = |
382 content::ExecuteScriptAndGetValue(main_frame, "get_cursor_position()"); | 381 content::ExecuteScriptAndGetValue(main_frame, "get_cursor_position()"); |
383 int cursor_pos = -1; | 382 int cursor_pos = -1; |
384 value->GetAsInteger(&cursor_pos); | 383 value->GetAsInteger(&cursor_pos); |
385 EXPECT_NE(-1, cursor_pos); | 384 EXPECT_NE(-1, cursor_pos); |
386 | 385 |
387 // Move the cursor handle. | 386 // Move the cursor handle. |
388 generator.GestureScrollSequence( | 387 generator.GestureScrollSequence( |
389 gfx::Point(50, 59), | 388 gfx::Point(50, 59), |
390 gfx::Point(10, 59), | 389 gfx::Point(10, 59), |
391 base::TimeDelta::FromMilliseconds(20), | 390 base::TimeDelta::FromMilliseconds(20), |
392 1); | 391 1); |
393 touch_editable->WaitForSelectionChangeCallback(); | 392 touch_editable->WaitForSelectionChangeCallback(); |
394 EXPECT_TRUE(GetTouchSelectionController(touch_editable)); | 393 EXPECT_TRUE(GetTouchSelectionController(touch_editable)); |
395 value = content::ExecuteScriptAndGetValue(main_frame, | 394 value = content::ExecuteScriptAndGetValue(main_frame, |
396 "get_cursor_position()"); | 395 "get_cursor_position()"); |
397 int new_cursor_pos = -1; | 396 int new_cursor_pos = -1; |
398 value->GetAsInteger(&new_cursor_pos); | 397 value->GetAsInteger(&new_cursor_pos); |
399 EXPECT_NE(-1, new_cursor_pos); | 398 EXPECT_NE(-1, new_cursor_pos); |
400 // Cursor should have moved. | 399 // Cursor should have moved. |
401 EXPECT_NE(new_cursor_pos, cursor_pos); | 400 EXPECT_NE(new_cursor_pos, cursor_pos); |
402 } | 401 } |
403 | 402 |
404 } // namespace content | 403 } // namespace content |
OLD | NEW |