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" |
(...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 DisplayUnitInfoList result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 1143 DisplayUnitInfoList result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
1144 ASSERT_GE(result.size(), 1u); | 1144 ASSERT_GE(result.size(), 1u); |
1145 const api::system_display::DisplayUnitInfo& primary_info = result[0]; | 1145 const api::system_display::DisplayUnitInfo& primary_info = result[0]; |
1146 // Ensure that we have two modes for the primary display so that we can | 1146 // Ensure that we have two modes for the primary display so that we can |
1147 // test chaning modes. | 1147 // test chaning modes. |
1148 ASSERT_GE(primary_info.modes.size(), 2u); | 1148 ASSERT_GE(primary_info.modes.size(), 2u); |
1149 | 1149 |
1150 // Get the currently active mode and one other mode to switch to. | 1150 // Get the currently active mode and one other mode to switch to. |
1151 int64_t id; | 1151 int64_t id; |
1152 base::StringToInt64(primary_info.id, &id); | 1152 base::StringToInt64(primary_info.id, &id); |
1153 scoped_refptr<ash::ManagedDisplayMode> active_mode = | 1153 scoped_refptr<display::ManagedDisplayMode> active_mode = |
1154 GetDisplayManager()->GetActiveModeForDisplayId(id); | 1154 GetDisplayManager()->GetActiveModeForDisplayId(id); |
1155 const api::system_display::DisplayMode* cur_mode = nullptr; | 1155 const api::system_display::DisplayMode* cur_mode = nullptr; |
1156 const api::system_display::DisplayMode* other_mode = nullptr; | 1156 const api::system_display::DisplayMode* other_mode = nullptr; |
1157 for (const auto& mode : primary_info.modes) { | 1157 for (const auto& mode : primary_info.modes) { |
1158 if (mode.is_selected) | 1158 if (mode.is_selected) |
1159 cur_mode = &mode; | 1159 cur_mode = &mode; |
1160 else if (!other_mode) | 1160 else if (!other_mode) |
1161 other_mode = &mode; | 1161 other_mode = &mode; |
1162 if (cur_mode && other_mode) | 1162 if (cur_mode && other_mode) |
1163 break; | 1163 break; |
1164 } | 1164 } |
1165 ASSERT_TRUE(cur_mode); | 1165 ASSERT_TRUE(cur_mode); |
1166 ASSERT_TRUE(other_mode); | 1166 ASSERT_TRUE(other_mode); |
1167 ASSERT_NE(other_mode, cur_mode); | 1167 ASSERT_NE(other_mode, cur_mode); |
1168 | 1168 |
1169 // Verify that other_mode differs from the active mode. | 1169 // Verify that other_mode differs from the active mode. |
1170 scoped_refptr<ash::ManagedDisplayMode> other_mode_ash( | 1170 scoped_refptr<display::ManagedDisplayMode> other_mode_ash( |
1171 new ash::ManagedDisplayMode( | 1171 new display::ManagedDisplayMode( |
1172 gfx::Size(other_mode->width_in_native_pixels, | 1172 gfx::Size(other_mode->width_in_native_pixels, |
1173 other_mode->height_in_native_pixels), | 1173 other_mode->height_in_native_pixels), |
1174 active_mode->refresh_rate(), active_mode->is_interlaced(), | 1174 active_mode->refresh_rate(), active_mode->is_interlaced(), |
1175 active_mode->native(), other_mode->ui_scale, | 1175 active_mode->native(), other_mode->ui_scale, |
1176 other_mode->device_scale_factor)); | 1176 other_mode->device_scale_factor)); |
1177 EXPECT_FALSE(active_mode->IsEquivalent(other_mode_ash)); | 1177 EXPECT_FALSE(active_mode->IsEquivalent(other_mode_ash)); |
1178 | 1178 |
1179 // Switch modes. | 1179 // Switch modes. |
1180 api::system_display::DisplayProperties info; | 1180 api::system_display::DisplayProperties info; |
1181 info.display_mode = | 1181 info.display_mode = |
1182 api::system_display::DisplayMode::FromValue(*other_mode->ToValue()); | 1182 api::system_display::DisplayMode::FromValue(*other_mode->ToValue()); |
1183 | 1183 |
1184 bool success = false; | 1184 bool success = false; |
1185 std::string error; | 1185 std::string error; |
1186 CallSetDisplayUnitInfo(base::Int64ToString(id), info, &success, &error); | 1186 CallSetDisplayUnitInfo(base::Int64ToString(id), info, &success, &error); |
1187 ASSERT_TRUE(success); | 1187 ASSERT_TRUE(success); |
1188 | 1188 |
1189 // Verify that other_mode now matches the active mode. | 1189 // Verify that other_mode now matches the active mode. |
1190 active_mode = GetDisplayManager()->GetActiveModeForDisplayId(id); | 1190 active_mode = GetDisplayManager()->GetActiveModeForDisplayId(id); |
1191 EXPECT_TRUE(active_mode->IsEquivalent(other_mode_ash)); | 1191 EXPECT_TRUE(active_mode->IsEquivalent(other_mode_ash)); |
1192 } | 1192 } |
1193 | 1193 |
1194 } // namespace | 1194 } // namespace |
1195 } // namespace extensions | 1195 } // namespace extensions |
OLD | NEW |