| 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 | 9 |
| 10 namespace content { | 10 namespace content { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 initial_size_params->physical_backing_size = initial_size_; | 94 initial_size_params->physical_backing_size = initial_size_; |
| 95 initial_size_params->needs_resize_ack = true; | 95 initial_size_params->needs_resize_ack = true; |
| 96 return initial_size_params; | 96 return initial_size_params; |
| 97 } | 97 } |
| 98 | 98 |
| 99 gfx::Size initial_size_; | 99 gfx::Size initial_size_; |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 TEST_F(RenderWidgetInitialSizeTest, InitialSize) { | 102 TEST_F(RenderWidgetInitialSizeTest, InitialSize) { |
| 103 EXPECT_EQ(initial_size_, widget()->size()); | 103 EXPECT_EQ(initial_size_, widget()->size()); |
| 104 EXPECT_EQ(initial_size_, gfx::Size(widget()->webwidget()->size())); | 104 EXPECT_EQ(initial_size_, gfx::Size(widget()->GetWebWidget()->size())); |
| 105 EXPECT_TRUE(next_paint_is_resize_ack()); | 105 EXPECT_TRUE(next_paint_is_resize_ack()); |
| 106 } | 106 } |
| 107 | 107 |
| 108 TEST_F(RenderWidgetTest, GetCompositionRangeValidComposition) { | 108 TEST_F(RenderWidgetTest, GetCompositionRangeValidComposition) { |
| 109 LoadHTML( | 109 LoadHTML( |
| 110 "<div contenteditable>EDITABLE</div>" | 110 "<div contenteditable>EDITABLE</div>" |
| 111 "<script> document.querySelector('div').focus(); </script>"); | 111 "<script> document.querySelector('div').focus(); </script>"); |
| 112 blink::WebVector<blink::WebCompositionUnderline> emptyUnderlines; | 112 blink::WebVector<blink::WebCompositionUnderline> emptyUnderlines; |
| 113 widget()->webwidget()->setComposition("hello", emptyUnderlines, 3, 3); | 113 widget()->GetWebWidget()->setComposition("hello", emptyUnderlines, 3, 3); |
| 114 gfx::Range range; | 114 gfx::Range range; |
| 115 GetCompositionRange(&range); | 115 GetCompositionRange(&range); |
| 116 EXPECT_TRUE(range.IsValid()); | 116 EXPECT_TRUE(range.IsValid()); |
| 117 EXPECT_EQ(0U, range.start()); | 117 EXPECT_EQ(0U, range.start()); |
| 118 EXPECT_EQ(5U, range.end()); | 118 EXPECT_EQ(5U, range.end()); |
| 119 } | 119 } |
| 120 | 120 |
| 121 TEST_F(RenderWidgetTest, GetCompositionRangeValidSelection) { | 121 TEST_F(RenderWidgetTest, GetCompositionRangeValidSelection) { |
| 122 LoadHTML( | 122 LoadHTML( |
| 123 "<div>NOT EDITABLE</div>" | 123 "<div>NOT EDITABLE</div>" |
| 124 "<script> document.execCommand('selectAll'); </script>"); | 124 "<script> document.execCommand('selectAll'); </script>"); |
| 125 gfx::Range range; | 125 gfx::Range range; |
| 126 GetCompositionRange(&range); | 126 GetCompositionRange(&range); |
| 127 EXPECT_TRUE(range.IsValid()); | 127 EXPECT_TRUE(range.IsValid()); |
| 128 EXPECT_EQ(0U, range.start()); | 128 EXPECT_EQ(0U, range.start()); |
| 129 EXPECT_EQ(12U, range.end()); | 129 EXPECT_EQ(12U, range.end()); |
| 130 } | 130 } |
| 131 | 131 |
| 132 TEST_F(RenderWidgetTest, GetCompositionRangeInvalid) { | 132 TEST_F(RenderWidgetTest, GetCompositionRangeInvalid) { |
| 133 LoadHTML("<div>NOT EDITABLE</div>"); | 133 LoadHTML("<div>NOT EDITABLE</div>"); |
| 134 gfx::Range range; | 134 gfx::Range range; |
| 135 GetCompositionRange(&range); | 135 GetCompositionRange(&range); |
| 136 // If this test ever starts failing, one likely outcome is that WebRange | 136 // If this test ever starts failing, one likely outcome is that WebRange |
| 137 // and gfx::Range::InvalidRange are no longer expressed in the same | 137 // and gfx::Range::InvalidRange are no longer expressed in the same |
| 138 // values of start/end. | 138 // values of start/end. |
| 139 EXPECT_FALSE(range.IsValid()); | 139 EXPECT_FALSE(range.IsValid()); |
| 140 } | 140 } |
| 141 | 141 |
| 142 } // namespace content | 142 } // namespace content |
| OLD | NEW |