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/files/file_path.h" | |
9 #include "base/files/file_util.h" | |
10 #include "base/memory/ref_counted_memory.h" | |
11 #include "base/strings/stringprintf.h" | |
12 #include "content/common/view_messages.h" | |
13 #include "content/renderer/render_view_impl.h" | 8 #include "content/renderer/render_view_impl.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | |
15 #include "third_party/WebKit/public/platform/WebScreenOrientationType.h" | |
16 #include "third_party/WebKit/public/platform/WebSize.h" | |
17 #include "third_party/WebKit/public/web/WebView.h" | |
18 #include "third_party/skia/include/core/SkBitmap.h" | |
19 #include "ui/gfx/codec/jpeg_codec.h" | |
20 #include "ui/gfx/geometry/size.h" | |
21 #include "ui/surface/transport_dib.h" | |
22 | 9 |
23 namespace content { | 10 namespace content { |
24 | 11 |
25 const int RenderWidgetTest::kNumBytesPerPixel = 4; | 12 const int RenderWidgetTest::kNumBytesPerPixel = 4; |
26 const int RenderWidgetTest::kLargeWidth = 1024; | 13 const int RenderWidgetTest::kLargeWidth = 1024; |
27 const int RenderWidgetTest::kLargeHeight = 768; | 14 const int RenderWidgetTest::kLargeHeight = 768; |
28 const int RenderWidgetTest::kSmallWidth = 600; | 15 const int RenderWidgetTest::kSmallWidth = 600; |
29 const int RenderWidgetTest::kSmallHeight = 450; | 16 const int RenderWidgetTest::kSmallHeight = 450; |
30 const int RenderWidgetTest::kTextPositionX = 800; | 17 const int RenderWidgetTest::kTextPositionX = 800; |
31 const int RenderWidgetTest::kTextPositionY = 600; | 18 const int RenderWidgetTest::kTextPositionY = 600; |
32 const uint32 RenderWidgetTest::kRedARGB = 0xFFFF0000; | 19 const uint32 RenderWidgetTest::kRedARGB = 0xFFFF0000; |
33 | 20 |
34 RenderWidgetTest::RenderWidgetTest() {} | 21 RenderWidgetTest::RenderWidgetTest() {} |
35 | 22 |
36 void RenderWidgetTest::TestOnResize() { | 23 RenderWidget* RenderWidgetTest::widget() { |
37 RenderWidget* widget = static_cast<RenderViewImpl*>(view_); | 24 return static_cast<RenderViewImpl*>(view_); |
| 25 } |
38 | 26 |
39 // The initial bounds is empty, so setting it to the same thing should do | 27 void RenderWidgetTest::OnResize(const ViewMsg_Resize_Params& params) { |
40 // nothing. | 28 widget()->OnResize(params); |
41 ViewMsg_Resize_Params resize_params; | 29 } |
42 resize_params.screen_info = blink::WebScreenInfo(); | |
43 resize_params.new_size = gfx::Size(); | |
44 resize_params.physical_backing_size = gfx::Size(); | |
45 resize_params.top_controls_height = 0.f; | |
46 resize_params.top_controls_shrink_blink_size = false; | |
47 resize_params.resizer_rect = gfx::Rect(); | |
48 resize_params.is_fullscreen = false; | |
49 widget->OnResize(resize_params); | |
50 EXPECT_FALSE(widget->next_paint_is_resize_ack()); | |
51 | 30 |
52 // Setting empty physical backing size should not send the ack. | 31 bool RenderWidgetTest::next_paint_is_resize_ack() { |
53 resize_params.new_size = gfx::Size(10, 10); | 32 return widget()->next_paint_is_resize_ack(); |
54 widget->OnResize(resize_params); | |
55 EXPECT_FALSE(widget->next_paint_is_resize_ack()); | |
56 | |
57 // Setting the bounds to a "real" rect should send the ack. | |
58 render_thread_->sink().ClearMessages(); | |
59 gfx::Size size(100, 100); | |
60 resize_params.new_size = size; | |
61 resize_params.physical_backing_size = size; | |
62 widget->OnResize(resize_params); | |
63 EXPECT_TRUE(widget->next_paint_is_resize_ack()); | |
64 | |
65 // Clear the flag. | |
66 // TODO(danakj): How real is this test any more? This flag is only existing | |
67 // for DCHECKs now. | |
68 widget->didCompleteSwapBuffers(); | |
69 | |
70 // Setting the same size again should not send the ack. | |
71 widget->OnResize(resize_params); | |
72 EXPECT_FALSE(widget->next_paint_is_resize_ack()); | |
73 | |
74 // Resetting the rect to empty should not send the ack. | |
75 resize_params.new_size = gfx::Size(); | |
76 resize_params.physical_backing_size = gfx::Size(); | |
77 widget->OnResize(resize_params); | |
78 EXPECT_FALSE(widget->next_paint_is_resize_ack()); | |
79 | |
80 // Changing the screen info should not send the ack. | |
81 resize_params.screen_info.orientationAngle = 90; | |
82 widget->OnResize(resize_params); | |
83 EXPECT_FALSE(widget->next_paint_is_resize_ack()); | |
84 | |
85 resize_params.screen_info.orientationType = | |
86 blink::WebScreenOrientationPortraitPrimary; | |
87 widget->OnResize(resize_params); | |
88 EXPECT_FALSE(widget->next_paint_is_resize_ack()); | |
89 } | 33 } |
90 | 34 |
91 } // namespace content | 35 } // namespace content |
OLD | NEW |