| OLD | NEW |
| 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 "base/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
| 6 #include "content/common/resize_params.h" | 6 #include "content/common/resize_params.h" |
| 7 #include "content/public/test/render_view_test.h" | 7 #include "content/public/test/render_view_test.h" |
| 8 #include "content/renderer/render_view_impl.h" | 8 #include "content/renderer/render_view_impl.h" |
| 9 #include "content/renderer/render_widget.h" | 9 #include "content/renderer/render_widget.h" |
| 10 #include "third_party/WebKit/public/web/WebFrameWidget.h" | 10 #include "third_party/WebKit/public/web/WebFrameWidget.h" |
| 11 #include "third_party/WebKit/public/web/WebInputMethodController.h" | 11 #include "third_party/WebKit/public/web/WebInputMethodController.h" |
| 12 #include "third_party/WebKit/public/web/WebRange.h" |
| 12 #include "ui/base/ime/text_input_type.h" | 13 #include "ui/base/ime/text_input_type.h" |
| 13 | 14 |
| 14 namespace content { | 15 namespace content { |
| 15 | 16 |
| 16 class RenderWidgetTest : public RenderViewTest { | 17 class RenderWidgetTest : public RenderViewTest { |
| 17 protected: | 18 protected: |
| 18 RenderWidget* widget() { | 19 RenderWidget* widget() { |
| 19 return static_cast<RenderViewImpl*>(view_)->GetWidget(); | 20 return static_cast<RenderViewImpl*>(view_)->GetWidget(); |
| 20 } | 21 } |
| 21 | 22 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 EXPECT_TRUE(next_paint_is_resize_ack()); | 124 EXPECT_TRUE(next_paint_is_resize_ack()); |
| 124 } | 125 } |
| 125 | 126 |
| 126 TEST_F(RenderWidgetTest, GetCompositionRangeValidComposition) { | 127 TEST_F(RenderWidgetTest, GetCompositionRangeValidComposition) { |
| 127 LoadHTML( | 128 LoadHTML( |
| 128 "<div contenteditable>EDITABLE</div>" | 129 "<div contenteditable>EDITABLE</div>" |
| 129 "<script> document.querySelector('div').focus(); </script>"); | 130 "<script> document.querySelector('div').focus(); </script>"); |
| 130 blink::WebVector<blink::WebCompositionUnderline> emptyUnderlines; | 131 blink::WebVector<blink::WebCompositionUnderline> emptyUnderlines; |
| 131 DCHECK(widget()->GetInputMethodController()); | 132 DCHECK(widget()->GetInputMethodController()); |
| 132 widget()->GetInputMethodController()->setComposition("hello", emptyUnderlines, | 133 widget()->GetInputMethodController()->setComposition("hello", emptyUnderlines, |
| 133 3, 3); | 134 blink::WebRange(), 3, 3); |
| 134 gfx::Range range; | 135 gfx::Range range; |
| 135 GetCompositionRange(&range); | 136 GetCompositionRange(&range); |
| 136 EXPECT_TRUE(range.IsValid()); | 137 EXPECT_TRUE(range.IsValid()); |
| 137 EXPECT_EQ(0U, range.start()); | 138 EXPECT_EQ(0U, range.start()); |
| 138 EXPECT_EQ(5U, range.end()); | 139 EXPECT_EQ(5U, range.end()); |
| 139 } | 140 } |
| 140 | 141 |
| 141 TEST_F(RenderWidgetTest, GetCompositionRangeForSelection) { | 142 TEST_F(RenderWidgetTest, GetCompositionRangeForSelection) { |
| 142 LoadHTML( | 143 LoadHTML( |
| 143 "<div>NOT EDITABLE</div>" | 144 "<div>NOT EDITABLE</div>" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 EXPECT_EQ("hello", GetInputMethodController()->textInputInfo().value.utf8()); | 200 EXPECT_EQ("hello", GetInputMethodController()->textInputInfo().value.utf8()); |
| 200 | 201 |
| 201 // Now give focus back again and commit text. | 202 // Now give focus back again and commit text. |
| 202 SetFocus(true); | 203 SetFocus(true); |
| 203 CommitText(text); | 204 CommitText(text); |
| 204 EXPECT_EQ("hello world", | 205 EXPECT_EQ("hello world", |
| 205 GetInputMethodController()->textInputInfo().value.utf8()); | 206 GetInputMethodController()->textInputInfo().value.utf8()); |
| 206 } | 207 } |
| 207 | 208 |
| 208 } // namespace content | 209 } // namespace content |
| OLD | NEW |