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

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

Issue 2382003002: Fix dictionary look-up for highlighted text in Mac. (Closed)
Patch Set: Rebased Created 4 years, 2 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
index 7785b671b3ee5b59db9511858d2cf49d7ce3f5d1..080d0fa07a85798e1111abfc4cb0fa2bb155da38 100644
--- a/content/public/test/text_input_test_utils.h
+++ b/content/public/test/text_input_test_utils.h
@@ -13,6 +13,14 @@
#include "ui/base/ime/text_input_mode.h"
#include "ui/base/ime/text_input_type.h"
+#ifdef OS_MACOSX
+#include "content/public/browser/browser_message_filter.h"
+#endif
+
+namespace ipc {
+class Message;
+}
+
namespace gfx {
class Range;
}
@@ -23,6 +31,8 @@ struct CompositionUnderline;
namespace content {
+class MessageLoopRunner;
+class RenderProcessHost;
class RenderWidgetHost;
class RenderWidgetHostView;
class RenderWidgetHostViewBase;
@@ -180,6 +190,48 @@ class TestInputMethodObserver {
TestInputMethodObserver();
};
+#ifdef OS_MACOSX
+// The test message filter for TextInputClientMac incoming messages from the
+// renderer.
+// NOTE: This filter should be added to the intended RenderProcessHost before
+// the actual TextInputClientMessageFilter, otherwise, the messages
+// will be handled and will never receive this filter.
+class TestTextInputClientMessageFilter : public BrowserMessageFilter {
+ public:
+ // Creates the filter and adds itself to |host|.
+ TestTextInputClientMessageFilter(RenderProcessHost* host);
+
+ // Wait until the IPC TextInputClientReplyMsg_GotStringForRange arrives.
+ void WaitForStringFromRange();
+
+ // BrowserMessageFilter overrides.
+ bool OnMessageReceived(const IPC::Message& message) override;
+
+ RenderProcessHost* process() const { return host_; }
+ std::string string_from_range() { return string_from_range_; }
+
+ private:
+ ~TestTextInputClientMessageFilter() override;
+ RenderProcessHost* const host_;
+ std::string string_from_range_;
+ bool received_string_from_range_;
+ scoped_refptr<MessageLoopRunner> message_loop_runner_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestTextInputClientMessageFilter);
+};
+
+// Requests the |tab_view| for the definition of the word identified by the
+// given selection range. |range| identifies a word in the focused
+// RenderWidgetHost underneath |tab_view| which may be different than the
+// RenderWidgetHost corresponding to |tab_view|.
+void AskForLookUpDictionaryForRange(RenderWidgetHostView* tab_view,
+ const gfx::Range& range);
+
+// Returns the total count of NSWindows instances which belong to the currently
+// running NSApplication.
+size_t GetOpenNSWindowsCount();
+#endif
+
} // namespace content
#endif // CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_

Powered by Google App Engine
This is Rietveld 408576698