| 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 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_TEXTINPUT_TEST_HELPER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_TEXTINPUT_TEST_HELPER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_TEXTINPUT_TEST_HELPER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_TEXTINPUT_TEST_HELPER_H_ |
| 7 | 7 |
| 8 #include "chrome/test/base/in_process_browser_test.h" | 8 #include "chrome/test/base/in_process_browser_test.h" |
| 9 #include "ui/base/ime/mock_input_method.h" | 9 #include "ui/base/ime/mock_input_method.h" |
| 10 #include "ui/base/ime/text_input_client.h" | 10 #include "ui/base/ime/text_input_client.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 DISALLOW_COPY_AND_ASSIGN(TextInputTestBase); | 28 DISALLOW_COPY_AND_ASSIGN(TextInputTestBase); |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 // Provides text input test utilities. | 31 // Provides text input test utilities. |
| 32 class TextInputTestHelper : public ui::InputMethodObserver { | 32 class TextInputTestHelper : public ui::InputMethodObserver { |
| 33 public: | 33 public: |
| 34 TextInputTestHelper(); | 34 TextInputTestHelper(); |
| 35 virtual ~TextInputTestHelper(); | 35 virtual ~TextInputTestHelper(); |
| 36 | 36 |
| 37 // Returns the latest status notified to ui::InputMethod | 37 // Returns the latest status notified to ui::InputMethod |
| 38 string16 GetSurroundingText() const; | 38 base::string16 GetSurroundingText() const; |
| 39 gfx::Rect GetCaretRect() const; | 39 gfx::Rect GetCaretRect() const; |
| 40 gfx::Rect GetCompositionHead() const; | 40 gfx::Rect GetCompositionHead() const; |
| 41 gfx::Range GetSelectionRange() const; | 41 gfx::Range GetSelectionRange() const; |
| 42 bool GetFocusState() const; | 42 bool GetFocusState() const; |
| 43 ui::TextInputType GetTextInputType() const; | 43 ui::TextInputType GetTextInputType() const; |
| 44 | 44 |
| 45 ui::TextInputClient* GetTextInputClient() const; | 45 ui::TextInputClient* GetTextInputClient() const; |
| 46 | 46 |
| 47 // Waiting function for each input method events. These functions runs message | 47 // Waiting function for each input method events. These functions runs message |
| 48 // loop until the expected event comes. | 48 // loop until the expected event comes. |
| 49 void WaitForTextInputStateChanged(ui::TextInputType expected_type); | 49 void WaitForTextInputStateChanged(ui::TextInputType expected_type); |
| 50 void WaitForFocus(); | 50 void WaitForFocus(); |
| 51 void WaitForBlur(); | 51 void WaitForBlur(); |
| 52 void WaitForCaretBoundsChanged(const gfx::Rect& expected_caret_rect, | 52 void WaitForCaretBoundsChanged(const gfx::Rect& expected_caret_rect, |
| 53 const gfx::Rect& expected_composition_head); | 53 const gfx::Rect& expected_composition_head); |
| 54 void WaitForSurroundingTextChanged(const string16& expected_text, | 54 void WaitForSurroundingTextChanged(const base::string16& expected_text, |
| 55 const gfx::Range& expected_selection); | 55 const gfx::Range& expected_selection); |
| 56 | 56 |
| 57 // Converts from string to gfx::Rect. The string should be "x,y,width,height". | 57 // Converts from string to gfx::Rect. The string should be "x,y,width,height". |
| 58 // Returns false if the conversion failed. | 58 // Returns false if the conversion failed. |
| 59 static bool ConvertRectFromString(const std::string& str, gfx::Rect* rect); | 59 static bool ConvertRectFromString(const std::string& str, gfx::Rect* rect); |
| 60 | 60 |
| 61 // Sends mouse clicking event to DOM element which has |id| id. | 61 // Sends mouse clicking event to DOM element which has |id| id. |
| 62 static bool ClickElement(const std::string& id, content::WebContents* tab); | 62 static bool ClickElement(const std::string& id, content::WebContents* tab); |
| 63 | 63 |
| 64 private: | 64 private: |
| (...skipping 12 matching lines...) Expand all Loading... |
| 77 virtual void OnBlur() OVERRIDE; | 77 virtual void OnBlur() OVERRIDE; |
| 78 virtual void OnCaretBoundsChanged(const ui::TextInputClient* client) OVERRIDE; | 78 virtual void OnCaretBoundsChanged(const ui::TextInputClient* client) OVERRIDE; |
| 79 virtual void OnTextInputStateChanged( | 79 virtual void OnTextInputStateChanged( |
| 80 const ui::TextInputClient* client) OVERRIDE; | 80 const ui::TextInputClient* client) OVERRIDE; |
| 81 virtual void OnInputMethodDestroyed( | 81 virtual void OnInputMethodDestroyed( |
| 82 const ui::InputMethod* input_method) OVERRIDE; | 82 const ui::InputMethod* input_method) OVERRIDE; |
| 83 | 83 |
| 84 // Represents waiting type of text input event. | 84 // Represents waiting type of text input event. |
| 85 WaitImeEventType waiting_type_; | 85 WaitImeEventType waiting_type_; |
| 86 | 86 |
| 87 string16 surrounding_text_; | 87 base::string16 surrounding_text_; |
| 88 gfx::Rect caret_rect_; | 88 gfx::Rect caret_rect_; |
| 89 gfx::Rect composition_head_; | 89 gfx::Rect composition_head_; |
| 90 gfx::Range selection_range_; | 90 gfx::Range selection_range_; |
| 91 bool focus_state_; | 91 bool focus_state_; |
| 92 ui::TextInputType latest_text_input_type_; | 92 ui::TextInputType latest_text_input_type_; |
| 93 | 93 |
| 94 DISALLOW_COPY_AND_ASSIGN(TextInputTestHelper); | 94 DISALLOW_COPY_AND_ASSIGN(TextInputTestHelper); |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 } // namespace chromeos | 97 } // namespace chromeos |
| 98 | 98 |
| 99 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_TEXTINPUT_TEST_HELPER_H_ | 99 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_TEXTINPUT_TEST_HELPER_H_ |
| OLD | NEW |