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

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

Issue 11421006: Desktop aura: Break aura::Window::SetParent in two. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ash_unittests Created 8 years 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) 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"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 public: 65 public:
66 RenderWidgetHostViewAuraTest() {} 66 RenderWidgetHostViewAuraTest() {}
67 67
68 virtual void SetUp() { 68 virtual void SetUp() {
69 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); 69 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_));
70 aura_test_helper_->SetUp(); 70 aura_test_helper_->SetUp();
71 71
72 browser_context_.reset(new TestBrowserContext); 72 browser_context_.reset(new TestBrowserContext);
73 MockRenderProcessHost* process_host = 73 MockRenderProcessHost* process_host =
74 new MockRenderProcessHost(browser_context_.get()); 74 new MockRenderProcessHost(browser_context_.get());
75
76 parent_host_ = new RenderWidgetHostImpl(
77 &delegate_, process_host, MSG_ROUTING_NONE);
78 parent_view_ = static_cast<RenderWidgetHostViewAura*>(
79 RenderWidgetHostView::CreateViewForWidget(parent_host_));
80 parent_view_->InitAsChild(NULL);
81 parent_view_->GetNativeView()->SetDefaultParentByRootWindow(
82 aura_test_helper_->root_window(), gfx::Rect());
83
75 widget_host_ = new RenderWidgetHostImpl( 84 widget_host_ = new RenderWidgetHostImpl(
76 &delegate_, process_host, MSG_ROUTING_NONE); 85 &delegate_, process_host, MSG_ROUTING_NONE);
77 view_ = static_cast<RenderWidgetHostViewAura*>( 86 view_ = static_cast<RenderWidgetHostViewAura*>(
78 RenderWidgetHostView::CreateViewForWidget(widget_host_)); 87 RenderWidgetHostView::CreateViewForWidget(widget_host_));
79 } 88 }
80 89
81 virtual void TearDown() { 90 virtual void TearDown() {
82 if (view_) 91 if (view_)
83 view_->Destroy(); 92 view_->Destroy();
84 delete widget_host_; 93 delete widget_host_;
85 94
95 parent_view_->Destroy();
96 delete parent_host_;
97
86 browser_context_.reset(); 98 browser_context_.reset();
87 aura_test_helper_->TearDown(); 99 aura_test_helper_->TearDown();
88 100
89 message_loop_.DeleteSoon(FROM_HERE, browser_context_.release()); 101 message_loop_.DeleteSoon(FROM_HERE, browser_context_.release());
90 message_loop_.RunUntilIdle(); 102 message_loop_.RunUntilIdle();
91 } 103 }
92 104
93 protected: 105 protected:
94 MessageLoopForUI message_loop_; 106 MessageLoopForUI message_loop_;
95 scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_; 107 scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_;
96 scoped_ptr<BrowserContext> browser_context_; 108 scoped_ptr<BrowserContext> browser_context_;
97 MockRenderWidgetHostDelegate delegate_; 109 MockRenderWidgetHostDelegate delegate_;
98 110
99 // Tests should set these to NULL if they've already triggered their 111 // Tests should set these to NULL if they've already triggered their
100 // destruction. 112 // destruction.
113 RenderWidgetHostImpl* parent_host_;
114 RenderWidgetHostViewAura* parent_view_;
115
116 // Tests should set these to NULL if they've already triggered their
117 // destruction.
101 RenderWidgetHostImpl* widget_host_; 118 RenderWidgetHostImpl* widget_host_;
102 RenderWidgetHostViewAura* view_; 119 RenderWidgetHostViewAura* view_;
103 120
104 private: 121 private:
105 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAuraTest); 122 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAuraTest);
106 }; 123 };
107 124
108 } // namespace 125 } // namespace
109 126
110 // Checks that a fullscreen view has the correct show-state and receives the 127 // Checks that a fullscreen view has the correct show-state and receives the
111 // focus. 128 // focus.
112 TEST_F(RenderWidgetHostViewAuraTest, FocusFullscreen) { 129 TEST_F(RenderWidgetHostViewAuraTest, FocusFullscreen) {
113 view_->InitAsFullscreen(NULL); 130 view_->InitAsFullscreen(parent_view_);
114 aura::Window* window = view_->GetNativeView(); 131 aura::Window* window = view_->GetNativeView();
115 ASSERT_TRUE(window != NULL); 132 ASSERT_TRUE(window != NULL);
116 EXPECT_EQ(ui::SHOW_STATE_FULLSCREEN, 133 EXPECT_EQ(ui::SHOW_STATE_FULLSCREEN,
117 window->GetProperty(aura::client::kShowStateKey)); 134 window->GetProperty(aura::client::kShowStateKey));
118 135
119 // Check that we requested and received the focus. 136 // Check that we requested and received the focus.
120 EXPECT_TRUE(window->HasFocus()); 137 EXPECT_TRUE(window->HasFocus());
121 138
122 // Check that we'll also say it's okay to activate the window when there's an 139 // Check that we'll also say it's okay to activate the window when there's an
123 // ActivationClient defined. 140 // ActivationClient defined.
124 EXPECT_TRUE(view_->ShouldActivate(NULL)); 141 EXPECT_TRUE(view_->ShouldActivate(NULL));
125 } 142 }
126 143
127 // Checks that a fullscreen view is destroyed when it loses the focus. 144 // Checks that a fullscreen view is destroyed when it loses the focus.
128 TEST_F(RenderWidgetHostViewAuraTest, DestroyFullscreenOnBlur) { 145 TEST_F(RenderWidgetHostViewAuraTest, DestroyFullscreenOnBlur) {
129 view_->InitAsFullscreen(NULL); 146 view_->InitAsFullscreen(parent_view_);
130 aura::Window* window = view_->GetNativeView(); 147 aura::Window* window = view_->GetNativeView();
131 ASSERT_TRUE(window != NULL); 148 ASSERT_TRUE(window != NULL);
132 ASSERT_TRUE(window->HasFocus()); 149 ASSERT_TRUE(window->HasFocus());
133 150
134 // After we create and focus another window, the RWHVA's window should be 151 // After we create and focus another window, the RWHVA's window should be
135 // destroyed. 152 // destroyed.
136 TestWindowObserver observer(window); 153 TestWindowObserver observer(window);
137 aura::test::TestWindowDelegate delegate; 154 aura::test::TestWindowDelegate delegate;
138 scoped_ptr<aura::Window> sibling(new aura::Window(&delegate)); 155 scoped_ptr<aura::Window> sibling(new aura::Window(&delegate));
139 sibling->Init(ui::LAYER_TEXTURED); 156 sibling->Init(ui::LAYER_TEXTURED);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 EXPECT_EQ(1U, view_->touch_event_.touchesLength); 274 EXPECT_EQ(1U, view_->touch_event_.touchesLength);
258 EXPECT_EQ(WebKit::WebTouchPoint::StateMoved, 275 EXPECT_EQ(WebKit::WebTouchPoint::StateMoved,
259 view_->touch_event_.touches[0].state); 276 view_->touch_event_.touches[0].state);
260 277
261 EXPECT_EQ(ui::ER_CONSUMED, view_->OnTouchEvent(&release)); 278 EXPECT_EQ(ui::ER_CONSUMED, view_->OnTouchEvent(&release));
262 EXPECT_EQ(WebKit::WebInputEvent::TouchEnd, view_->touch_event_.type); 279 EXPECT_EQ(WebKit::WebInputEvent::TouchEnd, view_->touch_event_.type);
263 EXPECT_EQ(0U, view_->touch_event_.touchesLength); 280 EXPECT_EQ(0U, view_->touch_event_.touchesLength);
264 } 281 }
265 282
266 } // namespace content 283 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.cc ('k') | content/browser/web_contents/web_contents_view_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698