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/display/screen_orientation_controller_chromeos.h" | 9 #include "ash/display/screen_orientation_controller_chromeos.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
11 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
12 #include "ash/test/screen_orientation_controller_test_api.h" | 12 #include "ash/test/screen_orientation_controller_test_api.h" |
13 #include "ash/wm/tablet_mode/tablet_mode_controller.h" | 13 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
18 #include "chrome/browser/extensions/display_info_provider_chromeos.h" | 18 #include "chrome/browser/extensions/display_info_provider_chromeos.h" |
19 #include "extensions/common/api/system_display.h" | 19 #include "extensions/common/api/system_display.h" |
20 #include "ui/display/display.h" | 20 #include "ui/display/display.h" |
21 #include "ui/display/display_layout.h" | 21 #include "ui/display/display_layout.h" |
22 #include "ui/display/display_switches.h" | 22 #include "ui/display/display_switches.h" |
23 #include "ui/display/manager/display_manager.h" | 23 #include "ui/display/manager/display_manager.h" |
24 #include "ui/display/test/display_manager_test_api.h" | 24 #include "ui/display/test/display_manager_test_api.h" |
25 #include "ui/display/types/display_constants.h" | 25 #include "ui/display/types/display_constants.h" |
26 #include "ui/gfx/geometry/rect.h" | 26 #include "ui/gfx/geometry/rect.h" |
27 | 27 |
28 namespace extensions { | 28 namespace extensions { |
29 namespace { | 29 namespace { |
30 | 30 |
31 using DisplayUnitInfoList = DisplayInfoProvider::DisplayUnitInfoList; | 31 using DisplayUnitInfoList = DisplayInfoProvider::DisplayUnitInfoList; |
32 using DisplayLayoutList = DisplayInfoProvider::DisplayLayoutList; | 32 using DisplayLayoutList = DisplayInfoProvider::DisplayLayoutList; |
33 | 33 |
34 void EnableTabletMode(bool enable) { | 34 void EnableMaximizeMode(bool enable) { |
35 ash::Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager( | 35 ash::Shell::Get() |
36 enable); | 36 ->maximize_mode_controller() |
| 37 ->EnableMaximizeModeWindowManager(enable); |
37 } | 38 } |
38 | 39 |
39 class DisplayInfoProviderChromeosTest : public ash::test::AshTestBase { | 40 class DisplayInfoProviderChromeosTest : public ash::test::AshTestBase { |
40 public: | 41 public: |
41 DisplayInfoProviderChromeosTest() {} | 42 DisplayInfoProviderChromeosTest() {} |
42 | 43 |
43 ~DisplayInfoProviderChromeosTest() override {} | 44 ~DisplayInfoProviderChromeosTest() override {} |
44 | 45 |
45 void SetUp() override { | 46 void SetUp() override { |
46 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 47 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1016 | 1017 |
1017 ASSERT_TRUE(success); | 1018 ASSERT_TRUE(success); |
1018 EXPECT_TRUE(error.empty()); | 1019 EXPECT_TRUE(error.empty()); |
1019 | 1020 |
1020 EXPECT_EQ("0,0 300x500", secondary.bounds().ToString()); | 1021 EXPECT_EQ("0,0 300x500", secondary.bounds().ToString()); |
1021 EXPECT_EQ(display::Display::ROTATE_0, secondary.rotation()); | 1022 EXPECT_EQ(display::Display::ROTATE_0, secondary.rotation()); |
1022 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().id(), | 1023 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().id(), |
1023 secondary.id()); | 1024 secondary.id()); |
1024 } | 1025 } |
1025 | 1026 |
1026 // Tests that rotation changes made before entering tablet mode are restored | 1027 // Tests that rotation changes made before entering maximize mode are restored |
1027 // upon exiting tablet mode, and that a rotation lock is not set. | 1028 // upon exiting maximize mode, and that a rotation lock is not set. |
1028 TEST_F(DisplayInfoProviderChromeosTest, SetRotationBeforeTabletMode) { | 1029 TEST_F(DisplayInfoProviderChromeosTest, SetRotationBeforeMaximizeMode) { |
1029 ash::ScreenOrientationController* screen_orientation_controller = | 1030 ash::ScreenOrientationController* screen_orientation_controller = |
1030 ash::Shell::Get()->screen_orientation_controller(); | 1031 ash::Shell::Get()->screen_orientation_controller(); |
1031 api::system_display::DisplayProperties info; | 1032 api::system_display::DisplayProperties info; |
1032 info.rotation.reset(new int(90)); | 1033 info.rotation.reset(new int(90)); |
1033 | 1034 |
1034 bool success = false; | 1035 bool success = false; |
1035 std::string error; | 1036 std::string error; |
1036 CallSetDisplayUnitInfo( | 1037 CallSetDisplayUnitInfo( |
1037 base::Int64ToString(display::Display::InternalDisplayId()), info, | 1038 base::Int64ToString(display::Display::InternalDisplayId()), info, |
1038 &success, &error); | 1039 &success, &error); |
1039 | 1040 |
1040 ASSERT_TRUE(success); | 1041 ASSERT_TRUE(success); |
1041 EXPECT_TRUE(error.empty()); | 1042 EXPECT_TRUE(error.empty()); |
1042 EXPECT_FALSE(screen_orientation_controller->rotation_locked()); | 1043 EXPECT_FALSE(screen_orientation_controller->rotation_locked()); |
1043 | 1044 |
1044 // Entering tablet mode enables accelerometer screen rotations. | 1045 // Entering maximize mode enables accelerometer screen rotations. |
1045 EnableTabletMode(true); | 1046 EnableMaximizeMode(true); |
1046 // Rotation lock should not activate because DisplayInfoProvider::SetInfo() | 1047 // Rotation lock should not activate because DisplayInfoProvider::SetInfo() |
1047 // was called when not in tablet mode. | 1048 // was called when not in maximize mode. |
1048 EXPECT_FALSE(screen_orientation_controller->rotation_locked()); | 1049 EXPECT_FALSE(screen_orientation_controller->rotation_locked()); |
1049 | 1050 |
1050 // ScreenOrientationController rotations override display info. | 1051 // ScreenOrientationController rotations override display info. |
1051 ash::test::ScreenOrientationControllerTestApi test_api( | 1052 ash::test::ScreenOrientationControllerTestApi test_api( |
1052 screen_orientation_controller); | 1053 screen_orientation_controller); |
1053 test_api.SetDisplayRotation(display::Display::ROTATE_0, | 1054 test_api.SetDisplayRotation(display::Display::ROTATE_0, |
1054 display::Display::ROTATION_SOURCE_ACTIVE); | 1055 display::Display::ROTATION_SOURCE_ACTIVE); |
1055 EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); | 1056 EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); |
1056 | 1057 |
1057 // Exiting tablet mode should restore the initial rotation | 1058 // Exiting maximize mode should restore the initial rotation |
1058 EnableTabletMode(false); | 1059 EnableMaximizeMode(false); |
1059 EXPECT_EQ(display::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); | 1060 EXPECT_EQ(display::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); |
1060 } | 1061 } |
1061 | 1062 |
1062 // Tests that rotation changes made during tablet mode lock the display | 1063 // Tests that rotation changes made during maximize mode lock the display |
1063 // against accelerometer rotations, and is set as user rotation locked. | 1064 // against accelerometer rotations, and is set as user rotation locked. |
1064 TEST_F(DisplayInfoProviderChromeosTest, SetRotationDuringTabletMode) { | 1065 TEST_F(DisplayInfoProviderChromeosTest, SetRotationDuringMaximizeMode) { |
1065 // Entering tablet mode enables accelerometer screen rotations. | 1066 // Entering maximize mode enables accelerometer screen rotations. |
1066 EnableTabletMode(true); | 1067 EnableMaximizeMode(true); |
1067 | 1068 |
1068 ASSERT_FALSE( | 1069 ASSERT_FALSE( |
1069 ash::Shell::Get()->screen_orientation_controller()->rotation_locked()); | 1070 ash::Shell::Get()->screen_orientation_controller()->rotation_locked()); |
1070 ASSERT_FALSE(ash::Shell::Get() | 1071 ASSERT_FALSE(ash::Shell::Get() |
1071 ->screen_orientation_controller() | 1072 ->screen_orientation_controller() |
1072 ->user_rotation_locked()); | 1073 ->user_rotation_locked()); |
1073 | 1074 |
1074 api::system_display::DisplayProperties info; | 1075 api::system_display::DisplayProperties info; |
1075 info.rotation.reset(new int(90)); | 1076 info.rotation.reset(new int(90)); |
1076 | 1077 |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1558 EXPECT_EQ(pairs.pair1.touch_point.y, data.point_pairs[0].second.y()); | 1559 EXPECT_EQ(pairs.pair1.touch_point.y, data.point_pairs[0].second.y()); |
1559 EXPECT_EQ(pairs.pair2.touch_point.y, data.point_pairs[1].second.y()); | 1560 EXPECT_EQ(pairs.pair2.touch_point.y, data.point_pairs[1].second.y()); |
1560 EXPECT_EQ(pairs.pair3.touch_point.y, data.point_pairs[2].second.y()); | 1561 EXPECT_EQ(pairs.pair3.touch_point.y, data.point_pairs[2].second.y()); |
1561 EXPECT_EQ(pairs.pair4.touch_point.y, data.point_pairs[3].second.y()); | 1562 EXPECT_EQ(pairs.pair4.touch_point.y, data.point_pairs[3].second.y()); |
1562 | 1563 |
1563 EXPECT_EQ(bounds.width, data.bounds.width()); | 1564 EXPECT_EQ(bounds.width, data.bounds.width()); |
1564 EXPECT_EQ(bounds.height, data.bounds.height()); | 1565 EXPECT_EQ(bounds.height, data.bounds.height()); |
1565 } | 1566 } |
1566 } // namespace | 1567 } // namespace |
1567 } // namespace extensions | 1568 } // namespace extensions |
OLD | NEW |