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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 return this; | 54 return this; |
55 } | 55 } |
56 virtual ui::ModalType GetModalType() const OVERRIDE { | 56 virtual ui::ModalType GetModalType() const OVERRIDE { |
57 return ui::MODAL_TYPE_SYSTEM; | 57 return ui::MODAL_TYPE_SYSTEM; |
58 } | 58 } |
59 | 59 |
60 private: | 60 private: |
61 DISALLOW_COPY_AND_ASSIGN(ModalWidgetDelegate); | 61 DISALLOW_COPY_AND_ASSIGN(ModalWidgetDelegate); |
62 }; | 62 }; |
63 | 63 |
| 64 internal::MultiDisplayManager* GetDisplayManager() { |
| 65 return static_cast<internal::MultiDisplayManager*>( |
| 66 aura::Env::GetInstance()->display_manager()); |
| 67 } |
| 68 |
64 } // namespace | 69 } // namespace |
65 | 70 |
66 class ExtendedDesktopTest : public test::AshTestBase { | 71 typedef test::AshTestBase ExtendedDesktopTest; |
67 public: | |
68 ExtendedDesktopTest() {} | |
69 virtual ~ExtendedDesktopTest() {} | |
70 | |
71 virtual void SetUp() OVERRIDE { | |
72 internal::DisplayController::SetExtendedDesktopEnabled(true); | |
73 AshTestBase::SetUp(); | |
74 } | |
75 | |
76 virtual void TearDown() OVERRIDE { | |
77 AshTestBase::TearDown(); | |
78 internal::DisplayController::SetExtendedDesktopEnabled(false); | |
79 } | |
80 | |
81 protected: | |
82 internal::MultiDisplayManager* display_manager() { | |
83 return static_cast<internal::MultiDisplayManager*>( | |
84 aura::Env::GetInstance()->display_manager()); | |
85 } | |
86 | |
87 private: | |
88 DISALLOW_COPY_AND_ASSIGN(ExtendedDesktopTest); | |
89 }; | |
90 | 72 |
91 // Test conditions that root windows in extended desktop mode | 73 // Test conditions that root windows in extended desktop mode |
92 // must satisfy. | 74 // must satisfy. |
93 TEST_F(ExtendedDesktopTest, Basic) { | 75 TEST_F(ExtendedDesktopTest, Basic) { |
94 UpdateDisplay("1000x600,600x400"); | 76 UpdateDisplay("1000x600,600x400"); |
95 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 77 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
96 | 78 |
97 // All root windows must have the root window controller. | 79 // All root windows must have the root window controller. |
98 ASSERT_EQ(2U, root_windows.size()); | 80 ASSERT_EQ(2U, root_windows.size()); |
99 for (Shell::RootWindowList::const_iterator iter = root_windows.begin(); | 81 for (Shell::RootWindowList::const_iterator iter = root_windows.begin(); |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 w1_t1->GetWindowBoundsInScreen().ToString()); | 438 w1_t1->GetWindowBoundsInScreen().ToString()); |
457 } | 439 } |
458 | 440 |
459 namespace internal { | 441 namespace internal { |
460 // Test if the Window::ConvertPointToTarget works across root windows. | 442 // Test if the Window::ConvertPointToTarget works across root windows. |
461 // TODO(oshima): Move multiple display suport and this test to aura. | 443 // TODO(oshima): Move multiple display suport and this test to aura. |
462 TEST_F(ExtendedDesktopTest, ConvertPoint) { | 444 TEST_F(ExtendedDesktopTest, ConvertPoint) { |
463 UpdateDisplay("1000x600,600x400"); | 445 UpdateDisplay("1000x600,600x400"); |
464 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 446 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
465 gfx::Display& display_1 = | 447 gfx::Display& display_1 = |
466 display_manager()->FindDisplayForRootWindow(root_windows[0]); | 448 GetDisplayManager()->FindDisplayForRootWindow(root_windows[0]); |
467 EXPECT_EQ("0,0", display_1.bounds().origin().ToString()); | 449 EXPECT_EQ("0,0", display_1.bounds().origin().ToString()); |
468 gfx::Display& display_2 = | 450 gfx::Display& display_2 = |
469 display_manager()->FindDisplayForRootWindow(root_windows[1]); | 451 GetDisplayManager()->FindDisplayForRootWindow(root_windows[1]); |
470 EXPECT_EQ("1000,0", display_2.bounds().origin().ToString()); | 452 EXPECT_EQ("1000,0", display_2.bounds().origin().ToString()); |
471 | 453 |
472 aura::Window* d1 = | 454 aura::Window* d1 = |
473 CreateTestWidget(gfx::Rect(10, 10, 100, 100))->GetNativeView(); | 455 CreateTestWidget(gfx::Rect(10, 10, 100, 100))->GetNativeView(); |
474 aura::Window* d2 = | 456 aura::Window* d2 = |
475 CreateTestWidget(gfx::Rect(1020, 20, 100, 100))->GetNativeView(); | 457 CreateTestWidget(gfx::Rect(1020, 20, 100, 100))->GetNativeView(); |
476 EXPECT_EQ(root_windows[0], d1->GetRootWindow()); | 458 EXPECT_EQ(root_windows[0], d1->GetRootWindow()); |
477 EXPECT_EQ(root_windows[1], d2->GetRootWindow()); | 459 EXPECT_EQ(root_windows[1], d2->GetRootWindow()); |
478 | 460 |
479 // Convert point in the Root2's window to the Root1's window Coord. | 461 // Convert point in the Root2's window to the Root1's window Coord. |
480 gfx::Point p(0, 0); | 462 gfx::Point p(0, 0); |
481 aura::Window::ConvertPointToTarget(root_windows[1], root_windows[0], &p); | 463 aura::Window::ConvertPointToTarget(root_windows[1], root_windows[0], &p); |
482 EXPECT_EQ("1000,0", p.ToString()); | 464 EXPECT_EQ("1000,0", p.ToString()); |
483 p.SetPoint(0, 0); | 465 p.SetPoint(0, 0); |
484 aura::Window::ConvertPointToTarget(d2, d1, &p); | 466 aura::Window::ConvertPointToTarget(d2, d1, &p); |
485 EXPECT_EQ("1010,10", p.ToString()); | 467 EXPECT_EQ("1010,10", p.ToString()); |
486 | 468 |
487 // Convert point in the Root1's window to the Root2's window Coord. | 469 // Convert point in the Root1's window to the Root2's window Coord. |
488 p.SetPoint(0, 0); | 470 p.SetPoint(0, 0); |
489 aura::Window::ConvertPointToTarget(root_windows[0], root_windows[1], &p); | 471 aura::Window::ConvertPointToTarget(root_windows[0], root_windows[1], &p); |
490 EXPECT_EQ("-1000,0", p.ToString()); | 472 EXPECT_EQ("-1000,0", p.ToString()); |
491 p.SetPoint(0, 0); | 473 p.SetPoint(0, 0); |
492 aura::Window::ConvertPointToTarget(d1, d2, &p); | 474 aura::Window::ConvertPointToTarget(d1, d2, &p); |
493 EXPECT_EQ("-1010,-10", p.ToString()); | 475 EXPECT_EQ("-1010,-10", p.ToString()); |
494 | 476 |
495 // Move the 2nd display to the bottom and test again. | 477 // Move the 2nd display to the bottom and test again. |
496 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( | 478 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( |
497 internal::DisplayController::BOTTOM); | 479 internal::DisplayController::BOTTOM); |
498 | 480 |
499 display_2 = display_manager()->FindDisplayForRootWindow(root_windows[1]); | 481 display_2 = GetDisplayManager()->FindDisplayForRootWindow(root_windows[1]); |
500 EXPECT_EQ("0,600", display_2.bounds().origin().ToString()); | 482 EXPECT_EQ("0,600", display_2.bounds().origin().ToString()); |
501 | 483 |
502 // Convert point in Root2's window to Root1's window Coord. | 484 // Convert point in Root2's window to Root1's window Coord. |
503 p.SetPoint(0, 0); | 485 p.SetPoint(0, 0); |
504 aura::Window::ConvertPointToTarget(root_windows[1], root_windows[0], &p); | 486 aura::Window::ConvertPointToTarget(root_windows[1], root_windows[0], &p); |
505 EXPECT_EQ("0,600", p.ToString()); | 487 EXPECT_EQ("0,600", p.ToString()); |
506 p.SetPoint(0, 0); | 488 p.SetPoint(0, 0); |
507 aura::Window::ConvertPointToTarget(d2, d1, &p); | 489 aura::Window::ConvertPointToTarget(d2, d1, &p); |
508 EXPECT_EQ("10,610", p.ToString()); | 490 EXPECT_EQ("10,610", p.ToString()); |
509 | 491 |
510 // Convert point in Root1's window to Root2's window Coord. | 492 // Convert point in Root1's window to Root2's window Coord. |
511 p.SetPoint(0, 0); | 493 p.SetPoint(0, 0); |
512 aura::Window::ConvertPointToTarget(root_windows[0], root_windows[1], &p); | 494 aura::Window::ConvertPointToTarget(root_windows[0], root_windows[1], &p); |
513 EXPECT_EQ("0,-600", p.ToString()); | 495 EXPECT_EQ("0,-600", p.ToString()); |
514 p.SetPoint(0, 0); | 496 p.SetPoint(0, 0); |
515 aura::Window::ConvertPointToTarget(d1, d2, &p); | 497 aura::Window::ConvertPointToTarget(d1, d2, &p); |
516 EXPECT_EQ("-10,-610", p.ToString()); | 498 EXPECT_EQ("-10,-610", p.ToString()); |
517 } | 499 } |
518 | 500 |
519 } // namespace internal | 501 } // namespace internal |
520 } // namespace ash | 502 } // namespace ash |
OLD | NEW |