| 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" |
| 11 #include "ui/aura/test/test_window_delegate.h" | 11 #include "ui/aura/test/test_window_delegate.h" |
| 12 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
| 13 #include "ui/aura/window_tree_host.h" | 13 #include "ui/aura/window_tree_host.h" |
| 14 #include "ui/events/event_processor.h" | 14 #include "ui/events/event_processor.h" |
| 15 #include "ui/events/event_utils.h" | 15 #include "ui/events/event_utils.h" |
| 16 #include "ui/events/test/event_generator.h" | 16 #include "ui/events/test/event_generator.h" |
| 17 #include "ui/gfx/screen.h" | 17 #include "ui/gfx/screen.h" |
| 18 #include "ui/views/test/test_views.h" | 18 #include "ui/views/test/test_views.h" |
| 19 #include "ui/views/test/test_views_delegate.h" |
| 19 #include "ui/views/test/views_test_base.h" | 20 #include "ui/views/test/views_test_base.h" |
| 20 #include "ui/views/test/widget_test.h" | 21 #include "ui/views/test/widget_test.h" |
| 21 #include "ui/views/widget/widget.h" | 22 #include "ui/views/widget/widget.h" |
| 22 #include "ui/wm/public/dispatcher_client.h" | 23 #include "ui/wm/public/dispatcher_client.h" |
| 23 | 24 |
| 24 namespace views { | 25 namespace views { |
| 25 namespace test { | 26 namespace test { |
| 26 | 27 |
| 27 typedef ViewsTestBase DesktopNativeWidgetAuraTest; | 28 typedef ViewsTestBase DesktopNativeWidgetAuraTest; |
| 28 | 29 |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 // This flag controls whether we need to wait for the destruction to complete | 358 // This flag controls whether we need to wait for the destruction to complete |
| 358 // before finishing the test. Defaults to true. | 359 // before finishing the test. Defaults to true. |
| 359 bool use_async_mode_; | 360 bool use_async_mode_; |
| 360 | 361 |
| 361 DISALLOW_COPY_AND_ASSIGN(DesktopAuraTopLevelWindowTest); | 362 DISALLOW_COPY_AND_ASSIGN(DesktopAuraTopLevelWindowTest); |
| 362 }; | 363 }; |
| 363 | 364 |
| 364 typedef WidgetTest DesktopAuraWidgetTest; | 365 typedef WidgetTest DesktopAuraWidgetTest; |
| 365 | 366 |
| 366 TEST_F(DesktopAuraWidgetTest, FullscreenWindowDestroyedBeforeOwnerTest) { | 367 TEST_F(DesktopAuraWidgetTest, FullscreenWindowDestroyedBeforeOwnerTest) { |
| 367 ViewsDelegate::views_delegate = NULL; | 368 set_views_delegate(nullptr); |
| 368 DesktopAuraTopLevelWindowTest fullscreen_window; | 369 DesktopAuraTopLevelWindowTest fullscreen_window; |
| 369 ASSERT_NO_FATAL_FAILURE(fullscreen_window.CreateTopLevelWindow( | 370 ASSERT_NO_FATAL_FAILURE(fullscreen_window.CreateTopLevelWindow( |
| 370 gfx::Rect(0, 0, 200, 200), true)); | 371 gfx::Rect(0, 0, 200, 200), true)); |
| 371 | 372 |
| 372 RunPendingMessages(); | 373 RunPendingMessages(); |
| 373 ASSERT_NO_FATAL_FAILURE(fullscreen_window.DestroyOwnedWindow()); | 374 ASSERT_NO_FATAL_FAILURE(fullscreen_window.DestroyOwnedWindow()); |
| 374 RunPendingMessages(); | 375 RunPendingMessages(); |
| 375 } | 376 } |
| 376 | 377 |
| 377 TEST_F(DesktopAuraWidgetTest, FullscreenWindowOwnerDestroyed) { | 378 TEST_F(DesktopAuraWidgetTest, FullscreenWindowOwnerDestroyed) { |
| 378 ViewsDelegate::views_delegate = NULL; | 379 set_views_delegate(nullptr); |
| 379 | 380 |
| 380 DesktopAuraTopLevelWindowTest fullscreen_window; | 381 DesktopAuraTopLevelWindowTest fullscreen_window; |
| 381 ASSERT_NO_FATAL_FAILURE(fullscreen_window.CreateTopLevelWindow( | 382 ASSERT_NO_FATAL_FAILURE(fullscreen_window.CreateTopLevelWindow( |
| 382 gfx::Rect(0, 0, 200, 200), true)); | 383 gfx::Rect(0, 0, 200, 200), true)); |
| 383 | 384 |
| 384 RunPendingMessages(); | 385 RunPendingMessages(); |
| 385 ASSERT_NO_FATAL_FAILURE(fullscreen_window.DestroyOwnerWindow()); | 386 ASSERT_NO_FATAL_FAILURE(fullscreen_window.DestroyOwnerWindow()); |
| 386 RunPendingMessages(); | 387 RunPendingMessages(); |
| 387 } | 388 } |
| 388 | 389 |
| 389 TEST_F(DesktopAuraWidgetTest, TopLevelOwnedPopupTest) { | 390 TEST_F(DesktopAuraWidgetTest, TopLevelOwnedPopupTest) { |
| 390 ViewsDelegate::views_delegate = NULL; | 391 set_views_delegate(nullptr); |
| 391 DesktopAuraTopLevelWindowTest popup_window; | 392 DesktopAuraTopLevelWindowTest popup_window; |
| 392 ASSERT_NO_FATAL_FAILURE(popup_window.CreateTopLevelWindow( | 393 ASSERT_NO_FATAL_FAILURE(popup_window.CreateTopLevelWindow( |
| 393 gfx::Rect(0, 0, 200, 200), false)); | 394 gfx::Rect(0, 0, 200, 200), false)); |
| 394 | 395 |
| 395 RunPendingMessages(); | 396 RunPendingMessages(); |
| 396 ASSERT_NO_FATAL_FAILURE(popup_window.DestroyOwnedWindow()); | 397 ASSERT_NO_FATAL_FAILURE(popup_window.DestroyOwnedWindow()); |
| 397 RunPendingMessages(); | 398 RunPendingMessages(); |
| 398 } | 399 } |
| 399 | 400 |
| 400 // This test validates that when a top level owned popup Aura window is | 401 // This test validates that when a top level owned popup Aura window is |
| 401 // resized, the widget is resized as well. | 402 // resized, the widget is resized as well. |
| 402 TEST_F(DesktopAuraWidgetTest, TopLevelOwnedPopupResizeTest) { | 403 TEST_F(DesktopAuraWidgetTest, TopLevelOwnedPopupResizeTest) { |
| 403 ViewsDelegate::views_delegate = NULL; | 404 set_views_delegate(nullptr); |
| 404 DesktopAuraTopLevelWindowTest popup_window; | 405 DesktopAuraTopLevelWindowTest popup_window; |
| 405 | 406 |
| 406 popup_window.set_use_async_mode(false); | 407 popup_window.set_use_async_mode(false); |
| 407 | 408 |
| 408 ASSERT_NO_FATAL_FAILURE(popup_window.CreateTopLevelWindow( | 409 ASSERT_NO_FATAL_FAILURE(popup_window.CreateTopLevelWindow( |
| 409 gfx::Rect(0, 0, 200, 200), false)); | 410 gfx::Rect(0, 0, 200, 200), false)); |
| 410 | 411 |
| 411 gfx::Rect new_size(0, 0, 400, 400); | 412 gfx::Rect new_size(0, 0, 400, 400); |
| 412 popup_window.owned_window()->SetBounds(new_size); | 413 popup_window.owned_window()->SetBounds(new_size); |
| 413 | 414 |
| 414 EXPECT_EQ(popup_window.top_level_widget()->GetNativeView()->bounds().size(), | 415 EXPECT_EQ(popup_window.top_level_widget()->GetNativeView()->bounds().size(), |
| 415 new_size.size()); | 416 new_size.size()); |
| 416 | 417 |
| 417 ASSERT_NO_FATAL_FAILURE(popup_window.DestroyOwnedWindow()); | 418 ASSERT_NO_FATAL_FAILURE(popup_window.DestroyOwnedWindow()); |
| 418 } | 419 } |
| 419 | 420 |
| 420 // This test validates that when a top level owned popup Aura window is | 421 // This test validates that when a top level owned popup Aura window is |
| 421 // repositioned, the widget is repositioned as well. | 422 // repositioned, the widget is repositioned as well. |
| 422 TEST_F(DesktopAuraWidgetTest, TopLevelOwnedPopupRepositionTest) { | 423 TEST_F(DesktopAuraWidgetTest, TopLevelOwnedPopupRepositionTest) { |
| 423 ViewsDelegate::views_delegate = NULL; | 424 set_views_delegate(nullptr); |
| 424 DesktopAuraTopLevelWindowTest popup_window; | 425 DesktopAuraTopLevelWindowTest popup_window; |
| 425 | 426 |
| 426 popup_window.set_use_async_mode(false); | 427 popup_window.set_use_async_mode(false); |
| 427 | 428 |
| 428 ASSERT_NO_FATAL_FAILURE(popup_window.CreateTopLevelWindow( | 429 ASSERT_NO_FATAL_FAILURE(popup_window.CreateTopLevelWindow( |
| 429 gfx::Rect(0, 0, 200, 200), false)); | 430 gfx::Rect(0, 0, 200, 200), false)); |
| 430 | 431 |
| 431 gfx::Rect new_pos(10, 10, 400, 400); | 432 gfx::Rect new_pos(10, 10, 400, 400); |
| 432 popup_window.owned_window()->SetBoundsInScreen( | 433 popup_window.owned_window()->SetBoundsInScreen( |
| 433 new_pos, | 434 new_pos, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 RunCloseWidgetDuringDispatchTest(this, ui::ET_MOUSE_PRESSED); | 503 RunCloseWidgetDuringDispatchTest(this, ui::ET_MOUSE_PRESSED); |
| 503 } | 504 } |
| 504 | 505 |
| 505 // Verifies deleting the widget from a mouse released event doesn't crash. | 506 // Verifies deleting the widget from a mouse released event doesn't crash. |
| 506 TEST_F(DesktopAuraWidgetTest, CloseWidgetDuringMouseReleased) { | 507 TEST_F(DesktopAuraWidgetTest, CloseWidgetDuringMouseReleased) { |
| 507 RunCloseWidgetDuringDispatchTest(this, ui::ET_MOUSE_RELEASED); | 508 RunCloseWidgetDuringDispatchTest(this, ui::ET_MOUSE_RELEASED); |
| 508 } | 509 } |
| 509 | 510 |
| 510 } // namespace test | 511 } // namespace test |
| 511 } // namespace views | 512 } // namespace views |
| OLD | NEW |