| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 virtual void Reset() { | 43 virtual void Reset() { |
| 44 selection_changed_callback_arrived_ = false; | 44 selection_changed_callback_arrived_ = false; |
| 45 waiting_for_selection_changed_callback_ = false; | 45 waiting_for_selection_changed_callback_ = false; |
| 46 waiting_for_gesture_ack_type_ = WebInputEvent::Undefined; | 46 waiting_for_gesture_ack_type_ = WebInputEvent::Undefined; |
| 47 last_gesture_ack_type_ = WebInputEvent::Undefined; | 47 last_gesture_ack_type_ = WebInputEvent::Undefined; |
| 48 fling_stop_callback_arrived_ = false; | 48 fling_stop_callback_arrived_ = false; |
| 49 waiting_for_fling_stop_callback_ = false; | 49 waiting_for_fling_stop_callback_ = false; |
| 50 } | 50 } |
| 51 | 51 |
| 52 virtual void OnSelectionOrCursorChanged(const gfx::Rect& anchor, | 52 virtual void OnSelectionOrCursorChanged(const gfx::Rect& anchor, |
| 53 const gfx::Rect& focus) OVERRIDE { | 53 const gfx::Rect& focus) override { |
| 54 selection_changed_callback_arrived_ = true; | 54 selection_changed_callback_arrived_ = true; |
| 55 TouchEditableImplAura::OnSelectionOrCursorChanged(anchor, focus); | 55 TouchEditableImplAura::OnSelectionOrCursorChanged(anchor, focus); |
| 56 if (waiting_for_selection_changed_callback_) | 56 if (waiting_for_selection_changed_callback_) |
| 57 selection_changed_wait_run_loop_->Quit(); | 57 selection_changed_wait_run_loop_->Quit(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 virtual void GestureEventAck(int gesture_event_type) OVERRIDE { | 60 virtual void GestureEventAck(int gesture_event_type) override { |
| 61 last_gesture_ack_type_ = | 61 last_gesture_ack_type_ = |
| 62 static_cast<WebInputEvent::Type>(gesture_event_type); | 62 static_cast<WebInputEvent::Type>(gesture_event_type); |
| 63 TouchEditableImplAura::GestureEventAck(gesture_event_type); | 63 TouchEditableImplAura::GestureEventAck(gesture_event_type); |
| 64 if (waiting_for_gesture_ack_type_ == gesture_event_type) | 64 if (waiting_for_gesture_ack_type_ == gesture_event_type) |
| 65 gesture_ack_wait_run_loop_->Quit(); | 65 gesture_ack_wait_run_loop_->Quit(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 virtual void DidStopFlinging() OVERRIDE { | 68 virtual void DidStopFlinging() override { |
| 69 fling_stop_callback_arrived_ = true; | 69 fling_stop_callback_arrived_ = true; |
| 70 TouchEditableImplAura::DidStopFlinging(); | 70 TouchEditableImplAura::DidStopFlinging(); |
| 71 if (waiting_for_fling_stop_callback_) | 71 if (waiting_for_fling_stop_callback_) |
| 72 fling_stop_wait_run_loop_->Quit(); | 72 fling_stop_wait_run_loop_->Quit(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 virtual void WaitForSelectionChangeCallback() { | 75 virtual void WaitForSelectionChangeCallback() { |
| 76 if (selection_changed_callback_arrived_) | 76 if (selection_changed_callback_arrived_) |
| 77 return; | 77 return; |
| 78 waiting_for_selection_changed_callback_ = true; | 78 waiting_for_selection_changed_callback_ = true; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 scoped_ptr<base::RunLoop> fling_stop_wait_run_loop_; | 111 scoped_ptr<base::RunLoop> fling_stop_wait_run_loop_; |
| 112 | 112 |
| 113 DISALLOW_COPY_AND_ASSIGN(TestTouchEditableImplAura); | 113 DISALLOW_COPY_AND_ASSIGN(TestTouchEditableImplAura); |
| 114 }; | 114 }; |
| 115 | 115 |
| 116 class TouchEditableImplAuraTest : public ContentBrowserTest { | 116 class TouchEditableImplAuraTest : public ContentBrowserTest { |
| 117 public: | 117 public: |
| 118 TouchEditableImplAuraTest() {} | 118 TouchEditableImplAuraTest() {} |
| 119 | 119 |
| 120 protected: | 120 protected: |
| 121 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 121 virtual void SetUpCommandLine(CommandLine* command_line) override { |
| 122 command_line->AppendSwitch(switches::kEnableTouchEditing); | 122 command_line->AppendSwitch(switches::kEnableTouchEditing); |
| 123 } | 123 } |
| 124 | 124 |
| 125 // Executes the javascript synchronously and makes sure the returned value is | 125 // Executes the javascript synchronously and makes sure the returned value is |
| 126 // freed properly. | 126 // freed properly. |
| 127 void ExecuteSyncJSFunction(RenderFrameHost* rfh, const std::string& jscript) { | 127 void ExecuteSyncJSFunction(RenderFrameHost* rfh, const std::string& jscript) { |
| 128 scoped_ptr<base::Value> value = | 128 scoped_ptr<base::Value> value = |
| 129 content::ExecuteScriptAndGetValue(rfh, jscript); | 129 content::ExecuteScriptAndGetValue(rfh, jscript); |
| 130 } | 130 } |
| 131 | 131 |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 value = content::ExecuteScriptAndGetValue(main_frame, | 442 value = content::ExecuteScriptAndGetValue(main_frame, |
| 443 "get_cursor_position()"); | 443 "get_cursor_position()"); |
| 444 int new_cursor_pos = -1; | 444 int new_cursor_pos = -1; |
| 445 value->GetAsInteger(&new_cursor_pos); | 445 value->GetAsInteger(&new_cursor_pos); |
| 446 EXPECT_NE(-1, new_cursor_pos); | 446 EXPECT_NE(-1, new_cursor_pos); |
| 447 // Cursor should have moved. | 447 // Cursor should have moved. |
| 448 EXPECT_NE(new_cursor_pos, cursor_pos); | 448 EXPECT_NE(new_cursor_pos, cursor_pos); |
| 449 } | 449 } |
| 450 | 450 |
| 451 } // namespace content | 451 } // namespace content |
| OLD | NEW |