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