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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 bitmap.height(), | 141 bitmap.height(), |
142 static_cast<int>(bitmap.rowBytes()), | 142 static_cast<int>(bitmap.rowBytes()), |
143 90 /* quality */, | 143 90 /* quality */, |
144 &bitmap_data->data())); | 144 &bitmap_data->data())); |
145 ASSERT_LT(0, file_util::WriteFile( | 145 ASSERT_LT(0, file_util::WriteFile( |
146 file_path, | 146 file_path, |
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() { |
| 152 RenderWidget* widget = static_cast<RenderViewImpl*>(view_); |
| 153 |
| 154 // The initial bounds is empty, so setting it to the same thing should do |
| 155 // nothing. |
| 156 widget->OnResize(gfx::Size(), gfx::Size(), 0, gfx::Rect(), false); |
| 157 EXPECT_FALSE(widget->next_paint_is_resize_ack()); |
| 158 |
| 159 // Setting empty physical backing size should not send the ack. |
| 160 widget->OnResize(gfx::Size(10, 10), gfx::Size(), 0, gfx::Rect(), false); |
| 161 EXPECT_FALSE(widget->next_paint_is_resize_ack()); |
| 162 |
| 163 // Setting the bounds to a "real" rect should send the ack. |
| 164 render_thread_->sink().ClearMessages(); |
| 165 gfx::Size size(100, 100); |
| 166 widget->OnResize(size, size, 0, gfx::Rect(), false); |
| 167 EXPECT_TRUE(widget->next_paint_is_resize_ack()); |
| 168 widget->DoDeferredUpdate(); |
| 169 ProcessPendingMessages(); |
| 170 |
| 171 const ViewHostMsg_UpdateRect* msg = |
| 172 static_cast<const ViewHostMsg_UpdateRect*>( |
| 173 render_thread_->sink().GetUniqueMessageMatching( |
| 174 ViewHostMsg_UpdateRect::ID)); |
| 175 ASSERT_TRUE(msg); |
| 176 ViewHostMsg_UpdateRect::Schema::Param params; |
| 177 EXPECT_TRUE(ViewHostMsg_UpdateRect::Read(msg, ¶ms)); |
| 178 EXPECT_TRUE(ViewHostMsg_UpdateRect_Flags::is_resize_ack(params.a.flags)); |
| 179 EXPECT_EQ(size, params.a.view_size); |
| 180 render_thread_->sink().ClearMessages(); |
| 181 |
| 182 // Setting the same size again should not send the ack. |
| 183 widget->OnResize(size, size, 0, gfx::Rect(), false); |
| 184 EXPECT_FALSE(widget->next_paint_is_resize_ack()); |
| 185 |
| 186 // Resetting the rect to empty should not send the ack. |
| 187 widget->OnResize(gfx::Size(), gfx::Size(), 0, gfx::Rect(), false); |
| 188 EXPECT_FALSE(widget->next_paint_is_resize_ack()); |
| 189 } |
| 190 |
151 } // namespace content | 191 } // namespace content |
OLD | NEW |