Index: content/public/test/text_input_test_utils.h |
diff --git a/content/public/test/text_input_test_utils.h b/content/public/test/text_input_test_utils.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f5a814144cf5dd909b8fd84a758ba3c1c0981048 |
--- /dev/null |
+++ b/content/public/test/text_input_test_utils.h |
@@ -0,0 +1,104 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_ |
+#define CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_ |
+ |
+#include <string> |
+#include <unordered_map> |
+#include <vector> |
+ |
+#include "base/callback.h" |
+#include "ui/base/ime/text_input_mode.h" |
+#include "ui/base/ime/text_input_type.h" |
+ |
+namespace content { |
+ |
+class RenderWidgetHostView; |
+class RenderWidgetHostViewBase; |
+class WebContents; |
+struct TextInputState; |
+ |
+// This class is intended to track TextInputState from TextInputManager. |
+class TestTextInputManagerObserver { |
+ public: |
+ using Callback = base::Callback<void(TestTextInputManagerObserver*)>; |
+ |
+ virtual ~TestTextInputManagerObserver(); |
+ |
+ // static |
+ static std::unique_ptr<TestTextInputManagerObserver> Create( |
+ WebContents* web_contents); |
+ // static |
+ static std::unordered_map<RenderWidgetHostView*, ui::TextInputType> |
+ GetTextInputTypeMap(WebContents* web_contents); |
+ |
+ virtual void SetUpdateCallback(const Callback& callback) {} |
+ virtual void SetDestructionCallback(const Callback& callback) {} |
+ virtual ui::TextInputType GetTextInputType() const = 0; |
+ virtual bool GetTextInputValue(std::string& value) const = 0; |
+ virtual const RenderWidgetHostView* GetActiveView() const = 0; |
+ virtual const RenderWidgetHostView* GetUpdatedView() const = 0; |
+ virtual bool IsTextInputStateChanged() const = 0; |
+}; |
+ |
+class RenderWidgetHostViewDestructionObserver { |
+ public: |
+ virtual ~RenderWidgetHostViewDestructionObserver(); |
+ // static |
+ static std::unique_ptr<RenderWidgetHostViewDestructionObserver> Create( |
+ RenderWidgetHostView* view); |
+ |
+ virtual void Wait() = 0; |
+}; |
+ |
+ui::TextInputType GetTextInputTypeFromWebContents(WebContents* web_contents); |
+ |
+RenderWidgetHostView* GetActiveViewFromWebContents(WebContents* web_contents); |
+ |
+// Helper class to create TextInputState structs on the browser side and send it |
+// to the |view|. |
+class TextInputStateSender { |
+ public: |
+ explicit TextInputStateSender(RenderWidgetHostView* view); |
+ virtual ~TextInputStateSender(); |
+ |
+ void Send(); |
+ |
+ void SetFromCurrentState(); |
+ |
+ // Adding the required setter methods. |
+ void SetType(ui::TextInputType type); |
+ void SetMode(ui::TextInputMode mode); |
+ void SetFlags(int flags); |
+ void SetCanComposeInline(bool can_compose_inline); |
+ void SetShowImeIfNeeded(bool show_ime_if_needed); |
+ void SetIsNonImeChange(bool is_non_ime_change); |
+ |
+ private: |
+ std::unique_ptr<TextInputState> text_input_state_; |
+ RenderWidgetHostViewBase* const view_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(TextInputStateSender); |
+}; |
+ |
+// This class is intended to observe the InputMethod. |
+class TestInputMethodObserver { |
+ public: |
+ // static |
+ static std::unique_ptr<TestInputMethodObserver> Create( |
+ WebContents* web_contents); |
+ |
+ virtual ~TestInputMethodObserver(); |
+ |
+ virtual ui::TextInputType GetTextInputTypeFromClient() const = 0; |
+ |
+ virtual void SetOnTextInputTypeChangedCallback( |
+ const base::Closure& callback) = 0; |
+ virtual void SetOnShowImeIfNeededCallback(const base::Closure& callback) = 0; |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_ |