Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_ |
| 6 #define CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_ | 6 #define CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 size_t GetRegisteredViewsCountFromTextInputManager(WebContents* web_contents); | 35 size_t GetRegisteredViewsCountFromTextInputManager(WebContents* web_contents); |
| 36 | 36 |
| 37 // Returns the RWHV corresponding to the frame with a focused <input> within the | 37 // Returns the RWHV corresponding to the frame with a focused <input> within the |
| 38 // given WebContents. | 38 // given WebContents. |
| 39 RenderWidgetHostView* GetActiveViewFromWebContents(WebContents* web_contents); | 39 RenderWidgetHostView* GetActiveViewFromWebContents(WebContents* web_contents); |
| 40 | 40 |
| 41 // This class provides the necessary API for accessing the state of and also | 41 // This class provides the necessary API for accessing the state of and also |
| 42 // observing the TextInputManager for WebContents. | 42 // observing the TextInputManager for WebContents. |
| 43 class TextInputManagerTester { | 43 class TextInputManagerTester { |
| 44 public: | 44 public: |
| 45 using Callback = base::Callback<void(TextInputManagerTester*)>; | 45 using Callback = base::Closure; |
|
sky
2016/07/01 00:03:49
nit: this using is a bit overkill now, just use ba
EhsanK
2016/07/01 00:29:57
Acknowledged.
| |
| 46 | 46 |
| 47 TextInputManagerTester(WebContents* web_contents); | 47 TextInputManagerTester(WebContents* web_contents); |
| 48 virtual ~TextInputManagerTester(); | 48 virtual ~TextInputManagerTester(); |
| 49 | 49 |
| 50 // Sets a callback which is invoked when a RWHV calls UpdateTextInputState | 50 // Sets a callback which is invoked when a RWHV calls UpdateTextInputState |
| 51 // on the TextInputManager which is being observed. | 51 // on the TextInputManager which is being observed. |
| 52 void SetUpdateTextInputStateCalledCallback(const Callback& callback); | 52 void SetUpdateTextInputStateCalledCallback(const Callback& callback); |
| 53 | 53 |
| 54 // Sets a callback which is invoked when a RWHV calls SelectionBoundsChanged | |
| 55 // on the TextInputManager which is being observed. | |
| 56 void SetOnSelectionBoundsChangedCallback(const Callback& callback); | |
| 57 | |
| 54 // Returns true if there is a focused <input> and populates |type| with | 58 // Returns true if there is a focused <input> and populates |type| with |
| 55 // |TextInputState.type| of the TextInputManager. | 59 // |TextInputState.type| of the TextInputManager. |
| 56 bool GetTextInputType(ui::TextInputType* type); | 60 bool GetTextInputType(ui::TextInputType* type); |
| 57 | 61 |
| 58 // Returns true if there is a focused <input> and populates |value| with | 62 // Returns true if there is a focused <input> and populates |value| with |
| 59 // |TextInputState.value| of the TextInputManager. | 63 // |TextInputState.value| of the TextInputManager. |
| 60 bool GetTextInputValue(std::string* value); | 64 bool GetTextInputValue(std::string* value); |
| 61 | 65 |
| 62 // Returns the RenderWidgetHostView with a focused <input> element or nullptr | 66 // Returns the RenderWidgetHostView with a focused <input> element or nullptr |
| 63 // if none exists. | 67 // if none exists. |
| 64 const RenderWidgetHostView* GetActiveView(); | 68 const RenderWidgetHostView* GetActiveView(); |
| 65 | 69 |
| 66 // Returns the RenderWidgetHostView which has most recently called | 70 // Returns the RenderWidgetHostView which has most recently updated any of its |
| 67 // TextInputManager::UpdateTextInputState on the TextInputManager which is | 71 // state (e.g., TextInputState or otherwise). |
| 68 // being observed. | |
| 69 const RenderWidgetHostView* GetUpdatedView(); | 72 const RenderWidgetHostView* GetUpdatedView(); |
| 70 | 73 |
| 71 // Returns true if a call to TextInputManager::UpdateTextInputState has led | 74 // Returns true if a call to TextInputManager::UpdateTextInputState has led |
| 72 // to a change in TextInputState (since the time the observer has been | 75 // to a change in TextInputState (since the time the observer has been |
| 73 // created). | 76 // created). |
| 74 bool IsTextInputStateChanged(); | 77 bool IsTextInputStateChanged(); |
| 75 | 78 |
| 76 private: | 79 private: |
| 77 // The actual internal observer of the TextInputManager. | 80 // The actual internal observer of the TextInputManager. |
| 78 class InternalObserver; | 81 class InternalObserver; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 const base::Closure& callback) = 0; | 149 const base::Closure& callback) = 0; |
| 147 virtual void SetOnShowImeIfNeededCallback(const base::Closure& callback) = 0; | 150 virtual void SetOnShowImeIfNeededCallback(const base::Closure& callback) = 0; |
| 148 | 151 |
| 149 protected: | 152 protected: |
| 150 TestInputMethodObserver(); | 153 TestInputMethodObserver(); |
| 151 }; | 154 }; |
| 152 | 155 |
| 153 } // namespace content | 156 } // namespace content |
| 154 | 157 |
| 155 #endif // CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_ | 158 #endif // CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_ |
| OLD | NEW |