Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: content/renderer/render_widget_browsertest.cc

Issue 953233002: Add |needs_resize_ack| flag to ViewMsg_Resize (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove DCHECK() Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/render_widget.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/view_messages.h"
5 #include "content/public/test/render_widget_test.h" 6 #include "content/public/test/render_widget_test.h"
7 #include "content/renderer/render_widget.h"
6 8
7 namespace content { 9 namespace content {
8 10
9 TEST_F(RenderWidgetTest, OnResize) { 11 TEST_F(RenderWidgetTest, OnResize) {
10 TestOnResize(); 12 // The initial bounds is empty, so setting it to the same thing should do
13 // nothing.
14 ViewMsg_Resize_Params resize_params;
15 resize_params.screen_info = blink::WebScreenInfo();
16 resize_params.new_size = gfx::Size();
17 resize_params.physical_backing_size = gfx::Size();
18 resize_params.top_controls_height = 0.f;
19 resize_params.top_controls_shrink_blink_size = false;
20 resize_params.resizer_rect = gfx::Rect();
21 resize_params.is_fullscreen = false;
22 resize_params.needs_resize_ack = false;
23 OnResize(resize_params);
24 EXPECT_EQ(resize_params.needs_resize_ack, next_paint_is_resize_ack());
25
26 // Setting empty physical backing size should not send the ack.
27 resize_params.new_size = gfx::Size(10, 10);
28 OnResize(resize_params);
29 EXPECT_EQ(resize_params.needs_resize_ack, next_paint_is_resize_ack());
30
31 // Setting the bounds to a "real" rect should send the ack.
32 render_thread_->sink().ClearMessages();
33 gfx::Size size(100, 100);
34 resize_params.new_size = size;
35 resize_params.physical_backing_size = size;
36 resize_params.needs_resize_ack = true;
37 OnResize(resize_params);
38 EXPECT_EQ(resize_params.needs_resize_ack, next_paint_is_resize_ack());
39
40 // Clear the flag.
41 widget()->didCompleteSwapBuffers();
42
43 // Setting the same size again should not send the ack.
44 resize_params.needs_resize_ack = false;
45 OnResize(resize_params);
46 EXPECT_EQ(resize_params.needs_resize_ack, next_paint_is_resize_ack());
47
48 // Resetting the rect to empty should not send the ack.
49 resize_params.new_size = gfx::Size();
50 resize_params.physical_backing_size = gfx::Size();
51 OnResize(resize_params);
52 EXPECT_EQ(resize_params.needs_resize_ack, next_paint_is_resize_ack());
53
54 // Changing the screen info should not send the ack.
55 resize_params.screen_info.orientationAngle = 90;
56 OnResize(resize_params);
57 EXPECT_EQ(resize_params.needs_resize_ack, next_paint_is_resize_ack());
58
59 resize_params.screen_info.orientationType =
60 blink::WebScreenOrientationPortraitPrimary;
61 OnResize(resize_params);
62 EXPECT_EQ(resize_params.needs_resize_ack, next_paint_is_resize_ack());
11 } 63 }
12 64
65 class RenderWidgetInitialSizeTest : public RenderWidgetTest {
66 public:
67 RenderWidgetInitialSizeTest()
68 : RenderWidgetTest(), initial_size_(200, 100) {}
69
70 protected:
71 scoped_ptr<ViewMsg_Resize_Params> InitialSizeParams() override {
72 scoped_ptr<ViewMsg_Resize_Params> initial_size_params(
73 new ViewMsg_Resize_Params());
74 initial_size_params->new_size = initial_size_;
75 initial_size_params->physical_backing_size = initial_size_;
76 initial_size_params->needs_resize_ack = true;
77 return initial_size_params.Pass();
78 }
79
80 gfx::Size initial_size_;
81 };
82
83 TEST_F(RenderWidgetInitialSizeTest, InitialSize) {
84 EXPECT_EQ(initial_size_, widget()->size());
85 EXPECT_EQ(initial_size_, gfx::Size(widget()->webwidget()->size()));
86 EXPECT_TRUE(next_paint_is_resize_ack());
87 }
88
89
13 } // namespace content 90 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_widget.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698