OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/system_display/display_info_provider.h" | 5 #include "extensions/browser/api/system_display/display_info_provider.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 9 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
10 #include "ash/common/wm_shell.h" | 10 #include "ash/common/wm_shell.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "ui/display/test/display_manager_test_api.h" | 25 #include "ui/display/test/display_manager_test_api.h" |
26 #include "ui/display/types/display_constants.h" | 26 #include "ui/display/types/display_constants.h" |
27 #include "ui/gfx/geometry/rect.h" | 27 #include "ui/gfx/geometry/rect.h" |
28 | 28 |
29 namespace extensions { | 29 namespace extensions { |
30 namespace { | 30 namespace { |
31 | 31 |
32 using DisplayUnitInfoList = DisplayInfoProvider::DisplayUnitInfoList; | 32 using DisplayUnitInfoList = DisplayInfoProvider::DisplayUnitInfoList; |
33 using DisplayLayoutList = DisplayInfoProvider::DisplayLayoutList; | 33 using DisplayLayoutList = DisplayInfoProvider::DisplayLayoutList; |
34 | 34 |
| 35 void EnableMaximizeMode(bool enable) { |
| 36 ash::WmShell::Get() |
| 37 ->maximize_mode_controller() |
| 38 ->EnableMaximizeModeWindowManager(enable); |
| 39 } |
| 40 |
35 class DisplayInfoProviderChromeosTest : public ash::test::AshTestBase { | 41 class DisplayInfoProviderChromeosTest : public ash::test::AshTestBase { |
36 public: | 42 public: |
37 DisplayInfoProviderChromeosTest() {} | 43 DisplayInfoProviderChromeosTest() {} |
38 | 44 |
39 ~DisplayInfoProviderChromeosTest() override {} | 45 ~DisplayInfoProviderChromeosTest() override {} |
40 | 46 |
41 void SetUp() override { | 47 void SetUp() override { |
42 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 48 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
43 switches::kUseFirstDisplayAsInternal); | 49 switches::kUseFirstDisplayAsInternal); |
44 ash::test::AshTestBase::SetUp(); | 50 ash::test::AshTestBase::SetUp(); |
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 std::string error; | 921 std::string error; |
916 CallSetDisplayUnitInfo( | 922 CallSetDisplayUnitInfo( |
917 base::Int64ToString(display::Display::InternalDisplayId()), info, | 923 base::Int64ToString(display::Display::InternalDisplayId()), info, |
918 &success, &error); | 924 &success, &error); |
919 | 925 |
920 ASSERT_TRUE(success); | 926 ASSERT_TRUE(success); |
921 EXPECT_TRUE(error.empty()); | 927 EXPECT_TRUE(error.empty()); |
922 EXPECT_FALSE(screen_orientation_controller->rotation_locked()); | 928 EXPECT_FALSE(screen_orientation_controller->rotation_locked()); |
923 | 929 |
924 // Entering maximize mode enables accelerometer screen rotations. | 930 // Entering maximize mode enables accelerometer screen rotations. |
925 ash::WmShell::Get() | 931 EnableMaximizeMode(true); |
926 ->maximize_mode_controller() | |
927 ->EnableMaximizeModeWindowManager(true); | |
928 // Rotation lock should not activate because DisplayInfoProvider::SetInfo() | 932 // Rotation lock should not activate because DisplayInfoProvider::SetInfo() |
929 // was called when not in maximize mode. | 933 // was called when not in maximize mode. |
930 EXPECT_FALSE(screen_orientation_controller->rotation_locked()); | 934 EXPECT_FALSE(screen_orientation_controller->rotation_locked()); |
931 | 935 |
932 // ScreenOrientationController rotations override display info. | 936 // ScreenOrientationController rotations override display info. |
933 ash::test::ScreenOrientationControllerTestApi test_api( | 937 ash::test::ScreenOrientationControllerTestApi test_api( |
934 screen_orientation_controller); | 938 screen_orientation_controller); |
935 test_api.SetDisplayRotation(display::Display::ROTATE_0, | 939 test_api.SetDisplayRotation(display::Display::ROTATE_0, |
936 display::Display::ROTATION_SOURCE_ACTIVE); | 940 display::Display::ROTATION_SOURCE_ACTIVE); |
937 EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); | 941 EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); |
938 | 942 |
939 // Exiting maximize mode should restore the initial rotation | 943 // Exiting maximize mode should restore the initial rotation |
940 ash::WmShell::Get() | 944 EnableMaximizeMode(false); |
941 ->maximize_mode_controller() | |
942 ->EnableMaximizeModeWindowManager(false); | |
943 EXPECT_EQ(display::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); | 945 EXPECT_EQ(display::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); |
944 } | 946 } |
945 | 947 |
946 // Tests that rotation changes made during maximize mode lock the display | 948 // Tests that rotation changes made during maximize mode lock the display |
947 // against accelerometer rotations. | 949 // against accelerometer rotations, and is set as user rotation locked. |
948 TEST_F(DisplayInfoProviderChromeosTest, SetRotationDuringMaximizeMode) { | 950 TEST_F(DisplayInfoProviderChromeosTest, SetRotationDuringMaximizeMode) { |
949 // Entering maximize mode enables accelerometer screen rotations. | 951 // Entering maximize mode enables accelerometer screen rotations. |
950 ash::WmShell::Get() | 952 EnableMaximizeMode(true); |
951 ->maximize_mode_controller() | |
952 ->EnableMaximizeModeWindowManager(true); | |
953 | 953 |
954 ASSERT_FALSE(ash::Shell::GetInstance() | 954 ASSERT_FALSE(ash::Shell::GetInstance() |
955 ->screen_orientation_controller() | 955 ->screen_orientation_controller() |
956 ->rotation_locked()); | 956 ->rotation_locked()); |
| 957 ASSERT_FALSE(ash::Shell::GetInstance() |
| 958 ->screen_orientation_controller() |
| 959 ->user_rotation_locked()); |
957 | 960 |
958 api::system_display::DisplayProperties info; | 961 api::system_display::DisplayProperties info; |
959 info.rotation.reset(new int(90)); | 962 info.rotation.reset(new int(90)); |
960 | 963 |
961 bool success = false; | 964 bool success = false; |
962 std::string error; | 965 std::string error; |
963 CallSetDisplayUnitInfo( | 966 CallSetDisplayUnitInfo( |
964 base::Int64ToString(display::Display::InternalDisplayId()), info, | 967 base::Int64ToString(display::Display::InternalDisplayId()), info, |
965 &success, &error); | 968 &success, &error); |
966 | 969 |
967 ASSERT_TRUE(success); | 970 ASSERT_TRUE(success); |
968 EXPECT_TRUE(error.empty()); | 971 EXPECT_TRUE(error.empty()); |
969 EXPECT_TRUE(ash::Shell::GetInstance() | 972 EXPECT_TRUE(ash::Shell::GetInstance() |
970 ->screen_orientation_controller() | 973 ->screen_orientation_controller() |
971 ->rotation_locked()); | 974 ->rotation_locked()); |
| 975 EXPECT_TRUE(ash::Shell::GetInstance() |
| 976 ->screen_orientation_controller() |
| 977 ->user_rotation_locked()); |
972 } | 978 } |
973 | 979 |
974 TEST_F(DisplayInfoProviderChromeosTest, SetInvalidRotation) { | 980 TEST_F(DisplayInfoProviderChromeosTest, SetInvalidRotation) { |
975 UpdateDisplay("1200x600,600x1000*2"); | 981 UpdateDisplay("1200x600,600x1000*2"); |
976 | 982 |
977 const display::Display& secondary = display_manager()->GetSecondaryDisplay(); | 983 const display::Display& secondary = display_manager()->GetSecondaryDisplay(); |
978 api::system_display::DisplayProperties info; | 984 api::system_display::DisplayProperties info; |
979 info.rotation.reset(new int(91)); | 985 info.rotation.reset(new int(91)); |
980 | 986 |
981 bool success = false; | 987 bool success = false; |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1444 EXPECT_EQ(pairs.pair1.touch_point.y, data.point_pairs[0].second.y()); | 1450 EXPECT_EQ(pairs.pair1.touch_point.y, data.point_pairs[0].second.y()); |
1445 EXPECT_EQ(pairs.pair2.touch_point.y, data.point_pairs[1].second.y()); | 1451 EXPECT_EQ(pairs.pair2.touch_point.y, data.point_pairs[1].second.y()); |
1446 EXPECT_EQ(pairs.pair3.touch_point.y, data.point_pairs[2].second.y()); | 1452 EXPECT_EQ(pairs.pair3.touch_point.y, data.point_pairs[2].second.y()); |
1447 EXPECT_EQ(pairs.pair4.touch_point.y, data.point_pairs[3].second.y()); | 1453 EXPECT_EQ(pairs.pair4.touch_point.y, data.point_pairs[3].second.y()); |
1448 | 1454 |
1449 EXPECT_EQ(bounds.width, data.bounds.width()); | 1455 EXPECT_EQ(bounds.width, data.bounds.width()); |
1450 EXPECT_EQ(bounds.height, data.bounds.height()); | 1456 EXPECT_EQ(bounds.height, data.bounds.height()); |
1451 } | 1457 } |
1452 } // namespace | 1458 } // namespace |
1453 } // namespace extensions | 1459 } // namespace extensions |
OLD | NEW |