Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
|
Fady Samuel
2013/12/19 21:35:01
What happened to these tests?
awong
2013/12/20 23:53:38
This is a file move. I'll see if I can fix in the
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/browser/renderer_host/render_widget_host_view_guest.h" | |
| 6 | |
| 7 #include "base/basictypes.h" | |
| 8 #include "base/message_loop/message_loop.h" | |
| 9 #include "content/browser/renderer_host/render_widget_host_delegate.h" | |
| 10 #include "content/browser/renderer_host/render_widget_host_impl.h" | |
| 11 #include "content/common/view_messages.h" | |
| 12 #include "content/public/browser/render_widget_host_view.h" | |
| 13 #include "content/public/test/mock_render_process_host.h" | |
| 14 #include "content/public/test/test_browser_context.h" | |
| 15 #include "content/test/test_render_view_host.h" | |
| 16 #include "testing/gtest/include/gtest/gtest.h" | |
| 17 | |
| 18 namespace content { | |
| 19 namespace { | |
| 20 class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate { | |
| 21 public: | |
| 22 MockRenderWidgetHostDelegate() {} | |
| 23 virtual ~MockRenderWidgetHostDelegate() {} | |
| 24 }; | |
| 25 | |
| 26 class RenderWidgetHostViewGuestTest : public testing::Test { | |
| 27 public: | |
| 28 RenderWidgetHostViewGuestTest() {} | |
| 29 | |
| 30 virtual void SetUp() { | |
| 31 browser_context_.reset(new TestBrowserContext); | |
| 32 MockRenderProcessHost* process_host = | |
| 33 new MockRenderProcessHost(browser_context_.get()); | |
| 34 widget_host_ = new RenderWidgetHostImpl( | |
| 35 &delegate_, process_host, MSG_ROUTING_NONE, false); | |
| 36 view_ = new RenderWidgetHostViewGuest( | |
| 37 widget_host_, NULL, new TestRenderWidgetHostView(widget_host_)); | |
| 38 } | |
| 39 | |
| 40 virtual void TearDown() { | |
| 41 if (view_) | |
| 42 view_->Destroy(); | |
| 43 delete widget_host_; | |
| 44 | |
| 45 browser_context_.reset(); | |
| 46 | |
| 47 message_loop_.DeleteSoon(FROM_HERE, browser_context_.release()); | |
| 48 message_loop_.RunUntilIdle(); | |
| 49 } | |
| 50 | |
| 51 protected: | |
| 52 base::MessageLoopForUI message_loop_; | |
| 53 scoped_ptr<BrowserContext> browser_context_; | |
| 54 MockRenderWidgetHostDelegate delegate_; | |
| 55 | |
| 56 // Tests should set these to NULL if they've already triggered their | |
| 57 // destruction. | |
| 58 RenderWidgetHostImpl* widget_host_; | |
| 59 RenderWidgetHostViewGuest* view_; | |
| 60 | |
| 61 private: | |
| 62 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewGuestTest); | |
| 63 }; | |
| 64 | |
| 65 } // namespace | |
| 66 | |
| 67 TEST_F(RenderWidgetHostViewGuestTest, VisibilityTest) { | |
| 68 view_->Show(); | |
| 69 ASSERT_TRUE(view_->IsShowing()); | |
| 70 | |
| 71 view_->Hide(); | |
| 72 ASSERT_FALSE(view_->IsShowing()); | |
| 73 | |
| 74 view_->WasShown(); | |
| 75 ASSERT_TRUE(view_->IsShowing()); | |
| 76 | |
| 77 view_->WasHidden(); | |
| 78 ASSERT_FALSE(view_->IsShowing()); | |
| 79 } | |
| 80 | |
| 81 } // namespace content | |
| OLD | NEW |