| 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 "content/browser/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.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" |
| 11 #include "content/public/browser/render_widget_host_view.h" | 11 #include "content/public/browser/render_widget_host_view.h" |
| 12 #include "content/public/test/mock_render_process_host.h" | 12 #include "content/public/test/mock_render_process_host.h" |
| 13 #include "content/public/test/test_browser_context.h" | 13 #include "content/public/test/test_browser_context.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "ui/aura/client/aura_constants.h" | 15 #include "ui/aura/client/aura_constants.h" |
| 16 #include "ui/aura/env.h" | 16 #include "ui/aura/env.h" |
| 17 #include "ui/aura/test/aura_test_helper.h" | 17 #include "ui/aura/test/aura_test_helper.h" |
| 18 #include "ui/aura/test/test_window_delegate.h" | 18 #include "ui/aura/test/test_window_delegate.h" |
| 19 #include "ui/aura/window.h" | 19 #include "ui/aura/window.h" |
| 20 #include "ui/aura/window_observer.h" | 20 #include "ui/aura/window_observer.h" |
| 21 #include "ui/base/ui_base_types.h" | 21 #include "ui/base/ui_base_types.h" |
| 22 | 22 |
| 23 class MockRenderWidgetHostDelegate : public content::RenderWidgetHostDelegate { | 23 namespace content { |
| 24 |
| 25 class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate { |
| 24 public: | 26 public: |
| 25 MockRenderWidgetHostDelegate() {} | 27 MockRenderWidgetHostDelegate() {} |
| 26 virtual ~MockRenderWidgetHostDelegate() {} | 28 virtual ~MockRenderWidgetHostDelegate() {} |
| 27 }; | 29 }; |
| 28 | 30 |
| 29 // Simple observer that keeps track of changes to a window for tests. | 31 // Simple observer that keeps track of changes to a window for tests. |
| 30 class TestWindowObserver : public aura::WindowObserver { | 32 class TestWindowObserver : public aura::WindowObserver { |
| 31 public: | 33 public: |
| 32 explicit TestWindowObserver(aura::Window* window_to_observe) | 34 explicit TestWindowObserver(aura::Window* window_to_observe) |
| 33 : window_(window_to_observe) { | 35 : window_(window_to_observe) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 58 }; | 60 }; |
| 59 | 61 |
| 60 class RenderWidgetHostViewAuraTest : public testing::Test { | 62 class RenderWidgetHostViewAuraTest : public testing::Test { |
| 61 public: | 63 public: |
| 62 RenderWidgetHostViewAuraTest() {} | 64 RenderWidgetHostViewAuraTest() {} |
| 63 | 65 |
| 64 virtual void SetUp() { | 66 virtual void SetUp() { |
| 65 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); | 67 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); |
| 66 aura_test_helper_->SetUp(); | 68 aura_test_helper_->SetUp(); |
| 67 | 69 |
| 68 browser_context_.reset(new content::TestBrowserContext); | 70 browser_context_.reset(new TestBrowserContext); |
| 69 content::MockRenderProcessHost* process_host = | 71 MockRenderProcessHost* process_host = |
| 70 new content::MockRenderProcessHost(browser_context_.get()); | 72 new MockRenderProcessHost(browser_context_.get()); |
| 71 widget_host_ = new content::RenderWidgetHostImpl( | 73 widget_host_ = new RenderWidgetHostImpl( |
| 72 &delegate_, process_host, MSG_ROUTING_NONE); | 74 &delegate_, process_host, MSG_ROUTING_NONE); |
| 73 view_ = static_cast<RenderWidgetHostViewAura*>( | 75 view_ = static_cast<RenderWidgetHostViewAura*>( |
| 74 content::RenderWidgetHostView::CreateViewForWidget(widget_host_)); | 76 RenderWidgetHostView::CreateViewForWidget(widget_host_)); |
| 75 } | 77 } |
| 76 | 78 |
| 77 virtual void TearDown() { | 79 virtual void TearDown() { |
| 78 if (view_) | 80 if (view_) |
| 79 view_->Destroy(); | 81 view_->Destroy(); |
| 80 delete widget_host_; | 82 delete widget_host_; |
| 81 | 83 |
| 82 browser_context_.reset(); | 84 browser_context_.reset(); |
| 83 aura_test_helper_->TearDown(); | 85 aura_test_helper_->TearDown(); |
| 84 | 86 |
| 85 message_loop_.DeleteSoon(FROM_HERE, browser_context_.release()); | 87 message_loop_.DeleteSoon(FROM_HERE, browser_context_.release()); |
| 86 message_loop_.RunAllPending(); | 88 message_loop_.RunAllPending(); |
| 87 } | 89 } |
| 88 | 90 |
| 89 protected: | 91 protected: |
| 90 MessageLoopForUI message_loop_; | 92 MessageLoopForUI message_loop_; |
| 91 scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_; | 93 scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_; |
| 92 scoped_ptr<content::BrowserContext> browser_context_; | 94 scoped_ptr<BrowserContext> browser_context_; |
| 93 MockRenderWidgetHostDelegate delegate_; | 95 MockRenderWidgetHostDelegate delegate_; |
| 94 | 96 |
| 95 // Tests should set these to NULL if they've already triggered their | 97 // Tests should set these to NULL if they've already triggered their |
| 96 // destruction. | 98 // destruction. |
| 97 content::RenderWidgetHostImpl* widget_host_; | 99 RenderWidgetHostImpl* widget_host_; |
| 98 RenderWidgetHostViewAura* view_; | 100 RenderWidgetHostViewAura* view_; |
| 99 | 101 |
| 100 private: | 102 private: |
| 101 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAuraTest); | 103 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAuraTest); |
| 102 }; | 104 }; |
| 103 | 105 |
| 104 // Checks that a fullscreen view has the correct show-state and receives the | 106 // Checks that a fullscreen view has the correct show-state and receives the |
| 105 // focus. | 107 // focus. |
| 106 TEST_F(RenderWidgetHostViewAuraTest, FocusFullscreen) { | 108 TEST_F(RenderWidgetHostViewAuraTest, FocusFullscreen) { |
| 107 view_->InitAsFullscreen(NULL); | 109 view_->InitAsFullscreen(NULL); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 133 sibling->Init(ui::LAYER_TEXTURED); | 135 sibling->Init(ui::LAYER_TEXTURED); |
| 134 sibling->Show(); | 136 sibling->Show(); |
| 135 window->parent()->AddChild(sibling.get()); | 137 window->parent()->AddChild(sibling.get()); |
| 136 sibling->Focus(); | 138 sibling->Focus(); |
| 137 ASSERT_TRUE(sibling->HasFocus()); | 139 ASSERT_TRUE(sibling->HasFocus()); |
| 138 ASSERT_TRUE(observer.destroyed()); | 140 ASSERT_TRUE(observer.destroyed()); |
| 139 | 141 |
| 140 widget_host_ = NULL; | 142 widget_host_ = NULL; |
| 141 view_ = NULL; | 143 view_ = NULL; |
| 142 } | 144 } |
| 145 |
| 146 } // namespace content |
| OLD | NEW |