OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ash/shell.h" | 5 #include "ash/shell.h" |
6 #include "base/strings/string_number_conversions.h" | 6 #include "base/strings/string_number_conversions.h" |
7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/chromeos/input_method/textinput_test_helper.h" | 9 #include "chrome/browser/chromeos/input_method/textinput_test_helper.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 ui::TextInputType TextInputTestHelper::GetTextInputType() const { | 66 ui::TextInputType TextInputTestHelper::GetTextInputType() const { |
67 return latest_text_input_type_; | 67 return latest_text_input_type_; |
68 } | 68 } |
69 | 69 |
70 ui::TextInputClient* TextInputTestHelper::GetTextInputClient() const { | 70 ui::TextInputClient* TextInputTestHelper::GetTextInputClient() const { |
71 return GetInputMethod()->GetTextInputClient(); | 71 return GetInputMethod()->GetTextInputClient(); |
72 } | 72 } |
73 | 73 |
74 void TextInputTestHelper::OnTextInputTypeChanged( | 74 void TextInputTestHelper::OnTextInputTypeChanged( |
75 const ui::TextInputClient* client) { | 75 const ui::TextInputClient* client) { |
76 latest_text_input_type_ = client->GetTextInputType(); | 76 latest_text_input_type_ = |
| 77 client ? client->GetTextInputType() : ui::TEXT_INPUT_TYPE_NONE; |
77 if (waiting_type_ == WAIT_ON_TEXT_INPUT_TYPE_CHANGED) | 78 if (waiting_type_ == WAIT_ON_TEXT_INPUT_TYPE_CHANGED) |
78 base::MessageLoop::current()->Quit(); | 79 base::MessageLoop::current()->Quit(); |
79 } | 80 } |
80 | 81 |
81 void TextInputTestHelper::OnShowImeIfNeeded() { | 82 void TextInputTestHelper::OnShowImeIfNeeded() { |
82 } | 83 } |
83 | 84 |
84 void TextInputTestHelper::OnInputMethodDestroyed( | 85 void TextInputTestHelper::OnInputMethodDestroyed( |
85 const ui::InputMethod* input_method) { | 86 const ui::InputMethod* input_method) { |
86 } | 87 } |
87 | 88 |
88 void TextInputTestHelper::OnFocus() { | 89 void TextInputTestHelper::OnFocus() { |
89 focus_state_ = true; | 90 focus_state_ = true; |
90 if (waiting_type_ == WAIT_ON_FOCUS) | 91 if (waiting_type_ == WAIT_ON_FOCUS) |
91 base::MessageLoop::current()->Quit(); | 92 base::MessageLoop::current()->Quit(); |
92 } | 93 } |
93 | 94 |
94 void TextInputTestHelper::OnBlur() { | 95 void TextInputTestHelper::OnBlur() { |
95 focus_state_ = false; | 96 focus_state_ = false; |
96 if (waiting_type_ == WAIT_ON_BLUR) | 97 if (waiting_type_ == WAIT_ON_BLUR) |
97 base::MessageLoop::current()->Quit(); | 98 base::MessageLoop::current()->Quit(); |
98 } | 99 } |
99 | 100 |
100 void TextInputTestHelper::OnCaretBoundsChanged( | 101 void TextInputTestHelper::OnCaretBoundsChanged( |
101 const ui::TextInputClient* client) { | 102 const ui::TextInputClient* client) { |
102 gfx::Range text_range; | 103 gfx::Range text_range; |
103 if (!GetTextInputClient()->GetTextRange(&text_range) || | 104 if (GetTextInputClient()) { |
104 !GetTextInputClient()->GetTextFromRange(text_range, &surrounding_text_) || | 105 if (!GetTextInputClient()->GetTextRange(&text_range) || |
105 !GetTextInputClient()->GetSelectionRange(&selection_range_)) | 106 !GetTextInputClient()->GetTextFromRange(text_range, |
| 107 &surrounding_text_) || |
| 108 !GetTextInputClient()->GetSelectionRange(&selection_range_)) |
106 return; | 109 return; |
| 110 } |
107 if (waiting_type_ == WAIT_ON_CARET_BOUNDS_CHANGED) | 111 if (waiting_type_ == WAIT_ON_CARET_BOUNDS_CHANGED) |
108 base::MessageLoop::current()->Quit(); | 112 base::MessageLoop::current()->Quit(); |
109 } | 113 } |
110 | 114 |
111 void TextInputTestHelper::OnTextInputStateChanged( | 115 void TextInputTestHelper::OnTextInputStateChanged( |
112 const ui::TextInputClient* client) { | 116 const ui::TextInputClient* client) { |
113 } | 117 } |
114 | 118 |
115 void TextInputTestHelper::WaitForTextInputStateChanged( | 119 void TextInputTestHelper::WaitForTextInputStateChanged( |
116 ui::TextInputType expected_type) { | 120 ui::TextInputType expected_type) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 mouse_event.y = rect.CenterPoint().y(); | 201 mouse_event.y = rect.CenterPoint().y(); |
198 mouse_event.clickCount = 1; | 202 mouse_event.clickCount = 1; |
199 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); | 203 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); |
200 | 204 |
201 mouse_event.type = blink::WebInputEvent::MouseUp; | 205 mouse_event.type = blink::WebInputEvent::MouseUp; |
202 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); | 206 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); |
203 return true; | 207 return true; |
204 } | 208 } |
205 | 209 |
206 } // namespace chromeos | 210 } // namespace chromeos |
OLD | NEW |