| 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 "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 Loading... |
| 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, GetCompositionRangeForSelection) { | 124 TEST_F(RenderWidgetTest, GetCompositionRangeForSelection) { |
| 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 // Selection range should not be treated as composition range. | 130 // Selection range should not be treated as composition range. |
| 127 EXPECT_FALSE(range.IsValid()); | 131 EXPECT_FALSE(range.IsValid()); |
| 128 } | 132 } |
| 129 | 133 |
| 130 TEST_F(RenderWidgetTest, GetCompositionRangeInvalid) { | 134 TEST_F(RenderWidgetTest, GetCompositionRangeInvalid) { |
| 131 LoadHTML("<div>NOT EDITABLE</div>"); | 135 LoadHTML("<div>NOT EDITABLE</div>"); |
| 132 gfx::Range range; | 136 gfx::Range range; |
| 133 GetCompositionRange(&range); | 137 GetCompositionRange(&range); |
| 134 // If this test ever starts failing, one likely outcome is that WebRange | 138 // If this test ever starts failing, one likely outcome is that WebRange |
| 135 // and gfx::Range::InvalidRange are no longer expressed in the same | 139 // and gfx::Range::InvalidRange are no longer expressed in the same |
| 136 // values of start/end. | 140 // values of start/end. |
| 137 EXPECT_FALSE(range.IsValid()); | 141 EXPECT_FALSE(range.IsValid()); |
| 138 } | 142 } |
| 139 | 143 |
| 140 } // namespace content | 144 } // namespace content |
| OLD | NEW |