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

Side by Side Diff: content/public/test/text_input_test_utils.h

Issue 2132633002: Tracking composition range on the browser side (Aura) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing creis@'s comments and changing a test method Created 4 years, 5 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 unified diff | Download patch
OLDNEW
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 #include <vector>
9 10
10 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/strings/string16.h"
11 #include "ui/base/ime/text_input_mode.h" 13 #include "ui/base/ime/text_input_mode.h"
12 #include "ui/base/ime/text_input_type.h" 14 #include "ui/base/ime/text_input_type.h"
13 15
16 namespace gfx {
17 class Range;
18 }
19
20 namespace ui {
21 struct CompositionUnderline;
22 }
23
14 namespace content { 24 namespace content {
15 25
26 class RenderWidgetHost;
16 class RenderWidgetHostView; 27 class RenderWidgetHostView;
17 class RenderWidgetHostViewBase; 28 class RenderWidgetHostViewBase;
18 class WebContents; 29 class WebContents;
19 struct TextInputState; 30 struct TextInputState;
20 31
21 // Returns the |TextInputState.type| from the TextInputManager owned by 32 // Returns the |TextInputState.type| from the TextInputManager owned by
22 // |web_contents|. 33 // |web_contents|.
23 ui::TextInputType GetTextInputTypeFromWebContents(WebContents* web_contents); 34 ui::TextInputType GetTextInputTypeFromWebContents(WebContents* web_contents);
24 35
25 // This method returns true if |view| is registered in the TextInputManager that 36 // This method returns true if |view| is registered in the TextInputManager that
26 // is owned by |web_contents|. If that is the case, the value of |type| will be 37 // is owned by |web_contents|. If that is the case, the value of |type| will be
27 // the |TextInputState.type| corresponding to the |view|. Returns false if 38 // the |TextInputState.type| corresponding to the |view|. Returns false if
28 // |view| is not registered. 39 // |view| is not registered.
29 bool GetTextInputTypeForView(WebContents* web_contents, 40 bool GetTextInputTypeForView(WebContents* web_contents,
30 RenderWidgetHostView* view, 41 RenderWidgetHostView* view,
31 ui::TextInputType* type); 42 ui::TextInputType* type);
32 43
33 // This method returns the number of RenderWidgetHostViews which are currently 44 // This method returns the number of RenderWidgetHostViews which are currently
34 // registered with the TextInputManager that is owned by |web_contents|. 45 // registered with the TextInputManager that is owned by |web_contents|.
35 size_t GetRegisteredViewsCountFromTextInputManager(WebContents* web_contents); 46 size_t GetRegisteredViewsCountFromTextInputManager(WebContents* web_contents);
36 47
37 // Returns the RWHV corresponding to the frame with a focused <input> within the 48 // Returns the RWHV corresponding to the frame with a focused <input> within the
38 // given WebContents. 49 // given WebContents.
39 RenderWidgetHostView* GetActiveViewFromWebContents(WebContents* web_contents); 50 RenderWidgetHostView* GetActiveViewFromWebContents(WebContents* web_contents);
40 51
52 // This method will send an InputMsg_ImeSetComposition IPC with the provided
53 // parameters to the |render_widget_host|.
54 void SetCompositionForRenderWidgetHost(
55 RenderWidgetHost* render_widget_host,
56 const base::string16& text,
57 const std::vector<ui::CompositionUnderline>& underlines,
58 const gfx::Range& replacement_range,
59 int selection_start,
60 int selection_end);
61
41 // This class provides the necessary API for accessing the state of and also 62 // This class provides the necessary API for accessing the state of and also
42 // observing the TextInputManager for WebContents. 63 // observing the TextInputManager for WebContents.
43 class TextInputManagerTester { 64 class TextInputManagerTester {
44 public: 65 public:
45 TextInputManagerTester(WebContents* web_contents); 66 TextInputManagerTester(WebContents* web_contents);
46 virtual ~TextInputManagerTester(); 67 virtual ~TextInputManagerTester();
47 68
48 // Sets a callback which is invoked when a RWHV calls UpdateTextInputState 69 // Sets a callback which is invoked when a RWHV calls UpdateTextInputState
49 // on the TextInputManager which is being observed. 70 // on the TextInputManager which is being observed.
50 void SetUpdateTextInputStateCalledCallback(const base::Closure& callback); 71 void SetUpdateTextInputStateCalledCallback(const base::Closure& callback);
51 72
52 // Sets a callback which is invoked when a RWHV calls SelectionBoundsChanged 73 // Sets a callback which is invoked when a RWHV calls SelectionBoundsChanged
53 // on the TextInputManager which is being observed. 74 // on the TextInputManager which is being observed.
54 void SetOnSelectionBoundsChangedCallback(const base::Closure& callback); 75 void SetOnSelectionBoundsChangedCallback(const base::Closure& callback);
55 76
77 // Sets a callback which is invoked when a RWHV calls
78 // ImeCompositionRangeChanged on the TextInputManager that is being observed.
79 void SetOnImeCompositionRangeChangedCallback(const base::Closure& callback);
80
56 // Returns true if there is a focused <input> and populates |type| with 81 // Returns true if there is a focused <input> and populates |type| with
57 // |TextInputState.type| of the TextInputManager. 82 // |TextInputState.type| of the TextInputManager.
58 bool GetTextInputType(ui::TextInputType* type); 83 bool GetTextInputType(ui::TextInputType* type);
59 84
60 // Returns true if there is a focused <input> and populates |value| with 85 // Returns true if there is a focused <input> and populates |value| with
61 // |TextInputState.value| of the TextInputManager. 86 // |TextInputState.value| of the TextInputManager.
62 bool GetTextInputValue(std::string* value); 87 bool GetTextInputValue(std::string* value);
63 88
64 // Returns the RenderWidgetHostView with a focused <input> element or nullptr 89 // Returns the RenderWidgetHostView with a focused <input> element or nullptr
65 // if none exists. 90 // if none exists.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 const base::Closure& callback) = 0; 172 const base::Closure& callback) = 0;
148 virtual void SetOnShowImeIfNeededCallback(const base::Closure& callback) = 0; 173 virtual void SetOnShowImeIfNeededCallback(const base::Closure& callback) = 0;
149 174
150 protected: 175 protected:
151 TestInputMethodObserver(); 176 TestInputMethodObserver();
152 }; 177 };
153 178
154 } // namespace content 179 } // namespace content
155 180
156 #endif // CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_ 181 #endif // CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_
OLDNEW
« no previous file with comments | « content/browser/renderer_host/text_input_manager.cc ('k') | content/public/test/text_input_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698