OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 // Test view focus retention when a widget's HWND is disabled and re-enabled. | 647 // Test view focus retention when a widget's HWND is disabled and re-enabled. |
648 TEST_F(WidgetTestInteractive, ViewFocusOnHWNDEnabledChanges) { | 648 TEST_F(WidgetTestInteractive, ViewFocusOnHWNDEnabledChanges) { |
649 Widget* widget = CreateTopLevelFramelessPlatformWidget(); | 649 Widget* widget = CreateTopLevelFramelessPlatformWidget(); |
650 widget->SetContentsView(new View); | 650 widget->SetContentsView(new View); |
651 for (size_t i = 0; i < 2; ++i) { | 651 for (size_t i = 0; i < 2; ++i) { |
652 widget->GetContentsView()->AddChildView(new View); | 652 widget->GetContentsView()->AddChildView(new View); |
653 widget->GetContentsView()->child_at(i)->SetFocusable(true); | 653 widget->GetContentsView()->child_at(i)->SetFocusable(true); |
654 } | 654 } |
655 | 655 |
656 widget->Show(); | 656 widget->Show(); |
| 657 widget->GetNativeWindow()->GetHost()->Show(); |
657 const HWND hwnd = HWNDForWidget(widget); | 658 const HWND hwnd = HWNDForWidget(widget); |
658 EXPECT_TRUE(::IsWindow(hwnd)); | 659 EXPECT_TRUE(::IsWindow(hwnd)); |
659 EXPECT_TRUE(::IsWindowEnabled(hwnd)); | 660 EXPECT_TRUE(::IsWindowEnabled(hwnd)); |
660 EXPECT_EQ(hwnd, ::GetActiveWindow()); | 661 EXPECT_EQ(hwnd, ::GetActiveWindow()); |
661 | 662 |
662 for (int i = 0; i < widget->GetContentsView()->child_count(); ++i) { | 663 for (int i = 0; i < widget->GetContentsView()->child_count(); ++i) { |
663 SCOPED_TRACE(base::StringPrintf("Child view %d", i)); | 664 SCOPED_TRACE(base::StringPrintf("Child view %d", i)); |
664 View* view = widget->GetContentsView()->child_at(i); | 665 View* view = widget->GetContentsView()->child_at(i); |
665 | 666 |
666 view->RequestFocus(); | 667 view->RequestFocus(); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 EXPECT_TRUE(::IsWindow(win32_native_window1)); | 734 EXPECT_TRUE(::IsWindow(win32_native_window1)); |
734 | 735 |
735 ::SendMessage(win32_native_window1, WM_NCACTIVATE, 1, 0); | 736 ::SendMessage(win32_native_window1, WM_NCACTIVATE, 1, 0); |
736 EXPECT_EQ(false, widget1.active()); | 737 EXPECT_EQ(false, widget1.active()); |
737 EXPECT_EQ(true, widget2.active()); | 738 EXPECT_EQ(true, widget2.active()); |
738 | 739 |
739 ::SetActiveWindow(win32_native_window1); | 740 ::SetActiveWindow(win32_native_window1); |
740 EXPECT_EQ(true, widget1.active()); | 741 EXPECT_EQ(true, widget1.active()); |
741 EXPECT_EQ(false, widget2.active()); | 742 EXPECT_EQ(false, widget2.active()); |
742 } | 743 } |
| 744 |
| 745 // On Windows if we create a fullscreen window on a thread, then it affects the |
| 746 // way other windows on the thread interact with the taskbar. To workaround |
| 747 // this we reduce the bounds of a fullscreen window by 1px when it loses |
| 748 // activation. This test verifies the same. |
| 749 TEST_F(WidgetTestInteractive, FullscreenBoundsReducedOnActivationLoss) { |
| 750 Widget widget1; |
| 751 Widget::InitParams params = |
| 752 CreateParams(Widget::InitParams::TYPE_WINDOW); |
| 753 params.native_widget = new DesktopNativeWidgetAura(&widget1); |
| 754 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 755 widget1.Init(params); |
| 756 widget1.SetBounds(gfx::Rect(0, 0, 200, 200)); |
| 757 widget1.Show(); |
| 758 |
| 759 widget1.Activate(); |
| 760 RunPendingMessages(); |
| 761 EXPECT_EQ(::GetActiveWindow(), |
| 762 widget1.GetNativeWindow()->GetHost()->GetAcceleratedWidget()); |
| 763 |
| 764 widget1.SetFullscreen(true); |
| 765 EXPECT_TRUE(widget1.IsFullscreen()); |
| 766 // Ensure that the StopIgnoringPosChanges task in HWNDMessageHandler runs. |
| 767 // This task is queued when a widget becomes fullscreen. |
| 768 RunPendingMessages(); |
| 769 EXPECT_EQ(::GetActiveWindow(), |
| 770 widget1.GetNativeWindow()->GetHost()->GetAcceleratedWidget()); |
| 771 gfx::Rect fullscreen_bounds = widget1.GetWindowBoundsInScreen(); |
| 772 |
| 773 Widget widget2; |
| 774 params.native_widget = new DesktopNativeWidgetAura(&widget2); |
| 775 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 776 widget2.Init(params); |
| 777 widget2.SetBounds(gfx::Rect(0, 0, 200, 200)); |
| 778 widget2.Show(); |
| 779 |
| 780 widget2.Activate(); |
| 781 RunPendingMessages(); |
| 782 EXPECT_EQ(::GetActiveWindow(), |
| 783 widget2.GetNativeWindow()->GetHost()->GetAcceleratedWidget()); |
| 784 |
| 785 gfx::Rect fullscreen_bounds_after_activation_loss = |
| 786 widget1.GetWindowBoundsInScreen(); |
| 787 |
| 788 // After deactivation loss the bounds of the fullscreen widget should be |
| 789 // reduced by 1px. |
| 790 EXPECT_EQ(fullscreen_bounds.height() - |
| 791 fullscreen_bounds_after_activation_loss.height(), 1); |
| 792 |
| 793 widget1.Activate(); |
| 794 RunPendingMessages(); |
| 795 EXPECT_EQ(::GetActiveWindow(), |
| 796 widget1.GetNativeWindow()->GetHost()->GetAcceleratedWidget()); |
| 797 |
| 798 gfx::Rect fullscreen_bounds_after_activate = |
| 799 widget1.GetWindowBoundsInScreen(); |
| 800 |
| 801 // After activation the bounds of the fullscreen widget should be restored. |
| 802 EXPECT_EQ(fullscreen_bounds, fullscreen_bounds_after_activate); |
| 803 |
| 804 widget1.CloseNow(); |
| 805 widget2.CloseNow(); |
| 806 } |
743 #endif // defined(OS_WIN) | 807 #endif // defined(OS_WIN) |
744 | 808 |
745 #if !defined(OS_CHROMEOS) | 809 #if !defined(OS_CHROMEOS) |
746 // Provides functionality to create a window modal dialog. | 810 // Provides functionality to create a window modal dialog. |
747 class ModalDialogDelegate : public DialogDelegateView { | 811 class ModalDialogDelegate : public DialogDelegateView { |
748 public: | 812 public: |
749 explicit ModalDialogDelegate(ui::ModalType type) : type_(type) {} | 813 explicit ModalDialogDelegate(ui::ModalType type) : type_(type) {} |
750 ~ModalDialogDelegate() override {} | 814 ~ModalDialogDelegate() override {} |
751 | 815 |
752 // WidgetDelegate overrides. | 816 // WidgetDelegate overrides. |
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1588 widget->GetInputMethod()->GetTextInputType()); | 1652 widget->GetInputMethod()->GetTextInputType()); |
1589 | 1653 |
1590 textfield->SetReadOnly(true); | 1654 textfield->SetReadOnly(true); |
1591 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, | 1655 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, |
1592 widget->GetInputMethod()->GetTextInputType()); | 1656 widget->GetInputMethod()->GetTextInputType()); |
1593 widget->CloseNow(); | 1657 widget->CloseNow(); |
1594 } | 1658 } |
1595 | 1659 |
1596 } // namespace test | 1660 } // namespace test |
1597 } // namespace views | 1661 } // namespace views |
OLD | NEW |