| 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*)>; | |
| 46 | |
| 47 TextInputManagerTester(WebContents* web_contents); | 45 TextInputManagerTester(WebContents* web_contents); |
| 48 virtual ~TextInputManagerTester(); | 46 virtual ~TextInputManagerTester(); |
| 49 | 47 |
| 50 // Sets a callback which is invoked when a RWHV calls UpdateTextInputState | 48 // Sets a callback which is invoked when a RWHV calls UpdateTextInputState |
| 51 // on the TextInputManager which is being observed. | 49 // on the TextInputManager which is being observed. |
| 52 void SetUpdateTextInputStateCalledCallback(const Callback& callback); | 50 void SetUpdateTextInputStateCalledCallback(const base::Closure& callback); |
| 51 |
| 52 // Sets a callback which is invoked when a RWHV calls SelectionBoundsChanged |
| 53 // on the TextInputManager which is being observed. |
| 54 void SetOnSelectionBoundsChangedCallback(const base::Closure& callback); |
| 53 | 55 |
| 54 // Returns true if there is a focused <input> and populates |type| with | 56 // Returns true if there is a focused <input> and populates |type| with |
| 55 // |TextInputState.type| of the TextInputManager. | 57 // |TextInputState.type| of the TextInputManager. |
| 56 bool GetTextInputType(ui::TextInputType* type); | 58 bool GetTextInputType(ui::TextInputType* type); |
| 57 | 59 |
| 58 // Returns true if there is a focused <input> and populates |value| with | 60 // Returns true if there is a focused <input> and populates |value| with |
| 59 // |TextInputState.value| of the TextInputManager. | 61 // |TextInputState.value| of the TextInputManager. |
| 60 bool GetTextInputValue(std::string* value); | 62 bool GetTextInputValue(std::string* value); |
| 61 | 63 |
| 62 // Returns the RenderWidgetHostView with a focused <input> element or nullptr | 64 // Returns the RenderWidgetHostView with a focused <input> element or nullptr |
| 63 // if none exists. | 65 // if none exists. |
| 64 const RenderWidgetHostView* GetActiveView(); | 66 const RenderWidgetHostView* GetActiveView(); |
| 65 | 67 |
| 66 // Returns the RenderWidgetHostView which has most recently called | 68 // Returns the RenderWidgetHostView which has most recently updated any of its |
| 67 // TextInputManager::UpdateTextInputState on the TextInputManager which is | 69 // state (e.g., TextInputState or otherwise). |
| 68 // being observed. | |
| 69 const RenderWidgetHostView* GetUpdatedView(); | 70 const RenderWidgetHostView* GetUpdatedView(); |
| 70 | 71 |
| 71 // Returns true if a call to TextInputManager::UpdateTextInputState has led | 72 // Returns true if a call to TextInputManager::UpdateTextInputState has led |
| 72 // to a change in TextInputState (since the time the observer has been | 73 // to a change in TextInputState (since the time the observer has been |
| 73 // created). | 74 // created). |
| 74 bool IsTextInputStateChanged(); | 75 bool IsTextInputStateChanged(); |
| 75 | 76 |
| 76 private: | 77 private: |
| 77 // The actual internal observer of the TextInputManager. | 78 // The actual internal observer of the TextInputManager. |
| 78 class InternalObserver; | 79 class InternalObserver; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 const base::Closure& callback) = 0; | 147 const base::Closure& callback) = 0; |
| 147 virtual void SetOnShowImeIfNeededCallback(const base::Closure& callback) = 0; | 148 virtual void SetOnShowImeIfNeededCallback(const base::Closure& callback) = 0; |
| 148 | 149 |
| 149 protected: | 150 protected: |
| 150 TestInputMethodObserver(); | 151 TestInputMethodObserver(); |
| 151 }; | 152 }; |
| 152 | 153 |
| 153 } // namespace content | 154 } // namespace content |
| 154 | 155 |
| 155 #endif // CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_ | 156 #endif // CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_ |
| OLD | NEW |