| 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 "ash/aura/wm_window_aura.h" |  | 
|    6 #include "ash/common/system/tray/system_tray.h" |    5 #include "ash/common/system/tray/system_tray.h" | 
|    7 #include "ash/common/wm/root_window_finder.h" |    6 #include "ash/common/wm/root_window_finder.h" | 
 |    7 #include "ash/common/wm_window.h" | 
|    8 #include "ash/public/cpp/shell_window_ids.h" |    8 #include "ash/public/cpp/shell_window_ids.h" | 
|    9 #include "ash/root_window_controller.h" |    9 #include "ash/root_window_controller.h" | 
|   10 #include "ash/shell.h" |   10 #include "ash/shell.h" | 
|   11 #include "ash/test/ash_test_base.h" |   11 #include "ash/test/ash_test_base.h" | 
|   12 #include "ash/wm/window_properties.h" |   12 #include "ash/wm/window_properties.h" | 
|   13 #include "ash/wm/window_util.h" |   13 #include "ash/wm/window_util.h" | 
|   14 #include "base/strings/string_util.h" |   14 #include "base/strings/string_util.h" | 
|   15 #include "base/strings/utf_string_conversions.h" |   15 #include "base/strings/utf_string_conversions.h" | 
|   16 #include "ui/aura/client/capture_client.h" |   16 #include "ui/aura/client/capture_client.h" | 
|   17 #include "ui/aura/client/focus_client.h" |   17 #include "ui/aura/client/focus_client.h" | 
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  302 } |  302 } | 
|  303  |  303  | 
|  304 TEST_F(ExtendedDesktopTest, GetRootWindowAt) { |  304 TEST_F(ExtendedDesktopTest, GetRootWindowAt) { | 
|  305   if (!SupportsMultipleDisplays()) |  305   if (!SupportsMultipleDisplays()) | 
|  306     return; |  306     return; | 
|  307  |  307  | 
|  308   UpdateDisplay("700x500,500x500"); |  308   UpdateDisplay("700x500,500x500"); | 
|  309   SetSecondaryDisplayLayout(display::DisplayPlacement::LEFT); |  309   SetSecondaryDisplayLayout(display::DisplayPlacement::LEFT); | 
|  310   aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |  310   aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 
|  311  |  311  | 
|  312   EXPECT_EQ(root_windows[1], WmWindowAura::GetAuraWindow( |  312   EXPECT_EQ(root_windows[1], WmWindow::GetAuraWindow( | 
|  313                                  wm::GetRootWindowAt(gfx::Point(-400, 100)))); |  313                                  wm::GetRootWindowAt(gfx::Point(-400, 100)))); | 
|  314   EXPECT_EQ(root_windows[1], WmWindowAura::GetAuraWindow( |  314   EXPECT_EQ(root_windows[1], | 
|  315                                  wm::GetRootWindowAt(gfx::Point(-1, 100)))); |  315             WmWindow::GetAuraWindow(wm::GetRootWindowAt(gfx::Point(-1, 100)))); | 
|  316   EXPECT_EQ(root_windows[0], WmWindowAura::GetAuraWindow( |  316   EXPECT_EQ(root_windows[0], | 
|  317                                  wm::GetRootWindowAt(gfx::Point(0, 300)))); |  317             WmWindow::GetAuraWindow(wm::GetRootWindowAt(gfx::Point(0, 300)))); | 
|  318   EXPECT_EQ(root_windows[0], WmWindowAura::GetAuraWindow( |  318   EXPECT_EQ(root_windows[0], | 
|  319                                  wm::GetRootWindowAt(gfx::Point(700, 300)))); |  319             WmWindow::GetAuraWindow(wm::GetRootWindowAt(gfx::Point(700, 300)))); | 
|  320  |  320  | 
|  321   // Zero origin. |  321   // Zero origin. | 
|  322   EXPECT_EQ(root_windows[0], |  322   EXPECT_EQ(root_windows[0], | 
|  323             WmWindowAura::GetAuraWindow(wm::GetRootWindowAt(gfx::Point(0, 0)))); |  323             WmWindow::GetAuraWindow(wm::GetRootWindowAt(gfx::Point(0, 0)))); | 
|  324  |  324  | 
|  325   // Out of range point should return the nearest root window |  325   // Out of range point should return the nearest root window | 
|  326   EXPECT_EQ(root_windows[1], WmWindowAura::GetAuraWindow( |  326   EXPECT_EQ(root_windows[1], | 
|  327                                  wm::GetRootWindowAt(gfx::Point(-600, 0)))); |  327             WmWindow::GetAuraWindow(wm::GetRootWindowAt(gfx::Point(-600, 0)))); | 
|  328   EXPECT_EQ(root_windows[0], WmWindowAura::GetAuraWindow( |  328   EXPECT_EQ(root_windows[0], | 
|  329                                  wm::GetRootWindowAt(gfx::Point(701, 100)))); |  329             WmWindow::GetAuraWindow(wm::GetRootWindowAt(gfx::Point(701, 100)))); | 
|  330 } |  330 } | 
|  331  |  331  | 
|  332 TEST_F(ExtendedDesktopTest, GetRootWindowMatching) { |  332 TEST_F(ExtendedDesktopTest, GetRootWindowMatching) { | 
|  333   if (!SupportsMultipleDisplays()) |  333   if (!SupportsMultipleDisplays()) | 
|  334     return; |  334     return; | 
|  335  |  335  | 
|  336   UpdateDisplay("700x500,500x500"); |  336   UpdateDisplay("700x500,500x500"); | 
|  337   SetSecondaryDisplayLayout(display::DisplayPlacement::LEFT); |  337   SetSecondaryDisplayLayout(display::DisplayPlacement::LEFT); | 
|  338  |  338  | 
|  339   aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |  339   aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 
|  340  |  340  | 
|  341   // Containing rect. |  341   // Containing rect. | 
|  342   EXPECT_EQ(root_windows[1], |  342   EXPECT_EQ(root_windows[1], WmWindow::GetAuraWindow(wm::GetRootWindowMatching( | 
|  343             WmWindowAura::GetAuraWindow( |  343                                  gfx::Rect(-300, 10, 50, 50)))); | 
|  344                 wm::GetRootWindowMatching(gfx::Rect(-300, 10, 50, 50)))); |  344   EXPECT_EQ(root_windows[0], WmWindow::GetAuraWindow(wm::GetRootWindowMatching( | 
|  345   EXPECT_EQ(root_windows[0], |  345                                  gfx::Rect(100, 10, 50, 50)))); | 
|  346             WmWindowAura::GetAuraWindow( |  | 
|  347                 wm::GetRootWindowMatching(gfx::Rect(100, 10, 50, 50)))); |  | 
|  348  |  346  | 
|  349   // Intersecting rect. |  347   // Intersecting rect. | 
|  350   EXPECT_EQ(root_windows[1], |  348   EXPECT_EQ(root_windows[1], WmWindow::GetAuraWindow(wm::GetRootWindowMatching( | 
|  351             WmWindowAura::GetAuraWindow( |  349                                  gfx::Rect(-200, 0, 300, 300)))); | 
|  352                 wm::GetRootWindowMatching(gfx::Rect(-200, 0, 300, 300)))); |  350   EXPECT_EQ(root_windows[0], WmWindow::GetAuraWindow(wm::GetRootWindowMatching( | 
|  353   EXPECT_EQ(root_windows[0], |  351                                  gfx::Rect(-100, 0, 300, 300)))); | 
|  354             WmWindowAura::GetAuraWindow( |  | 
|  355                 wm::GetRootWindowMatching(gfx::Rect(-100, 0, 300, 300)))); |  | 
|  356  |  352  | 
|  357   // Zero origin. |  353   // Zero origin. | 
|  358   EXPECT_EQ(root_windows[0], |  354   EXPECT_EQ(root_windows[0], WmWindow::GetAuraWindow(wm::GetRootWindowMatching( | 
|  359             WmWindowAura::GetAuraWindow( |  355                                  gfx::Rect(0, 0, 0, 0)))); | 
|  360                 wm::GetRootWindowMatching(gfx::Rect(0, 0, 0, 0)))); |  356   EXPECT_EQ(root_windows[0], WmWindow::GetAuraWindow(wm::GetRootWindowMatching( | 
|  361   EXPECT_EQ(root_windows[0], |  357                                  gfx::Rect(0, 0, 1, 1)))); | 
|  362             WmWindowAura::GetAuraWindow( |  | 
|  363                 wm::GetRootWindowMatching(gfx::Rect(0, 0, 1, 1)))); |  | 
|  364  |  358  | 
|  365   // Empty rect. |  359   // Empty rect. | 
|  366   EXPECT_EQ(root_windows[1], |  360   EXPECT_EQ(root_windows[1], WmWindow::GetAuraWindow(wm::GetRootWindowMatching( | 
|  367             WmWindowAura::GetAuraWindow( |  361                                  gfx::Rect(-400, 100, 0, 0)))); | 
|  368                 wm::GetRootWindowMatching(gfx::Rect(-400, 100, 0, 0)))); |  362   EXPECT_EQ(root_windows[0], WmWindow::GetAuraWindow(wm::GetRootWindowMatching( | 
|  369   EXPECT_EQ(root_windows[0], |  363                                  gfx::Rect(100, 100, 0, 0)))); | 
|  370             WmWindowAura::GetAuraWindow( |  | 
|  371                 wm::GetRootWindowMatching(gfx::Rect(100, 100, 0, 0)))); |  | 
|  372  |  364  | 
|  373   // Out of range rect should return the primary root window. |  365   // Out of range rect should return the primary root window. | 
|  374   EXPECT_EQ(root_windows[0], |  366   EXPECT_EQ(root_windows[0], WmWindow::GetAuraWindow(wm::GetRootWindowMatching( | 
|  375             WmWindowAura::GetAuraWindow( |  367                                  gfx::Rect(-600, -300, 50, 50)))); | 
|  376                 wm::GetRootWindowMatching(gfx::Rect(-600, -300, 50, 50)))); |  368   EXPECT_EQ(root_windows[0], WmWindow::GetAuraWindow(wm::GetRootWindowMatching( | 
|  377   EXPECT_EQ(root_windows[0], |  369                                  gfx::Rect(0, 1000, 50, 50)))); | 
|  378             WmWindowAura::GetAuraWindow( |  | 
|  379                 wm::GetRootWindowMatching(gfx::Rect(0, 1000, 50, 50)))); |  | 
|  380 } |  370 } | 
|  381  |  371  | 
|  382 TEST_F(ExtendedDesktopTest, Capture) { |  372 TEST_F(ExtendedDesktopTest, Capture) { | 
|  383   if (!SupportsMultipleDisplays()) |  373   if (!SupportsMultipleDisplays()) | 
|  384     return; |  374     return; | 
|  385  |  375  | 
|  386   UpdateDisplay("1000x600,600x400"); |  376   UpdateDisplay("1000x600,600x400"); | 
|  387   aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |  377   aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 
|  388  |  378  | 
|  389   aura::test::EventCountDelegate r1_d1; |  379   aura::test::EventCountDelegate r1_d1; | 
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  926   generator.ReleaseLeftButton(); |  916   generator.ReleaseLeftButton(); | 
|  927   EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset()); |  917   EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset()); | 
|  928  |  918  | 
|  929   generator.MoveMouseTo(400, 150); |  919   generator.MoveMouseTo(400, 150); | 
|  930   EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset()); |  920   EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset()); | 
|  931  |  921  | 
|  932   ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |  922   ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 
|  933 } |  923 } | 
|  934  |  924  | 
|  935 }  // namespace ash |  925 }  // namespace ash | 
| OLD | NEW |