| 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_manager.h" | 5 #include "ash/display/display_manager.h" |
| 6 | 6 |
| 7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/screen_ash.h" | 8 #include "ash/screen_ash.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
| 11 #include "ash/test/display_manager_test_api.h" | 11 #include "ash/test/display_manager_test_api.h" |
| 12 #include "ash/test/mirror_window_test_api.h" |
| 12 #include "base/format_macros.h" | 13 #include "base/format_macros.h" |
| 13 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
| 14 #include "ui/aura/env.h" | 15 #include "ui/aura/env.h" |
| 15 #include "ui/aura/root_window.h" | 16 #include "ui/aura/root_window.h" |
| 16 #include "ui/aura/test/event_generator.h" | 17 #include "ui/aura/test/event_generator.h" |
| 17 #include "ui/aura/window_observer.h" | 18 #include "ui/aura/window_observer.h" |
| 18 #include "ui/gfx/display_observer.h" | 19 #include "ui/gfx/display_observer.h" |
| 19 #include "ui/gfx/display.h" | 20 #include "ui/gfx/display.h" |
| 20 | 21 |
| 21 namespace ash { | 22 namespace ash { |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 UpdateDisplay("100x200/r,300x400/l"); | 706 UpdateDisplay("100x200/r,300x400/l"); |
| 706 EXPECT_EQ("1,1 100x200", | 707 EXPECT_EQ("1,1 100x200", |
| 707 GetDisplayInfoAt(0).bounds_in_pixel().ToString()); | 708 GetDisplayInfoAt(0).bounds_in_pixel().ToString()); |
| 708 EXPECT_EQ("200x100", | 709 EXPECT_EQ("200x100", |
| 709 GetDisplayInfoAt(0).size_in_pixel().ToString()); | 710 GetDisplayInfoAt(0).size_in_pixel().ToString()); |
| 710 | 711 |
| 711 EXPECT_EQ("1,201 300x400", | 712 EXPECT_EQ("1,201 300x400", |
| 712 GetDisplayInfoAt(1).bounds_in_pixel().ToString()); | 713 GetDisplayInfoAt(1).bounds_in_pixel().ToString()); |
| 713 EXPECT_EQ("400x300", | 714 EXPECT_EQ("400x300", |
| 714 GetDisplayInfoAt(1).size_in_pixel().ToString()); | 715 GetDisplayInfoAt(1).size_in_pixel().ToString()); |
| 716 reset(); |
| 715 UpdateDisplay("100x200/b,300x400"); | 717 UpdateDisplay("100x200/b,300x400"); |
| 718 EXPECT_EQ("2 0 0", GetCountSummary()); |
| 719 reset(); |
| 720 |
| 716 EXPECT_EQ("1,1 100x200", | 721 EXPECT_EQ("1,1 100x200", |
| 717 GetDisplayInfoAt(0).bounds_in_pixel().ToString()); | 722 GetDisplayInfoAt(0).bounds_in_pixel().ToString()); |
| 718 EXPECT_EQ("100x200", | 723 EXPECT_EQ("100x200", |
| 719 GetDisplayInfoAt(0).size_in_pixel().ToString()); | 724 GetDisplayInfoAt(0).size_in_pixel().ToString()); |
| 720 | 725 |
| 721 EXPECT_EQ("1,201 300x400", | 726 EXPECT_EQ("1,201 300x400", |
| 722 GetDisplayInfoAt(1).bounds_in_pixel().ToString()); | 727 GetDisplayInfoAt(1).bounds_in_pixel().ToString()); |
| 723 EXPECT_EQ("300x400", | 728 EXPECT_EQ("300x400", |
| 724 GetDisplayInfoAt(1).size_in_pixel().ToString()); | 729 GetDisplayInfoAt(1).size_in_pixel().ToString()); |
| 730 |
| 731 UpdateDisplay("200x200"); |
| 732 EXPECT_EQ("1 0 1", GetCountSummary()); |
| 733 reset(); |
| 734 |
| 735 UpdateDisplay("200x200/l"); |
| 736 EXPECT_EQ("1 0 0", GetCountSummary()); |
| 725 } | 737 } |
| 726 | 738 |
| 727 TEST_F(DisplayManagerTest, UIScale) { | 739 TEST_F(DisplayManagerTest, UIScale) { |
| 728 UpdateDisplay("1280x800"); | 740 UpdateDisplay("1280x800"); |
| 729 int64 display_id = Shell::GetScreen()->GetPrimaryDisplay().id(); | 741 int64 display_id = Shell::GetScreen()->GetPrimaryDisplay().id(); |
| 730 display_manager()->SetDisplayUIScale(display_id, 1.125f); | 742 display_manager()->SetDisplayUIScale(display_id, 1.125f); |
| 731 EXPECT_EQ(1.0, GetDisplayInfoAt(0).ui_scale()); | 743 EXPECT_EQ(1.0, GetDisplayInfoAt(0).ui_scale()); |
| 732 display_manager()->SetDisplayUIScale(display_id, 0.8f); | 744 display_manager()->SetDisplayUIScale(display_id, 0.8f); |
| 733 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).ui_scale()); | 745 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).ui_scale()); |
| 734 display_manager()->SetDisplayUIScale(display_id, 0.75f); | 746 display_manager()->SetDisplayUIScale(display_id, 0.75f); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 EXPECT_EQ("150,225", env->last_mouse_location().ToString()); | 844 EXPECT_EQ("150,225", env->last_mouse_location().ToString()); |
| 833 | 845 |
| 834 // Test on 2nd display. | 846 // Test on 2nd display. |
| 835 UpdateDisplay("600x400,400x300*2"); | 847 UpdateDisplay("600x400,400x300*2"); |
| 836 generator2.MoveMouseToInHost(200, 100); | 848 generator2.MoveMouseToInHost(200, 100); |
| 837 EXPECT_EQ("700,50", env->last_mouse_location().ToString()); | 849 EXPECT_EQ("700,50", env->last_mouse_location().ToString()); |
| 838 UpdateDisplay("600x400,400x300*2@1.5"); | 850 UpdateDisplay("600x400,400x300*2@1.5"); |
| 839 EXPECT_EQ("750,75", env->last_mouse_location().ToString()); | 851 EXPECT_EQ("750,75", env->last_mouse_location().ToString()); |
| 840 } | 852 } |
| 841 | 853 |
| 854 #if defined(OS_WIN) |
| 855 // This does not work on metro. |
| 856 #define MAYBE_SoftwareMirroring DISABLED_SoftwareMirroring |
| 857 #else |
| 858 #define MAYBE_SoftwareMirroring SoftwareMirroring |
| 859 #endif |
| 860 |
| 861 TEST_F(DisplayManagerTest, MAYBE_SoftwareMirroring) { |
| 862 UpdateDisplay("300x400,400x500"); |
| 863 |
| 864 test::MirrorWindowTestApi test_api; |
| 865 EXPECT_EQ(NULL, test_api.GetRootWindow()); |
| 866 |
| 867 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 868 display_manager->SetSoftwareMirroring(true); |
| 869 display_manager->UpdateDisplays(); |
| 870 EXPECT_EQ(1U, display_manager->GetNumDisplays()); |
| 871 EXPECT_EQ("0,0 300x400", |
| 872 Shell::GetScreen()->GetPrimaryDisplay().bounds().ToString()); |
| 873 EXPECT_EQ("400x500", test_api.GetRootWindow()->GetHostSize().ToString()); |
| 874 EXPECT_TRUE(display_manager->IsMirrored()); |
| 875 |
| 876 display_manager->SetMirrorMode(false); |
| 877 EXPECT_EQ(NULL, test_api.GetRootWindow()); |
| 878 EXPECT_EQ(2U, display_manager->GetNumDisplays()); |
| 879 EXPECT_FALSE(display_manager->IsMirrored()); |
| 880 } |
| 881 |
| 842 } // namespace internal | 882 } // namespace internal |
| 843 } // namespace ash | 883 } // namespace ash |
| OLD | NEW |