| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/shared_memory.h" | 7 #include "base/shared_memory.h" |
| 8 #include "base/timer.h" | 8 #include "base/timer.h" |
| 9 #include "content/browser/browser_thread_impl.h" | 9 #include "content/browser/browser_thread_impl.h" |
| 10 #include "content/browser/renderer_host/backing_store.h" | 10 #include "content/browser/renderer_host/backing_store.h" |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 ASSERT_FALSE(process_->sink().GetFirstMessageMatching(ViewMsg_Resize::ID)); | 366 ASSERT_FALSE(process_->sink().GetFirstMessageMatching(ViewMsg_Resize::ID)); |
| 367 | 367 |
| 368 // Now clearing the bounds should send out a notification but we shouldn't | 368 // Now clearing the bounds should send out a notification but we shouldn't |
| 369 // expect a resize ack (since the renderer won't ack empty sizes). The message | 369 // expect a resize ack (since the renderer won't ack empty sizes). The message |
| 370 // should contain the new size (0x0) and not the previous one that we skipped | 370 // should contain the new size (0x0) and not the previous one that we skipped |
| 371 process_->sink().ClearMessages(); | 371 process_->sink().ClearMessages(); |
| 372 view_->set_bounds(gfx::Rect()); | 372 view_->set_bounds(gfx::Rect()); |
| 373 host_->WasResized(); | 373 host_->WasResized(); |
| 374 EXPECT_FALSE(host_->resize_ack_pending_); | 374 EXPECT_FALSE(host_->resize_ack_pending_); |
| 375 EXPECT_EQ(gfx::Size(), host_->in_flight_size_); | 375 EXPECT_EQ(gfx::Size(), host_->in_flight_size_); |
| 376 EXPECT_EQ(gfx::Size(), host_->current_size_); | |
| 377 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); | 376 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); |
| 378 | 377 |
| 379 // Send a rect that has no area but has either width or height set. | 378 // Send a rect that has no area but has either width or height set. |
| 380 // since we do not expect ACK, current_size_ should be updated right away. | |
| 381 process_->sink().ClearMessages(); | 379 process_->sink().ClearMessages(); |
| 382 view_->set_bounds(gfx::Rect(0, 0, 0, 30)); | 380 view_->set_bounds(gfx::Rect(0, 0, 0, 30)); |
| 383 host_->WasResized(); | 381 host_->WasResized(); |
| 384 EXPECT_FALSE(host_->resize_ack_pending_); | 382 EXPECT_FALSE(host_->resize_ack_pending_); |
| 385 EXPECT_EQ(gfx::Size(), host_->in_flight_size_); | 383 EXPECT_EQ(gfx::Size(0, 30), host_->in_flight_size_); |
| 386 EXPECT_EQ(gfx::Size(0, 30), host_->current_size_); | |
| 387 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); | 384 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); |
| 388 | 385 |
| 389 // Set the same size again. It should not be sent again. | 386 // Set the same size again. It should not be sent again. |
| 390 process_->sink().ClearMessages(); | 387 process_->sink().ClearMessages(); |
| 391 host_->WasResized(); | 388 host_->WasResized(); |
| 392 EXPECT_FALSE(host_->resize_ack_pending_); | 389 EXPECT_FALSE(host_->resize_ack_pending_); |
| 393 EXPECT_EQ(gfx::Size(), host_->in_flight_size_); | 390 EXPECT_EQ(gfx::Size(0, 30), host_->in_flight_size_); |
| 394 EXPECT_EQ(gfx::Size(0, 30), host_->current_size_); | |
| 395 EXPECT_FALSE(process_->sink().GetFirstMessageMatching(ViewMsg_Resize::ID)); | 391 EXPECT_FALSE(process_->sink().GetFirstMessageMatching(ViewMsg_Resize::ID)); |
| 396 | 392 |
| 397 // A different size should be sent again, however. | 393 // A different size should be sent again, however. |
| 398 view_->set_bounds(gfx::Rect(0, 0, 0, 31)); | 394 view_->set_bounds(gfx::Rect(0, 0, 0, 31)); |
| 399 host_->WasResized(); | 395 host_->WasResized(); |
| 400 EXPECT_FALSE(host_->resize_ack_pending_); | 396 EXPECT_FALSE(host_->resize_ack_pending_); |
| 401 EXPECT_EQ(gfx::Size(), host_->in_flight_size_); | 397 EXPECT_EQ(gfx::Size(0, 31), host_->in_flight_size_); |
| 402 EXPECT_EQ(gfx::Size(0, 31), host_->current_size_); | |
| 403 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); | 398 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); |
| 404 } | 399 } |
| 405 | 400 |
| 406 // Test for crbug.com/25097. If a renderer crashes between a resize and the | 401 // Test for crbug.com/25097. If a renderer crashes between a resize and the |
| 407 // corresponding update message, we must be sure to clear the resize ack logic. | 402 // corresponding update message, we must be sure to clear the resize ack logic. |
| 408 TEST_F(RenderWidgetHostTest, ResizeThenCrash) { | 403 TEST_F(RenderWidgetHostTest, ResizeThenCrash) { |
| 409 // Setting the bounds to a "real" rect should send out the notification. | 404 // Setting the bounds to a "real" rect should send out the notification. |
| 410 gfx::Rect original_size(0, 0, 100, 100); | 405 gfx::Rect original_size(0, 0, 100, 100); |
| 411 view_->set_bounds(original_size); | 406 view_->set_bounds(original_size); |
| 412 host_->WasResized(); | 407 host_->WasResized(); |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 // Start it again to ensure it still works. | 735 // Start it again to ensure it still works. |
| 741 EXPECT_FALSE(host_->unresponsive_timer_fired()); | 736 EXPECT_FALSE(host_->unresponsive_timer_fired()); |
| 742 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); | 737 host_->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); |
| 743 | 738 |
| 744 // Wait long enough for first timeout and see if it fired. | 739 // Wait long enough for first timeout and see if it fired. |
| 745 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 740 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 746 MessageLoop::QuitClosure(), 40); | 741 MessageLoop::QuitClosure(), 40); |
| 747 MessageLoop::current()->Run(); | 742 MessageLoop::current()->Run(); |
| 748 EXPECT_TRUE(host_->unresponsive_timer_fired()); | 743 EXPECT_TRUE(host_->unresponsive_timer_fired()); |
| 749 } | 744 } |
| OLD | NEW |