| 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" |
| 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" |
| 22 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
| 23 #include "ui/aura/window_tree_host.h" | 24 #include "ui/aura/window_tree_host.h" |
| 24 #include "ui/base/ui_base_switches.h" | 25 #include "ui/base/ui_base_switches.h" |
| 25 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 26 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 26 #include "ui/events/event_utils.h" | 27 #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 Loading... |
| 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 ui::test::EventGenerator generator(content->GetRootWindow(), content); | 152 aura::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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 WebContentsImpl* web_contents = | 324 WebContentsImpl* web_contents = |
| 325 static_cast<WebContentsImpl*>(shell()->web_contents()); | 325 static_cast<WebContentsImpl*>(shell()->web_contents()); |
| 326 RenderFrameHost* main_frame = web_contents->GetMainFrame(); | 326 RenderFrameHost* main_frame = web_contents->GetMainFrame(); |
| 327 WebContentsViewAura* view_aura = static_cast<WebContentsViewAura*>( | 327 WebContentsViewAura* view_aura = static_cast<WebContentsViewAura*>( |
| 328 web_contents->GetView()); | 328 web_contents->GetView()); |
| 329 TestTouchEditableImplAura* touch_editable = new TestTouchEditableImplAura; | 329 TestTouchEditableImplAura* touch_editable = new TestTouchEditableImplAura; |
| 330 view_aura->SetTouchEditableForTest(touch_editable); | 330 view_aura->SetTouchEditableForTest(touch_editable); |
| 331 RenderWidgetHostViewAura* rwhva = static_cast<RenderWidgetHostViewAura*>( | 331 RenderWidgetHostViewAura* rwhva = static_cast<RenderWidgetHostViewAura*>( |
| 332 web_contents->GetRenderWidgetHostView()); | 332 web_contents->GetRenderWidgetHostView()); |
| 333 aura::Window* content = web_contents->GetContentNativeView(); | 333 aura::Window* content = web_contents->GetContentNativeView(); |
| 334 ui::test::EventGenerator generator(content->GetRootWindow(), content); | 334 aura::test::EventGenerator generator(content->GetRootWindow(), content); |
| 335 gfx::Rect bounds = content->GetBoundsInRootWindow(); | 335 gfx::Rect bounds = content->GetBoundsInRootWindow(); |
| 336 EXPECT_EQ(GetRenderWidgetHostViewAura(touch_editable), rwhva); | 336 EXPECT_EQ(GetRenderWidgetHostViewAura(touch_editable), rwhva); |
| 337 | 337 |
| 338 ExecuteSyncJSFunction(main_frame, "focus_textfield()"); | 338 ExecuteSyncJSFunction(main_frame, "focus_textfield()"); |
| 339 touch_editable->WaitForSelectionChangeCallback(); | 339 touch_editable->WaitForSelectionChangeCallback(); |
| 340 | 340 |
| 341 // Tap textfield | 341 // Tap textfield |
| 342 touch_editable->Reset(); | 342 touch_editable->Reset(); |
| 343 generator.GestureTapAt(gfx::Point(bounds.x() + 50, bounds.y() + 40)); | 343 generator.GestureTapAt(gfx::Point(bounds.x() + 50, bounds.y() + 40)); |
| 344 // Tap Down acks are sent synchronously, while Tap acks are asynchronous. | 344 // Tap Down acks are sent synchronously, while Tap acks are asynchronous. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 367 value = content::ExecuteScriptAndGetValue(main_frame, | 367 value = content::ExecuteScriptAndGetValue(main_frame, |
| 368 "get_cursor_position()"); | 368 "get_cursor_position()"); |
| 369 int new_cursor_pos = -1; | 369 int new_cursor_pos = -1; |
| 370 value->GetAsInteger(&new_cursor_pos); | 370 value->GetAsInteger(&new_cursor_pos); |
| 371 EXPECT_NE(-1, new_cursor_pos); | 371 EXPECT_NE(-1, new_cursor_pos); |
| 372 // Cursor should have moved. | 372 // Cursor should have moved. |
| 373 EXPECT_NE(new_cursor_pos, cursor_pos); | 373 EXPECT_NE(new_cursor_pos, cursor_pos); |
| 374 } | 374 } |
| 375 | 375 |
| 376 } // namespace content | 376 } // namespace content |
| OLD | NEW |