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 <set> | 6 #include <set> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1213 gfx::Rect(0, 0, 200, 200), false)); | 1213 gfx::Rect(0, 0, 200, 200), false)); |
1214 | 1214 |
1215 RunPendingMessages(); | 1215 RunPendingMessages(); |
1216 ASSERT_NO_FATAL_FAILURE(popup_window.DestroyOwnedWindow()); | 1216 ASSERT_NO_FATAL_FAILURE(popup_window.DestroyOwnedWindow()); |
1217 RunPendingMessages(); | 1217 RunPendingMessages(); |
1218 } | 1218 } |
1219 | 1219 |
1220 #if defined(OS_WIN) | 1220 #if defined(OS_WIN) |
1221 // TODO(ananta) | 1221 // TODO(ananta) |
1222 // Fix this test to work on Linux Aura. Need to implement the | 1222 // Fix this test to work on Linux Aura. Need to implement the |
1223 // views::DesktopRootWindowHostX11::SetSize function | 1223 // views::DesktopWindowTreeHostX11::SetSize function |
1224 // This test validates that when a top level owned popup Aura window is | 1224 // This test validates that when a top level owned popup Aura window is |
1225 // resized, the widget is resized as well. | 1225 // resized, the widget is resized as well. |
1226 TEST_F(WidgetTest, DesktopAuraTopLevelOwnedPopupResizeTest) { | 1226 TEST_F(WidgetTest, DesktopAuraTopLevelOwnedPopupResizeTest) { |
1227 ViewsDelegate::views_delegate = NULL; | 1227 ViewsDelegate::views_delegate = NULL; |
1228 DesktopAuraTopLevelWindowTest popup_window; | 1228 DesktopAuraTopLevelWindowTest popup_window; |
1229 ASSERT_NO_FATAL_FAILURE(popup_window.CreateTopLevelWindow( | 1229 ASSERT_NO_FATAL_FAILURE(popup_window.CreateTopLevelWindow( |
1230 gfx::Rect(0, 0, 200, 200), false)); | 1230 gfx::Rect(0, 0, 200, 200), false)); |
1231 | 1231 |
1232 gfx::Rect new_size(0, 0, 400, 400); | 1232 gfx::Rect new_size(0, 0, 400, 400); |
1233 popup_window.owned_window()->SetBounds(new_size); | 1233 popup_window.owned_window()->SetBounds(new_size); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1315 | 1315 |
1316 DISALLOW_COPY_AND_ASSIGN(CloseWidgetView); | 1316 DISALLOW_COPY_AND_ASSIGN(CloseWidgetView); |
1317 }; | 1317 }; |
1318 | 1318 |
1319 // Generates two moves (first generates enter, second real move), a press, drag | 1319 // Generates two moves (first generates enter, second real move), a press, drag |
1320 // and release stopping at |last_event_type|. | 1320 // and release stopping at |last_event_type|. |
1321 void GenerateMouseEvents(Widget* widget, ui::EventType last_event_type) { | 1321 void GenerateMouseEvents(Widget* widget, ui::EventType last_event_type) { |
1322 const gfx::Rect screen_bounds(widget->GetWindowBoundsInScreen()); | 1322 const gfx::Rect screen_bounds(widget->GetWindowBoundsInScreen()); |
1323 ui::MouseEvent move_event(ui::ET_MOUSE_MOVED, screen_bounds.CenterPoint(), | 1323 ui::MouseEvent move_event(ui::ET_MOUSE_MOVED, screen_bounds.CenterPoint(), |
1324 screen_bounds.CenterPoint(), 0, 0); | 1324 screen_bounds.CenterPoint(), 0, 0); |
1325 aura::RootWindowHostDelegate* rwhd = | 1325 aura::WindowTreeHostDelegate* rwhd = |
1326 widget->GetNativeWindow()->GetDispatcher()->AsRootWindowHostDelegate(); | 1326 widget->GetNativeWindow()->GetDispatcher()->AsWindowTreeHostDelegate(); |
1327 rwhd->OnHostMouseEvent(&move_event); | 1327 rwhd->OnHostMouseEvent(&move_event); |
1328 if (last_event_type == ui::ET_MOUSE_ENTERED) | 1328 if (last_event_type == ui::ET_MOUSE_ENTERED) |
1329 return; | 1329 return; |
1330 rwhd->OnHostMouseEvent(&move_event); | 1330 rwhd->OnHostMouseEvent(&move_event); |
1331 if (last_event_type == ui::ET_MOUSE_MOVED) | 1331 if (last_event_type == ui::ET_MOUSE_MOVED) |
1332 return; | 1332 return; |
1333 | 1333 |
1334 ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, screen_bounds.CenterPoint(), | 1334 ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, screen_bounds.CenterPoint(), |
1335 screen_bounds.CenterPoint(), 0, 0); | 1335 screen_bounds.CenterPoint(), 0, 0); |
1336 rwhd->OnHostMouseEvent(&press_event); | 1336 rwhd->OnHostMouseEvent(&press_event); |
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2079 widget_view->SetBounds(0, 0, 10, 10); | 2079 widget_view->SetBounds(0, 0, 10, 10); |
2080 top_level_widget.GetRootView()->AddChildView(widget_view); | 2080 top_level_widget.GetRootView()->AddChildView(widget_view); |
2081 | 2081 |
2082 gfx::Point cursor_location_main(5, 5); | 2082 gfx::Point cursor_location_main(5, 5); |
2083 ui::MouseEvent move_main(ui::ET_MOUSE_MOVED, | 2083 ui::MouseEvent move_main(ui::ET_MOUSE_MOVED, |
2084 cursor_location_main, | 2084 cursor_location_main, |
2085 cursor_location_main, | 2085 cursor_location_main, |
2086 ui::EF_NONE, | 2086 ui::EF_NONE, |
2087 ui::EF_NONE); | 2087 ui::EF_NONE); |
2088 top_level_widget.GetNativeView()->GetDispatcher()-> | 2088 top_level_widget.GetNativeView()->GetDispatcher()-> |
2089 AsRootWindowHostDelegate()->OnHostMouseEvent(&move_main); | 2089 AsWindowTreeHostDelegate()->OnHostMouseEvent(&move_main); |
2090 | 2090 |
2091 EXPECT_EQ(1, widget_view->GetEventCount(ui::ET_MOUSE_ENTERED)); | 2091 EXPECT_EQ(1, widget_view->GetEventCount(ui::ET_MOUSE_ENTERED)); |
2092 widget_view->ResetCounts(); | 2092 widget_view->ResetCounts(); |
2093 | 2093 |
2094 // Create a modal dialog and validate that a mouse down message makes it to | 2094 // Create a modal dialog and validate that a mouse down message makes it to |
2095 // the main view within the dialog. | 2095 // the main view within the dialog. |
2096 | 2096 |
2097 // This instance will be destroyed when the dialog is destroyed. | 2097 // This instance will be destroyed when the dialog is destroyed. |
2098 ModalDialogDelegate* dialog_delegate = new ModalDialogDelegate; | 2098 ModalDialogDelegate* dialog_delegate = new ModalDialogDelegate; |
2099 | 2099 |
2100 Widget* modal_dialog_widget = views::DialogDelegate::CreateDialogWidget( | 2100 Widget* modal_dialog_widget = views::DialogDelegate::CreateDialogWidget( |
2101 dialog_delegate, NULL, top_level_widget.GetNativeWindow()); | 2101 dialog_delegate, NULL, top_level_widget.GetNativeWindow()); |
2102 modal_dialog_widget->SetBounds(gfx::Rect(100, 100, 200, 200)); | 2102 modal_dialog_widget->SetBounds(gfx::Rect(100, 100, 200, 200)); |
2103 EventCountView* dialog_widget_view = new EventCountView(); | 2103 EventCountView* dialog_widget_view = new EventCountView(); |
2104 dialog_widget_view->SetBounds(0, 0, 50, 50); | 2104 dialog_widget_view->SetBounds(0, 0, 50, 50); |
2105 modal_dialog_widget->GetRootView()->AddChildView(dialog_widget_view); | 2105 modal_dialog_widget->GetRootView()->AddChildView(dialog_widget_view); |
2106 modal_dialog_widget->Show(); | 2106 modal_dialog_widget->Show(); |
2107 EXPECT_TRUE(modal_dialog_widget->IsVisible()); | 2107 EXPECT_TRUE(modal_dialog_widget->IsVisible()); |
2108 | 2108 |
2109 gfx::Point cursor_location_dialog(100, 100); | 2109 gfx::Point cursor_location_dialog(100, 100); |
2110 ui::MouseEvent mouse_down_dialog(ui::ET_MOUSE_PRESSED, | 2110 ui::MouseEvent mouse_down_dialog(ui::ET_MOUSE_PRESSED, |
2111 cursor_location_dialog, | 2111 cursor_location_dialog, |
2112 cursor_location_dialog, | 2112 cursor_location_dialog, |
2113 ui::EF_NONE, | 2113 ui::EF_NONE, |
2114 ui::EF_NONE); | 2114 ui::EF_NONE); |
2115 top_level_widget.GetNativeView()->GetDispatcher()-> | 2115 top_level_widget.GetNativeView()->GetDispatcher()-> |
2116 AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_down_dialog); | 2116 AsWindowTreeHostDelegate()->OnHostMouseEvent(&mouse_down_dialog); |
2117 EXPECT_EQ(1, dialog_widget_view->GetEventCount(ui::ET_MOUSE_PRESSED)); | 2117 EXPECT_EQ(1, dialog_widget_view->GetEventCount(ui::ET_MOUSE_PRESSED)); |
2118 | 2118 |
2119 // Send a mouse move message to the main window. It should not be received by | 2119 // Send a mouse move message to the main window. It should not be received by |
2120 // the main window as the modal dialog is still active. | 2120 // the main window as the modal dialog is still active. |
2121 gfx::Point cursor_location_main2(6, 6); | 2121 gfx::Point cursor_location_main2(6, 6); |
2122 ui::MouseEvent mouse_down_main(ui::ET_MOUSE_MOVED, | 2122 ui::MouseEvent mouse_down_main(ui::ET_MOUSE_MOVED, |
2123 cursor_location_main2, | 2123 cursor_location_main2, |
2124 cursor_location_main2, | 2124 cursor_location_main2, |
2125 ui::EF_NONE, | 2125 ui::EF_NONE, |
2126 ui::EF_NONE); | 2126 ui::EF_NONE); |
2127 top_level_widget.GetNativeView()->GetDispatcher()-> | 2127 top_level_widget.GetNativeView()->GetDispatcher()-> |
2128 AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_down_main); | 2128 AsWindowTreeHostDelegate()->OnHostMouseEvent(&mouse_down_main); |
2129 EXPECT_EQ(0, widget_view->GetEventCount(ui::ET_MOUSE_MOVED)); | 2129 EXPECT_EQ(0, widget_view->GetEventCount(ui::ET_MOUSE_MOVED)); |
2130 | 2130 |
2131 modal_dialog_widget->CloseNow(); | 2131 modal_dialog_widget->CloseNow(); |
2132 top_level_widget.CloseNow(); | 2132 top_level_widget.CloseNow(); |
2133 } | 2133 } |
2134 | 2134 |
2135 #if defined(USE_AURA) | 2135 #if defined(USE_AURA) |
2136 // Verifies nativeview visbility matches that of Widget visibility when | 2136 // Verifies nativeview visbility matches that of Widget visibility when |
2137 // SetFullscreen is invoked. | 2137 // SetFullscreen is invoked. |
2138 TEST_F(WidgetTest, FullscreenStatePropagated) { | 2138 TEST_F(WidgetTest, FullscreenStatePropagated) { |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2254 EXPECT_EQ(activate_result, MA_ACTIVATE); | 2254 EXPECT_EQ(activate_result, MA_ACTIVATE); |
2255 | 2255 |
2256 modal_dialog_widget->CloseNow(); | 2256 modal_dialog_widget->CloseNow(); |
2257 top_level_widget.CloseNow(); | 2257 top_level_widget.CloseNow(); |
2258 } | 2258 } |
2259 #endif | 2259 #endif |
2260 #endif | 2260 #endif |
2261 | 2261 |
2262 } // namespace test | 2262 } // namespace test |
2263 } // namespace views | 2263 } // namespace views |
OLD | NEW |