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