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

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

Issue 2333813002: Introduce WebInputMethodController to blink (Closed)
Patch Set: Explicitly asking for TextInputState updates Created 4 years, 1 month 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 EXPECT_EQ(initial_size_, widget()->size()); 104 EXPECT_EQ(initial_size_, widget()->size());
103 EXPECT_EQ(initial_size_, gfx::Size(widget()->GetWebWidget()->size())); 105 EXPECT_EQ(initial_size_, gfx::Size(widget()->GetWebWidget()->size()));
104 EXPECT_TRUE(next_paint_is_resize_ack()); 106 EXPECT_TRUE(next_paint_is_resize_ack());
105 } 107 }
106 108
107 TEST_F(RenderWidgetTest, GetCompositionRangeValidComposition) { 109 TEST_F(RenderWidgetTest, GetCompositionRangeValidComposition) {
108 LoadHTML( 110 LoadHTML(
109 "<div contenteditable>EDITABLE</div>" 111 "<div contenteditable>EDITABLE</div>"
110 "<script> document.querySelector('div').focus(); </script>"); 112 "<script> document.querySelector('div').focus(); </script>");
111 blink::WebVector<blink::WebCompositionUnderline> emptyUnderlines; 113 blink::WebVector<blink::WebCompositionUnderline> emptyUnderlines;
112 widget()->GetWebWidget()->setComposition("hello", emptyUnderlines, 3, 3); 114 DCHECK(widget()->GetInputMethodController());
115 widget()->GetInputMethodController()->setComposition("hello", emptyUnderlines,
116 3, 3);
113 gfx::Range range; 117 gfx::Range range;
114 GetCompositionRange(&range); 118 GetCompositionRange(&range);
115 EXPECT_TRUE(range.IsValid()); 119 EXPECT_TRUE(range.IsValid());
116 EXPECT_EQ(0U, range.start()); 120 EXPECT_EQ(0U, range.start());
117 EXPECT_EQ(5U, range.end()); 121 EXPECT_EQ(5U, range.end());
118 } 122 }
119 123
120 TEST_F(RenderWidgetTest, GetCompositionRangeValidSelection) { 124 TEST_F(RenderWidgetTest, GetCompositionRangeValidSelection) {
121 LoadHTML( 125 LoadHTML(
122 "<div>NOT EDITABLE</div>" 126 "<div>NOT EDITABLE</div>"
123 "<script> document.execCommand('selectAll'); </script>"); 127 "<script> document.execCommand('selectAll'); </script>");
124 gfx::Range range; 128 gfx::Range range;
125 GetCompositionRange(&range); 129 GetCompositionRange(&range);
126 EXPECT_TRUE(range.IsValid()); 130 EXPECT_TRUE(range.IsValid());
127 EXPECT_EQ(0U, range.start()); 131 EXPECT_EQ(0U, range.start());
128 EXPECT_EQ(12U, range.end()); 132 EXPECT_EQ(12U, range.end());
129 } 133 }
130 134
131 TEST_F(RenderWidgetTest, GetCompositionRangeInvalid) { 135 TEST_F(RenderWidgetTest, GetCompositionRangeInvalid) {
132 LoadHTML("<div>NOT EDITABLE</div>"); 136 LoadHTML("<div>NOT EDITABLE</div>");
133 gfx::Range range; 137 gfx::Range range;
134 GetCompositionRange(&range); 138 GetCompositionRange(&range);
135 // If this test ever starts failing, one likely outcome is that WebRange 139 // If this test ever starts failing, one likely outcome is that WebRange
136 // and gfx::Range::InvalidRange are no longer expressed in the same 140 // and gfx::Range::InvalidRange are no longer expressed in the same
137 // values of start/end. 141 // values of start/end.
138 EXPECT_FALSE(range.IsValid()); 142 EXPECT_FALSE(range.IsValid());
139 } 143 }
140 144
141 } // namespace content 145 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698