Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: ui/views/widget/widget_unittest.cc

Issue 184903003: Window ownership -> WindowTreeHost (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/widget/widget_interactive_uitest.cc ('k') | ui/views/win/hwnd_util_aurawin.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1277 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 // nested message loops from such events, nor has the code ever really dealt 1288 // nested message loops from such events, nor has the code ever really dealt
1289 // with this situation. 1289 // with this situation.
1290 1290
1291 // Generates two moves (first generates enter, second real move), a press, drag 1291 // Generates two moves (first generates enter, second real move), a press, drag
1292 // and release stopping at |last_event_type|. 1292 // and release stopping at |last_event_type|.
1293 void GenerateMouseEvents(Widget* widget, ui::EventType last_event_type) { 1293 void GenerateMouseEvents(Widget* widget, ui::EventType last_event_type) {
1294 const gfx::Rect screen_bounds(widget->GetWindowBoundsInScreen()); 1294 const gfx::Rect screen_bounds(widget->GetWindowBoundsInScreen());
1295 ui::MouseEvent move_event(ui::ET_MOUSE_MOVED, screen_bounds.CenterPoint(), 1295 ui::MouseEvent move_event(ui::ET_MOUSE_MOVED, screen_bounds.CenterPoint(),
1296 screen_bounds.CenterPoint(), 0, 0); 1296 screen_bounds.CenterPoint(), 0, 0);
1297 aura::WindowEventDispatcher* dispatcher = 1297 aura::WindowEventDispatcher* dispatcher =
1298 widget->GetNativeWindow()->GetDispatcher(); 1298 widget->GetNativeWindow()->GetHost()->dispatcher();
1299 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move_event); 1299 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move_event);
1300 if (last_event_type == ui::ET_MOUSE_ENTERED || details.dispatcher_destroyed) 1300 if (last_event_type == ui::ET_MOUSE_ENTERED || details.dispatcher_destroyed)
1301 return; 1301 return;
1302 details = dispatcher->OnEventFromSource(&move_event); 1302 details = dispatcher->OnEventFromSource(&move_event);
1303 if (last_event_type == ui::ET_MOUSE_MOVED || details.dispatcher_destroyed) 1303 if (last_event_type == ui::ET_MOUSE_MOVED || details.dispatcher_destroyed)
1304 return; 1304 return;
1305 1305
1306 ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, screen_bounds.CenterPoint(), 1306 ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, screen_bounds.CenterPoint(),
1307 screen_bounds.CenterPoint(), 0, 0); 1307 screen_bounds.CenterPoint(), 0, 0);
1308 details = dispatcher->OnEventFromSource(&press_event); 1308 details = dispatcher->OnEventFromSource(&press_event);
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
2058 widget_view->SetBounds(0, 0, 10, 10); 2058 widget_view->SetBounds(0, 0, 10, 10);
2059 top_level_widget.GetRootView()->AddChildView(widget_view); 2059 top_level_widget.GetRootView()->AddChildView(widget_view);
2060 2060
2061 gfx::Point cursor_location_main(5, 5); 2061 gfx::Point cursor_location_main(5, 5);
2062 ui::MouseEvent move_main(ui::ET_MOUSE_MOVED, 2062 ui::MouseEvent move_main(ui::ET_MOUSE_MOVED,
2063 cursor_location_main, 2063 cursor_location_main,
2064 cursor_location_main, 2064 cursor_location_main,
2065 ui::EF_NONE, 2065 ui::EF_NONE,
2066 ui::EF_NONE); 2066 ui::EF_NONE);
2067 ui::EventDispatchDetails details = top_level_widget.GetNativeView()-> 2067 ui::EventDispatchDetails details = top_level_widget.GetNativeView()->
2068 GetDispatcher()->OnEventFromSource(&move_main); 2068 GetHost()->dispatcher()->OnEventFromSource(&move_main);
2069 ASSERT_FALSE(details.dispatcher_destroyed); 2069 ASSERT_FALSE(details.dispatcher_destroyed);
2070 2070
2071 EXPECT_EQ(1, widget_view->GetEventCount(ui::ET_MOUSE_ENTERED)); 2071 EXPECT_EQ(1, widget_view->GetEventCount(ui::ET_MOUSE_ENTERED));
2072 widget_view->ResetCounts(); 2072 widget_view->ResetCounts();
2073 2073
2074 // Create a modal dialog and validate that a mouse down message makes it to 2074 // Create a modal dialog and validate that a mouse down message makes it to
2075 // the main view within the dialog. 2075 // the main view within the dialog.
2076 2076
2077 // This instance will be destroyed when the dialog is destroyed. 2077 // This instance will be destroyed when the dialog is destroyed.
2078 ModalDialogDelegate* dialog_delegate = new ModalDialogDelegate; 2078 ModalDialogDelegate* dialog_delegate = new ModalDialogDelegate;
2079 2079
2080 Widget* modal_dialog_widget = views::DialogDelegate::CreateDialogWidget( 2080 Widget* modal_dialog_widget = views::DialogDelegate::CreateDialogWidget(
2081 dialog_delegate, NULL, top_level_widget.GetNativeWindow()); 2081 dialog_delegate, NULL, top_level_widget.GetNativeWindow());
2082 modal_dialog_widget->SetBounds(gfx::Rect(100, 100, 200, 200)); 2082 modal_dialog_widget->SetBounds(gfx::Rect(100, 100, 200, 200));
2083 EventCountView* dialog_widget_view = new EventCountView(); 2083 EventCountView* dialog_widget_view = new EventCountView();
2084 dialog_widget_view->SetBounds(0, 0, 50, 50); 2084 dialog_widget_view->SetBounds(0, 0, 50, 50);
2085 modal_dialog_widget->GetRootView()->AddChildView(dialog_widget_view); 2085 modal_dialog_widget->GetRootView()->AddChildView(dialog_widget_view);
2086 modal_dialog_widget->Show(); 2086 modal_dialog_widget->Show();
2087 EXPECT_TRUE(modal_dialog_widget->IsVisible()); 2087 EXPECT_TRUE(modal_dialog_widget->IsVisible());
2088 2088
2089 gfx::Point cursor_location_dialog(100, 100); 2089 gfx::Point cursor_location_dialog(100, 100);
2090 ui::MouseEvent mouse_down_dialog(ui::ET_MOUSE_PRESSED, 2090 ui::MouseEvent mouse_down_dialog(ui::ET_MOUSE_PRESSED,
2091 cursor_location_dialog, 2091 cursor_location_dialog,
2092 cursor_location_dialog, 2092 cursor_location_dialog,
2093 ui::EF_NONE, 2093 ui::EF_NONE,
2094 ui::EF_NONE); 2094 ui::EF_NONE);
2095 details = top_level_widget.GetNativeView()->GetDispatcher()-> 2095 details = top_level_widget.GetNativeView()->GetHost()->dispatcher()->
2096 OnEventFromSource(&mouse_down_dialog); 2096 OnEventFromSource(&mouse_down_dialog);
2097 ASSERT_FALSE(details.dispatcher_destroyed); 2097 ASSERT_FALSE(details.dispatcher_destroyed);
2098 EXPECT_EQ(1, dialog_widget_view->GetEventCount(ui::ET_MOUSE_PRESSED)); 2098 EXPECT_EQ(1, dialog_widget_view->GetEventCount(ui::ET_MOUSE_PRESSED));
2099 2099
2100 // Send a mouse move message to the main window. It should not be received by 2100 // Send a mouse move message to the main window. It should not be received by
2101 // the main window as the modal dialog is still active. 2101 // the main window as the modal dialog is still active.
2102 gfx::Point cursor_location_main2(6, 6); 2102 gfx::Point cursor_location_main2(6, 6);
2103 ui::MouseEvent mouse_down_main(ui::ET_MOUSE_MOVED, 2103 ui::MouseEvent mouse_down_main(ui::ET_MOUSE_MOVED,
2104 cursor_location_main2, 2104 cursor_location_main2,
2105 cursor_location_main2, 2105 cursor_location_main2,
2106 ui::EF_NONE, 2106 ui::EF_NONE,
2107 ui::EF_NONE); 2107 ui::EF_NONE);
2108 details = top_level_widget.GetNativeView()->GetDispatcher()-> 2108 details = top_level_widget.GetNativeView()->GetHost()->dispatcher()->
2109 OnEventFromSource(&mouse_down_main); 2109 OnEventFromSource(&mouse_down_main);
2110 ASSERT_FALSE(details.dispatcher_destroyed); 2110 ASSERT_FALSE(details.dispatcher_destroyed);
2111 EXPECT_EQ(0, widget_view->GetEventCount(ui::ET_MOUSE_MOVED)); 2111 EXPECT_EQ(0, widget_view->GetEventCount(ui::ET_MOUSE_MOVED));
2112 2112
2113 modal_dialog_widget->CloseNow(); 2113 modal_dialog_widget->CloseNow();
2114 top_level_widget.CloseNow(); 2114 top_level_widget.CloseNow();
2115 } 2115 }
2116 2116
2117 #if defined(USE_AURA) 2117 #if defined(USE_AURA)
2118 // Verifies nativeview visbility matches that of Widget visibility when 2118 // Verifies nativeview visbility matches that of Widget visibility when
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
2402 child_widget.Init(child_params); 2402 child_widget.Init(child_params);
2403 child_widget.AddObserver(&observer); 2403 child_widget.AddObserver(&observer);
2404 child_widget.Show(); 2404 child_widget.Show();
2405 2405
2406 parent_widget.CloseNow(); 2406 parent_widget.CloseNow();
2407 } 2407 }
2408 #endif 2408 #endif
2409 2409
2410 } // namespace test 2410 } // namespace test
2411 } // namespace views 2411 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/widget_interactive_uitest.cc ('k') | ui/views/win/hwnd_util_aurawin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698