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

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

Issue 37733003: Make GetRootWindow() return a Window instead of a RootWindow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month 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 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 DISALLOW_COPY_AND_ASSIGN(CloseWidgetView); 1303 DISALLOW_COPY_AND_ASSIGN(CloseWidgetView);
1304 }; 1304 };
1305 1305
1306 // Generates two moves (first generates enter, second real move), a press, drag 1306 // Generates two moves (first generates enter, second real move), a press, drag
1307 // and release stopping at |last_event_type|. 1307 // and release stopping at |last_event_type|.
1308 void GenerateMouseEvents(Widget* widget, ui::EventType last_event_type) { 1308 void GenerateMouseEvents(Widget* widget, ui::EventType last_event_type) {
1309 const gfx::Rect screen_bounds(widget->GetWindowBoundsInScreen()); 1309 const gfx::Rect screen_bounds(widget->GetWindowBoundsInScreen());
1310 ui::MouseEvent move_event(ui::ET_MOUSE_MOVED, screen_bounds.CenterPoint(), 1310 ui::MouseEvent move_event(ui::ET_MOUSE_MOVED, screen_bounds.CenterPoint(),
1311 screen_bounds.CenterPoint(), 0); 1311 screen_bounds.CenterPoint(), 0);
1312 aura::RootWindowHostDelegate* rwhd = 1312 aura::RootWindowHostDelegate* rwhd =
1313 widget->GetNativeWindow()->GetRootWindow()->AsRootWindowHostDelegate(); 1313 widget->GetNativeWindow()->GetDispatcher()->AsRootWindowHostDelegate();
1314 rwhd->OnHostMouseEvent(&move_event); 1314 rwhd->OnHostMouseEvent(&move_event);
1315 if (last_event_type == ui::ET_MOUSE_ENTERED) 1315 if (last_event_type == ui::ET_MOUSE_ENTERED)
1316 return; 1316 return;
1317 rwhd->OnHostMouseEvent(&move_event); 1317 rwhd->OnHostMouseEvent(&move_event);
1318 if (last_event_type == ui::ET_MOUSE_MOVED) 1318 if (last_event_type == ui::ET_MOUSE_MOVED)
1319 return; 1319 return;
1320 1320
1321 ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, screen_bounds.CenterPoint(), 1321 ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, screen_bounds.CenterPoint(),
1322 screen_bounds.CenterPoint(), 0); 1322 screen_bounds.CenterPoint(), 0);
1323 rwhd->OnHostMouseEvent(&press_event); 1323 rwhd->OnHostMouseEvent(&press_event);
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
2010 // Create a view and validate that a mouse moves makes it to the view. 2010 // Create a view and validate that a mouse moves makes it to the view.
2011 EventCountView* widget_view = new EventCountView(); 2011 EventCountView* widget_view = new EventCountView();
2012 widget_view->SetBounds(0, 0, 10, 10); 2012 widget_view->SetBounds(0, 0, 10, 10);
2013 top_level_widget.GetRootView()->AddChildView(widget_view); 2013 top_level_widget.GetRootView()->AddChildView(widget_view);
2014 2014
2015 gfx::Point cursor_location_main(5, 5); 2015 gfx::Point cursor_location_main(5, 5);
2016 ui::MouseEvent move_main(ui::ET_MOUSE_MOVED, 2016 ui::MouseEvent move_main(ui::ET_MOUSE_MOVED,
2017 cursor_location_main, 2017 cursor_location_main,
2018 cursor_location_main, 2018 cursor_location_main,
2019 ui::EF_NONE); 2019 ui::EF_NONE);
2020 top_level_widget.GetNativeView()->GetRootWindow()-> 2020 top_level_widget.GetNativeView()->GetDispatcher()->
2021 AsRootWindowHostDelegate()->OnHostMouseEvent(&move_main); 2021 AsRootWindowHostDelegate()->OnHostMouseEvent(&move_main);
2022 2022
2023 EXPECT_EQ(1, widget_view->GetEventCount(ui::ET_MOUSE_ENTERED)); 2023 EXPECT_EQ(1, widget_view->GetEventCount(ui::ET_MOUSE_ENTERED));
2024 widget_view->ResetCounts(); 2024 widget_view->ResetCounts();
2025 2025
2026 // Create a modal dialog and validate that a mouse down message makes it to 2026 // Create a modal dialog and validate that a mouse down message makes it to
2027 // the main view within the dialog. 2027 // the main view within the dialog.
2028 2028
2029 // This instance will be destroyed when the dialog is destroyed. 2029 // This instance will be destroyed when the dialog is destroyed.
2030 ModalDialogDelegate* dialog_delegate = new ModalDialogDelegate; 2030 ModalDialogDelegate* dialog_delegate = new ModalDialogDelegate;
2031 2031
2032 Widget* modal_dialog_widget = views::DialogDelegate::CreateDialogWidget( 2032 Widget* modal_dialog_widget = views::DialogDelegate::CreateDialogWidget(
2033 dialog_delegate, NULL, top_level_widget.GetNativeWindow()); 2033 dialog_delegate, NULL, top_level_widget.GetNativeWindow());
2034 modal_dialog_widget->SetBounds(gfx::Rect(100, 100, 200, 200)); 2034 modal_dialog_widget->SetBounds(gfx::Rect(100, 100, 200, 200));
2035 EventCountView* dialog_widget_view = new EventCountView(); 2035 EventCountView* dialog_widget_view = new EventCountView();
2036 dialog_widget_view->SetBounds(0, 0, 50, 50); 2036 dialog_widget_view->SetBounds(0, 0, 50, 50);
2037 modal_dialog_widget->GetRootView()->AddChildView(dialog_widget_view); 2037 modal_dialog_widget->GetRootView()->AddChildView(dialog_widget_view);
2038 modal_dialog_widget->Show(); 2038 modal_dialog_widget->Show();
2039 EXPECT_TRUE(modal_dialog_widget->IsVisible()); 2039 EXPECT_TRUE(modal_dialog_widget->IsVisible());
2040 2040
2041 gfx::Point cursor_location_dialog(100, 100); 2041 gfx::Point cursor_location_dialog(100, 100);
2042 ui::MouseEvent mouse_down_dialog(ui::ET_MOUSE_PRESSED, 2042 ui::MouseEvent mouse_down_dialog(ui::ET_MOUSE_PRESSED,
2043 cursor_location_dialog, 2043 cursor_location_dialog,
2044 cursor_location_dialog, 2044 cursor_location_dialog,
2045 ui::EF_NONE); 2045 ui::EF_NONE);
2046 top_level_widget.GetNativeView()->GetRootWindow()-> 2046 top_level_widget.GetNativeView()->GetDispatcher()->
2047 AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_down_dialog); 2047 AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_down_dialog);
2048 EXPECT_EQ(1, dialog_widget_view->GetEventCount(ui::ET_MOUSE_PRESSED)); 2048 EXPECT_EQ(1, dialog_widget_view->GetEventCount(ui::ET_MOUSE_PRESSED));
2049 2049
2050 // Send a mouse move message to the main window. It should not be received by 2050 // Send a mouse move message to the main window. It should not be received by
2051 // the main window as the modal dialog is still active. 2051 // the main window as the modal dialog is still active.
2052 gfx::Point cursor_location_main2(6, 6); 2052 gfx::Point cursor_location_main2(6, 6);
2053 ui::MouseEvent mouse_down_main(ui::ET_MOUSE_MOVED, 2053 ui::MouseEvent mouse_down_main(ui::ET_MOUSE_MOVED,
2054 cursor_location_main2, 2054 cursor_location_main2,
2055 cursor_location_main2, 2055 cursor_location_main2,
2056 ui::EF_NONE); 2056 ui::EF_NONE);
2057 top_level_widget.GetNativeView()->GetRootWindow()-> 2057 top_level_widget.GetNativeView()->GetDispatcher()->
2058 AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_down_main); 2058 AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_down_main);
2059 EXPECT_EQ(0, widget_view->GetEventCount(ui::ET_MOUSE_MOVED)); 2059 EXPECT_EQ(0, widget_view->GetEventCount(ui::ET_MOUSE_MOVED));
2060 2060
2061 modal_dialog_widget->CloseNow(); 2061 modal_dialog_widget->CloseNow();
2062 top_level_widget.CloseNow(); 2062 top_level_widget.CloseNow();
2063 } 2063 }
2064 2064
2065 #if defined(OS_WIN) 2065 #if defined(OS_WIN)
2066 2066
2067 // Provides functionality to test widget activation via an activation flag 2067 // Provides functionality to test widget activation via an activation flag
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
2151 EXPECT_EQ(activate_result, MA_ACTIVATE); 2151 EXPECT_EQ(activate_result, MA_ACTIVATE);
2152 2152
2153 modal_dialog_widget->CloseNow(); 2153 modal_dialog_widget->CloseNow();
2154 top_level_widget.CloseNow(); 2154 top_level_widget.CloseNow();
2155 } 2155 }
2156 #endif 2156 #endif
2157 #endif 2157 #endif
2158 2158
2159 } // namespace test 2159 } // namespace test
2160 } // namespace views 2160 } // 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