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" |
11 #include "ui/gfx/geometry/rect.h" | 11 #include "ui/gfx/geometry/rect.h" |
12 #include "ui/gfx/range/range.h" | 12 #include "ui/gfx/range/range.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 class WebContents; | 15 class WebContents; |
16 } // namespace content | 16 } // namespace content |
17 | 17 |
18 namespace chromeos { | 18 namespace chromeos { |
19 | 19 |
20 // The base class of text input testing. | 20 // The base class of text input testing. |
21 class TextInputTestBase : public InProcessBrowserTest { | 21 class TextInputTestBase : public InProcessBrowserTest { |
22 public: | 22 public: |
23 TextInputTestBase() {} | 23 TextInputTestBase() {} |
24 virtual ~TextInputTestBase() {} | 24 ~TextInputTestBase() override {} |
25 | 25 |
26 virtual void SetUpInProcessBrowserTestFixture() override; | 26 void SetUpInProcessBrowserTestFixture() override; |
| 27 |
27 private: | 28 private: |
28 DISALLOW_COPY_AND_ASSIGN(TextInputTestBase); | 29 DISALLOW_COPY_AND_ASSIGN(TextInputTestBase); |
29 }; | 30 }; |
30 | 31 |
31 // Provides text input test utilities. | 32 // Provides text input test utilities. |
32 class TextInputTestHelper : public ui::InputMethodObserver { | 33 class TextInputTestHelper : public ui::InputMethodObserver { |
33 public: | 34 public: |
34 TextInputTestHelper(); | 35 TextInputTestHelper(); |
35 virtual ~TextInputTestHelper(); | 36 ~TextInputTestHelper() override; |
36 | 37 |
37 // Returns the latest status notified to ui::InputMethod | 38 // Returns the latest status notified to ui::InputMethod |
38 base::string16 GetSurroundingText() const; | 39 base::string16 GetSurroundingText() const; |
39 gfx::Rect GetCaretRect() const; | 40 gfx::Rect GetCaretRect() const; |
40 gfx::Rect GetCompositionHead() const; | 41 gfx::Rect GetCompositionHead() const; |
41 gfx::Range GetSelectionRange() const; | 42 gfx::Range GetSelectionRange() const; |
42 bool GetFocusState() const; | 43 bool GetFocusState() const; |
43 ui::TextInputType GetTextInputType() const; | 44 ui::TextInputType GetTextInputType() const; |
44 | 45 |
45 ui::TextInputClient* GetTextInputClient() const; | 46 ui::TextInputClient* GetTextInputClient() const; |
(...skipping 18 matching lines...) Expand all Loading... |
64 private: | 65 private: |
65 enum WaitImeEventType { | 66 enum WaitImeEventType { |
66 NO_WAIT, | 67 NO_WAIT, |
67 WAIT_ON_BLUR, | 68 WAIT_ON_BLUR, |
68 WAIT_ON_CARET_BOUNDS_CHANGED, | 69 WAIT_ON_CARET_BOUNDS_CHANGED, |
69 WAIT_ON_FOCUS, | 70 WAIT_ON_FOCUS, |
70 WAIT_ON_TEXT_INPUT_TYPE_CHANGED, | 71 WAIT_ON_TEXT_INPUT_TYPE_CHANGED, |
71 }; | 72 }; |
72 | 73 |
73 // ui::InputMethodObserver overrides. | 74 // ui::InputMethodObserver overrides. |
74 virtual void OnTextInputTypeChanged( | 75 void OnTextInputTypeChanged(const ui::TextInputClient* client) override; |
75 const ui::TextInputClient* client) override; | 76 void OnFocus() override; |
76 virtual void OnFocus() override; | 77 void OnBlur() override; |
77 virtual void OnBlur() override; | 78 void OnCaretBoundsChanged(const ui::TextInputClient* client) override; |
78 virtual void OnCaretBoundsChanged(const ui::TextInputClient* client) override; | 79 void OnTextInputStateChanged(const ui::TextInputClient* client) override; |
79 virtual void OnTextInputStateChanged( | 80 void OnShowImeIfNeeded() override; |
80 const ui::TextInputClient* client) override; | 81 void OnInputMethodDestroyed(const ui::InputMethod* input_method) override; |
81 virtual void OnShowImeIfNeeded() override; | |
82 virtual void OnInputMethodDestroyed( | |
83 const ui::InputMethod* input_method) override; | |
84 | 82 |
85 // Represents waiting type of text input event. | 83 // Represents waiting type of text input event. |
86 WaitImeEventType waiting_type_; | 84 WaitImeEventType waiting_type_; |
87 | 85 |
88 base::string16 surrounding_text_; | 86 base::string16 surrounding_text_; |
89 gfx::Rect caret_rect_; | 87 gfx::Rect caret_rect_; |
90 gfx::Rect composition_head_; | 88 gfx::Rect composition_head_; |
91 gfx::Range selection_range_; | 89 gfx::Range selection_range_; |
92 bool focus_state_; | 90 bool focus_state_; |
93 ui::TextInputType latest_text_input_type_; | 91 ui::TextInputType latest_text_input_type_; |
94 | 92 |
95 DISALLOW_COPY_AND_ASSIGN(TextInputTestHelper); | 93 DISALLOW_COPY_AND_ASSIGN(TextInputTestHelper); |
96 }; | 94 }; |
97 | 95 |
98 } // namespace chromeos | 96 } // namespace chromeos |
99 | 97 |
100 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_TEXTINPUT_TEST_HELPER_H_ | 98 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_TEXTINPUT_TEST_HELPER_H_ |
OLD | NEW |