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

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

Issue 406413004: Cleanups for aura/test/event_generator.h (resolve TODOs) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix gn 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 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"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "content/browser/web_contents/web_contents_impl.h" 12 #include "content/browser/web_contents/web_contents_impl.h"
13 #include "content/browser/web_contents/web_contents_view_aura.h" 13 #include "content/browser/web_contents/web_contents_view_aura.h"
14 #include "content/public/browser/render_frame_host.h" 14 #include "content/public/browser/render_frame_host.h"
15 #include "content/public/common/content_switches.h" 15 #include "content/public/common/content_switches.h"
16 #include "content/public/test/browser_test_utils.h" 16 #include "content/public/test/browser_test_utils.h"
17 #include "content/public/test/content_browser_test.h" 17 #include "content/public/test/content_browser_test.h"
18 #include "content/public/test/content_browser_test_utils.h" 18 #include "content/public/test/content_browser_test_utils.h"
19 #include "content/public/test/test_utils.h" 19 #include "content/public/test/test_utils.h"
20 #include "content/shell/browser/shell.h" 20 #include "content/shell/browser/shell.h"
21 #include "third_party/WebKit/public/web/WebInputEvent.h" 21 #include "third_party/WebKit/public/web/WebInputEvent.h"
22 #include "ui/aura/test/event_generator.h"
23 #include "ui/aura/window.h" 22 #include "ui/aura/window.h"
24 #include "ui/aura/window_tree_host.h" 23 #include "ui/aura/window_tree_host.h"
25 #include "ui/base/ui_base_switches.h" 24 #include "ui/base/ui_base_switches.h"
26 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 25 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
27 #include "ui/events/event_utils.h" 26 #include "ui/events/event_utils.h"
27 #include "ui/events/test/event_generator.h"
28 28
29 using blink::WebInputEvent; 29 using blink::WebInputEvent;
30 30
31 namespace content { 31 namespace content {
32 32
33 class TestTouchEditableImplAura : public TouchEditableImplAura { 33 class TestTouchEditableImplAura : public TouchEditableImplAura {
34 public: 34 public:
35 TestTouchEditableImplAura() 35 TestTouchEditableImplAura()
36 : selection_changed_callback_arrived_(false), 36 : selection_changed_callback_arrived_(false),
37 waiting_for_selection_changed_callback_(false), 37 waiting_for_selection_changed_callback_(false),
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 WebContentsImpl* web_contents = 142 WebContentsImpl* web_contents =
143 static_cast<WebContentsImpl*>(shell()->web_contents()); 143 static_cast<WebContentsImpl*>(shell()->web_contents());
144 RenderFrameHost* main_frame = web_contents->GetMainFrame(); 144 RenderFrameHost* main_frame = web_contents->GetMainFrame();
145 WebContentsViewAura* view_aura = static_cast<WebContentsViewAura*>( 145 WebContentsViewAura* view_aura = static_cast<WebContentsViewAura*>(
146 web_contents->GetView()); 146 web_contents->GetView());
147 TestTouchEditableImplAura* touch_editable = new TestTouchEditableImplAura; 147 TestTouchEditableImplAura* touch_editable = new TestTouchEditableImplAura;
148 view_aura->SetTouchEditableForTest(touch_editable); 148 view_aura->SetTouchEditableForTest(touch_editable);
149 RenderWidgetHostViewAura* rwhva = static_cast<RenderWidgetHostViewAura*>( 149 RenderWidgetHostViewAura* rwhva = static_cast<RenderWidgetHostViewAura*>(
150 web_contents->GetRenderWidgetHostView()); 150 web_contents->GetRenderWidgetHostView());
151 aura::Window* content = web_contents->GetContentNativeView(); 151 aura::Window* content = web_contents->GetContentNativeView();
152 aura::test::EventGenerator generator(content->GetRootWindow(), content); 152 ui::test::EventGenerator generator(content->GetRootWindow(), content);
153 gfx::Rect bounds = content->GetBoundsInRootWindow(); 153 gfx::Rect bounds = content->GetBoundsInRootWindow();
154 154
155 touch_editable->Reset(); 155 touch_editable->Reset();
156 ExecuteSyncJSFunction(main_frame, "select_all_text()"); 156 ExecuteSyncJSFunction(main_frame, "select_all_text()");
157 touch_editable->WaitForSelectionChangeCallback(); 157 touch_editable->WaitForSelectionChangeCallback();
158 158
159 // Tap inside selection to bring up selection handles. 159 // Tap inside selection to bring up selection handles.
160 generator.GestureTapAt(gfx::Point(bounds.x() + 10, bounds.y() + 10)); 160 generator.GestureTapAt(gfx::Point(bounds.x() + 10, bounds.y() + 10));
161 EXPECT_EQ(GetRenderWidgetHostViewAura(touch_editable), rwhva); 161 EXPECT_EQ(GetRenderWidgetHostViewAura(touch_editable), rwhva);
162 162
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 WebContentsImpl* web_contents = 318 WebContentsImpl* web_contents =
319 static_cast<WebContentsImpl*>(shell()->web_contents()); 319 static_cast<WebContentsImpl*>(shell()->web_contents());
320 RenderFrameHost* main_frame = web_contents->GetMainFrame(); 320 RenderFrameHost* main_frame = web_contents->GetMainFrame();
321 WebContentsViewAura* view_aura = static_cast<WebContentsViewAura*>( 321 WebContentsViewAura* view_aura = static_cast<WebContentsViewAura*>(
322 web_contents->GetView()); 322 web_contents->GetView());
323 TestTouchEditableImplAura* touch_editable = new TestTouchEditableImplAura; 323 TestTouchEditableImplAura* touch_editable = new TestTouchEditableImplAura;
324 view_aura->SetTouchEditableForTest(touch_editable); 324 view_aura->SetTouchEditableForTest(touch_editable);
325 RenderWidgetHostViewAura* rwhva = static_cast<RenderWidgetHostViewAura*>( 325 RenderWidgetHostViewAura* rwhva = static_cast<RenderWidgetHostViewAura*>(
326 web_contents->GetRenderWidgetHostView()); 326 web_contents->GetRenderWidgetHostView());
327 aura::Window* content = web_contents->GetContentNativeView(); 327 aura::Window* content = web_contents->GetContentNativeView();
328 aura::test::EventGenerator generator(content->GetRootWindow(), content); 328 ui::test::EventGenerator generator(content->GetRootWindow(), content);
329 gfx::Rect bounds = content->GetBoundsInRootWindow(); 329 gfx::Rect bounds = content->GetBoundsInRootWindow();
330 EXPECT_EQ(GetRenderWidgetHostViewAura(touch_editable), rwhva); 330 EXPECT_EQ(GetRenderWidgetHostViewAura(touch_editable), rwhva);
331 331
332 ExecuteSyncJSFunction(main_frame, "focus_textfield()"); 332 ExecuteSyncJSFunction(main_frame, "focus_textfield()");
333 touch_editable->WaitForSelectionChangeCallback(); 333 touch_editable->WaitForSelectionChangeCallback();
334 334
335 // Tap textfield 335 // Tap textfield
336 touch_editable->Reset(); 336 touch_editable->Reset();
337 generator.GestureTapAt(gfx::Point(bounds.x() + 50, bounds.y() + 40)); 337 generator.GestureTapAt(gfx::Point(bounds.x() + 50, bounds.y() + 40));
338 // Tap Down acks are sent synchronously, while Tap acks are asynchronous. 338 // Tap Down acks are sent synchronously, while Tap acks are asynchronous.
(...skipping 22 matching lines...) Expand all
361 value = content::ExecuteScriptAndGetValue(main_frame, 361 value = content::ExecuteScriptAndGetValue(main_frame,
362 "get_cursor_position()"); 362 "get_cursor_position()");
363 int new_cursor_pos = -1; 363 int new_cursor_pos = -1;
364 value->GetAsInteger(&new_cursor_pos); 364 value->GetAsInteger(&new_cursor_pos);
365 EXPECT_NE(-1, new_cursor_pos); 365 EXPECT_NE(-1, new_cursor_pos);
366 // Cursor should have moved. 366 // Cursor should have moved.
367 EXPECT_NE(new_cursor_pos, cursor_pos); 367 EXPECT_NE(new_cursor_pos, cursor_pos);
368 } 368 }
369 369
370 } // namespace content 370 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698