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

Side by Side Diff: content/renderer/render_widget_browsertest.cc

Issue 2333813002: Introduce WebInputMethodController to blink (Closed)
Patch Set: Moved ConfirmCompositionBehavior to WebInputMethodController Created 4 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "content/common/resize_params.h" 5 #include "content/common/resize_params.h"
6 #include "content/public/test/render_view_test.h" 6 #include "content/public/test/render_view_test.h"
7 #include "content/renderer/render_view_impl.h" 7 #include "content/renderer/render_view_impl.h"
8 #include "content/renderer/render_widget.h" 8 #include "content/renderer/render_widget.h"
9 #include "third_party/WebKit/public/web/WebFrameWidget.h"
10 #include "third_party/WebKit/public/web/WebInputMethodController.h"
9 11
10 namespace content { 12 namespace content {
11 13
12 class RenderWidgetTest : public RenderViewTest { 14 class RenderWidgetTest : public RenderViewTest {
13 protected: 15 protected:
14 RenderWidget* widget() { 16 RenderWidget* widget() {
15 return static_cast<RenderViewImpl*>(view_)->GetWidget(); 17 return static_cast<RenderViewImpl*>(view_)->GetWidget();
16 } 18 }
17 19
18 void OnResize(const ResizeParams& params) { 20 void OnResize(const ResizeParams& params) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 EXPECT_EQ(initial_size_, widget()->size()); 105 EXPECT_EQ(initial_size_, widget()->size());
104 EXPECT_EQ(initial_size_, gfx::Size(widget()->GetWebWidget()->size())); 106 EXPECT_EQ(initial_size_, gfx::Size(widget()->GetWebWidget()->size()));
105 EXPECT_TRUE(next_paint_is_resize_ack()); 107 EXPECT_TRUE(next_paint_is_resize_ack());
106 } 108 }
107 109
108 TEST_F(RenderWidgetTest, GetCompositionRangeValidComposition) { 110 TEST_F(RenderWidgetTest, GetCompositionRangeValidComposition) {
109 LoadHTML( 111 LoadHTML(
110 "<div contenteditable>EDITABLE</div>" 112 "<div contenteditable>EDITABLE</div>"
111 "<script> document.querySelector('div').focus(); </script>"); 113 "<script> document.querySelector('div').focus(); </script>");
112 blink::WebVector<blink::WebCompositionUnderline> emptyUnderlines; 114 blink::WebVector<blink::WebCompositionUnderline> emptyUnderlines;
113 widget()->GetWebWidget()->setComposition("hello", emptyUnderlines, 3, 3); 115 DCHECK(widget()->GetInputMethodController());
116 widget()->GetInputMethodController()->setComposition("hello", emptyUnderlines,
117 3, 3);
114 gfx::Range range; 118 gfx::Range range;
115 GetCompositionRange(&range); 119 GetCompositionRange(&range);
116 EXPECT_TRUE(range.IsValid()); 120 EXPECT_TRUE(range.IsValid());
117 EXPECT_EQ(0U, range.start()); 121 EXPECT_EQ(0U, range.start());
118 EXPECT_EQ(5U, range.end()); 122 EXPECT_EQ(5U, range.end());
119 } 123 }
120 124
121 TEST_F(RenderWidgetTest, GetCompositionRangeValidSelection) { 125 TEST_F(RenderWidgetTest, GetCompositionRangeValidSelection) {
122 LoadHTML( 126 LoadHTML(
123 "<div>NOT EDITABLE</div>" 127 "<div>NOT EDITABLE</div>"
124 "<script> document.execCommand('selectAll'); </script>"); 128 "<script> document.execCommand('selectAll'); </script>");
125 gfx::Range range; 129 gfx::Range range;
126 GetCompositionRange(&range); 130 GetCompositionRange(&range);
127 EXPECT_TRUE(range.IsValid()); 131 EXPECT_TRUE(range.IsValid());
128 EXPECT_EQ(0U, range.start()); 132 EXPECT_EQ(0U, range.start());
129 EXPECT_EQ(12U, range.end()); 133 EXPECT_EQ(12U, range.end());
130 } 134 }
131 135
132 TEST_F(RenderWidgetTest, GetCompositionRangeInvalid) { 136 TEST_F(RenderWidgetTest, GetCompositionRangeInvalid) {
133 LoadHTML("<div>NOT EDITABLE</div>"); 137 LoadHTML("<div>NOT EDITABLE</div>");
134 gfx::Range range; 138 gfx::Range range;
135 GetCompositionRange(&range); 139 GetCompositionRange(&range);
136 // If this test ever starts failing, one likely outcome is that WebRange 140 // If this test ever starts failing, one likely outcome is that WebRange
137 // and gfx::Range::InvalidRange are no longer expressed in the same 141 // and gfx::Range::InvalidRange are no longer expressed in the same
138 // values of start/end. 142 // values of start/end.
139 EXPECT_FALSE(range.IsValid()); 143 EXPECT_FALSE(range.IsValid());
140 } 144 }
141 145
142 } // namespace content 146 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698