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

Side by Side Diff: content/browser/renderer_host/render_widget_host_unittest.cc

Issue 1078123002: Send resize event when the screen info changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 8 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
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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "base/timer/timer.h" 10 #include "base/timer/timer.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 : RenderWidgetHostImpl(delegate, process, routing_id, false), 134 : RenderWidgetHostImpl(delegate, process, routing_id, false),
135 unresponsive_timer_fired_(false) { 135 unresponsive_timer_fired_(false) {
136 acked_touch_event_type_ = blink::WebInputEvent::Undefined; 136 acked_touch_event_type_ = blink::WebInputEvent::Undefined;
137 } 137 }
138 138
139 // Allow poking at a few private members. 139 // Allow poking at a few private members.
140 using RenderWidgetHostImpl::GetResizeParams; 140 using RenderWidgetHostImpl::GetResizeParams;
141 using RenderWidgetHostImpl::OnUpdateRect; 141 using RenderWidgetHostImpl::OnUpdateRect;
142 using RenderWidgetHostImpl::RendererExited; 142 using RenderWidgetHostImpl::RendererExited;
143 using RenderWidgetHostImpl::SetInitialRenderSizeParams; 143 using RenderWidgetHostImpl::SetInitialRenderSizeParams;
144 using RenderWidgetHostImpl::UpdateScreenInfo;
144 using RenderWidgetHostImpl::old_resize_params_; 145 using RenderWidgetHostImpl::old_resize_params_;
145 using RenderWidgetHostImpl::is_hidden_; 146 using RenderWidgetHostImpl::is_hidden_;
146 using RenderWidgetHostImpl::resize_ack_pending_; 147 using RenderWidgetHostImpl::resize_ack_pending_;
147 using RenderWidgetHostImpl::input_router_; 148 using RenderWidgetHostImpl::input_router_;
148 149
149 void OnTouchEventAck(const TouchEventWithLatencyInfo& event, 150 void OnTouchEventAck(const TouchEventWithLatencyInfo& event,
150 InputEventAckState ack_result) override { 151 InputEventAckState ack_result) override {
151 // Sniff touch acks. 152 // Sniff touch acks.
152 acked_touch_event_type_ = event.event.type; 153 acked_touch_event_type_ = event.event.type;
153 RenderWidgetHostImpl::OnTouchEventAck(event, ack_result); 154 RenderWidgetHostImpl::OnTouchEventAck(event, ack_result);
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 if (IsDelegatedRendererEnabled()) 440 if (IsDelegatedRendererEnabled())
440 ImageTransportFactory::Terminate(); 441 ImageTransportFactory::Terminate();
441 #endif 442 #endif
442 443
443 // Process all pending tasks to avoid leaks. 444 // Process all pending tasks to avoid leaks.
444 base::MessageLoop::current()->RunUntilIdle(); 445 base::MessageLoop::current()->RunUntilIdle();
445 } 446 }
446 447
447 void SetInitialRenderSizeParams() { 448 void SetInitialRenderSizeParams() {
448 ViewMsg_Resize_Params render_size_params; 449 ViewMsg_Resize_Params render_size_params;
450 host_->UpdateScreenInfo();
449 host_->GetResizeParams(&render_size_params); 451 host_->GetResizeParams(&render_size_params);
450 host_->SetInitialRenderSizeParams(render_size_params); 452 host_->SetInitialRenderSizeParams(render_size_params);
451 } 453 }
452 454
453 virtual void ConfigureView(TestView* view) { 455 virtual void ConfigureView(TestView* view) {
454 } 456 }
455 457
456 int64 GetLatencyComponentId() { 458 int64 GetLatencyComponentId() {
457 return host_->GetLatencyComponentId(); 459 return host_->GetLatencyComponentId();
458 } 460 }
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 class RenderWidgetHostWithSourceTest 599 class RenderWidgetHostWithSourceTest
598 : public RenderWidgetHostTest, 600 : public RenderWidgetHostTest,
599 public testing::WithParamInterface<WebGestureDevice> {}; 601 public testing::WithParamInterface<WebGestureDevice> {};
600 #endif // GTEST_HAS_PARAM_TEST 602 #endif // GTEST_HAS_PARAM_TEST
601 603
602 } // namespace 604 } // namespace
603 605
604 // ----------------------------------------------------------------------------- 606 // -----------------------------------------------------------------------------
605 607
606 TEST_F(RenderWidgetHostTest, Resize) { 608 TEST_F(RenderWidgetHostTest, Resize) {
607 // The initial bounds is the empty rect, and the screen info hasn't been sent 609 // The initial bounds is the empty rect, so setting it to the same thing
608 // yet, so setting it to the same thing shouldn't send the resize message. 610 // shouldn't send the resize message.
609 view_->set_bounds(gfx::Rect()); 611 view_->set_bounds(gfx::Rect());
610 host_->WasResized(); 612 host_->WasResized();
611 EXPECT_FALSE(host_->resize_ack_pending_); 613 EXPECT_FALSE(host_->resize_ack_pending_);
612 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); 614 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
613 615
614 // No resize ack if the physical backing gets set, but the view bounds are 616 // No resize ack if the physical backing gets set, but the view bounds are
615 // zero. 617 // zero.
616 view_->SetMockPhysicalBackingSize(gfx::Size(200, 200)); 618 view_->SetMockPhysicalBackingSize(gfx::Size(200, 200));
617 host_->WasResized(); 619 host_->WasResized();
618 EXPECT_FALSE(host_->resize_ack_pending_); 620 EXPECT_FALSE(host_->resize_ack_pending_);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 EXPECT_FALSE(process_->sink().GetFirstMessageMatching(ViewMsg_Resize::ID)); 714 EXPECT_FALSE(process_->sink().GetFirstMessageMatching(ViewMsg_Resize::ID));
713 715
714 // A different size should be sent again, however. 716 // A different size should be sent again, however.
715 view_->set_bounds(gfx::Rect(0, 0, 0, 31)); 717 view_->set_bounds(gfx::Rect(0, 0, 0, 31));
716 host_->WasResized(); 718 host_->WasResized();
717 EXPECT_FALSE(host_->resize_ack_pending_); 719 EXPECT_FALSE(host_->resize_ack_pending_);
718 EXPECT_EQ(gfx::Size(0, 31), host_->old_resize_params_->new_size); 720 EXPECT_EQ(gfx::Size(0, 31), host_->old_resize_params_->new_size);
719 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); 721 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
720 } 722 }
721 723
724 // Test that a resize event is sent if InvalidateScreenInfo() was called.
725 TEST_F(RenderWidgetHostTest, ResizeScreenInfo) {
726 host_->InvalidateScreenInfo();
727 host_->WasResized();
728 EXPECT_FALSE(host_->resize_ack_pending_);
729 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
730 }
731
722 // Test for crbug.com/25097. If a renderer crashes between a resize and the 732 // Test for crbug.com/25097. If a renderer crashes between a resize and the
723 // corresponding update message, we must be sure to clear the resize ack logic. 733 // corresponding update message, we must be sure to clear the resize ack logic.
724 TEST_F(RenderWidgetHostTest, ResizeThenCrash) { 734 TEST_F(RenderWidgetHostTest, ResizeThenCrash) {
725 // Clear the first Resize message that carried screen info. 735 // Clear the first Resize message that carried screen info.
726 process_->sink().ClearMessages(); 736 process_->sink().ClearMessages();
727 737
728 // Setting the bounds to a "real" rect should send out the notification. 738 // Setting the bounds to a "real" rect should send out the notification.
729 gfx::Rect original_size(0, 0, 100, 100); 739 gfx::Rect original_size(0, 0, 100, 100);
730 view_->set_bounds(original_size); 740 view_->set_bounds(original_size);
731 host_->WasResized(); 741 host_->WasResized();
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 // Having an initial size set means that the size information had been sent 1503 // Having an initial size set means that the size information had been sent
1494 // with the reqiest to new up the RenderView and so subsequent WasResized 1504 // with the reqiest to new up the RenderView and so subsequent WasResized
1495 // calls should not result in new IPC (unless the size has actually changed). 1505 // calls should not result in new IPC (unless the size has actually changed).
1496 host_->WasResized(); 1506 host_->WasResized();
1497 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); 1507 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
1498 EXPECT_EQ(initial_size_, host_->old_resize_params_->new_size); 1508 EXPECT_EQ(initial_size_, host_->old_resize_params_->new_size);
1499 EXPECT_TRUE(host_->resize_ack_pending_); 1509 EXPECT_TRUE(host_->resize_ack_pending_);
1500 } 1510 }
1501 1511
1502 } // namespace content 1512 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698