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/window_tree_host_manager.h" | 5 #include "ash/display/window_tree_host_manager.h" |
6 | 6 |
| 7 #include <memory> |
| 8 |
7 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
8 #include "ash/display/display_info.h" | 10 #include "ash/display/display_info.h" |
9 #include "ash/display/display_layout_store.h" | 11 #include "ash/display/display_layout_store.h" |
10 #include "ash/display/display_manager.h" | 12 #include "ash/display/display_manager.h" |
11 #include "ash/display/display_util.h" | 13 #include "ash/display/display_util.h" |
12 #include "ash/screen_util.h" | 14 #include "ash/screen_util.h" |
13 #include "ash/shelf/shelf.h" | 15 #include "ash/shelf/shelf.h" |
14 #include "ash/shelf/shelf_widget.h" | 16 #include "ash/shelf/shelf_widget.h" |
15 #include "ash/shell.h" | 17 #include "ash/shell.h" |
16 #include "ash/test/ash_test_base.h" | 18 #include "ash/test/ash_test_base.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 } | 182 } |
181 | 183 |
182 gfx::Display GetSecondaryDisplay() { | 184 gfx::Display GetSecondaryDisplay() { |
183 return gfx::Screen::GetScreen()->GetDisplayNearestWindow( | 185 return gfx::Screen::GetScreen()->GetDisplayNearestWindow( |
184 Shell::GetAllRootWindows()[1]); | 186 Shell::GetAllRootWindows()[1]); |
185 } | 187 } |
186 | 188 |
187 void SetSecondaryDisplayLayoutAndOffset( | 189 void SetSecondaryDisplayLayoutAndOffset( |
188 display::DisplayPlacement::Position position, | 190 display::DisplayPlacement::Position position, |
189 int offset) { | 191 int offset) { |
190 scoped_ptr<display::DisplayLayout> layout( | 192 std::unique_ptr<display::DisplayLayout> layout( |
191 test::CreateDisplayLayout(position, offset)); | 193 test::CreateDisplayLayout(position, offset)); |
192 ASSERT_GT(gfx::Screen::GetScreen()->GetNumDisplays(), 1); | 194 ASSERT_GT(gfx::Screen::GetScreen()->GetNumDisplays(), 1); |
193 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( | 195 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( |
194 std::move(layout)); | 196 std::move(layout)); |
195 } | 197 } |
196 | 198 |
197 void SetSecondaryDisplayLayout(display::DisplayPlacement::Position position) { | 199 void SetSecondaryDisplayLayout(display::DisplayPlacement::Position position) { |
198 SetSecondaryDisplayLayoutAndOffset(position, 0); | 200 SetSecondaryDisplayLayoutAndOffset(position, 0); |
199 } | 201 } |
200 | 202 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 return; | 391 return; |
390 | 392 |
391 EXPECT_TRUE(startup_helper()->displays_initialized()); | 393 EXPECT_TRUE(startup_helper()->displays_initialized()); |
392 } | 394 } |
393 | 395 |
394 TEST_F(WindowTreeHostManagerTest, SecondaryDisplayLayout) { | 396 TEST_F(WindowTreeHostManagerTest, SecondaryDisplayLayout) { |
395 if (!SupportsMultipleDisplays()) | 397 if (!SupportsMultipleDisplays()) |
396 return; | 398 return; |
397 | 399 |
398 // Creates windows to catch activation change event. | 400 // Creates windows to catch activation change event. |
399 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1)); | 401 std::unique_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1)); |
400 w1->Focus(); | 402 w1->Focus(); |
401 | 403 |
402 TestObserver observer; | 404 TestObserver observer; |
403 UpdateDisplay("500x500,400x400"); | 405 UpdateDisplay("500x500,400x400"); |
404 EXPECT_EQ(1, observer.CountAndReset()); // resize and add | 406 EXPECT_EQ(1, observer.CountAndReset()); // resize and add |
405 EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset()); | 407 EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset()); |
406 EXPECT_EQ(1, observer.GetWorkareaChangedCountAndReset()); | 408 EXPECT_EQ(1, observer.GetWorkareaChangedCountAndReset()); |
407 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 409 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
408 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 410 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
409 gfx::Insets insets(5, 5, 5, 5); | 411 gfx::Insets insets(5, 5, 5, 5); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 return info; | 553 return info; |
552 } | 554 } |
553 | 555 |
554 } // namespace | 556 } // namespace |
555 | 557 |
556 TEST_F(WindowTreeHostManagerTest, MirrorToDockedWithFullscreen) { | 558 TEST_F(WindowTreeHostManagerTest, MirrorToDockedWithFullscreen) { |
557 if (!SupportsMultipleDisplays()) | 559 if (!SupportsMultipleDisplays()) |
558 return; | 560 return; |
559 | 561 |
560 // Creates windows to catch activation change event. | 562 // Creates windows to catch activation change event. |
561 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1)); | 563 std::unique_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1)); |
562 w1->Focus(); | 564 w1->Focus(); |
563 | 565 |
564 // Docked mode. | 566 // Docked mode. |
565 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 567 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
566 | 568 |
567 const DisplayInfo internal_display_info = CreateMirroredDisplayInfo(1, 2.0f); | 569 const DisplayInfo internal_display_info = CreateMirroredDisplayInfo(1, 2.0f); |
568 const DisplayInfo external_display_info = CreateMirroredDisplayInfo(2, 1.0f); | 570 const DisplayInfo external_display_info = CreateMirroredDisplayInfo(2, 1.0f); |
569 | 571 |
570 std::vector<DisplayInfo> display_info_list; | 572 std::vector<DisplayInfo> display_info_list; |
571 // Mirror. | 573 // Mirror. |
(...skipping 29 matching lines...) Expand all Loading... |
601 | 603 |
602 EXPECT_TRUE(window_state->IsFullscreen()); | 604 EXPECT_TRUE(window_state->IsFullscreen()); |
603 EXPECT_EQ("0,0 500x500", w1->bounds().ToString()); | 605 EXPECT_EQ("0,0 500x500", w1->bounds().ToString()); |
604 } | 606 } |
605 | 607 |
606 TEST_F(WindowTreeHostManagerTest, BoundsUpdated) { | 608 TEST_F(WindowTreeHostManagerTest, BoundsUpdated) { |
607 if (!SupportsMultipleDisplays()) | 609 if (!SupportsMultipleDisplays()) |
608 return; | 610 return; |
609 | 611 |
610 // Creates windows to catch activation change event. | 612 // Creates windows to catch activation change event. |
611 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1)); | 613 std::unique_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1)); |
612 w1->Focus(); | 614 w1->Focus(); |
613 | 615 |
614 TestObserver observer; | 616 TestObserver observer; |
615 SetDefaultDisplayLayout(display::DisplayPlacement::BOTTOM); | 617 SetDefaultDisplayLayout(display::DisplayPlacement::BOTTOM); |
616 UpdateDisplay("200x200,300x300"); // layout, resize and add. | 618 UpdateDisplay("200x200,300x300"); // layout, resize and add. |
617 EXPECT_EQ(1, observer.CountAndReset()); | 619 EXPECT_EQ(1, observer.CountAndReset()); |
618 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 620 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
619 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 621 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
620 | 622 |
621 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 623 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1490 widget->GetNativeWindow()->GetRootWindow()); | 1492 widget->GetNativeWindow()->GetRootWindow()); |
1491 event_generator.MoveMouseToCenterOf(widget->GetNativeWindow()); | 1493 event_generator.MoveMouseToCenterOf(widget->GetNativeWindow()); |
1492 | 1494 |
1493 UpdateDisplay("300x300"); | 1495 UpdateDisplay("300x300"); |
1494 watcher.Stop(); | 1496 watcher.Stop(); |
1495 | 1497 |
1496 widget->CloseNow(); | 1498 widget->CloseNow(); |
1497 } | 1499 } |
1498 | 1500 |
1499 } // namespace ash | 1501 } // namespace ash |
OLD | NEW |