| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 5 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "ui/aura/client/aura_constants.h" | 8 #include "ui/aura/client/aura_constants.h" |
| 9 #include "ui/aura/client/cursor_client.h" | 9 #include "ui/aura/client/cursor_client.h" |
| 10 #include "ui/aura/client/window_tree_client.h" | 10 #include "ui/aura/client/window_tree_client.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 namespace views { | 24 namespace views { |
| 25 namespace test { | 25 namespace test { |
| 26 | 26 |
| 27 typedef ViewsTestBase DesktopNativeWidgetAuraTest; | 27 typedef ViewsTestBase DesktopNativeWidgetAuraTest; |
| 28 | 28 |
| 29 // Verifies creating a Widget with a parent that is not in a RootWindow doesn't | 29 // Verifies creating a Widget with a parent that is not in a RootWindow doesn't |
| 30 // crash. | 30 // crash. |
| 31 TEST_F(DesktopNativeWidgetAuraTest, CreateWithParentNotInRootWindow) { | 31 TEST_F(DesktopNativeWidgetAuraTest, CreateWithParentNotInRootWindow) { |
| 32 scoped_ptr<aura::Window> window(new aura::Window(NULL)); | 32 scoped_ptr<aura::Window> window(new aura::Window(NULL)); |
| 33 window->Init(ui::LAYER_NOT_DRAWN); |
| 33 Widget widget; | 34 Widget widget; |
| 34 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); | 35 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); |
| 35 params.bounds = gfx::Rect(0, 0, 200, 200); | 36 params.bounds = gfx::Rect(0, 0, 200, 200); |
| 36 params.parent = window.get(); | 37 params.parent = window.get(); |
| 37 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 38 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 38 params.native_widget = new DesktopNativeWidgetAura(&widget); | 39 params.native_widget = new DesktopNativeWidgetAura(&widget); |
| 39 widget.Init(params); | 40 widget.Init(params); |
| 40 } | 41 } |
| 41 | 42 |
| 42 // Verifies that the Aura windows making up a widget instance have the correct | 43 // Verifies that the Aura windows making up a widget instance have the correct |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 Widget::InitParams init_params = | 193 Widget::InitParams init_params = |
| 193 CreateParams(Widget::InitParams::TYPE_WINDOW); | 194 CreateParams(Widget::InitParams::TYPE_WINDOW); |
| 194 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 195 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 195 DesktopNativeWidgetAura* desktop_native_widget_aura = | 196 DesktopNativeWidgetAura* desktop_native_widget_aura = |
| 196 new DesktopNativeWidgetAura(&widget); | 197 new DesktopNativeWidgetAura(&widget); |
| 197 init_params.native_widget = desktop_native_widget_aura; | 198 init_params.native_widget = desktop_native_widget_aura; |
| 198 widget.Init(init_params); | 199 widget.Init(init_params); |
| 199 | 200 |
| 200 // Owned by |widget|. | 201 // Owned by |widget|. |
| 201 aura::Window* window = new aura::Window(&delegate); | 202 aura::Window* window = new aura::Window(&delegate); |
| 203 window->Init(ui::LAYER_NOT_DRAWN); |
| 202 window->Show(); | 204 window->Show(); |
| 203 widget.GetNativeWindow()->parent()->AddChild(window); | 205 widget.GetNativeWindow()->parent()->AddChild(window); |
| 204 | 206 |
| 205 widget.Show(); | 207 widget.Show(); |
| 206 } | 208 } |
| 207 } | 209 } |
| 208 | 210 |
| 209 void QuitNestedLoopAndCloseWidget(scoped_ptr<Widget> widget, | 211 void QuitNestedLoopAndCloseWidget(scoped_ptr<Widget> widget, |
| 210 base::Closure* quit_runloop) { | 212 base::Closure* quit_runloop) { |
| 211 quit_runloop->Run(); | 213 quit_runloop->Run(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 internal::NativeWidgetDelegate* delegate) override { | 270 internal::NativeWidgetDelegate* delegate) override { |
| 269 if (!params->native_widget) | 271 if (!params->native_widget) |
| 270 params->native_widget = new views::DesktopNativeWidgetAura(delegate); | 272 params->native_widget = new views::DesktopNativeWidgetAura(delegate); |
| 271 } | 273 } |
| 272 | 274 |
| 273 void CreateTopLevelWindow(const gfx::Rect& bounds, bool fullscreen) { | 275 void CreateTopLevelWindow(const gfx::Rect& bounds, bool fullscreen) { |
| 274 Widget::InitParams init_params; | 276 Widget::InitParams init_params; |
| 275 init_params.type = Widget::InitParams::TYPE_WINDOW; | 277 init_params.type = Widget::InitParams::TYPE_WINDOW; |
| 276 init_params.bounds = bounds; | 278 init_params.bounds = bounds; |
| 277 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 279 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 278 init_params.layer_type = aura::WINDOW_LAYER_NOT_DRAWN; | 280 init_params.layer_type = ui::LAYER_NOT_DRAWN; |
| 279 init_params.accept_events = fullscreen; | 281 init_params.accept_events = fullscreen; |
| 280 | 282 |
| 281 widget_.Init(init_params); | 283 widget_.Init(init_params); |
| 282 | 284 |
| 283 owned_window_ = new aura::Window(&child_window_delegate_); | 285 owned_window_ = new aura::Window(&child_window_delegate_); |
| 284 owned_window_->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 286 owned_window_->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
| 285 owned_window_->SetName("TestTopLevelWindow"); | 287 owned_window_->SetName("TestTopLevelWindow"); |
| 286 if (fullscreen) { | 288 if (fullscreen) { |
| 287 owned_window_->SetProperty(aura::client::kShowStateKey, | 289 owned_window_->SetProperty(aura::client::kShowStateKey, |
| 288 ui::SHOW_STATE_FULLSCREEN); | 290 ui::SHOW_STATE_FULLSCREEN); |
| 289 } else { | 291 } else { |
| 290 owned_window_->SetType(ui::wm::WINDOW_TYPE_MENU); | 292 owned_window_->SetType(ui::wm::WINDOW_TYPE_MENU); |
| 291 } | 293 } |
| 292 owned_window_->Init(aura::WINDOW_LAYER_TEXTURED); | 294 owned_window_->Init(ui::LAYER_TEXTURED); |
| 293 aura::client::ParentWindowWithContext( | 295 aura::client::ParentWindowWithContext( |
| 294 owned_window_, | 296 owned_window_, |
| 295 widget_.GetNativeView()->GetRootWindow(), | 297 widget_.GetNativeView()->GetRootWindow(), |
| 296 gfx::Rect(0, 0, 1900, 1600)); | 298 gfx::Rect(0, 0, 1900, 1600)); |
| 297 owned_window_->Show(); | 299 owned_window_->Show(); |
| 298 owned_window_->AddObserver(this); | 300 owned_window_->AddObserver(this); |
| 299 | 301 |
| 300 ASSERT_TRUE(owned_window_->parent() != NULL); | 302 ASSERT_TRUE(owned_window_->parent() != NULL); |
| 301 owned_window_->parent()->AddObserver(this); | 303 owned_window_->parent()->AddObserver(this); |
| 302 | 304 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 RunCloseWidgetDuringDispatchTest(this, ui::ET_MOUSE_PRESSED); | 502 RunCloseWidgetDuringDispatchTest(this, ui::ET_MOUSE_PRESSED); |
| 501 } | 503 } |
| 502 | 504 |
| 503 // Verifies deleting the widget from a mouse released event doesn't crash. | 505 // Verifies deleting the widget from a mouse released event doesn't crash. |
| 504 TEST_F(DesktopAuraWidgetTest, CloseWidgetDuringMouseReleased) { | 506 TEST_F(DesktopAuraWidgetTest, CloseWidgetDuringMouseReleased) { |
| 505 RunCloseWidgetDuringDispatchTest(this, ui::ET_MOUSE_RELEASED); | 507 RunCloseWidgetDuringDispatchTest(this, ui::ET_MOUSE_RELEASED); |
| 506 } | 508 } |
| 507 | 509 |
| 508 } // namespace test | 510 } // namespace test |
| 509 } // namespace views | 511 } // namespace views |
| OLD | NEW |