| 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/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "content/browser/renderer_host/test_render_view_host.h" | 9 #include "content/browser/renderer_host/test_render_view_host.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "ui/aura/client/aura_constants.h" | 11 #include "ui/aura/client/aura_constants.h" |
| 12 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
| 13 #include "ui/base/ui_base_types.h" | 13 #include "ui/base/ui_base_types.h" |
| 14 | 14 |
| 15 using content::RenderWidgetHostView; | 15 using content::RenderWidgetHostView; |
| 16 using content::RenderViewHostImplTestHarness; |
| 16 | 17 |
| 17 // This approach (of using RenderViewHostTestHarness's RenderViewHost for a new | 18 // This approach (of using RenderViewHostTestHarness's RenderViewHost for a new |
| 18 // RenderWidgetHostView) is borrowed from RenderWidgetHostViewMacTest. | 19 // RenderWidgetHostView) is borrowed from RenderWidgetHostViewMacTest. |
| 19 class RenderWidgetHostViewAuraTest : public RenderViewHostTestHarness { | 20 class RenderWidgetHostViewAuraTest : public RenderViewHostImplTestHarness { |
| 20 public: | 21 public: |
| 21 RenderWidgetHostViewAuraTest() : old_rwhv_(NULL) {} | 22 RenderWidgetHostViewAuraTest() : old_rwhv_(NULL) {} |
| 22 | 23 |
| 23 virtual void SetUp() { | 24 virtual void SetUp() { |
| 24 RenderViewHostTestHarness::SetUp(); | 25 RenderViewHostTestHarness::SetUp(); |
| 25 old_rwhv_ = rvh()->GetView(); | 26 old_rwhv_ = rvh()->GetView(); |
| 26 rwhv_aura_ = static_cast<RenderWidgetHostViewAura*>( | 27 rwhv_aura_ = static_cast<RenderWidgetHostViewAura*>( |
| 27 RenderWidgetHostView::CreateViewForWidget(rvh())); | 28 RenderWidgetHostView::CreateViewForWidget(rvh())); |
| 28 } | 29 } |
| 29 | 30 |
| 30 virtual void TearDown() { | 31 virtual void TearDown() { |
| 31 aura::Window* window = rwhv_aura_->GetNativeView(); | 32 aura::Window* window = rwhv_aura_->GetNativeView(); |
| 32 if (window->parent()) | 33 if (window->parent()) |
| 33 window->parent()->RemoveChild(window); | 34 window->parent()->RemoveChild(window); |
| 34 rwhv_aura_->Destroy(); | 35 rwhv_aura_->Destroy(); |
| 35 // Destroying RWHV sets the host's view to NULL, so destroying view first, | 36 // Destroying RWHV sets the host's view to NULL, so destroying view first, |
| 36 // then set the view. | 37 // then set the view. |
| 37 rvh()->SetView(old_rwhv_); | 38 test_rvh()->SetView(old_rwhv_); |
| 38 RenderViewHostTestHarness::TearDown(); | 39 RenderViewHostTestHarness::TearDown(); |
| 39 } | 40 } |
| 40 | 41 |
| 41 protected: | 42 protected: |
| 42 RenderWidgetHostViewAura* rwhv_aura_; | 43 RenderWidgetHostViewAura* rwhv_aura_; |
| 43 | 44 |
| 44 private: | 45 private: |
| 45 RenderWidgetHostView* old_rwhv_; | 46 RenderWidgetHostView* old_rwhv_; |
| 46 | 47 |
| 47 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAuraTest); | 48 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAuraTest); |
| 48 }; | 49 }; |
| 49 | 50 |
| 50 // Checks that a fullscreen view has the correct show-state and receives the | 51 // Checks that a fullscreen view has the correct show-state and receives the |
| 51 // focus. | 52 // focus. |
| 52 TEST_F(RenderWidgetHostViewAuraTest, Fullscreen) { | 53 TEST_F(RenderWidgetHostViewAuraTest, Fullscreen) { |
| 53 rwhv_aura_->InitAsFullscreen(NULL); | 54 rwhv_aura_->InitAsFullscreen(NULL); |
| 54 | 55 |
| 55 aura::Window* window = rwhv_aura_->GetNativeView(); | 56 aura::Window* window = rwhv_aura_->GetNativeView(); |
| 56 ASSERT_TRUE(window != NULL); | 57 ASSERT_TRUE(window != NULL); |
| 57 EXPECT_EQ(ui::SHOW_STATE_FULLSCREEN, | 58 EXPECT_EQ(ui::SHOW_STATE_FULLSCREEN, |
| 58 window->GetProperty(aura::client::kShowStateKey)); | 59 window->GetProperty(aura::client::kShowStateKey)); |
| 59 | 60 |
| 60 // Check that we requested and received the focus. | 61 // Check that we requested and received the focus. |
| 61 EXPECT_TRUE(window->HasFocus()); | 62 EXPECT_TRUE(window->HasFocus()); |
| 62 | 63 |
| 63 // Check that we'll also say it's okay to activate the window when there's an | 64 // Check that we'll also say it's okay to activate the window when there's an |
| 64 // ActivationClient defined. | 65 // ActivationClient defined. |
| 65 EXPECT_TRUE(rwhv_aura_->ShouldActivate(NULL)); | 66 EXPECT_TRUE(rwhv_aura_->ShouldActivate(NULL)); |
| 66 } | 67 } |
| OLD | NEW |