Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_ | |
| 6 #define CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <unordered_map> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/callback.h" | |
| 13 #include "ui/base/ime/text_input_mode.h" | |
| 14 #include "ui/base/ime/text_input_type.h" | |
| 15 | |
| 16 namespace content { | |
| 17 | |
| 18 class RenderWidgetHostView; | |
| 19 class RenderWidgetHostViewBase; | |
| 20 class WebContents; | |
| 21 struct TextInputState; | |
| 22 | |
| 23 // This class is intended to track TextInputState from TextInputManager. | |
| 24 class TestTextInputManagerObserver { | |
| 25 public: | |
| 26 using Callback = base::Callback<void(TestTextInputManagerObserver*)>; | |
| 27 | |
| 28 virtual ~TestTextInputManagerObserver(); | |
| 29 | |
| 30 // static | |
| 31 static std::unique_ptr<TestTextInputManagerObserver> Create( | |
| 32 WebContents* web_contents); | |
| 33 // static | |
| 34 static std::unordered_map<const RenderWidgetHostView*, ui::TextInputType> | |
|
EhsanK
2016/05/24 20:42:47
This is now a raw function and a friend of TextInp
| |
| 35 GetTextInputTypeMap(WebContents* web_contents); | |
| 36 | |
| 37 virtual void SetUpdateCallback(const Callback& callback) {} | |
|
Charlie Reis
2016/05/18 20:46:05
These all need comments. That's especially true f
EhsanK
2016/05/24 20:42:47
Acknowledged.
| |
| 38 virtual void SetUpdateCalledCallback(const Callback& callback) {} | |
| 39 virtual ui::TextInputType GetTextInputType() const = 0; | |
|
Charlie Reis
2016/05/18 20:46:05
nit: We don't put const in content/ public interfa
EhsanK
2016/05/24 20:42:47
Acknowledged.
| |
| 40 virtual bool GetTextInputValue(std::string& value) const = 0; | |
| 41 virtual const RenderWidgetHostView* GetActiveView() const = 0; | |
| 42 virtual const RenderWidgetHostView* GetUpdatedView() const = 0; | |
| 43 virtual bool IsTextInputStateChanged() const = 0; | |
| 44 }; | |
| 45 | |
| 46 class RenderWidgetHostViewDestructionObserver { | |
| 47 public: | |
| 48 virtual ~RenderWidgetHostViewDestructionObserver(); | |
| 49 // static | |
| 50 static std::unique_ptr<RenderWidgetHostViewDestructionObserver> Create( | |
| 51 RenderWidgetHostView* view); | |
| 52 | |
| 53 virtual void Wait() = 0; | |
| 54 }; | |
| 55 | |
| 56 ui::TextInputType GetTextInputTypeFromWebContents(WebContents* web_contents); | |
|
Charlie Reis
2016/05/18 20:46:05
Please add comments for all classes and functions
EhsanK
2016/05/24 20:42:47
Acknowledged.
| |
| 57 | |
| 58 RenderWidgetHostView* GetActiveViewFromWebContents(WebContents* web_contents); | |
| 59 | |
| 60 // Helper class to create TextInputState structs on the browser side and send it | |
| 61 // to the |view|. | |
|
Charlie Reis
2016/05/18 20:46:05
|view| is also on the browser side. Maybe you can
EhsanK
2016/05/24 20:42:47
TextInputState is normally instantiated on the ren
| |
| 62 class TextInputStateSender { | |
| 63 public: | |
| 64 explicit TextInputStateSender(RenderWidgetHostView* view); | |
| 65 virtual ~TextInputStateSender(); | |
| 66 | |
| 67 void Send(); | |
| 68 | |
| 69 void SetFromCurrentState(); | |
| 70 | |
| 71 // Adding the required setter methods. | |
|
Charlie Reis
2016/05/18 20:46:05
nit: Drop "Adding" and explain what these are requ
EhsanK
2016/05/24 20:42:47
Acknowledged.
| |
| 72 void SetType(ui::TextInputType type); | |
| 73 void SetMode(ui::TextInputMode mode); | |
| 74 void SetFlags(int flags); | |
| 75 void SetCanComposeInline(bool can_compose_inline); | |
| 76 void SetShowImeIfNeeded(bool show_ime_if_needed); | |
| 77 void SetIsNonImeChange(bool is_non_ime_change); | |
| 78 | |
| 79 private: | |
| 80 std::unique_ptr<TextInputState> text_input_state_; | |
| 81 RenderWidgetHostViewBase* const view_; | |
| 82 | |
| 83 DISALLOW_COPY_AND_ASSIGN(TextInputStateSender); | |
| 84 }; | |
| 85 | |
| 86 // This class is intended to observe the InputMethod. | |
|
Charlie Reis
2016/05/18 20:46:05
I think it's worth mentioning that the Create meth
EhsanK
2016/05/24 20:42:47
Acknowledged.
| |
| 87 class TestInputMethodObserver { | |
| 88 public: | |
| 89 // static | |
| 90 static std::unique_ptr<TestInputMethodObserver> Create( | |
| 91 WebContents* web_contents); | |
| 92 | |
| 93 virtual ~TestInputMethodObserver(); | |
| 94 | |
| 95 virtual ui::TextInputType GetTextInputTypeFromClient() const = 0; | |
| 96 | |
| 97 virtual void SetOnTextInputTypeChangedCallback( | |
| 98 const base::Closure& callback) = 0; | |
| 99 virtual void SetOnShowImeIfNeededCallback(const base::Closure& callback) = 0; | |
| 100 }; | |
| 101 | |
| 102 } // namespace content | |
| 103 | |
| 104 #endif // CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_ | |
| OLD | NEW |