| 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/ash_switches.h" | 9 #include "ash/common/ash_switches.h" |
| 10 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 10 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| 11 #include "ash/common/wm_shell.h" |
| 11 #include "ash/display/display_manager.h" | 12 #include "ash/display/display_manager.h" |
| 12 #include "ash/display/screen_orientation_controller_chromeos.h" | 13 #include "ash/display/screen_orientation_controller_chromeos.h" |
| 13 #include "ash/screen_util.h" | 14 #include "ash/screen_util.h" |
| 14 #include "ash/shell.h" | 15 #include "ash/shell.h" |
| 15 #include "ash/test/ash_test_base.h" | 16 #include "ash/test/ash_test_base.h" |
| 16 #include "ash/test/display_manager_test_api.h" | 17 #include "ash/test/display_manager_test_api.h" |
| 17 #include "base/command_line.h" | 18 #include "base/command_line.h" |
| 18 #include "base/macros.h" | 19 #include "base/macros.h" |
| 19 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
| 20 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
| (...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 std::string error; | 910 std::string error; |
| 910 CallSetDisplayUnitInfo( | 911 CallSetDisplayUnitInfo( |
| 911 base::Int64ToString(display::Display::InternalDisplayId()), info, | 912 base::Int64ToString(display::Display::InternalDisplayId()), info, |
| 912 &success, &error); | 913 &success, &error); |
| 913 | 914 |
| 914 ASSERT_TRUE(success); | 915 ASSERT_TRUE(success); |
| 915 EXPECT_TRUE(error.empty()); | 916 EXPECT_TRUE(error.empty()); |
| 916 EXPECT_FALSE(screen_orientation_controller->rotation_locked()); | 917 EXPECT_FALSE(screen_orientation_controller->rotation_locked()); |
| 917 | 918 |
| 918 // Entering maximize mode enables accelerometer screen rotations. | 919 // Entering maximize mode enables accelerometer screen rotations. |
| 919 ash::Shell::GetInstance() | 920 ash::WmShell::Get() |
| 920 ->maximize_mode_controller() | 921 ->maximize_mode_controller() |
| 921 ->EnableMaximizeModeWindowManager(true); | 922 ->EnableMaximizeModeWindowManager(true); |
| 922 // Rotation lock should not activate because DisplayInfoProvider::SetInfo() | 923 // Rotation lock should not activate because DisplayInfoProvider::SetInfo() |
| 923 // was called when not in maximize mode. | 924 // was called when not in maximize mode. |
| 924 EXPECT_FALSE(screen_orientation_controller->rotation_locked()); | 925 EXPECT_FALSE(screen_orientation_controller->rotation_locked()); |
| 925 | 926 |
| 926 // ScreenOrientationController rotations override display info. | 927 // ScreenOrientationController rotations override display info. |
| 927 screen_orientation_controller->SetDisplayRotation( | 928 screen_orientation_controller->SetDisplayRotation( |
| 928 display::Display::ROTATE_0, display::Display::ROTATION_SOURCE_ACTIVE); | 929 display::Display::ROTATE_0, display::Display::ROTATION_SOURCE_ACTIVE); |
| 929 EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); | 930 EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); |
| 930 | 931 |
| 931 // Exiting maximize mode should restore the initial rotation | 932 // Exiting maximize mode should restore the initial rotation |
| 932 ash::Shell::GetInstance() | 933 ash::WmShell::Get() |
| 933 ->maximize_mode_controller() | 934 ->maximize_mode_controller() |
| 934 ->EnableMaximizeModeWindowManager(false); | 935 ->EnableMaximizeModeWindowManager(false); |
| 935 EXPECT_EQ(display::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); | 936 EXPECT_EQ(display::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); |
| 936 } | 937 } |
| 937 | 938 |
| 938 // Tests that rotation changes made during maximize mode lock the display | 939 // Tests that rotation changes made during maximize mode lock the display |
| 939 // against accelerometer rotations. | 940 // against accelerometer rotations. |
| 940 TEST_F(DisplayInfoProviderChromeosTest, SetRotationDuringMaximizeMode) { | 941 TEST_F(DisplayInfoProviderChromeosTest, SetRotationDuringMaximizeMode) { |
| 941 // Entering maximize mode enables accelerometer screen rotations. | 942 // Entering maximize mode enables accelerometer screen rotations. |
| 942 ash::Shell::GetInstance() | 943 ash::WmShell::Get() |
| 943 ->maximize_mode_controller() | 944 ->maximize_mode_controller() |
| 944 ->EnableMaximizeModeWindowManager(true); | 945 ->EnableMaximizeModeWindowManager(true); |
| 945 | 946 |
| 946 ASSERT_FALSE(ash::Shell::GetInstance() | 947 ASSERT_FALSE(ash::Shell::GetInstance() |
| 947 ->screen_orientation_controller() | 948 ->screen_orientation_controller() |
| 948 ->rotation_locked()); | 949 ->rotation_locked()); |
| 949 | 950 |
| 950 api::system_display::DisplayProperties info; | 951 api::system_display::DisplayProperties info; |
| 951 info.rotation.reset(new int(90)); | 952 info.rotation.reset(new int(90)); |
| 952 | 953 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1183 CallSetDisplayUnitInfo(base::Int64ToString(id), info, &success, &error); | 1184 CallSetDisplayUnitInfo(base::Int64ToString(id), info, &success, &error); |
| 1184 ASSERT_TRUE(success); | 1185 ASSERT_TRUE(success); |
| 1185 | 1186 |
| 1186 // Verify that other_mode now matches the active mode. | 1187 // Verify that other_mode now matches the active mode. |
| 1187 active_mode = GetDisplayManager()->GetActiveModeForDisplayId(id); | 1188 active_mode = GetDisplayManager()->GetActiveModeForDisplayId(id); |
| 1188 EXPECT_TRUE(active_mode.IsEquivalent(other_mode_ash)); | 1189 EXPECT_TRUE(active_mode.IsEquivalent(other_mode_ash)); |
| 1189 } | 1190 } |
| 1190 | 1191 |
| 1191 } // namespace | 1192 } // namespace |
| 1192 } // namespace extensions | 1193 } // namespace extensions |
| OLD | NEW |