Chromium Code Reviews| 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/display/screen_orientation_controller_chromeos.h" | 10 #include "ash/display/screen_orientation_controller_chromeos.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 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) { | |
| 35 ash::Shell::GetInstance() | |
| 36 ->maximize_mode_controller() | |
| 37 ->EnableMaximizeModeWindowManager(enable); | |
| 38 } | |
| 39 | |
| 34 class DisplayInfoProviderChromeosTest : public ash::test::AshTestBase { | 40 class DisplayInfoProviderChromeosTest : public ash::test::AshTestBase { |
| 35 public: | 41 public: |
| 36 DisplayInfoProviderChromeosTest() {} | 42 DisplayInfoProviderChromeosTest() {} |
| 37 | 43 |
| 38 ~DisplayInfoProviderChromeosTest() override {} | 44 ~DisplayInfoProviderChromeosTest() override {} |
| 39 | 45 |
| 40 void SetUp() override { | 46 void SetUp() override { |
| 41 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 47 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 42 switches::kUseFirstDisplayAsInternal); | 48 switches::kUseFirstDisplayAsInternal); |
| 43 ash::test::AshTestBase::SetUp(); | 49 ash::test::AshTestBase::SetUp(); |
| (...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 914 std::string error; | 920 std::string error; |
| 915 CallSetDisplayUnitInfo( | 921 CallSetDisplayUnitInfo( |
| 916 base::Int64ToString(display::Display::InternalDisplayId()), info, | 922 base::Int64ToString(display::Display::InternalDisplayId()), info, |
| 917 &success, &error); | 923 &success, &error); |
| 918 | 924 |
| 919 ASSERT_TRUE(success); | 925 ASSERT_TRUE(success); |
| 920 EXPECT_TRUE(error.empty()); | 926 EXPECT_TRUE(error.empty()); |
| 921 EXPECT_FALSE(screen_orientation_controller->rotation_locked()); | 927 EXPECT_FALSE(screen_orientation_controller->rotation_locked()); |
| 922 | 928 |
| 923 // Entering maximize mode enables accelerometer screen rotations. | 929 // Entering maximize mode enables accelerometer screen rotations. |
| 924 ash::Shell::Get() | 930 EnableMaximizeMode(true); |
| 925 ->maximize_mode_controller() | |
| 926 ->EnableMaximizeModeWindowManager(true); | |
| 927 // Rotation lock should not activate because DisplayInfoProvider::SetInfo() | 931 // Rotation lock should not activate because DisplayInfoProvider::SetInfo() |
| 928 // was called when not in maximize mode. | 932 // was called when not in maximize mode. |
| 929 EXPECT_FALSE(screen_orientation_controller->rotation_locked()); | 933 EXPECT_FALSE(screen_orientation_controller->rotation_locked()); |
| 930 | 934 |
| 931 // ScreenOrientationController rotations override display info. | 935 // ScreenOrientationController rotations override display info. |
| 932 ash::test::ScreenOrientationControllerTestApi test_api( | 936 ash::test::ScreenOrientationControllerTestApi test_api( |
| 933 screen_orientation_controller); | 937 screen_orientation_controller); |
| 934 test_api.SetDisplayRotation(display::Display::ROTATE_0, | 938 test_api.SetDisplayRotation(display::Display::ROTATE_0, |
| 935 display::Display::ROTATION_SOURCE_ACTIVE); | 939 display::Display::ROTATION_SOURCE_ACTIVE); |
| 936 EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); | 940 EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); |
| 937 | 941 |
| 938 // Exiting maximize mode should restore the initial rotation | 942 // Exiting maximize mode should restore the initial rotation |
| 939 ash::Shell::Get() | 943 EnableMaximizeMode(false); |
| 940 ->maximize_mode_controller() | |
| 941 ->EnableMaximizeModeWindowManager(false); | |
| 942 EXPECT_EQ(display::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); | 944 EXPECT_EQ(display::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); |
| 943 } | 945 } |
| 944 | 946 |
| 945 // Tests that rotation changes made during maximize mode lock the display | 947 // Tests that rotation changes made during maximize mode lock the display |
| 946 // against accelerometer rotations. | 948 // against accelerometer rotations, and is set as user rotation locked. |
| 947 TEST_F(DisplayInfoProviderChromeosTest, SetRotationDuringMaximizeMode) { | 949 TEST_F(DisplayInfoProviderChromeosTest, SetRotationDuringMaximizeMode) { |
| 948 // Entering maximize mode enables accelerometer screen rotations. | 950 // Entering maximize mode enables accelerometer screen rotations. |
| 949 ash::Shell::Get() | 951 EnableMaximizeMode(true); |
| 950 ->maximize_mode_controller() | |
| 951 ->EnableMaximizeModeWindowManager(true); | |
| 952 | 952 |
| 953 ASSERT_FALSE(ash::Shell::GetInstance() | 953 ASSERT_FALSE(ash::Shell::GetInstance() |
| 954 ->screen_orientation_controller() | 954 ->screen_orientation_controller() |
| 955 ->rotation_locked()); | 955 ->rotation_locked()); |
| 956 ASSERT_FALSE(ash::Shell::GetInstance() | |
| 957 ->screen_orientation_controller() | |
| 958 ->user_rotation_locked()); | |
| 956 | 959 |
| 957 api::system_display::DisplayProperties info; | 960 api::system_display::DisplayProperties info; |
| 958 info.rotation.reset(new int(90)); | 961 info.rotation.reset(new int(90)); |
| 959 | 962 |
| 960 bool success = false; | 963 bool success = false; |
| 961 std::string error; | 964 std::string error; |
| 962 CallSetDisplayUnitInfo( | 965 CallSetDisplayUnitInfo( |
| 963 base::Int64ToString(display::Display::InternalDisplayId()), info, | 966 base::Int64ToString(display::Display::InternalDisplayId()), info, |
| 964 &success, &error); | 967 &success, &error); |
| 965 | 968 |
| 966 ASSERT_TRUE(success); | 969 ASSERT_TRUE(success); |
| 967 EXPECT_TRUE(error.empty()); | 970 EXPECT_TRUE(error.empty()); |
| 968 EXPECT_TRUE(ash::Shell::GetInstance() | 971 EXPECT_TRUE(ash::Shell::GetInstance() |
| 969 ->screen_orientation_controller() | 972 ->screen_orientation_controller() |
| 970 ->rotation_locked()); | 973 ->rotation_locked()); |
| 974 EXPECT_TRUE(ash::Shell::GetInstance() | |
| 975 ->screen_orientation_controller() | |
| 976 ->user_rotation_locked()); | |
|
lazyboy
2017/04/03 20:52:34
Do we want to cleanup afterwards, i.e. EnableMaxim
Qiang(Joe) Xu
2017/04/03 21:08:08
It doesn't need the cleanup for EnableMaximizeMode
lazyboy
2017/04/03 21:23:29
Acknowledged.
if we don't force the touchview mod
| |
| 971 } | 977 } |
| 972 | 978 |
| 973 TEST_F(DisplayInfoProviderChromeosTest, SetInvalidRotation) { | 979 TEST_F(DisplayInfoProviderChromeosTest, SetInvalidRotation) { |
| 974 UpdateDisplay("1200x600,600x1000*2"); | 980 UpdateDisplay("1200x600,600x1000*2"); |
| 975 | 981 |
| 976 const display::Display& secondary = display_manager()->GetSecondaryDisplay(); | 982 const display::Display& secondary = display_manager()->GetSecondaryDisplay(); |
| 977 api::system_display::DisplayProperties info; | 983 api::system_display::DisplayProperties info; |
| 978 info.rotation.reset(new int(91)); | 984 info.rotation.reset(new int(91)); |
| 979 | 985 |
| 980 bool success = false; | 986 bool success = false; |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1443 EXPECT_EQ(pairs.pair1.touch_point.y, data.point_pairs[0].second.y()); | 1449 EXPECT_EQ(pairs.pair1.touch_point.y, data.point_pairs[0].second.y()); |
| 1444 EXPECT_EQ(pairs.pair2.touch_point.y, data.point_pairs[1].second.y()); | 1450 EXPECT_EQ(pairs.pair2.touch_point.y, data.point_pairs[1].second.y()); |
| 1445 EXPECT_EQ(pairs.pair3.touch_point.y, data.point_pairs[2].second.y()); | 1451 EXPECT_EQ(pairs.pair3.touch_point.y, data.point_pairs[2].second.y()); |
| 1446 EXPECT_EQ(pairs.pair4.touch_point.y, data.point_pairs[3].second.y()); | 1452 EXPECT_EQ(pairs.pair4.touch_point.y, data.point_pairs[3].second.y()); |
| 1447 | 1453 |
| 1448 EXPECT_EQ(bounds.width, data.bounds.width()); | 1454 EXPECT_EQ(bounds.width, data.bounds.width()); |
| 1449 EXPECT_EQ(bounds.height, data.bounds.height()); | 1455 EXPECT_EQ(bounds.height, data.bounds.height()); |
| 1450 } | 1456 } |
| 1451 } // namespace | 1457 } // namespace |
| 1452 } // namespace extensions | 1458 } // namespace extensions |
| OLD | NEW |