Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2726)

Unified Diff: content/public/test/text_input_test_utils.h

Issue 1948343002: [reland] Browser Side Text Input State Tracking for OOPIF (Aura Only) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing kenrb@ Comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..8f57fdd88bb03a7e789deb8280aafc50cddcdba4
--- /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<const RenderWidgetHostView*, ui::TextInputType>
EhsanK 2016/05/24 20:42:47 This is now a raw function and a friend of TextInp
+ GetTextInputTypeMap(WebContents* web_contents);
+
+ 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.
+ virtual void SetUpdateCalledCallback(const Callback& callback) {}
+ 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.
+ 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);
Charlie Reis 2016/05/18 20:46:05 Please add comments for all classes and functions
EhsanK 2016/05/24 20:42:47 Acknowledged.
+
+RenderWidgetHostView* GetActiveViewFromWebContents(WebContents* web_contents);
+
+// Helper class to create TextInputState structs on the browser side and send it
+// 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
+class TextInputStateSender {
+ public:
+ explicit TextInputStateSender(RenderWidgetHostView* view);
+ virtual ~TextInputStateSender();
+
+ void Send();
+
+ void SetFromCurrentState();
+
+ // 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.
+ 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.
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.
+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_

Powered by Google App Engine
This is Rietveld 408576698