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

Side by Side Diff: content/browser/web_contents/touch_editable_impl_aura_browsertest.cc

Issue 23823004: Re-enable TouchCursorInTextfieldTest with some fixes and logs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added a TODO to remove logs Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 10, 287 10,
288 0, 288 0,
289 ui::EventTimeForNow(), 289 ui::EventTimeForNow(),
290 ui::GestureEventDetails( 290 ui::GestureEventDetails(
291 ui::ET_GESTURE_LONG_PRESS, 0, 0), 291 ui::ET_GESTURE_LONG_PRESS, 0, 0),
292 1); 292 1);
293 rwhva->OnGestureEvent(&scroll_end); 293 rwhva->OnGestureEvent(&scroll_end);
294 EXPECT_TRUE(touch_editable->touch_selection_controller_.get()); 294 EXPECT_TRUE(touch_editable->touch_selection_controller_.get());
295 } 295 }
296 296
297 // TODO(mohsen): Remove logs if the test showed no flakiness anymore.
297 void TestTouchCursorInTextfield() { 298 void TestTouchCursorInTextfield() {
298 ASSERT_NO_FATAL_FAILURE( 299 ASSERT_NO_FATAL_FAILURE(
299 StartTestWithPage("files/touch_selection.html")); 300 StartTestWithPage("files/touch_selection.html"));
300 WebContentsImpl* web_contents = 301 WebContentsImpl* web_contents =
301 static_cast<WebContentsImpl*>(shell()->web_contents()); 302 static_cast<WebContentsImpl*>(shell()->web_contents());
302 RenderViewHostImpl* view_host = static_cast<RenderViewHostImpl*>( 303 RenderViewHostImpl* view_host = static_cast<RenderViewHostImpl*>(
303 web_contents->GetRenderViewHost()); 304 web_contents->GetRenderViewHost());
304 WebContentsViewAura* view_aura = static_cast<WebContentsViewAura*>( 305 WebContentsViewAura* view_aura = static_cast<WebContentsViewAura*>(
305 web_contents->GetView()); 306 web_contents->GetView());
306 TestTouchEditableImplAura* touch_editable = new TestTouchEditableImplAura; 307 TestTouchEditableImplAura* touch_editable = new TestTouchEditableImplAura;
307 view_aura->SetTouchEditableForTest(touch_editable); 308 view_aura->SetTouchEditableForTest(touch_editable);
308 RenderWidgetHostViewAura* rwhva = static_cast<RenderWidgetHostViewAura*>( 309 RenderWidgetHostViewAura* rwhva = static_cast<RenderWidgetHostViewAura*>(
309 web_contents->GetRenderWidgetHostView()); 310 web_contents->GetRenderWidgetHostView());
310 aura::Window* content = web_contents->GetView()->GetContentNativeView(); 311 aura::Window* content = web_contents->GetView()->GetContentNativeView();
311 aura::test::EventGenerator generator(content->GetRootWindow(), content); 312 aura::test::EventGenerator generator(content->GetRootWindow(), content);
312 gfx::Rect bounds = content->GetBoundsInRootWindow(); 313 gfx::Rect bounds = content->GetBoundsInRootWindow();
313 EXPECT_EQ(touch_editable->rwhva_, rwhva); 314 EXPECT_EQ(touch_editable->rwhva_, rwhva);
315
316 LOG(INFO) << "Focus the textfield.";
314 ExecuteSyncJSFunction(view_host, "focus_textfield()"); 317 ExecuteSyncJSFunction(view_host, "focus_textfield()");
315 318
316 // Tap textfield 319 // Tap textfield
317 touch_editable->Reset(); 320 touch_editable->Reset();
321 LOG(INFO) << "Tap in the textfield.";
318 generator.GestureTapAt(gfx::Point(bounds.x() + 50, bounds.y() + 40)); 322 generator.GestureTapAt(gfx::Point(bounds.x() + 50, bounds.y() + 40));
323 LOG(INFO) << "Wait for tap-down ACK.";
319 touch_editable->WaitForGestureAck(); // Wait for Tap Down Ack 324 touch_editable->WaitForGestureAck(); // Wait for Tap Down Ack
320 touch_editable->Reset(); 325 touch_editable->Reset();
326 LOG(INFO) << "Wait for tap ACK.";
321 touch_editable->WaitForGestureAck(); // Wait for Tap Ack. 327 touch_editable->WaitForGestureAck(); // Wait for Tap Ack.
322 328
329 LOG(INFO) << "Test the touch selection handle.";
323 // Check if cursor handle is showing. 330 // Check if cursor handle is showing.
324 ui::TouchSelectionController* controller = 331 ui::TouchSelectionController* controller =
325 touch_editable->touch_selection_controller_.get(); 332 touch_editable->touch_selection_controller_.get();
326 EXPECT_NE(ui::TEXT_INPUT_TYPE_NONE, touch_editable->text_input_type_); 333 EXPECT_NE(ui::TEXT_INPUT_TYPE_NONE, touch_editable->text_input_type_);
327 EXPECT_TRUE(controller); 334 EXPECT_TRUE(controller);
328 335
336 LOG(INFO) << "Test cursor position.";
329 scoped_ptr<base::Value> value = 337 scoped_ptr<base::Value> value =
330 content::ExecuteScriptAndGetValue(view_host, "get_cursor_position()"); 338 content::ExecuteScriptAndGetValue(view_host, "get_cursor_position()");
331 int cursor_pos = -1; 339 int cursor_pos = -1;
332 value->GetAsInteger(&cursor_pos); 340 value->GetAsInteger(&cursor_pos);
333 EXPECT_NE(-1, cursor_pos); 341 EXPECT_NE(-1, cursor_pos);
334 342
335 // Move the cursor handle. 343 // Move the cursor handle.
344 LOG(INFO) << "Drag the touch selection handle to change its position.";
336 generator.GestureScrollSequence( 345 generator.GestureScrollSequence(
337 gfx::Point(50, 59), 346 gfx::Point(50, 59),
338 gfx::Point(10, 59), 347 gfx::Point(10, 59),
339 base::TimeDelta::FromMilliseconds(20), 348 base::TimeDelta::FromMilliseconds(20),
340 1); 349 1);
350 LOG(INFO) << "Wait for cursor position to change.";
351 touch_editable->WaitForSelectionChangeCallback();
352 LOG(INFO) << "Check cursor position is changed.";
341 EXPECT_TRUE(touch_editable->touch_selection_controller_.get()); 353 EXPECT_TRUE(touch_editable->touch_selection_controller_.get());
342 value = content::ExecuteScriptAndGetValue( 354 value = content::ExecuteScriptAndGetValue(view_host,
343 view_host, "get_cursor_position()"); 355 "get_cursor_position()");
344 int new_cursor_pos = -1; 356 int new_cursor_pos = -1;
345 value->GetAsInteger(&new_cursor_pos); 357 value->GetAsInteger(&new_cursor_pos);
346 EXPECT_NE(-1, new_cursor_pos); 358 EXPECT_NE(-1, new_cursor_pos);
347 // Cursor should have moved. 359 // Cursor should have moved.
348 EXPECT_NE(new_cursor_pos, cursor_pos); 360 EXPECT_NE(new_cursor_pos, cursor_pos);
349 } 361 }
350 362
351 private: 363 private:
352 DISALLOW_COPY_AND_ASSIGN(TouchEditableImplAuraTest); 364 DISALLOW_COPY_AND_ASSIGN(TouchEditableImplAuraTest);
353 }; 365 };
354 366
355 IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest, 367 IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest,
356 TouchSelectionOriginatingFromWebpageTest) { 368 TouchSelectionOriginatingFromWebpageTest) {
357 TestTouchSelectionOriginatingFromWebpage(); 369 TestTouchSelectionOriginatingFromWebpage();
358 } 370 }
359 371
360 IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest, 372 IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest,
361 TestTouchSelectionHiddenWhenScrolling) { 373 TestTouchSelectionHiddenWhenScrolling) {
362 TestTouchSelectionHiddenWhenScrolling(); 374 TestTouchSelectionHiddenWhenScrolling();
363 } 375 }
364 376
365 IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest, 377 IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest,
366 TouchSelectionOnLongPressTest) { 378 TouchSelectionOnLongPressTest) {
367 TestTouchSelectionOnLongPress(); 379 TestTouchSelectionOnLongPress();
368 } 380 }
369 381
370 // TODO(miu): Disabled test due to flakiness. http://crbug.com/235991
371 IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest, 382 IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest,
372 DISABLED_TouchCursorInTextfieldTest) { 383 TouchCursorInTextfieldTest) {
373 TestTouchCursorInTextfield(); 384 TestTouchCursorInTextfield();
374 } 385 }
375 386
376 } // namespace content 387 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/test/data/touch_selection.html » ('j') | content/test/data/touch_selection.html » ('J')

Powered by Google App Engine
This is Rietveld 408576698