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