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

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

Issue 77203002: Revert 236048 "Rename RootWindowHost* to WindowTreeHost*" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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
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 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 1302
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::WindowTreeHostDelegate* rwhd = 1312 aura::RootWindowHostDelegate* rwhd =
1313 widget->GetNativeWindow()->GetDispatcher()->AsWindowTreeHostDelegate(); 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 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
2007 EventCountView* widget_view = new EventCountView(); 2007 EventCountView* widget_view = new EventCountView();
2008 widget_view->SetBounds(0, 0, 10, 10); 2008 widget_view->SetBounds(0, 0, 10, 10);
2009 top_level_widget.GetRootView()->AddChildView(widget_view); 2009 top_level_widget.GetRootView()->AddChildView(widget_view);
2010 2010
2011 gfx::Point cursor_location_main(5, 5); 2011 gfx::Point cursor_location_main(5, 5);
2012 ui::MouseEvent move_main(ui::ET_MOUSE_MOVED, 2012 ui::MouseEvent move_main(ui::ET_MOUSE_MOVED,
2013 cursor_location_main, 2013 cursor_location_main,
2014 cursor_location_main, 2014 cursor_location_main,
2015 ui::EF_NONE); 2015 ui::EF_NONE);
2016 top_level_widget.GetNativeView()->GetDispatcher()-> 2016 top_level_widget.GetNativeView()->GetDispatcher()->
2017 AsWindowTreeHostDelegate()->OnHostMouseEvent(&move_main); 2017 AsRootWindowHostDelegate()->OnHostMouseEvent(&move_main);
2018 2018
2019 EXPECT_EQ(1, widget_view->GetEventCount(ui::ET_MOUSE_ENTERED)); 2019 EXPECT_EQ(1, widget_view->GetEventCount(ui::ET_MOUSE_ENTERED));
2020 widget_view->ResetCounts(); 2020 widget_view->ResetCounts();
2021 2021
2022 // Create a modal dialog and validate that a mouse down message makes it to 2022 // Create a modal dialog and validate that a mouse down message makes it to
2023 // the main view within the dialog. 2023 // the main view within the dialog.
2024 2024
2025 // This instance will be destroyed when the dialog is destroyed. 2025 // This instance will be destroyed when the dialog is destroyed.
2026 ModalDialogDelegate* dialog_delegate = new ModalDialogDelegate; 2026 ModalDialogDelegate* dialog_delegate = new ModalDialogDelegate;
2027 2027
2028 Widget* modal_dialog_widget = views::DialogDelegate::CreateDialogWidget( 2028 Widget* modal_dialog_widget = views::DialogDelegate::CreateDialogWidget(
2029 dialog_delegate, NULL, top_level_widget.GetNativeWindow()); 2029 dialog_delegate, NULL, top_level_widget.GetNativeWindow());
2030 modal_dialog_widget->SetBounds(gfx::Rect(100, 100, 200, 200)); 2030 modal_dialog_widget->SetBounds(gfx::Rect(100, 100, 200, 200));
2031 EventCountView* dialog_widget_view = new EventCountView(); 2031 EventCountView* dialog_widget_view = new EventCountView();
2032 dialog_widget_view->SetBounds(0, 0, 50, 50); 2032 dialog_widget_view->SetBounds(0, 0, 50, 50);
2033 modal_dialog_widget->GetRootView()->AddChildView(dialog_widget_view); 2033 modal_dialog_widget->GetRootView()->AddChildView(dialog_widget_view);
2034 modal_dialog_widget->Show(); 2034 modal_dialog_widget->Show();
2035 EXPECT_TRUE(modal_dialog_widget->IsVisible()); 2035 EXPECT_TRUE(modal_dialog_widget->IsVisible());
2036 2036
2037 gfx::Point cursor_location_dialog(100, 100); 2037 gfx::Point cursor_location_dialog(100, 100);
2038 ui::MouseEvent mouse_down_dialog(ui::ET_MOUSE_PRESSED, 2038 ui::MouseEvent mouse_down_dialog(ui::ET_MOUSE_PRESSED,
2039 cursor_location_dialog, 2039 cursor_location_dialog,
2040 cursor_location_dialog, 2040 cursor_location_dialog,
2041 ui::EF_NONE); 2041 ui::EF_NONE);
2042 top_level_widget.GetNativeView()->GetDispatcher()-> 2042 top_level_widget.GetNativeView()->GetDispatcher()->
2043 AsWindowTreeHostDelegate()->OnHostMouseEvent(&mouse_down_dialog); 2043 AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_down_dialog);
2044 EXPECT_EQ(1, dialog_widget_view->GetEventCount(ui::ET_MOUSE_PRESSED)); 2044 EXPECT_EQ(1, dialog_widget_view->GetEventCount(ui::ET_MOUSE_PRESSED));
2045 2045
2046 // Send a mouse move message to the main window. It should not be received by 2046 // Send a mouse move message to the main window. It should not be received by
2047 // the main window as the modal dialog is still active. 2047 // the main window as the modal dialog is still active.
2048 gfx::Point cursor_location_main2(6, 6); 2048 gfx::Point cursor_location_main2(6, 6);
2049 ui::MouseEvent mouse_down_main(ui::ET_MOUSE_MOVED, 2049 ui::MouseEvent mouse_down_main(ui::ET_MOUSE_MOVED,
2050 cursor_location_main2, 2050 cursor_location_main2,
2051 cursor_location_main2, 2051 cursor_location_main2,
2052 ui::EF_NONE); 2052 ui::EF_NONE);
2053 top_level_widget.GetNativeView()->GetDispatcher()-> 2053 top_level_widget.GetNativeView()->GetDispatcher()->
2054 AsWindowTreeHostDelegate()->OnHostMouseEvent(&mouse_down_main); 2054 AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_down_main);
2055 EXPECT_EQ(0, widget_view->GetEventCount(ui::ET_MOUSE_MOVED)); 2055 EXPECT_EQ(0, widget_view->GetEventCount(ui::ET_MOUSE_MOVED));
2056 2056
2057 modal_dialog_widget->CloseNow(); 2057 modal_dialog_widget->CloseNow();
2058 top_level_widget.CloseNow(); 2058 top_level_widget.CloseNow();
2059 } 2059 }
2060 2060
2061 #if defined(OS_WIN) 2061 #if defined(OS_WIN)
2062 2062
2063 // Provides functionality to test widget activation via an activation flag 2063 // Provides functionality to test widget activation via an activation flag
2064 // which can be set by an accessor. 2064 // which can be set by an accessor.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
2147 EXPECT_EQ(activate_result, MA_ACTIVATE); 2147 EXPECT_EQ(activate_result, MA_ACTIVATE);
2148 2148
2149 modal_dialog_widget->CloseNow(); 2149 modal_dialog_widget->CloseNow();
2150 top_level_widget.CloseNow(); 2150 top_level_widget.CloseNow();
2151 } 2151 }
2152 #endif 2152 #endif
2153 #endif 2153 #endif
2154 2154
2155 } // namespace test 2155 } // namespace test
2156 } // namespace views 2156 } // namespace views
OLDNEW
« no previous file with comments | « trunk/src/ui/views/widget/widget_interactive_uitest.cc ('k') | trunk/src/ui/views/win/hwnd_message_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698