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

Unified 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, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/render_widget.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_widget_browsertest.cc
diff --git a/content/renderer/render_widget_browsertest.cc b/content/renderer/render_widget_browsertest.cc
index 3a2bb1aaac6d96b9101876bb766377455e7f59af..b0ed636c204f3e6f2546e988b57ae87d19c638ef 100644
--- a/content/renderer/render_widget_browsertest.cc
+++ b/content/renderer/render_widget_browsertest.cc
@@ -2,12 +2,89 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "content/common/view_messages.h"
#include "content/public/test/render_widget_test.h"
+#include "content/renderer/render_widget.h"
namespace content {
TEST_F(RenderWidgetTest, OnResize) {
- TestOnResize();
+ // The initial bounds is empty, so setting it to the same thing should do
+ // nothing.
+ ViewMsg_Resize_Params resize_params;
+ resize_params.screen_info = blink::WebScreenInfo();
+ resize_params.new_size = gfx::Size();
+ resize_params.physical_backing_size = gfx::Size();
+ resize_params.top_controls_height = 0.f;
+ resize_params.top_controls_shrink_blink_size = false;
+ resize_params.resizer_rect = gfx::Rect();
+ resize_params.is_fullscreen = false;
+ resize_params.needs_resize_ack = false;
+ OnResize(resize_params);
+ EXPECT_EQ(resize_params.needs_resize_ack, next_paint_is_resize_ack());
+
+ // Setting empty physical backing size should not send the ack.
+ resize_params.new_size = gfx::Size(10, 10);
+ OnResize(resize_params);
+ EXPECT_EQ(resize_params.needs_resize_ack, next_paint_is_resize_ack());
+
+ // Setting the bounds to a "real" rect should send the ack.
+ render_thread_->sink().ClearMessages();
+ gfx::Size size(100, 100);
+ resize_params.new_size = size;
+ resize_params.physical_backing_size = size;
+ resize_params.needs_resize_ack = true;
+ OnResize(resize_params);
+ EXPECT_EQ(resize_params.needs_resize_ack, next_paint_is_resize_ack());
+
+ // Clear the flag.
+ widget()->didCompleteSwapBuffers();
+
+ // Setting the same size again should not send the ack.
+ resize_params.needs_resize_ack = false;
+ OnResize(resize_params);
+ EXPECT_EQ(resize_params.needs_resize_ack, next_paint_is_resize_ack());
+
+ // Resetting the rect to empty should not send the ack.
+ resize_params.new_size = gfx::Size();
+ resize_params.physical_backing_size = gfx::Size();
+ OnResize(resize_params);
+ EXPECT_EQ(resize_params.needs_resize_ack, next_paint_is_resize_ack());
+
+ // Changing the screen info should not send the ack.
+ resize_params.screen_info.orientationAngle = 90;
+ OnResize(resize_params);
+ EXPECT_EQ(resize_params.needs_resize_ack, next_paint_is_resize_ack());
+
+ resize_params.screen_info.orientationType =
+ blink::WebScreenOrientationPortraitPrimary;
+ OnResize(resize_params);
+ EXPECT_EQ(resize_params.needs_resize_ack, next_paint_is_resize_ack());
}
+class RenderWidgetInitialSizeTest : public RenderWidgetTest {
+ public:
+ RenderWidgetInitialSizeTest()
+ : RenderWidgetTest(), initial_size_(200, 100) {}
+
+ protected:
+ scoped_ptr<ViewMsg_Resize_Params> InitialSizeParams() override {
+ scoped_ptr<ViewMsg_Resize_Params> initial_size_params(
+ new ViewMsg_Resize_Params());
+ initial_size_params->new_size = initial_size_;
+ initial_size_params->physical_backing_size = initial_size_;
+ initial_size_params->needs_resize_ack = true;
+ return initial_size_params.Pass();
+ }
+
+ gfx::Size initial_size_;
+};
+
+TEST_F(RenderWidgetInitialSizeTest, InitialSize) {
+ EXPECT_EQ(initial_size_, widget()->size());
+ EXPECT_EQ(initial_size_, gfx::Size(widget()->webwidget()->size()));
+ EXPECT_TRUE(next_paint_is_resize_ack());
+}
+
+
} // namespace content
« 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