| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 | 6 |
| 7 #include "ash/accessibility_delegate.h" | 7 #include "ash/accessibility_delegate.h" |
| 8 #include "ash/drag_drop/drag_drop_controller.h" | 8 #include "ash/drag_drop/drag_drop_controller.h" |
| 9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/screen_util.h" | 10 #include "ash/screen_util.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #include "ui/gfx/transform_util.h" | 48 #include "ui/gfx/transform_util.h" |
| 49 #include "ui/views/controls/label.h" | 49 #include "ui/views/controls/label.h" |
| 50 #include "ui/views/widget/native_widget_aura.h" | 50 #include "ui/views/widget/native_widget_aura.h" |
| 51 #include "ui/views/widget/widget_delegate.h" | 51 #include "ui/views/widget/widget_delegate.h" |
| 52 #include "ui/wm/core/window_util.h" | 52 #include "ui/wm/core/window_util.h" |
| 53 #include "ui/wm/public/activation_delegate.h" | 53 #include "ui/wm/public/activation_delegate.h" |
| 54 | 54 |
| 55 namespace ash { | 55 namespace ash { |
| 56 namespace { | 56 namespace { |
| 57 | 57 |
| 58 typedef std::vector<aura::Window*> WindowList; | |
| 59 typedef std::map<const aura::Window*, int> WindowIndexMap; | |
| 60 | |
| 61 class NonActivatableActivationDelegate | 58 class NonActivatableActivationDelegate |
| 62 : public aura::client::ActivationDelegate { | 59 : public aura::client::ActivationDelegate { |
| 63 public: | 60 public: |
| 64 bool ShouldActivate() const override { return false; } | 61 bool ShouldActivate() const override { return false; } |
| 65 }; | 62 }; |
| 66 | 63 |
| 67 void CancelDrag(DragDropController* controller, bool* canceled) { | 64 void CancelDrag(DragDropController* controller, bool* canceled) { |
| 68 if (controller->IsDragDropInProgress()) { | 65 if (controller->IsDragDropInProgress()) { |
| 69 *canceled = true; | 66 *canceled = true; |
| 70 controller->DragCancel(); | 67 controller->DragCancel(); |
| 71 } | 68 } |
| 72 } | 69 } |
| 73 | 70 |
| 74 // Fills the |index_map| with (window*, list index) entries based on each | |
| 75 // windows index in the |windows| list. | |
| 76 void GetWindowIndexMap(const WindowList& windows, | |
| 77 WindowIndexMap* index_map) { | |
| 78 int index = 0; | |
| 79 for (auto window : windows) { | |
| 80 (*index_map)[window] = index; | |
| 81 ++index; | |
| 82 } | |
| 83 } | |
| 84 | |
| 85 } // namespace | 71 } // namespace |
| 86 | 72 |
| 87 class WindowSelectorTest : public test::AshTestBase { | 73 class WindowSelectorTest : public test::AshTestBase { |
| 88 public: | 74 public: |
| 89 WindowSelectorTest() {} | 75 WindowSelectorTest() {} |
| 90 ~WindowSelectorTest() override {} | 76 ~WindowSelectorTest() override {} |
| 91 | 77 |
| 92 void SetUp() override { | 78 void SetUp() override { |
| 93 test::AshTestBase::SetUp(); | 79 test::AshTestBase::SetUp(); |
| 94 ASSERT_TRUE(test::TestShelfDelegate::instance()); | 80 ASSERT_TRUE(test::TestShelfDelegate::instance()); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 | 187 |
| 202 const std::vector<WindowSelectorItem*>& GetWindowItemsForRoot(int index) { | 188 const std::vector<WindowSelectorItem*>& GetWindowItemsForRoot(int index) { |
| 203 return ash::Shell::GetInstance()->window_selector_controller()-> | 189 return ash::Shell::GetInstance()->window_selector_controller()-> |
| 204 window_selector_->grid_list_[index]->window_list_.get(); | 190 window_selector_->grid_list_[index]->window_list_.get(); |
| 205 } | 191 } |
| 206 | 192 |
| 207 const aura::Window* GetSelectedWindow() { | 193 const aura::Window* GetSelectedWindow() { |
| 208 WindowSelector* ws = ash::Shell::GetInstance()-> | 194 WindowSelector* ws = ash::Shell::GetInstance()-> |
| 209 window_selector_controller()->window_selector_.get(); | 195 window_selector_controller()->window_selector_.get(); |
| 210 return ws->grid_list_[ws->selected_grid_index_]-> | 196 return ws->grid_list_[ws->selected_grid_index_]-> |
| 211 SelectedWindow()->SelectionWindow(); | 197 SelectedWindow()->GetWindow(); |
| 212 } | 198 } |
| 213 | 199 |
| 214 bool selection_widget_active() { | 200 bool selection_widget_active() { |
| 215 WindowSelector* ws = ash::Shell::GetInstance()-> | 201 WindowSelector* ws = ash::Shell::GetInstance()-> |
| 216 window_selector_controller()->window_selector_.get(); | 202 window_selector_controller()->window_selector_.get(); |
| 217 return ws->grid_list_[ws->selected_grid_index_]->is_selecting(); | 203 return ws->grid_list_[ws->selected_grid_index_]->is_selecting(); |
| 218 } | 204 } |
| 219 | 205 |
| 220 bool showing_filter_widget() { | 206 bool showing_filter_widget() { |
| 221 WindowSelector* ws = ash::Shell::GetInstance()-> | 207 WindowSelector* ws = ash::Shell::GetInstance()-> |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 EXPECT_EQ(window2.get(), GetFocusedWindow()); | 285 EXPECT_EQ(window2.get(), GetFocusedWindow()); |
| 300 // Hide the cursor before entering overview to test that it will be shown. | 286 // Hide the cursor before entering overview to test that it will be shown. |
| 301 aura::client::GetCursorClient(root_window)->HideCursor(); | 287 aura::client::GetCursorClient(root_window)->HideCursor(); |
| 302 | 288 |
| 303 // In overview mode the windows should no longer overlap and the text filter | 289 // In overview mode the windows should no longer overlap and the text filter |
| 304 // widget should be focused. | 290 // widget should be focused. |
| 305 ToggleOverview(); | 291 ToggleOverview(); |
| 306 EXPECT_EQ(text_filter_widget()->GetNativeWindow(), GetFocusedWindow()); | 292 EXPECT_EQ(text_filter_widget()->GetNativeWindow(), GetFocusedWindow()); |
| 307 EXPECT_FALSE(WindowsOverlapping(window1.get(), window2.get())); | 293 EXPECT_FALSE(WindowsOverlapping(window1.get(), window2.get())); |
| 308 EXPECT_FALSE(WindowsOverlapping(window1.get(), panel1.get())); | 294 EXPECT_FALSE(WindowsOverlapping(window1.get(), panel1.get())); |
| 309 // Panels 1 and 2 should still be overlapping being in a single selector | 295 EXPECT_FALSE(WindowsOverlapping(panel1.get(), panel2.get())); |
| 310 // item. | |
| 311 EXPECT_TRUE(WindowsOverlapping(panel1.get(), panel2.get())); | |
| 312 | 296 |
| 313 // Clicking window 1 should activate it. | 297 // Clicking window 1 should activate it. |
| 314 ClickWindow(window1.get()); | 298 ClickWindow(window1.get()); |
| 315 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); | 299 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); |
| 316 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); | 300 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); |
| 317 EXPECT_EQ(window1.get(), GetFocusedWindow()); | 301 EXPECT_EQ(window1.get(), GetFocusedWindow()); |
| 318 | 302 |
| 319 // Cursor should have been unlocked. | 303 // Cursor should have been unlocked. |
| 320 EXPECT_FALSE(aura::client::GetCursorClient(root_window)->IsCursorLocked()); | 304 EXPECT_FALSE(aura::client::GetCursorClient(root_window)->IsCursorLocked()); |
| 321 } | 305 } |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 EXPECT_EQ(root_windows[0], panel2->GetRootWindow()); | 811 EXPECT_EQ(root_windows[0], panel2->GetRootWindow()); |
| 828 EXPECT_EQ(root_windows[1], panel3->GetRootWindow()); | 812 EXPECT_EQ(root_windows[1], panel3->GetRootWindow()); |
| 829 EXPECT_EQ(root_windows[1], panel4->GetRootWindow()); | 813 EXPECT_EQ(root_windows[1], panel4->GetRootWindow()); |
| 830 | 814 |
| 831 const std::vector<WindowSelectorItem*>& primary_window_items = | 815 const std::vector<WindowSelectorItem*>& primary_window_items = |
| 832 GetWindowItemsForRoot(0); | 816 GetWindowItemsForRoot(0); |
| 833 const std::vector<WindowSelectorItem*>& secondary_window_items = | 817 const std::vector<WindowSelectorItem*>& secondary_window_items = |
| 834 GetWindowItemsForRoot(1); | 818 GetWindowItemsForRoot(1); |
| 835 | 819 |
| 836 // Window indices are based on top-down order. The reverse of our creation. | 820 // Window indices are based on top-down order. The reverse of our creation. |
| 837 IsWindowAndCloseButtonInScreen(window1.get(), primary_window_items[2]); | 821 IsWindowAndCloseButtonInScreen(window1.get(), primary_window_items[3]); |
| 838 IsWindowAndCloseButtonInScreen(window2.get(), primary_window_items[1]); | 822 IsWindowAndCloseButtonInScreen(window2.get(), primary_window_items[2]); |
| 839 IsWindowAndCloseButtonInScreen(window3.get(), secondary_window_items[2]); | 823 IsWindowAndCloseButtonInScreen(window3.get(), secondary_window_items[3]); |
| 840 IsWindowAndCloseButtonInScreen(window4.get(), secondary_window_items[1]); | 824 IsWindowAndCloseButtonInScreen(window4.get(), secondary_window_items[2]); |
| 841 | 825 |
| 842 IsWindowAndCloseButtonInScreen(panel1.get(), primary_window_items[0]); | 826 IsWindowAndCloseButtonInScreen(panel1.get(), primary_window_items[1]); |
| 843 IsWindowAndCloseButtonInScreen(panel2.get(), primary_window_items[0]); | 827 IsWindowAndCloseButtonInScreen(panel2.get(), primary_window_items[0]); |
| 844 IsWindowAndCloseButtonInScreen(panel3.get(), secondary_window_items[0]); | 828 IsWindowAndCloseButtonInScreen(panel3.get(), secondary_window_items[1]); |
| 845 IsWindowAndCloseButtonInScreen(panel4.get(), secondary_window_items[0]); | 829 IsWindowAndCloseButtonInScreen(panel4.get(), secondary_window_items[0]); |
| 846 | |
| 847 EXPECT_TRUE(WindowsOverlapping(panel1.get(), panel2.get())); | |
| 848 EXPECT_TRUE(WindowsOverlapping(panel3.get(), panel4.get())); | |
| 849 EXPECT_FALSE(WindowsOverlapping(panel1.get(), panel3.get())); | |
| 850 } | 830 } |
| 851 | 831 |
| 852 // Tests shutting down during overview. | 832 // Tests shutting down during overview. |
| 853 TEST_F(WindowSelectorTest, Shutdown) { | 833 TEST_F(WindowSelectorTest, Shutdown) { |
| 854 gfx::Rect bounds(0, 0, 400, 400); | 834 gfx::Rect bounds(0, 0, 400, 400); |
| 855 // These windows will be deleted when the test exits and the Shell instance | 835 // These windows will be deleted when the test exits and the Shell instance |
| 856 // is shut down. | 836 // is shut down. |
| 857 aura::Window* window1(CreateWindow(bounds)); | 837 aura::Window* window1(CreateWindow(bounds)); |
| 858 aura::Window* window2(CreateWindow(bounds)); | 838 aura::Window* window2(CreateWindow(bounds)); |
| 859 aura::Window* window3(CreatePanelWindow(bounds)); | 839 aura::Window* window3(CreatePanelWindow(bounds)); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 gfx::Rect target_bounds(window_item->target_bounds()); | 927 gfx::Rect target_bounds(window_item->target_bounds()); |
| 948 gfx::Rect expected_label_bounds(target_bounds.x(), | 928 gfx::Rect expected_label_bounds(target_bounds.x(), |
| 949 target_bounds.bottom() - label-> | 929 target_bounds.bottom() - label-> |
| 950 GetPreferredSize().height(), | 930 GetPreferredSize().height(), |
| 951 target_bounds.width(), | 931 target_bounds.width(), |
| 952 label->GetPreferredSize().height()); | 932 label->GetPreferredSize().height()); |
| 953 gfx::Rect real_label_bounds = label->GetWidget()->GetNativeWindow()->bounds(); | 933 gfx::Rect real_label_bounds = label->GetWidget()->GetNativeWindow()->bounds(); |
| 954 EXPECT_EQ(real_label_bounds, expected_label_bounds); | 934 EXPECT_EQ(real_label_bounds, expected_label_bounds); |
| 955 } | 935 } |
| 956 | 936 |
| 957 // Tests that a label is created for the active panel in a group of panels in | |
| 958 // overview mode. | |
| 959 TEST_F(WindowSelectorTest, CreateLabelUnderPanel) { | |
| 960 scoped_ptr<aura::Window> panel1(CreatePanelWindow(gfx::Rect(0, 0, 100, 100))); | |
| 961 scoped_ptr<aura::Window> panel2(CreatePanelWindow(gfx::Rect(0, 0, 100, 100))); | |
| 962 base::string16 panel1_title = base::UTF8ToUTF16("My panel"); | |
| 963 base::string16 panel2_title = base::UTF8ToUTF16("Another panel"); | |
| 964 base::string16 updated_panel1_title = base::UTF8ToUTF16("WebDriver Torso"); | |
| 965 base::string16 updated_panel2_title = base::UTF8ToUTF16("Da panel"); | |
| 966 panel1->SetTitle(panel1_title); | |
| 967 panel2->SetTitle(panel2_title); | |
| 968 wm::ActivateWindow(panel1.get()); | |
| 969 ToggleOverview(); | |
| 970 WindowSelectorItem* window_item = GetWindowItemsForRoot(0).back(); | |
| 971 views::Label* label = GetLabelView(window_item); | |
| 972 // Has the label view been created? | |
| 973 ASSERT_TRUE(label); | |
| 974 | |
| 975 // Verify the label matches the active window title. | |
| 976 EXPECT_EQ(label->text(), panel1_title); | |
| 977 // Verify that updating the title also updates the label. | |
| 978 panel1->SetTitle(updated_panel1_title); | |
| 979 EXPECT_EQ(label->text(), updated_panel1_title); | |
| 980 // After destroying the first panel, the label should match the second panel. | |
| 981 panel1.reset(); | |
| 982 label = GetLabelView(window_item); | |
| 983 EXPECT_EQ(label->text(), panel2_title); | |
| 984 // Also test updating the title on the second panel. | |
| 985 panel2->SetTitle(updated_panel2_title); | |
| 986 EXPECT_EQ(label->text(), updated_panel2_title); | |
| 987 } | |
| 988 | |
| 989 // Tests that overview updates the window positions if the display orientation | 937 // Tests that overview updates the window positions if the display orientation |
| 990 // changes. | 938 // changes. |
| 991 TEST_F(WindowSelectorTest, DisplayOrientationChanged) { | 939 TEST_F(WindowSelectorTest, DisplayOrientationChanged) { |
| 992 if (!SupportsHostWindowResize()) | 940 if (!SupportsHostWindowResize()) |
| 993 return; | 941 return; |
| 994 | 942 |
| 995 aura::Window* root_window = Shell::GetInstance()->GetPrimaryRootWindow(); | 943 aura::Window* root_window = Shell::GetInstance()->GetPrimaryRootWindow(); |
| 996 UpdateDisplay("600x200"); | 944 UpdateDisplay("600x200"); |
| 997 EXPECT_EQ("0,0 600x200", root_window->bounds().ToString()); | 945 EXPECT_EQ("0,0 600x200", root_window->bounds().ToString()); |
| 998 gfx::Rect window_bounds(0, 0, 150, 150); | 946 gfx::Rect window_bounds(0, 0, 150, 150); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1157 panel_manager->GetCalloutWidgetForPanel(panel2.get())->IsVisible()); | 1105 panel_manager->GetCalloutWidgetForPanel(panel2.get())->IsVisible()); |
| 1158 | 1106 |
| 1159 // Ending the overview should show them again. | 1107 // Ending the overview should show them again. |
| 1160 ToggleOverview(); | 1108 ToggleOverview(); |
| 1161 EXPECT_TRUE( | 1109 EXPECT_TRUE( |
| 1162 panel_manager->GetCalloutWidgetForPanel(panel1.get())->IsVisible()); | 1110 panel_manager->GetCalloutWidgetForPanel(panel1.get())->IsVisible()); |
| 1163 EXPECT_TRUE( | 1111 EXPECT_TRUE( |
| 1164 panel_manager->GetCalloutWidgetForPanel(panel2.get())->IsVisible()); | 1112 panel_manager->GetCalloutWidgetForPanel(panel2.get())->IsVisible()); |
| 1165 } | 1113 } |
| 1166 | 1114 |
| 1167 // Tests that when panels are grouped that the close button only closes the | |
| 1168 // currently active panel. After the removal window selection should still be | |
| 1169 // active, and the label should have changed. Removing the last panel should | |
| 1170 // cause selection to end. | |
| 1171 TEST_F(WindowSelectorTest, CloseButtonOnPanels) { | |
| 1172 scoped_ptr<views::Widget> widget1(CreatePanelWindowWidget( | |
| 1173 gfx::Rect(0, 0, 300, 100))); | |
| 1174 scoped_ptr<views::Widget> widget2(CreatePanelWindowWidget( | |
| 1175 gfx::Rect(100, 0, 100, 100))); | |
| 1176 aura::Window* window1 = widget1->GetNativeWindow(); | |
| 1177 aura::Window* window2 = widget2->GetNativeWindow(); | |
| 1178 base::string16 panel1_title = base::UTF8ToUTF16("Panel 1"); | |
| 1179 base::string16 panel2_title = base::UTF8ToUTF16("Panel 2"); | |
| 1180 window1->SetTitle(panel1_title); | |
| 1181 window2->SetTitle(panel2_title); | |
| 1182 wm::ActivateWindow(window1); | |
| 1183 ToggleOverview(); | |
| 1184 | |
| 1185 gfx::RectF bounds1 = GetTransformedBoundsInRootWindow(window1); | |
| 1186 gfx::Point point1(bounds1.top_right().x() - 1, bounds1.top_right().y() - 1); | |
| 1187 ui::test::EventGenerator event_generator1(window1->GetRootWindow(), point1); | |
| 1188 | |
| 1189 EXPECT_FALSE(widget1->IsClosed()); | |
| 1190 event_generator1.ClickLeftButton(); | |
| 1191 EXPECT_TRUE(widget1->IsClosed()); | |
| 1192 RunAllPendingInMessageLoop(); | |
| 1193 EXPECT_TRUE(IsSelecting()); | |
| 1194 WindowSelectorItem* window_item = GetWindowItemsForRoot(0).front(); | |
| 1195 EXPECT_FALSE(window_item->empty()); | |
| 1196 EXPECT_TRUE(window_item->Contains(window2)); | |
| 1197 EXPECT_TRUE(GetCloseButton(window_item)->IsVisible()); | |
| 1198 | |
| 1199 | |
| 1200 views::Label* label = GetLabelView(window_item); | |
| 1201 EXPECT_EQ(label->text(), panel2_title); | |
| 1202 | |
| 1203 gfx::RectF bounds2 = GetTransformedBoundsInRootWindow(window2); | |
| 1204 gfx::Point point2(bounds2.top_right().x() - 1, bounds2.top_right().y() - 1); | |
| 1205 ui::test::EventGenerator event_generator2(window2->GetRootWindow(), point2); | |
| 1206 | |
| 1207 EXPECT_FALSE(widget2->IsClosed()); | |
| 1208 event_generator2.ClickLeftButton(); | |
| 1209 EXPECT_TRUE(widget2->IsClosed()); | |
| 1210 RunAllPendingInMessageLoop(); | |
| 1211 EXPECT_FALSE(IsSelecting()); | |
| 1212 } | |
| 1213 | |
| 1214 // Creates three windows and tests filtering them by title. | 1115 // Creates three windows and tests filtering them by title. |
| 1215 TEST_F(WindowSelectorTest, BasicTextFiltering) { | 1116 TEST_F(WindowSelectorTest, BasicTextFiltering) { |
| 1216 gfx::Rect bounds(0, 0, 100, 100); | 1117 gfx::Rect bounds(0, 0, 100, 100); |
| 1217 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); | 1118 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); |
| 1218 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 1119 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 1219 scoped_ptr<aura::Window> window0(CreateWindow(bounds)); | 1120 scoped_ptr<aura::Window> window0(CreateWindow(bounds)); |
| 1220 base::string16 window2_title = base::UTF8ToUTF16("Highway to test"); | 1121 base::string16 window2_title = base::UTF8ToUTF16("Highway to test"); |
| 1221 base::string16 window1_title = base::UTF8ToUTF16("For those about to test"); | 1122 base::string16 window1_title = base::UTF8ToUTF16("For those about to test"); |
| 1222 base::string16 window0_title = base::UTF8ToUTF16("We salute you"); | 1123 base::string16 window0_title = base::UTF8ToUTF16("We salute you"); |
| 1223 window0->SetTitle(window0_title); | 1124 window0->SetTitle(window0_title); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1342 | 1243 |
| 1343 // Switch to overview mode. | 1244 // Switch to overview mode. |
| 1344 ToggleOverview(); | 1245 ToggleOverview(); |
| 1345 ASSERT_TRUE(IsSelecting()); | 1246 ASSERT_TRUE(IsSelecting()); |
| 1346 | 1247 |
| 1347 // Tap should now exit overview mode. | 1248 // Tap should now exit overview mode. |
| 1348 generator.GestureTapAt(point_in_background_page); | 1249 generator.GestureTapAt(point_in_background_page); |
| 1349 EXPECT_FALSE(IsSelecting()); | 1250 EXPECT_FALSE(IsSelecting()); |
| 1350 } | 1251 } |
| 1351 | 1252 |
| 1352 // Tests that the transparent overlays z-order matches the windows z-order. | |
| 1353 TEST_F(WindowSelectorTest, PanelStackOrdering) { | |
| 1354 gfx::Rect bounds1(0, 0, 100, 100); | |
| 1355 gfx::Rect bounds2(10, 0, 100, 100); | |
| 1356 gfx::Rect bounds3(20, 0, 100, 100); | |
| 1357 scoped_ptr<aura::Window> panel1(CreatePanelWindow(bounds1)); | |
| 1358 scoped_ptr<aura::Window> panel2(CreatePanelWindow(bounds2)); | |
| 1359 scoped_ptr<aura::Window> panel3(CreatePanelWindow(bounds3)); | |
| 1360 | |
| 1361 wm::ActivateWindow(panel2.get()); | |
| 1362 wm::ActivateWindow(panel3.get()); | |
| 1363 wm::ActivateWindow(panel1.get()); | |
| 1364 | |
| 1365 WindowIndexMap z_order; | |
| 1366 GetWindowIndexMap(panel1->parent()->children(), &z_order); | |
| 1367 ASSERT_GT(z_order[panel1.get()], z_order[panel2.get()]); | |
| 1368 ASSERT_GT(z_order[panel2.get()], z_order[panel3.get()]); | |
| 1369 | |
| 1370 WindowList mru_windows = ash::Shell::GetInstance()->mru_window_tracker()-> | |
| 1371 BuildMruWindowList(); | |
| 1372 WindowIndexMap mru_rank; | |
| 1373 GetWindowIndexMap(mru_windows, &mru_rank); | |
| 1374 ASSERT_LT(mru_rank[panel1.get()], mru_rank[panel3.get()]); | |
| 1375 ASSERT_LT(mru_rank[panel3.get()], mru_rank[panel2.get()]); | |
| 1376 | |
| 1377 ToggleOverview(); | |
| 1378 | |
| 1379 gfx::Rect panel1_transformed_bounds( | |
| 1380 gfx::ToEnclosingRect(GetTransformedTargetBounds(panel1.get()))); | |
| 1381 gfx::Rect panel2_transformed_bounds( | |
| 1382 gfx::ToEnclosingRect(GetTransformedTargetBounds(panel2.get()))); | |
| 1383 gfx::Rect panel3_transformed_bounds( | |
| 1384 gfx::ToEnclosingRect(GetTransformedTargetBounds(panel3.get()))); | |
| 1385 | |
| 1386 gfx::Rect target_rect(panel2_transformed_bounds); | |
| 1387 target_rect.Intersect(panel3_transformed_bounds); | |
| 1388 target_rect.Subtract(panel1_transformed_bounds); | |
| 1389 gfx::Point tap_target(target_rect.CenterPoint()); | |
| 1390 | |
| 1391 ASSERT_TRUE(panel3_transformed_bounds.Contains(tap_target)); | |
| 1392 | |
| 1393 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | |
| 1394 generator.GestureTapAt(tap_target); | |
| 1395 EXPECT_EQ(panel2.get(), GetFocusedWindow()); | |
| 1396 } | |
| 1397 | |
| 1398 // Tests that individual panels can be selected on a secondary display. | |
| 1399 TEST_F(WindowSelectorTest, PanelSelectionOnSecondaryDisplay) { | |
| 1400 if (!SupportsMultipleDisplays()) | |
| 1401 return; | |
| 1402 | |
| 1403 UpdateDisplay("600x400,600x400"); | |
| 1404 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | |
| 1405 | |
| 1406 gfx::Rect bounds1(700, 0, 100, 100); | |
| 1407 gfx::Rect bounds2(710, 0, 100, 100); | |
| 1408 scoped_ptr<aura::Window> panel1(CreatePanelWindow(bounds1)); | |
| 1409 scoped_ptr<aura::Window> panel2(CreatePanelWindow(bounds2)); | |
| 1410 | |
| 1411 wm::ActivateWindow(panel2.get()); | |
| 1412 wm::ActivateWindow(panel1.get()); | |
| 1413 | |
| 1414 WindowList mru_windows = ash::Shell::GetInstance()->mru_window_tracker()-> | |
| 1415 BuildMruWindowList(); | |
| 1416 WindowIndexMap mru_rank; | |
| 1417 GetWindowIndexMap(mru_windows, &mru_rank); | |
| 1418 ASSERT_LT(mru_rank[panel1.get()], mru_rank[panel2.get()]); | |
| 1419 ASSERT_EQ(panel1.get(), GetFocusedWindow()); | |
| 1420 | |
| 1421 ToggleOverview(); | |
| 1422 | |
| 1423 gfx::Rect panel2_transformed_bounds( | |
| 1424 gfx::ToEnclosingRect(GetTransformedBoundsInRootWindow(panel2.get()))); | |
| 1425 gfx::Point tap_target(panel2_transformed_bounds.right() - 2, | |
| 1426 panel2_transformed_bounds.bottom() - 2); | |
| 1427 | |
| 1428 ui::test::EventGenerator generator(root_windows[1]); | |
| 1429 generator.GestureTapAt(tap_target); | |
| 1430 EXPECT_EQ(panel2.get(), GetFocusedWindow()); | |
| 1431 } | |
| 1432 | |
| 1433 } // namespace ash | 1253 } // namespace ash |
| OLD | NEW |