| 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 class DesktopAuraTopLevelWindowTest | 244 class DesktopAuraTopLevelWindowTest |
| 245 : public views::TestViewsDelegate, | 245 : public views::TestViewsDelegate, |
| 246 public aura::WindowObserver { | 246 public aura::WindowObserver { |
| 247 public: | 247 public: |
| 248 DesktopAuraTopLevelWindowTest() | 248 DesktopAuraTopLevelWindowTest() |
| 249 : top_level_widget_(NULL), | 249 : top_level_widget_(NULL), |
| 250 owned_window_(NULL), | 250 owned_window_(NULL), |
| 251 owner_destroyed_(false), | 251 owner_destroyed_(false), |
| 252 owned_window_destroyed_(false) {} | 252 owned_window_destroyed_(false) {} |
| 253 | 253 |
| 254 virtual ~DesktopAuraTopLevelWindowTest() { | 254 ~DesktopAuraTopLevelWindowTest() override { |
| 255 EXPECT_TRUE(owner_destroyed_); | 255 EXPECT_TRUE(owner_destroyed_); |
| 256 EXPECT_TRUE(owned_window_destroyed_); | 256 EXPECT_TRUE(owned_window_destroyed_); |
| 257 top_level_widget_ = NULL; | 257 top_level_widget_ = NULL; |
| 258 owned_window_ = NULL; | 258 owned_window_ = NULL; |
| 259 } | 259 } |
| 260 | 260 |
| 261 // views::TestViewsDelegate overrides. | 261 // views::TestViewsDelegate overrides. |
| 262 virtual void OnBeforeWidgetInit( | 262 void OnBeforeWidgetInit(Widget::InitParams* params, |
| 263 Widget::InitParams* params, | 263 internal::NativeWidgetDelegate* delegate) override { |
| 264 internal::NativeWidgetDelegate* delegate) override { | |
| 265 if (!params->native_widget) | 264 if (!params->native_widget) |
| 266 params->native_widget = new views::DesktopNativeWidgetAura(delegate); | 265 params->native_widget = new views::DesktopNativeWidgetAura(delegate); |
| 267 } | 266 } |
| 268 | 267 |
| 269 void CreateTopLevelWindow(const gfx::Rect& bounds, bool fullscreen) { | 268 void CreateTopLevelWindow(const gfx::Rect& bounds, bool fullscreen) { |
| 270 Widget::InitParams init_params; | 269 Widget::InitParams init_params; |
| 271 init_params.type = Widget::InitParams::TYPE_WINDOW; | 270 init_params.type = Widget::InitParams::TYPE_WINDOW; |
| 272 init_params.bounds = bounds; | 271 init_params.bounds = bounds; |
| 273 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 272 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 274 init_params.layer_type = aura::WINDOW_LAYER_NOT_DRAWN; | 273 init_params.layer_type = aura::WINDOW_LAYER_NOT_DRAWN; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 304 void DestroyOwnedWindow() { | 303 void DestroyOwnedWindow() { |
| 305 ASSERT_TRUE(owned_window_ != NULL); | 304 ASSERT_TRUE(owned_window_ != NULL); |
| 306 delete owned_window_; | 305 delete owned_window_; |
| 307 } | 306 } |
| 308 | 307 |
| 309 void DestroyOwnerWindow() { | 308 void DestroyOwnerWindow() { |
| 310 ASSERT_TRUE(top_level_widget_ != NULL); | 309 ASSERT_TRUE(top_level_widget_ != NULL); |
| 311 top_level_widget_->CloseNow(); | 310 top_level_widget_->CloseNow(); |
| 312 } | 311 } |
| 313 | 312 |
| 314 virtual void OnWindowDestroying(aura::Window* window) override { | 313 void OnWindowDestroying(aura::Window* window) override { |
| 315 window->RemoveObserver(this); | 314 window->RemoveObserver(this); |
| 316 if (window == owned_window_) { | 315 if (window == owned_window_) { |
| 317 owned_window_destroyed_ = true; | 316 owned_window_destroyed_ = true; |
| 318 } else if (window == top_level_widget_->GetNativeView()) { | 317 } else if (window == top_level_widget_->GetNativeView()) { |
| 319 owner_destroyed_ = true; | 318 owner_destroyed_ = true; |
| 320 } else { | 319 } else { |
| 321 ADD_FAILURE() << "Unexpected window destroyed callback: " << window; | 320 ADD_FAILURE() << "Unexpected window destroyed callback: " << window; |
| 322 } | 321 } |
| 323 } | 322 } |
| 324 | 323 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 | 389 |
| 391 EXPECT_EQ(popup_window.top_level_widget()->GetNativeView()->bounds().size(), | 390 EXPECT_EQ(popup_window.top_level_widget()->GetNativeView()->bounds().size(), |
| 392 new_size.size()); | 391 new_size.size()); |
| 393 RunPendingMessages(); | 392 RunPendingMessages(); |
| 394 ASSERT_NO_FATAL_FAILURE(popup_window.DestroyOwnedWindow()); | 393 ASSERT_NO_FATAL_FAILURE(popup_window.DestroyOwnedWindow()); |
| 395 RunPendingMessages(); | 394 RunPendingMessages(); |
| 396 } | 395 } |
| 397 | 396 |
| 398 } // namespace test | 397 } // namespace test |
| 399 } // namespace views | 398 } // namespace views |
| OLD | NEW |