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

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

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

Powered by Google App Engine
This is Rietveld 408576698