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

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

Issue 16267002: Re-fix http://crbug.com/87176, and add a test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Much shorter test Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "content/browser/renderer_host/render_widget_host_view_guest.h" 5 #include "content/browser/renderer_host/render_widget_host_view_guest.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "content/browser/renderer_host/render_widget_host_delegate.h" 9 #include "content/browser/renderer_host/render_widget_host_delegate.h"
10 #include "content/browser/renderer_host/render_widget_host_impl.h" 10 #include "content/browser/renderer_host/render_widget_host_impl.h"
(...skipping 15 matching lines...) Expand all
26 class RenderWidgetHostViewGuestTest : public testing::Test { 26 class RenderWidgetHostViewGuestTest : public testing::Test {
27 public: 27 public:
28 RenderWidgetHostViewGuestTest() {} 28 RenderWidgetHostViewGuestTest() {}
29 29
30 virtual void SetUp() { 30 virtual void SetUp() {
31 browser_context_.reset(new TestBrowserContext); 31 browser_context_.reset(new TestBrowserContext);
32 MockRenderProcessHost* process_host = 32 MockRenderProcessHost* process_host =
33 new MockRenderProcessHost(browser_context_.get()); 33 new MockRenderProcessHost(browser_context_.get());
34 widget_host_ = new RenderWidgetHostImpl( 34 widget_host_ = new RenderWidgetHostImpl(
35 &delegate_, process_host, MSG_ROUTING_NONE); 35 &delegate_, process_host, MSG_ROUTING_NONE);
36 test_platform_view_.reset(new TestRenderWidgetHostView(widget_host_)); 36 view_ = new RenderWidgetHostViewGuest(
37 view_ = static_cast<RenderWidgetHostViewGuest*>( 37 widget_host_, NULL, new TestRenderWidgetHostView(widget_host_));
38 new RenderWidgetHostViewGuest(
39 widget_host_, NULL, test_platform_view_.get()));
40 } 38 }
41 39
42 virtual void TearDown() { 40 virtual void TearDown() {
43 if (view_) 41 if (view_)
44 view_->Destroy(); 42 view_->Destroy();
45 delete widget_host_; 43 delete widget_host_;
46 44
47 browser_context_.reset(); 45 browser_context_.reset();
48 46
49 message_loop_.DeleteSoon(FROM_HERE, browser_context_.release()); 47 message_loop_.DeleteSoon(FROM_HERE, browser_context_.release());
50 message_loop_.RunUntilIdle(); 48 message_loop_.RunUntilIdle();
51 } 49 }
52 50
53 protected: 51 protected:
54 base::MessageLoopForUI message_loop_; 52 base::MessageLoopForUI message_loop_;
55 scoped_ptr<BrowserContext> browser_context_; 53 scoped_ptr<BrowserContext> browser_context_;
56 MockRenderWidgetHostDelegate delegate_; 54 MockRenderWidgetHostDelegate delegate_;
57 55
58 // Tests should set these to NULL if they've already triggered their 56 // Tests should set these to NULL if they've already triggered their
59 // destruction. 57 // destruction.
60 RenderWidgetHostImpl* widget_host_; 58 RenderWidgetHostImpl* widget_host_;
61 RenderWidgetHostViewGuest* view_; 59 RenderWidgetHostViewGuest* view_;
62 60
63 scoped_ptr<TestRenderWidgetHostView> test_platform_view_;
64
65 private: 61 private:
66 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewGuestTest); 62 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewGuestTest);
67 }; 63 };
68 64
69 } // namespace 65 } // namespace
70 66
71 TEST_F(RenderWidgetHostViewGuestTest, VisibilityTest) { 67 TEST_F(RenderWidgetHostViewGuestTest, VisibilityTest) {
72 view_->Show(); 68 view_->Show();
73 ASSERT_TRUE(view_->IsShowing()); 69 ASSERT_TRUE(view_->IsShowing());
74 70
75 view_->Hide(); 71 view_->Hide();
76 ASSERT_FALSE(view_->IsShowing()); 72 ASSERT_FALSE(view_->IsShowing());
77 73
78 view_->WasShown(); 74 view_->WasShown();
79 ASSERT_TRUE(view_->IsShowing()); 75 ASSERT_TRUE(view_->IsShowing());
80 76
81 view_->WasHidden(); 77 view_->WasHidden();
82 ASSERT_FALSE(view_->IsShowing()); 78 ASSERT_FALSE(view_->IsShowing());
83 } 79 }
84 80
85 } // namespace content 81 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698