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/public/test/render_widget_test.h" | 5 #include "content/public/test/render_widget_test.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 ASSERT_TRUE(tmp_bitmap.copyTo(snapshot, SkBitmap::kARGB_8888_Config)); | 71 ASSERT_TRUE(tmp_bitmap.copyTo(snapshot, SkBitmap::kARGB_8888_Config)); |
72 } | 72 } |
73 | 73 |
74 void RenderWidgetTest::TestResizeAndPaint() { | 74 void RenderWidgetTest::TestResizeAndPaint() { |
75 // Hello World message is only visible if the view size is at least | 75 // Hello World message is only visible if the view size is at least |
76 // kTextPositionX x kTextPositionY | 76 // kTextPositionX x kTextPositionY |
77 LoadHTML(base::StringPrintf( | 77 LoadHTML(base::StringPrintf( |
78 "<html><body><div style='position: absolute; top: %d; left: " | 78 "<html><body><div style='position: absolute; top: %d; left: " |
79 "%d; background-color: red;'>Hello World</div></body></html>", | 79 "%d; background-color: red;'>Hello World</div></body></html>", |
80 kTextPositionY, kTextPositionX).c_str()); | 80 kTextPositionY, kTextPositionX).c_str()); |
81 WebKit::WebSize old_size = view_->GetWebView()->size(); | 81 blink::WebSize old_size = view_->GetWebView()->size(); |
82 | 82 |
83 SkBitmap bitmap; | 83 SkBitmap bitmap; |
84 // If we re-size the view to something smaller than where the 'Hello World' | 84 // If we re-size the view to something smaller than where the 'Hello World' |
85 // text is displayed we won't see any text in the snapshot. Hence, | 85 // text is displayed we won't see any text in the snapshot. Hence, |
86 // the snapshot should not contain any red. | 86 // the snapshot should not contain any red. |
87 gfx::Size size(kSmallWidth, kSmallHeight); | 87 gfx::Size size(kSmallWidth, kSmallHeight); |
88 ResizeAndPaint(size, size, &bitmap); | 88 ResizeAndPaint(size, size, &bitmap); |
89 // Make sure that the view has been re-sized to its old size. | 89 // Make sure that the view has been re-sized to its old size. |
90 EXPECT_TRUE(old_size == view_->GetWebView()->size()); | 90 EXPECT_TRUE(old_size == view_->GetWebView()->size()); |
91 EXPECT_EQ(kSmallWidth, bitmap.width()); | 91 EXPECT_EQ(kSmallWidth, bitmap.width()); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 reinterpret_cast<const char*>(bitmap_data->front()), | 147 reinterpret_cast<const char*>(bitmap_data->front()), |
148 bitmap_data->size())); | 148 bitmap_data->size())); |
149 } | 149 } |
150 | 150 |
151 void RenderWidgetTest::TestOnResize() { | 151 void RenderWidgetTest::TestOnResize() { |
152 RenderWidget* widget = static_cast<RenderViewImpl*>(view_); | 152 RenderWidget* widget = static_cast<RenderViewImpl*>(view_); |
153 | 153 |
154 // The initial bounds is empty, so setting it to the same thing should do | 154 // The initial bounds is empty, so setting it to the same thing should do |
155 // nothing. | 155 // nothing. |
156 ViewMsg_Resize_Params resize_params; | 156 ViewMsg_Resize_Params resize_params; |
157 resize_params.screen_info = WebKit::WebScreenInfo(); | 157 resize_params.screen_info = blink::WebScreenInfo(); |
158 resize_params.new_size = gfx::Size(); | 158 resize_params.new_size = gfx::Size(); |
159 resize_params.physical_backing_size = gfx::Size(); | 159 resize_params.physical_backing_size = gfx::Size(); |
160 resize_params.overdraw_bottom_height = 0.f; | 160 resize_params.overdraw_bottom_height = 0.f; |
161 resize_params.resizer_rect = gfx::Rect(); | 161 resize_params.resizer_rect = gfx::Rect(); |
162 resize_params.is_fullscreen = false; | 162 resize_params.is_fullscreen = false; |
163 widget->OnResize(resize_params); | 163 widget->OnResize(resize_params); |
164 EXPECT_FALSE(widget->next_paint_is_resize_ack()); | 164 EXPECT_FALSE(widget->next_paint_is_resize_ack()); |
165 | 165 |
166 // Setting empty physical backing size should not send the ack. | 166 // Setting empty physical backing size should not send the ack. |
167 resize_params.new_size = gfx::Size(10, 10); | 167 resize_params.new_size = gfx::Size(10, 10); |
(...skipping 28 matching lines...) Expand all Loading... |
196 EXPECT_FALSE(widget->next_paint_is_resize_ack()); | 196 EXPECT_FALSE(widget->next_paint_is_resize_ack()); |
197 | 197 |
198 // Resetting the rect to empty should not send the ack. | 198 // Resetting the rect to empty should not send the ack. |
199 resize_params.new_size = gfx::Size(); | 199 resize_params.new_size = gfx::Size(); |
200 resize_params.physical_backing_size = gfx::Size(); | 200 resize_params.physical_backing_size = gfx::Size(); |
201 widget->OnResize(resize_params); | 201 widget->OnResize(resize_params); |
202 EXPECT_FALSE(widget->next_paint_is_resize_ack()); | 202 EXPECT_FALSE(widget->next_paint_is_resize_ack()); |
203 } | 203 } |
204 | 204 |
205 } // namespace content | 205 } // namespace content |
OLD | NEW |