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