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 26 matching lines...) Expand all Loading... |
37 views::Widget* widget = new views::Widget; | 37 views::Widget* widget = new views::Widget; |
38 widget->Init(params); | 38 widget->Init(params); |
39 widget->Show(); | 39 widget->Show(); |
40 return widget; | 40 return widget; |
41 } | 41 } |
42 | 42 |
43 views::Widget* CreateTestWidget(const gfx::Rect& bounds) { | 43 views::Widget* CreateTestWidget(const gfx::Rect& bounds) { |
44 return CreateTestWidgetWithParent(NULL, bounds, false); | 44 return CreateTestWidgetWithParent(NULL, bounds, false); |
45 } | 45 } |
46 | 46 |
| 47 void SetSecondaryDisplayLayout(DisplayLayout::Position position) { |
| 48 DisplayController* display_controller = |
| 49 Shell::GetInstance()->display_controller(); |
| 50 DisplayLayout layout = display_controller->default_display_layout(); |
| 51 layout.position = position; |
| 52 display_controller->SetDefaultDisplayLayout(layout); |
| 53 } |
| 54 |
47 class ModalWidgetDelegate : public views::WidgetDelegateView { | 55 class ModalWidgetDelegate : public views::WidgetDelegateView { |
48 public: | 56 public: |
49 ModalWidgetDelegate() {} | 57 ModalWidgetDelegate() {} |
50 virtual ~ModalWidgetDelegate() {} | 58 virtual ~ModalWidgetDelegate() {} |
51 | 59 |
52 // Overridden from views::WidgetDelegate: | 60 // Overridden from views::WidgetDelegate: |
53 virtual views::View* GetContentsView() OVERRIDE { | 61 virtual views::View* GetContentsView() OVERRIDE { |
54 return this; | 62 return this; |
55 } | 63 } |
56 virtual ui::ModalType GetModalType() const OVERRIDE { | 64 virtual ui::ModalType GetModalType() const OVERRIDE { |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); | 243 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); |
236 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); | 244 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); |
237 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); | 245 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); |
238 EXPECT_TRUE(wm::IsActiveWindow(d1_w2->GetNativeView())); | 246 EXPECT_TRUE(wm::IsActiveWindow(d1_w2->GetNativeView())); |
239 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); | 247 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); |
240 EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView())); | 248 EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView())); |
241 } | 249 } |
242 | 250 |
243 TEST_F(ExtendedDesktopTest, GetRootWindowAt) { | 251 TEST_F(ExtendedDesktopTest, GetRootWindowAt) { |
244 UpdateDisplay("700x500,500x500"); | 252 UpdateDisplay("700x500,500x500"); |
245 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( | 253 SetSecondaryDisplayLayout(DisplayLayout::LEFT); |
246 internal::DisplayController::LEFT); | |
247 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 254 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
248 | 255 |
249 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-400, 100))); | 256 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-400, 100))); |
250 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-1, 100))); | 257 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-1, 100))); |
251 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 300))); | 258 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 300))); |
252 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(700,300))); | 259 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(700,300))); |
253 | 260 |
254 // Zero origin. | 261 // Zero origin. |
255 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 0))); | 262 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 0))); |
256 | 263 |
257 // Out of range point should return the primary root window | 264 // Out of range point should return the primary root window |
258 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(-600, 0))); | 265 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(-600, 0))); |
259 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(701, 100))); | 266 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(701, 100))); |
260 } | 267 } |
261 | 268 |
262 TEST_F(ExtendedDesktopTest, GetRootWindowMatching) { | 269 TEST_F(ExtendedDesktopTest, GetRootWindowMatching) { |
263 UpdateDisplay("700x500,500x500"); | 270 UpdateDisplay("700x500,500x500"); |
264 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( | 271 SetSecondaryDisplayLayout(DisplayLayout::LEFT); |
265 internal::DisplayController::LEFT); | |
266 | 272 |
267 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 273 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
268 | 274 |
269 // Containing rect. | 275 // Containing rect. |
270 EXPECT_EQ(root_windows[1], | 276 EXPECT_EQ(root_windows[1], |
271 wm::GetRootWindowMatching(gfx::Rect(-300, 10, 50, 50))); | 277 wm::GetRootWindowMatching(gfx::Rect(-300, 10, 50, 50))); |
272 EXPECT_EQ(root_windows[0], | 278 EXPECT_EQ(root_windows[0], |
273 wm::GetRootWindowMatching(gfx::Rect(100, 10, 50, 50))); | 279 wm::GetRootWindowMatching(gfx::Rect(100, 10, 50, 50))); |
274 | 280 |
275 // Intersecting rect. | 281 // Intersecting rect. |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 | 503 |
498 // Convert point in the Root1's window to the Root2's window Coord. | 504 // Convert point in the Root1's window to the Root2's window Coord. |
499 p.SetPoint(0, 0); | 505 p.SetPoint(0, 0); |
500 aura::Window::ConvertPointToTarget(root_windows[0], root_windows[1], &p); | 506 aura::Window::ConvertPointToTarget(root_windows[0], root_windows[1], &p); |
501 EXPECT_EQ("-1000,0", p.ToString()); | 507 EXPECT_EQ("-1000,0", p.ToString()); |
502 p.SetPoint(0, 0); | 508 p.SetPoint(0, 0); |
503 aura::Window::ConvertPointToTarget(d1, d2, &p); | 509 aura::Window::ConvertPointToTarget(d1, d2, &p); |
504 EXPECT_EQ("-1010,-10", p.ToString()); | 510 EXPECT_EQ("-1010,-10", p.ToString()); |
505 | 511 |
506 // Move the 2nd display to the bottom and test again. | 512 // Move the 2nd display to the bottom and test again. |
507 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( | 513 SetSecondaryDisplayLayout(DisplayLayout::BOTTOM); |
508 internal::DisplayController::BOTTOM); | |
509 | 514 |
510 display_2 = GetDisplayManager()->FindDisplayForRootWindow(root_windows[1]); | 515 display_2 = GetDisplayManager()->FindDisplayForRootWindow(root_windows[1]); |
511 EXPECT_EQ("0,600", display_2.bounds().origin().ToString()); | 516 EXPECT_EQ("0,600", display_2.bounds().origin().ToString()); |
512 | 517 |
513 // Convert point in Root2's window to Root1's window Coord. | 518 // Convert point in Root2's window to Root1's window Coord. |
514 p.SetPoint(0, 0); | 519 p.SetPoint(0, 0); |
515 aura::Window::ConvertPointToTarget(root_windows[1], root_windows[0], &p); | 520 aura::Window::ConvertPointToTarget(root_windows[1], root_windows[0], &p); |
516 EXPECT_EQ("0,600", p.ToString()); | 521 EXPECT_EQ("0,600", p.ToString()); |
517 p.SetPoint(0, 0); | 522 p.SetPoint(0, 0); |
518 aura::Window::ConvertPointToTarget(d2, d1, &p); | 523 aura::Window::ConvertPointToTarget(d2, d1, &p); |
519 EXPECT_EQ("10,610", p.ToString()); | 524 EXPECT_EQ("10,610", p.ToString()); |
520 | 525 |
521 // Convert point in Root1's window to Root2's window Coord. | 526 // Convert point in Root1's window to Root2's window Coord. |
522 p.SetPoint(0, 0); | 527 p.SetPoint(0, 0); |
523 aura::Window::ConvertPointToTarget(root_windows[0], root_windows[1], &p); | 528 aura::Window::ConvertPointToTarget(root_windows[0], root_windows[1], &p); |
524 EXPECT_EQ("0,-600", p.ToString()); | 529 EXPECT_EQ("0,-600", p.ToString()); |
525 p.SetPoint(0, 0); | 530 p.SetPoint(0, 0); |
526 aura::Window::ConvertPointToTarget(d1, d2, &p); | 531 aura::Window::ConvertPointToTarget(d1, d2, &p); |
527 EXPECT_EQ("-10,-610", p.ToString()); | 532 EXPECT_EQ("-10,-610", p.ToString()); |
528 } | 533 } |
529 | 534 |
530 } // namespace internal | 535 } // namespace internal |
531 } // namespace ash | 536 } // namespace ash |
OLD | NEW |