| 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/display/display_controller.h" | 5 #include "ash/display/display_controller.h" |
| 6 #include "ash/display/multi_display_manager.h" | 6 #include "ash/display/multi_display_manager.h" |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
| 9 #include "ash/wm/coordinate_conversion.h" | 9 #include "ash/wm/coordinate_conversion.h" |
| 10 #include "ash/wm/property_util.h" | 10 #include "ash/wm/property_util.h" |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); | 236 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); |
| 237 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); | 237 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); |
| 238 EXPECT_TRUE(wm::IsActiveWindow(d1_w2->GetNativeView())); | 238 EXPECT_TRUE(wm::IsActiveWindow(d1_w2->GetNativeView())); |
| 239 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); | 239 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); |
| 240 EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView())); | 240 EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView())); |
| 241 } | 241 } |
| 242 | 242 |
| 243 TEST_F(ExtendedDesktopTest, GetRootWindowAt) { | 243 TEST_F(ExtendedDesktopTest, GetRootWindowAt) { |
| 244 UpdateDisplay("700x500,500x500"); | 244 UpdateDisplay("700x500,500x500"); |
| 245 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( | 245 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( |
| 246 internal::DisplayController::LEFT); | 246 internal::DisplayLayout::LEFT); |
| 247 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 247 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 248 | 248 |
| 249 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-400, 100))); | 249 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-400, 100))); |
| 250 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-1, 100))); | 250 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-1, 100))); |
| 251 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 300))); | 251 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 300))); |
| 252 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(700,300))); | 252 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(700,300))); |
| 253 | 253 |
| 254 // Zero origin. | 254 // Zero origin. |
| 255 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 0))); | 255 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 0))); |
| 256 | 256 |
| 257 // Out of range point should return the primary root window | 257 // Out of range point should return the primary root window |
| 258 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(-600, 0))); | 258 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(-600, 0))); |
| 259 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(701, 100))); | 259 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(701, 100))); |
| 260 } | 260 } |
| 261 | 261 |
| 262 TEST_F(ExtendedDesktopTest, GetRootWindowMatching) { | 262 TEST_F(ExtendedDesktopTest, GetRootWindowMatching) { |
| 263 UpdateDisplay("700x500,500x500"); | 263 UpdateDisplay("700x500,500x500"); |
| 264 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( | 264 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( |
| 265 internal::DisplayController::LEFT); | 265 internal::DisplayLayout::LEFT); |
| 266 | 266 |
| 267 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 267 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 268 | 268 |
| 269 // Containing rect. | 269 // Containing rect. |
| 270 EXPECT_EQ(root_windows[1], | 270 EXPECT_EQ(root_windows[1], |
| 271 wm::GetRootWindowMatching(gfx::Rect(-300, 10, 50, 50))); | 271 wm::GetRootWindowMatching(gfx::Rect(-300, 10, 50, 50))); |
| 272 EXPECT_EQ(root_windows[0], | 272 EXPECT_EQ(root_windows[0], |
| 273 wm::GetRootWindowMatching(gfx::Rect(100, 10, 50, 50))); | 273 wm::GetRootWindowMatching(gfx::Rect(100, 10, 50, 50))); |
| 274 | 274 |
| 275 // Intersecting rect. | 275 // Intersecting rect. |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 // Convert point in the Root1's window to the Root2's window Coord. | 498 // Convert point in the Root1's window to the Root2's window Coord. |
| 499 p.SetPoint(0, 0); | 499 p.SetPoint(0, 0); |
| 500 aura::Window::ConvertPointToTarget(root_windows[0], root_windows[1], &p); | 500 aura::Window::ConvertPointToTarget(root_windows[0], root_windows[1], &p); |
| 501 EXPECT_EQ("-1000,0", p.ToString()); | 501 EXPECT_EQ("-1000,0", p.ToString()); |
| 502 p.SetPoint(0, 0); | 502 p.SetPoint(0, 0); |
| 503 aura::Window::ConvertPointToTarget(d1, d2, &p); | 503 aura::Window::ConvertPointToTarget(d1, d2, &p); |
| 504 EXPECT_EQ("-1010,-10", p.ToString()); | 504 EXPECT_EQ("-1010,-10", p.ToString()); |
| 505 | 505 |
| 506 // Move the 2nd display to the bottom and test again. | 506 // Move the 2nd display to the bottom and test again. |
| 507 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( | 507 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( |
| 508 internal::DisplayController::BOTTOM); | 508 internal::DisplayLayout::BOTTOM); |
| 509 | 509 |
| 510 display_2 = GetDisplayManager()->FindDisplayForRootWindow(root_windows[1]); | 510 display_2 = GetDisplayManager()->FindDisplayForRootWindow(root_windows[1]); |
| 511 EXPECT_EQ("0,600", display_2.bounds().origin().ToString()); | 511 EXPECT_EQ("0,600", display_2.bounds().origin().ToString()); |
| 512 | 512 |
| 513 // Convert point in Root2's window to Root1's window Coord. | 513 // Convert point in Root2's window to Root1's window Coord. |
| 514 p.SetPoint(0, 0); | 514 p.SetPoint(0, 0); |
| 515 aura::Window::ConvertPointToTarget(root_windows[1], root_windows[0], &p); | 515 aura::Window::ConvertPointToTarget(root_windows[1], root_windows[0], &p); |
| 516 EXPECT_EQ("0,600", p.ToString()); | 516 EXPECT_EQ("0,600", p.ToString()); |
| 517 p.SetPoint(0, 0); | 517 p.SetPoint(0, 0); |
| 518 aura::Window::ConvertPointToTarget(d2, d1, &p); | 518 aura::Window::ConvertPointToTarget(d2, d1, &p); |
| 519 EXPECT_EQ("10,610", p.ToString()); | 519 EXPECT_EQ("10,610", p.ToString()); |
| 520 | 520 |
| 521 // Convert point in Root1's window to Root2's window Coord. | 521 // Convert point in Root1's window to Root2's window Coord. |
| 522 p.SetPoint(0, 0); | 522 p.SetPoint(0, 0); |
| 523 aura::Window::ConvertPointToTarget(root_windows[0], root_windows[1], &p); | 523 aura::Window::ConvertPointToTarget(root_windows[0], root_windows[1], &p); |
| 524 EXPECT_EQ("0,-600", p.ToString()); | 524 EXPECT_EQ("0,-600", p.ToString()); |
| 525 p.SetPoint(0, 0); | 525 p.SetPoint(0, 0); |
| 526 aura::Window::ConvertPointToTarget(d1, d2, &p); | 526 aura::Window::ConvertPointToTarget(d1, d2, &p); |
| 527 EXPECT_EQ("-10,-610", p.ToString()); | 527 EXPECT_EQ("-10,-610", p.ToString()); |
| 528 } | 528 } |
| 529 | 529 |
| 530 } // namespace internal | 530 } // namespace internal |
| 531 } // namespace ash | 531 } // namespace ash |
| OLD | NEW |