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

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

Issue 536063002: Clean up RenderWidgetHostView destruction (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Safer scheme Created 6 years, 3 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 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 gfx::Rect original_size(0, 0, 100, 100); 740 gfx::Rect original_size(0, 0, 100, 100);
741 view_->set_bounds(original_size); 741 view_->set_bounds(original_size);
742 host_->WasResized(); 742 host_->WasResized();
743 EXPECT_TRUE(host_->resize_ack_pending_); 743 EXPECT_TRUE(host_->resize_ack_pending_);
744 EXPECT_EQ(original_size.size(), host_->last_requested_size_); 744 EXPECT_EQ(original_size.size(), host_->last_requested_size_);
745 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); 745 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
746 746
747 // Simulate a renderer crash before the update message. Ensure all the 747 // Simulate a renderer crash before the update message. Ensure all the
748 // resize ack logic is cleared. Must clear the view first so it doesn't get 748 // resize ack logic is cleared. Must clear the view first so it doesn't get
749 // deleted. 749 // deleted.
750 host_->SetView(NULL); 750 host_->ViewDestroyed(view_.get());
751 host_->RendererExited(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); 751 host_->RendererExited(base::TERMINATION_STATUS_PROCESS_CRASHED, -1);
752 EXPECT_FALSE(host_->resize_ack_pending_); 752 EXPECT_FALSE(host_->resize_ack_pending_);
753 EXPECT_EQ(gfx::Size(), host_->last_requested_size_); 753 EXPECT_EQ(gfx::Size(), host_->last_requested_size_);
754 754
755 // Reset the view so we can exit the test cleanly. 755 // Reset the view so we can exit the test cleanly.
756 host_->SetView(view_.get()); 756 host_->SetView(view_.get());
757 } 757 }
758 758
759 // Unable to include render_widget_host_view_mac.h and compile. 759 // Unable to include render_widget_host_view_mac.h and compile.
760 #if !defined(OS_MACOSX) 760 #if !defined(OS_MACOSX)
(...skipping 16 matching lines...) Expand all
777 const IPC::Message* set_background = 777 const IPC::Message* set_background =
778 process_->sink().GetUniqueMessageMatching( 778 process_->sink().GetUniqueMessageMatching(
779 ViewMsg_SetBackgroundOpaque::ID); 779 ViewMsg_SetBackgroundOpaque::ID);
780 ASSERT_TRUE(set_background); 780 ASSERT_TRUE(set_background);
781 Tuple1<bool> sent_background; 781 Tuple1<bool> sent_background;
782 ViewMsg_SetBackgroundOpaque::Read(set_background, &sent_background); 782 ViewMsg_SetBackgroundOpaque::Read(set_background, &sent_background);
783 EXPECT_FALSE(sent_background.a); 783 EXPECT_FALSE(sent_background.a);
784 784
785 #if defined(USE_AURA) 785 #if defined(USE_AURA)
786 // See the comment above |InitAsChild(NULL)|. 786 // See the comment above |InitAsChild(NULL)|.
787 host_->SetView(NULL); 787 host_->ViewDestroyed(view_.get());
788 static_cast<RenderWidgetHostViewBase*>(view.release())->Destroy(); 788 static_cast<RenderWidgetHostViewBase*>(view.release())->Destroy();
789 #endif 789 #endif
790 } 790 }
791 #endif 791 #endif
792 792
793 // Test that we don't paint when we're hidden, but we still send the ACK. Most 793 // Test that we don't paint when we're hidden, but we still send the ACK. Most
794 // of the rest of the painting is tested in the GetBackingStore* ones. 794 // of the rest of the painting is tested in the GetBackingStore* ones.
795 TEST_F(RenderWidgetHostTest, HiddenPaint) { 795 TEST_F(RenderWidgetHostTest, HiddenPaint) {
796 BrowserThreadImpl ui_thread(BrowserThread::UI, base::MessageLoop::current()); 796 BrowserThreadImpl ui_thread(BrowserThread::UI, base::MessageLoop::current());
797 // Hide the widget, it should have sent out a message to the renderer. 797 // Hide the widget, it should have sent out a message to the renderer.
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
1424 1424
1425 ASSERT_TRUE(host_->is_hidden()); 1425 ASSERT_TRUE(host_->is_hidden());
1426 host_->RendererExited(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); 1426 host_->RendererExited(base::TERMINATION_STATUS_PROCESS_CRASHED, -1);
1427 ASSERT_FALSE(host_->is_hidden()); 1427 ASSERT_FALSE(host_->is_hidden());
1428 1428
1429 // Make sure the input router is in a fresh state. 1429 // Make sure the input router is in a fresh state.
1430 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); 1430 ASSERT_FALSE(host_->input_router()->HasPendingEvents());
1431 } 1431 }
1432 1432
1433 } // namespace content 1433 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698