| OLD | NEW |
| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <memory> | 6 #include <memory> |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 | 303 |
| 304 parent->Show(); | 304 parent->Show(); |
| 305 EXPECT_TRUE(child->IsVisible()); | 305 EXPECT_TRUE(child->IsVisible()); |
| 306 EXPECT_TRUE(IsWindowStackedAbove(child, parent.get())); | 306 EXPECT_TRUE(IsWindowStackedAbove(child, parent.get())); |
| 307 EXPECT_FALSE(IsWindowStackedAbove(parent.get(), child)); // Sanity check. | 307 EXPECT_FALSE(IsWindowStackedAbove(parent.get(), child)); // Sanity check. |
| 308 | 308 |
| 309 WidgetAutoclosePtr popover(CreateTopLevelPlatformWidget()); | 309 WidgetAutoclosePtr popover(CreateTopLevelPlatformWidget()); |
| 310 popover->SetBounds(gfx::Rect(150, 90, 340, 240)); | 310 popover->SetBounds(gfx::Rect(150, 90, 340, 240)); |
| 311 popover->Show(); | 311 popover->Show(); |
| 312 | 312 |
| 313 EXPECT_TRUE(IsWindowStackedAbove(popover.get(), child)); | 313 // NOTE: for aura-mus-client stacking of top-levels is not maintained in the |
| 314 // client, so z-order of top-levels can't be determined. |
| 315 if (!IsAuraMusClient()) |
| 316 EXPECT_TRUE(IsWindowStackedAbove(popover.get(), child)); |
| 314 EXPECT_TRUE(IsWindowStackedAbove(child, parent.get())); | 317 EXPECT_TRUE(IsWindowStackedAbove(child, parent.get())); |
| 315 | 318 |
| 316 // Showing the parent again should raise it and its child above the popover. | 319 // Showing the parent again should raise it and its child above the popover. |
| 317 parent->Show(); | 320 parent->Show(); |
| 318 EXPECT_TRUE(IsWindowStackedAbove(child, parent.get())); | 321 EXPECT_TRUE(IsWindowStackedAbove(child, parent.get())); |
| 319 EXPECT_TRUE(IsWindowStackedAbove(parent.get(), popover.get())); | 322 if (!IsAuraMusClient()) |
| 323 EXPECT_TRUE(IsWindowStackedAbove(parent.get(), popover.get())); |
| 320 | 324 |
| 321 // Test grandchildren. | 325 // Test grandchildren. |
| 322 Widget* grandchild = CreateChildPlatformWidget(child->GetNativeView()); | 326 Widget* grandchild = CreateChildPlatformWidget(child->GetNativeView()); |
| 323 grandchild->SetBounds(gfx::Rect(5, 5, 15, 10)); | 327 grandchild->SetBounds(gfx::Rect(5, 5, 15, 10)); |
| 324 grandchild->ShowInactive(); | 328 grandchild->ShowInactive(); |
| 325 EXPECT_TRUE(IsWindowStackedAbove(grandchild, child)); | 329 EXPECT_TRUE(IsWindowStackedAbove(grandchild, child)); |
| 326 EXPECT_TRUE(IsWindowStackedAbove(child, parent.get())); | 330 EXPECT_TRUE(IsWindowStackedAbove(child, parent.get())); |
| 327 EXPECT_TRUE(IsWindowStackedAbove(parent.get(), popover.get())); | 331 if (!IsAuraMusClient()) |
| 332 EXPECT_TRUE(IsWindowStackedAbove(parent.get(), popover.get())); |
| 328 | 333 |
| 329 popover->Show(); | 334 popover->Show(); |
| 330 EXPECT_TRUE(IsWindowStackedAbove(popover.get(), grandchild)); | 335 if (!IsAuraMusClient()) |
| 336 EXPECT_TRUE(IsWindowStackedAbove(popover.get(), grandchild)); |
| 331 EXPECT_TRUE(IsWindowStackedAbove(grandchild, child)); | 337 EXPECT_TRUE(IsWindowStackedAbove(grandchild, child)); |
| 332 | 338 |
| 333 parent->Show(); | 339 parent->Show(); |
| 334 EXPECT_TRUE(IsWindowStackedAbove(grandchild, child)); | 340 EXPECT_TRUE(IsWindowStackedAbove(grandchild, child)); |
| 335 EXPECT_TRUE(IsWindowStackedAbove(child, popover.get())); | 341 if (!IsAuraMusClient()) |
| 342 EXPECT_TRUE(IsWindowStackedAbove(child, popover.get())); |
| 336 | 343 |
| 337 // Test hiding and reshowing. | 344 // Test hiding and reshowing. |
| 338 parent->Hide(); | 345 parent->Hide(); |
| 339 EXPECT_FALSE(grandchild->IsVisible()); | 346 EXPECT_FALSE(grandchild->IsVisible()); |
| 340 parent->Show(); | 347 parent->Show(); |
| 341 | 348 |
| 342 EXPECT_TRUE(IsWindowStackedAbove(grandchild, child)); | 349 EXPECT_TRUE(IsWindowStackedAbove(grandchild, child)); |
| 343 EXPECT_TRUE(IsWindowStackedAbove(child, parent.get())); | 350 EXPECT_TRUE(IsWindowStackedAbove(child, parent.get())); |
| 344 EXPECT_TRUE(IsWindowStackedAbove(parent.get(), popover.get())); | 351 if (!IsAuraMusClient()) |
| 352 EXPECT_TRUE(IsWindowStackedAbove(parent.get(), popover.get())); |
| 345 | 353 |
| 346 grandchild->Hide(); | 354 grandchild->Hide(); |
| 347 EXPECT_FALSE(grandchild->IsVisible()); | 355 EXPECT_FALSE(grandchild->IsVisible()); |
| 348 grandchild->ShowInactive(); | 356 grandchild->ShowInactive(); |
| 349 | 357 |
| 350 EXPECT_TRUE(IsWindowStackedAbove(grandchild, child)); | 358 EXPECT_TRUE(IsWindowStackedAbove(grandchild, child)); |
| 351 EXPECT_TRUE(IsWindowStackedAbove(child, parent.get())); | 359 EXPECT_TRUE(IsWindowStackedAbove(child, parent.get())); |
| 352 EXPECT_TRUE(IsWindowStackedAbove(parent.get(), popover.get())); | 360 if (!IsAuraMusClient()) |
| 361 EXPECT_TRUE(IsWindowStackedAbove(parent.get(), popover.get())); |
| 353 } | 362 } |
| 354 | 363 |
| 355 //////////////////////////////////////////////////////////////////////////////// | 364 //////////////////////////////////////////////////////////////////////////////// |
| 356 // Widget ownership tests. | 365 // Widget ownership tests. |
| 357 // | 366 // |
| 358 // Tests various permutations of Widget ownership specified in the | 367 // Tests various permutations of Widget ownership specified in the |
| 359 // InitParams::Ownership param. | 368 // InitParams::Ownership param. |
| 360 | 369 |
| 361 // A WidgetTest that supplies a toplevel widget for NativeWidget to parent to. | 370 // A WidgetTest that supplies a toplevel widget for NativeWidget to parent to. |
| 362 class WidgetOwnershipTest : public WidgetTest { | 371 class WidgetOwnershipTest : public WidgetTest { |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 EXPECT_EQ(child2, widget_hidden()); | 849 EXPECT_EQ(child2, widget_hidden()); |
| 841 | 850 |
| 842 child1->Show(); | 851 child1->Show(); |
| 843 EXPECT_EQ(child1, widget_shown()); | 852 EXPECT_EQ(child1, widget_shown()); |
| 844 | 853 |
| 845 child2->Show(); | 854 child2->Show(); |
| 846 EXPECT_EQ(child2, widget_shown()); | 855 EXPECT_EQ(child2, widget_shown()); |
| 847 } | 856 } |
| 848 | 857 |
| 849 TEST_F(WidgetObserverTest, DestroyBubble) { | 858 TEST_F(WidgetObserverTest, DestroyBubble) { |
| 859 // TODO: reenable once http://crbug.com/663903 is fixed. |
| 860 if (IsAuraMusClient()) |
| 861 return; |
| 862 |
| 850 // This test expect NativeWidgetAura, force its creation. | 863 // This test expect NativeWidgetAura, force its creation. |
| 851 ViewsDelegate::GetInstance()->set_native_widget_factory( | 864 ViewsDelegate::GetInstance()->set_native_widget_factory( |
| 852 ViewsDelegate::NativeWidgetFactory()); | 865 ViewsDelegate::NativeWidgetFactory()); |
| 853 | 866 |
| 854 WidgetAutoclosePtr anchor(CreateTopLevelPlatformWidget()); | 867 WidgetAutoclosePtr anchor(CreateTopLevelPlatformWidget()); |
| 855 anchor->Show(); | 868 anchor->Show(); |
| 856 | 869 |
| 857 BubbleDialogDelegateView* bubble_delegate = | 870 BubbleDialogDelegateView* bubble_delegate = |
| 858 new TestBubbleDialogDelegateView(anchor->client_view()); | 871 new TestBubbleDialogDelegateView(anchor->client_view()); |
| 859 { | 872 { |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1268 EXPECT_FALSE(contents_view->HasFocus()); | 1281 EXPECT_FALSE(contents_view->HasFocus()); |
| 1269 EXPECT_TRUE(bubble_delegate_view->HasFocus()); | 1282 EXPECT_TRUE(bubble_delegate_view->HasFocus()); |
| 1270 | 1283 |
| 1271 bubble_delegate_view->GetWidget()->CloseNow(); | 1284 bubble_delegate_view->GetWidget()->CloseNow(); |
| 1272 | 1285 |
| 1273 // Closing the bubble should result in focus going back to the contents view. | 1286 // Closing the bubble should result in focus going back to the contents view. |
| 1274 EXPECT_TRUE(contents_view->HasFocus()); | 1287 EXPECT_TRUE(contents_view->HasFocus()); |
| 1275 } | 1288 } |
| 1276 | 1289 |
| 1277 TEST_F(WidgetTest, BubbleControlsResetOnInit) { | 1290 TEST_F(WidgetTest, BubbleControlsResetOnInit) { |
| 1278 // This test creates a NativeWidgetAura and then a bubble parented to it. This | 1291 // TODO: enable once http://crbug.com/660994 is fixed. |
| 1279 // means the test needs a NativeWidgetAura for the bubble as well. | 1292 if (IsAuraMusClient()) |
| 1280 ViewsDelegate::GetInstance()->set_native_widget_factory( | 1293 return; |
| 1281 ViewsDelegate::NativeWidgetFactory()); | |
| 1282 | 1294 |
| 1283 WidgetAutoclosePtr anchor(CreateTopLevelPlatformWidget()); | 1295 WidgetAutoclosePtr anchor(CreateTopLevelPlatformWidget()); |
| 1284 anchor->Show(); | 1296 anchor->Show(); |
| 1285 | 1297 |
| 1286 { | 1298 { |
| 1287 TestBubbleDialogDelegateView* bubble_delegate = | 1299 TestBubbleDialogDelegateView* bubble_delegate = |
| 1288 new TestBubbleDialogDelegateView(anchor->client_view()); | 1300 new TestBubbleDialogDelegateView(anchor->client_view()); |
| 1289 WidgetAutoclosePtr bubble_widget( | 1301 WidgetAutoclosePtr bubble_widget( |
| 1290 BubbleDialogDelegateView::CreateBubble(bubble_delegate)); | 1302 BubbleDialogDelegateView::CreateBubble(bubble_delegate)); |
| 1291 EXPECT_TRUE(bubble_delegate->reset_controls_called_); | 1303 EXPECT_TRUE(bubble_delegate->reset_controls_called_); |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1691 | 1703 |
| 1692 widget->Show(); | 1704 widget->Show(); |
| 1693 | 1705 |
| 1694 // SynthesizeMouseMoveEvent does nothing until the mouse is entered. | 1706 // SynthesizeMouseMoveEvent does nothing until the mouse is entered. |
| 1695 widget->SynthesizeMouseMoveEvent(); | 1707 widget->SynthesizeMouseMoveEvent(); |
| 1696 EXPECT_EQ(0, v1->GetEventCount(ui::ET_MOUSE_MOVED)); | 1708 EXPECT_EQ(0, v1->GetEventCount(ui::ET_MOUSE_MOVED)); |
| 1697 EXPECT_EQ(0, v2->GetEventCount(ui::ET_MOUSE_MOVED)); | 1709 EXPECT_EQ(0, v2->GetEventCount(ui::ET_MOUSE_MOVED)); |
| 1698 | 1710 |
| 1699 gfx::Point cursor_location(5, 5); | 1711 gfx::Point cursor_location(5, 5); |
| 1700 ui::test::EventGenerator generator( | 1712 ui::test::EventGenerator generator( |
| 1701 IsMus() ? widget->GetNativeWindow() : GetContext(), | 1713 IsMus() || IsAuraMusClient() ? widget->GetNativeWindow() : GetContext(), |
| 1702 widget->GetNativeWindow()); | 1714 widget->GetNativeWindow()); |
| 1703 generator.MoveMouseTo(cursor_location); | 1715 generator.MoveMouseTo(cursor_location); |
| 1704 | 1716 |
| 1705 EXPECT_EQ(1, v1->GetEventCount(ui::ET_MOUSE_MOVED)); | 1717 EXPECT_EQ(1, v1->GetEventCount(ui::ET_MOUSE_MOVED)); |
| 1706 EXPECT_EQ(0, v2->GetEventCount(ui::ET_MOUSE_MOVED)); | 1718 EXPECT_EQ(0, v2->GetEventCount(ui::ET_MOUSE_MOVED)); |
| 1707 | 1719 |
| 1708 // SynthesizeMouseMoveEvent dispatches an mousemove event. | 1720 // SynthesizeMouseMoveEvent dispatches an mousemove event. |
| 1709 widget->SynthesizeMouseMoveEvent(); | 1721 widget->SynthesizeMouseMoveEvent(); |
| 1710 EXPECT_EQ(2, v1->GetEventCount(ui::ET_MOUSE_MOVED)); | 1722 EXPECT_EQ(2, v1->GetEventCount(ui::ET_MOUSE_MOVED)); |
| 1711 | 1723 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1747 widget->Show(); | 1759 widget->Show(); |
| 1748 widget->SetSize(gfx::Size(300, 300)); | 1760 widget->SetSize(gfx::Size(300, 300)); |
| 1749 | 1761 |
| 1750 EventCountView* event_count_view = new EventCountView(); | 1762 EventCountView* event_count_view = new EventCountView(); |
| 1751 event_count_view->SetBounds(0, 0, 300, 300); | 1763 event_count_view->SetBounds(0, 0, 300, 300); |
| 1752 widget->GetRootView()->AddChildView(event_count_view); | 1764 widget->GetRootView()->AddChildView(event_count_view); |
| 1753 | 1765 |
| 1754 MousePressEventConsumer consumer; | 1766 MousePressEventConsumer consumer; |
| 1755 event_count_view->AddPostTargetHandler(&consumer); | 1767 event_count_view->AddPostTargetHandler(&consumer); |
| 1756 | 1768 |
| 1757 std::unique_ptr<ui::test::EventGenerator> generator( | 1769 ui::test::EventGenerator generator( |
| 1758 new ui::test::EventGenerator( | 1770 IsMus() || IsAuraMusClient() ? widget->GetNativeWindow() : GetContext(), |
| 1759 IsMus() ? widget->GetNativeWindow() : GetContext(), | 1771 widget->GetNativeWindow()); |
| 1760 widget->GetNativeWindow())); | 1772 generator.PressTouch(); |
| 1761 generator->PressTouch(); | 1773 generator.ClickLeftButton(); |
| 1762 generator->ClickLeftButton(); | |
| 1763 | 1774 |
| 1764 EXPECT_EQ(1, event_count_view->GetEventCount(ui::ET_MOUSE_PRESSED)); | 1775 EXPECT_EQ(1, event_count_view->GetEventCount(ui::ET_MOUSE_PRESSED)); |
| 1765 EXPECT_EQ(1, event_count_view->GetEventCount(ui::ET_MOUSE_RELEASED)); | 1776 EXPECT_EQ(1, event_count_view->GetEventCount(ui::ET_MOUSE_RELEASED)); |
| 1766 | 1777 |
| 1767 // For mus it's important we destroy the widget before the EventGenerator. | 1778 // For mus it's important we destroy the widget before the EventGenerator. |
| 1768 widget->CloseNow(); | 1779 widget->CloseNow(); |
| 1769 } | 1780 } |
| 1770 | 1781 |
| 1771 #endif // !defined(OS_MACOSX) || defined(USE_AURA) | 1782 #endif // !defined(OS_MACOSX) || defined(USE_AURA) |
| 1772 | 1783 |
| 1773 // Tests that when there is no active capture, that a mouse press causes capture | 1784 // Tests that when there is no active capture, that a mouse press causes capture |
| 1774 // to be set. | 1785 // to be set. |
| 1775 TEST_F(WidgetTest, MousePressCausesCapture) { | 1786 TEST_F(WidgetTest, MousePressCausesCapture) { |
| 1776 Widget* widget = CreateTopLevelNativeWidget(); | 1787 Widget* widget = CreateTopLevelNativeWidget(); |
| 1777 widget->Show(); | 1788 widget->Show(); |
| 1778 widget->SetSize(gfx::Size(300, 300)); | 1789 widget->SetSize(gfx::Size(300, 300)); |
| 1779 | 1790 |
| 1780 EventCountView* event_count_view = new EventCountView(); | 1791 EventCountView* event_count_view = new EventCountView(); |
| 1781 event_count_view->SetBounds(0, 0, 300, 300); | 1792 event_count_view->SetBounds(0, 0, 300, 300); |
| 1782 widget->GetRootView()->AddChildView(event_count_view); | 1793 widget->GetRootView()->AddChildView(event_count_view); |
| 1783 | 1794 |
| 1784 // No capture has been set. | 1795 // No capture has been set. |
| 1785 EXPECT_EQ(nullptr, internal::NativeWidgetPrivate::GetGlobalCapture( | 1796 EXPECT_EQ(nullptr, internal::NativeWidgetPrivate::GetGlobalCapture( |
| 1786 widget->GetNativeView())); | 1797 widget->GetNativeView())); |
| 1787 | 1798 |
| 1788 MousePressEventConsumer consumer; | 1799 MousePressEventConsumer consumer; |
| 1789 event_count_view->AddPostTargetHandler(&consumer); | 1800 event_count_view->AddPostTargetHandler(&consumer); |
| 1790 std::unique_ptr<ui::test::EventGenerator> generator( | 1801 ui::test::EventGenerator generator( |
| 1791 new ui::test::EventGenerator( | 1802 IsMus() || IsAuraMusClient() ? widget->GetNativeWindow() : GetContext(), |
| 1792 IsMus() ? widget->GetNativeWindow() : GetContext(), | 1803 widget->GetNativeWindow()); |
| 1793 widget->GetNativeWindow())); | 1804 generator.PressLeftButton(); |
| 1794 generator->PressLeftButton(); | |
| 1795 | 1805 |
| 1796 EXPECT_EQ(1, event_count_view->GetEventCount(ui::ET_MOUSE_PRESSED)); | 1806 EXPECT_EQ(1, event_count_view->GetEventCount(ui::ET_MOUSE_PRESSED)); |
| 1797 EXPECT_EQ( | 1807 EXPECT_EQ( |
| 1798 widget->GetNativeView(), | 1808 widget->GetNativeView(), |
| 1799 internal::NativeWidgetPrivate::GetGlobalCapture(widget->GetNativeView())); | 1809 internal::NativeWidgetPrivate::GetGlobalCapture(widget->GetNativeView())); |
| 1800 | 1810 |
| 1801 // For mus it's important we destroy the widget before the EventGenerator. | 1811 // For mus it's important we destroy the widget before the EventGenerator. |
| 1802 widget->CloseNow(); | 1812 widget->CloseNow(); |
| 1803 } | 1813 } |
| 1804 | 1814 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1844 event_count_view->SetBounds(0, 0, 300, 300); | 1854 event_count_view->SetBounds(0, 0, 300, 300); |
| 1845 widget->GetRootView()->AddChildView(event_count_view); | 1855 widget->GetRootView()->AddChildView(event_count_view); |
| 1846 | 1856 |
| 1847 EXPECT_EQ(nullptr, internal::NativeWidgetPrivate::GetGlobalCapture( | 1857 EXPECT_EQ(nullptr, internal::NativeWidgetPrivate::GetGlobalCapture( |
| 1848 widget->GetNativeView())); | 1858 widget->GetNativeView())); |
| 1849 | 1859 |
| 1850 Widget* widget2 = CreateTopLevelNativeWidget(); | 1860 Widget* widget2 = CreateTopLevelNativeWidget(); |
| 1851 // Gives explicit capture to |widget2| | 1861 // Gives explicit capture to |widget2| |
| 1852 CaptureEventConsumer consumer(widget2); | 1862 CaptureEventConsumer consumer(widget2); |
| 1853 event_count_view->AddPostTargetHandler(&consumer); | 1863 event_count_view->AddPostTargetHandler(&consumer); |
| 1854 std::unique_ptr<ui::test::EventGenerator> generator( | 1864 ui::test::EventGenerator generator( |
| 1855 new ui::test::EventGenerator( | 1865 IsMus() || IsAuraMusClient() ? widget->GetNativeWindow() : GetContext(), |
| 1856 IsMus() ? widget->GetNativeWindow() : GetContext(), | 1866 widget->GetNativeWindow()); |
| 1857 widget->GetNativeWindow())); | |
| 1858 // This event should implicitly give capture to |widget|, except that | 1867 // This event should implicitly give capture to |widget|, except that |
| 1859 // |consumer| will explicitly set capture on |widget2|. | 1868 // |consumer| will explicitly set capture on |widget2|. |
| 1860 generator->PressLeftButton(); | 1869 generator.PressLeftButton(); |
| 1861 | 1870 |
| 1862 EXPECT_EQ(1, event_count_view->GetEventCount(ui::ET_MOUSE_PRESSED)); | 1871 EXPECT_EQ(1, event_count_view->GetEventCount(ui::ET_MOUSE_PRESSED)); |
| 1863 EXPECT_NE( | 1872 EXPECT_NE( |
| 1864 widget->GetNativeView(), | 1873 widget->GetNativeView(), |
| 1865 internal::NativeWidgetPrivate::GetGlobalCapture(widget->GetNativeView())); | 1874 internal::NativeWidgetPrivate::GetGlobalCapture(widget->GetNativeView())); |
| 1866 EXPECT_EQ( | 1875 EXPECT_EQ( |
| 1867 widget2->GetNativeView(), | 1876 widget2->GetNativeView(), |
| 1868 internal::NativeWidgetPrivate::GetGlobalCapture(widget->GetNativeView())); | 1877 internal::NativeWidgetPrivate::GetGlobalCapture(widget->GetNativeView())); |
| 1869 | 1878 |
| 1870 // For mus it's important we destroy the widget before the EventGenerator. | 1879 // For mus it's important we destroy the widget before the EventGenerator. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1939 | 1948 |
| 1940 TEST_F(WidgetTest, WidgetDeleted_InOnMousePressed) { | 1949 TEST_F(WidgetTest, WidgetDeleted_InOnMousePressed) { |
| 1941 // This test doesn't work in mus as it assumes widget and GetContext() | 1950 // This test doesn't work in mus as it assumes widget and GetContext() |
| 1942 // share an aura hierarchy. Test coverage of deletion from mouse pressed is | 1951 // share an aura hierarchy. Test coverage of deletion from mouse pressed is |
| 1943 // important though and should be added, hence the NOTIMPLEMENTED(). | 1952 // important though and should be added, hence the NOTIMPLEMENTED(). |
| 1944 // http://crbug.com/594260. | 1953 // http://crbug.com/594260. |
| 1945 if (IsMus()) { | 1954 if (IsMus()) { |
| 1946 NOTIMPLEMENTED(); | 1955 NOTIMPLEMENTED(); |
| 1947 return; | 1956 return; |
| 1948 } | 1957 } |
| 1958 // TODO: test uses GetContext(), which is not applicable to aura-mus. |
| 1959 // http://crbug.com/663809. |
| 1960 if (IsAuraMusClient()) |
| 1961 return; |
| 1962 |
| 1949 Widget* widget = new Widget; | 1963 Widget* widget = new Widget; |
| 1950 Widget::InitParams params = | 1964 Widget::InitParams params = |
| 1951 CreateParams(views::Widget::InitParams::TYPE_POPUP); | 1965 CreateParams(views::Widget::InitParams::TYPE_POPUP); |
| 1952 widget->Init(params); | 1966 widget->Init(params); |
| 1953 | 1967 |
| 1954 widget->SetContentsView(new CloseWidgetView(ui::ET_MOUSE_PRESSED)); | 1968 widget->SetContentsView(new CloseWidgetView(ui::ET_MOUSE_PRESSED)); |
| 1955 | 1969 |
| 1956 widget->SetSize(gfx::Size(100, 100)); | 1970 widget->SetSize(gfx::Size(100, 100)); |
| 1957 widget->Show(); | 1971 widget->Show(); |
| 1958 | 1972 |
| 1959 ui::test::EventGenerator generator(GetContext(), widget->GetNativeWindow()); | 1973 ui::test::EventGenerator generator(GetContext(), widget->GetNativeWindow()); |
| 1960 | 1974 |
| 1961 WidgetDeletionObserver deletion_observer(widget); | 1975 WidgetDeletionObserver deletion_observer(widget); |
| 1962 generator.ClickLeftButton(); | 1976 generator.ClickLeftButton(); |
| 1963 EXPECT_FALSE(deletion_observer.IsWidgetAlive()); | 1977 EXPECT_FALSE(deletion_observer.IsWidgetAlive()); |
| 1964 | 1978 |
| 1965 // Yay we did not crash! | 1979 // Yay we did not crash! |
| 1966 } | 1980 } |
| 1967 | 1981 |
| 1968 // No touch on desktop Mac. Tracked in http://crbug.com/445520. | 1982 // No touch on desktop Mac. Tracked in http://crbug.com/445520. |
| 1969 #if !defined(OS_MACOSX) || defined(USE_AURA) | 1983 #if !defined(OS_MACOSX) || defined(USE_AURA) |
| 1970 | 1984 |
| 1971 TEST_F(WidgetTest, WidgetDeleted_InDispatchGestureEvent) { | 1985 TEST_F(WidgetTest, WidgetDeleted_InDispatchGestureEvent) { |
| 1972 // This test doesn't make sense for mus. | 1986 // This test doesn't make sense for mus. |
| 1973 if (IsMus()) | 1987 if (IsMus()) |
| 1974 return; | 1988 return; |
| 1989 // TODO: test uses GetContext(), which is not applicable to aura-mus. |
| 1990 // http://crbug.com/663809. |
| 1991 if (IsAuraMusClient()) |
| 1992 return; |
| 1975 | 1993 |
| 1976 Widget* widget = new Widget; | 1994 Widget* widget = new Widget; |
| 1977 Widget::InitParams params = | 1995 Widget::InitParams params = |
| 1978 CreateParams(views::Widget::InitParams::TYPE_POPUP); | 1996 CreateParams(views::Widget::InitParams::TYPE_POPUP); |
| 1979 widget->Init(params); | 1997 widget->Init(params); |
| 1980 | 1998 |
| 1981 widget->SetContentsView(new CloseWidgetView(ui::ET_GESTURE_TAP_DOWN)); | 1999 widget->SetContentsView(new CloseWidgetView(ui::ET_GESTURE_TAP_DOWN)); |
| 1982 | 2000 |
| 1983 widget->SetSize(gfx::Size(100, 100)); | 2001 widget->SetSize(gfx::Size(100, 100)); |
| 1984 widget->Show(); | 2002 widget->Show(); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2192 TEST_F(WidgetTest, NoCrashOnWidgetDelete) { | 2210 TEST_F(WidgetTest, NoCrashOnWidgetDelete) { |
| 2193 std::unique_ptr<Widget> widget(new Widget); | 2211 std::unique_ptr<Widget> widget(new Widget); |
| 2194 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); | 2212 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); |
| 2195 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 2213 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 2196 widget->Init(params); | 2214 widget->Init(params); |
| 2197 } | 2215 } |
| 2198 | 2216 |
| 2199 // Tests that we do not crash when a Widget is destroyed before it finishes | 2217 // Tests that we do not crash when a Widget is destroyed before it finishes |
| 2200 // processing of pending input events in the message loop. | 2218 // processing of pending input events in the message loop. |
| 2201 TEST_F(WidgetTest, NoCrashOnWidgetDeleteWithPendingEvents) { | 2219 TEST_F(WidgetTest, NoCrashOnWidgetDeleteWithPendingEvents) { |
| 2220 // TODO: test uses GetContext(), which is not applicable to aura-mus. |
| 2221 // http://crbug.com/663809. |
| 2222 if (IsAuraMusClient()) |
| 2223 return; |
| 2224 |
| 2202 std::unique_ptr<Widget> widget(new Widget); | 2225 std::unique_ptr<Widget> widget(new Widget); |
| 2203 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); | 2226 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); |
| 2204 params.bounds = gfx::Rect(0, 0, 200, 200); | 2227 params.bounds = gfx::Rect(0, 0, 200, 200); |
| 2205 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 2228 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 2206 widget->Init(params); | 2229 widget->Init(params); |
| 2207 widget->Show(); | 2230 widget->Show(); |
| 2208 | 2231 |
| 2209 ui::test::EventGenerator generator(GetContext(), widget->GetNativeWindow()); | 2232 ui::test::EventGenerator generator(GetContext(), widget->GetNativeWindow()); |
| 2210 generator.MoveMouseTo(10, 10); | 2233 generator.MoveMouseTo(10, 10); |
| 2211 | 2234 |
| (...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3232 child_widget.AddObserver(&observer); | 3255 child_widget.AddObserver(&observer); |
| 3233 child_widget.Show(); | 3256 child_widget.Show(); |
| 3234 | 3257 |
| 3235 parent_widget.CloseNow(); | 3258 parent_widget.CloseNow(); |
| 3236 } | 3259 } |
| 3237 #endif // !defined(OS_CHROMEOS) | 3260 #endif // !defined(OS_CHROMEOS) |
| 3238 | 3261 |
| 3239 // Tests that events propagate through from the dispatcher with the correct | 3262 // Tests that events propagate through from the dispatcher with the correct |
| 3240 // event type, and that the different platforms behave the same. | 3263 // event type, and that the different platforms behave the same. |
| 3241 TEST_F(WidgetTest, MouseEventTypesViaGenerator) { | 3264 TEST_F(WidgetTest, MouseEventTypesViaGenerator) { |
| 3265 // TODO: test uses GetContext(), which is not applicable to aura-mus. |
| 3266 // http://crbug.com/663809. |
| 3267 if (IsAuraMusClient()) |
| 3268 return; |
| 3269 |
| 3242 EventCountView* view = new EventCountView; | 3270 EventCountView* view = new EventCountView; |
| 3243 view->set_handle_mode(EventCountView::CONSUME_EVENTS); | 3271 view->set_handle_mode(EventCountView::CONSUME_EVENTS); |
| 3244 view->SetBounds(10, 10, 50, 40); | 3272 view->SetBounds(10, 10, 50, 40); |
| 3245 | 3273 |
| 3246 WidgetAutoclosePtr widget(CreateTopLevelFramelessPlatformWidget()); | 3274 WidgetAutoclosePtr widget(CreateTopLevelFramelessPlatformWidget()); |
| 3247 widget->GetRootView()->AddChildView(view); | 3275 widget->GetRootView()->AddChildView(view); |
| 3248 | 3276 |
| 3249 widget->SetBounds(gfx::Rect(0, 0, 100, 80)); | 3277 widget->SetBounds(gfx::Rect(0, 0, 100, 80)); |
| 3250 widget->Show(); | 3278 widget->Show(); |
| 3251 | 3279 |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3543 private: | 3571 private: |
| 3544 float last_scale_factor_ = 0.f; | 3572 float last_scale_factor_ = 0.f; |
| 3545 | 3573 |
| 3546 DISALLOW_COPY_AND_ASSIGN(ScaleFactorView); | 3574 DISALLOW_COPY_AND_ASSIGN(ScaleFactorView); |
| 3547 }; | 3575 }; |
| 3548 | 3576 |
| 3549 } | 3577 } |
| 3550 | 3578 |
| 3551 // Ensure scale factor changes are propagated from the native Widget. | 3579 // Ensure scale factor changes are propagated from the native Widget. |
| 3552 TEST_F(WidgetTest, OnDeviceScaleFactorChanged) { | 3580 TEST_F(WidgetTest, OnDeviceScaleFactorChanged) { |
| 3581 // This relies on the NativeWidget being the WindowDelegate, which is not the |
| 3582 // case for aura-mus-client. |
| 3583 if (IsAuraMusClient()) |
| 3584 return; |
| 3585 |
| 3553 // Automatically close the widget, but not delete it. | 3586 // Automatically close the widget, but not delete it. |
| 3554 WidgetAutoclosePtr widget(CreateTopLevelPlatformWidget()); | 3587 WidgetAutoclosePtr widget(CreateTopLevelPlatformWidget()); |
| 3555 ScaleFactorView* view = new ScaleFactorView; | 3588 ScaleFactorView* view = new ScaleFactorView; |
| 3556 widget->GetRootView()->AddChildView(view); | 3589 widget->GetRootView()->AddChildView(view); |
| 3557 float scale_factor = widget->GetLayer()->device_scale_factor(); | 3590 float scale_factor = widget->GetLayer()->device_scale_factor(); |
| 3558 EXPECT_NE(scale_factor, 0.f); | 3591 EXPECT_NE(scale_factor, 0.f); |
| 3559 | 3592 |
| 3560 // For views that are not layer-backed, adding the view won't notify the view | 3593 // For views that are not layer-backed, adding the view won't notify the view |
| 3561 // about the initial scale factor. Fake it. | 3594 // about the initial scale factor. Fake it. |
| 3562 view->OnDeviceScaleFactorChanged(scale_factor); | 3595 view->OnDeviceScaleFactorChanged(scale_factor); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3636 // Moving the child to a different widget should call the removals observer. | 3669 // Moving the child to a different widget should call the removals observer. |
| 3637 WidgetAutoclosePtr widget2(CreateTopLevelPlatformWidget()); | 3670 WidgetAutoclosePtr widget2(CreateTopLevelPlatformWidget()); |
| 3638 widget2->client_view()->AddChildView(child); | 3671 widget2->client_view()->AddChildView(child); |
| 3639 EXPECT_TRUE(removals_observer.DidRemoveView(child)); | 3672 EXPECT_TRUE(removals_observer.DidRemoveView(child)); |
| 3640 | 3673 |
| 3641 widget->RemoveRemovalsObserver(&removals_observer); | 3674 widget->RemoveRemovalsObserver(&removals_observer); |
| 3642 } | 3675 } |
| 3643 | 3676 |
| 3644 // Test dispatch of ui::ET_MOUSEWHEEL. | 3677 // Test dispatch of ui::ET_MOUSEWHEEL. |
| 3645 TEST_F(WidgetTest, MouseWheelEvent) { | 3678 TEST_F(WidgetTest, MouseWheelEvent) { |
| 3679 // TODO: test uses GetContext(), which is not applicable to aura-mus. |
| 3680 // http://crbug.com/663809. |
| 3681 if (IsAuraMusClient()) |
| 3682 return; |
| 3683 |
| 3646 WidgetAutoclosePtr widget(CreateTopLevelPlatformWidget()); | 3684 WidgetAutoclosePtr widget(CreateTopLevelPlatformWidget()); |
| 3647 widget->SetBounds(gfx::Rect(0, 0, 600, 600)); | 3685 widget->SetBounds(gfx::Rect(0, 0, 600, 600)); |
| 3648 EventCountView* event_count_view = new EventCountView(); | 3686 EventCountView* event_count_view = new EventCountView(); |
| 3649 widget->GetContentsView()->AddChildView(event_count_view); | 3687 widget->GetContentsView()->AddChildView(event_count_view); |
| 3650 event_count_view->SetBounds(0, 0, 600, 600); | 3688 event_count_view->SetBounds(0, 0, 600, 600); |
| 3651 widget->Show(); | 3689 widget->Show(); |
| 3652 | 3690 |
| 3653 ui::test::EventGenerator event_generator(GetContext(), | 3691 ui::test::EventGenerator event_generator(GetContext(), |
| 3654 widget->GetNativeWindow()); | 3692 widget->GetNativeWindow()); |
| 3655 | 3693 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3857 Transparency_DesktopWidgetTranslucent | 3895 Transparency_DesktopWidgetTranslucent |
| 3858 #endif | 3896 #endif |
| 3859 TEST_F(CompositingWidgetTest, MAYBE_Transparency_DesktopWidgetTranslucent) { | 3897 TEST_F(CompositingWidgetTest, MAYBE_Transparency_DesktopWidgetTranslucent) { |
| 3860 CheckAllWidgetsForOpacity(Widget::InitParams::TRANSLUCENT_WINDOW); | 3898 CheckAllWidgetsForOpacity(Widget::InitParams::TRANSLUCENT_WINDOW); |
| 3861 } | 3899 } |
| 3862 | 3900 |
| 3863 #endif // !defined(OS_CHROMEOS) | 3901 #endif // !defined(OS_CHROMEOS) |
| 3864 | 3902 |
| 3865 } // namespace test | 3903 } // namespace test |
| 3866 } // namespace views | 3904 } // namespace views |
| OLD | NEW |