| 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 ash::DisplayMode active_mode = | 1153 scoped_refptr<ash::DisplayMode> 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 ash::DisplayMode other_mode_ash; | 1170 scoped_refptr<ash::DisplayMode> other_mode_ash(new ash::DisplayMode( |
| 1171 other_mode_ash.size.SetSize(other_mode->width_in_native_pixels, | 1171 gfx::Size(other_mode->width_in_native_pixels, |
| 1172 other_mode->height_in_native_pixels); | 1172 other_mode->height_in_native_pixels), |
| 1173 other_mode_ash.ui_scale = other_mode->ui_scale; | 1173 active_mode->refresh_rate(), active_mode->is_interlaced(), |
| 1174 other_mode_ash.device_scale_factor = other_mode->device_scale_factor; | 1174 active_mode->native(), other_mode->ui_scale, |
| 1175 EXPECT_FALSE(active_mode.IsEquivalent(other_mode_ash)); | 1175 other_mode->device_scale_factor)); |
| 1176 EXPECT_FALSE(active_mode->IsEquivalent(other_mode_ash)); |
| 1176 | 1177 |
| 1177 // Switch modes. | 1178 // Switch modes. |
| 1178 api::system_display::DisplayProperties info; | 1179 api::system_display::DisplayProperties info; |
| 1179 info.display_mode = | 1180 info.display_mode = |
| 1180 api::system_display::DisplayMode::FromValue(*other_mode->ToValue()); | 1181 api::system_display::DisplayMode::FromValue(*other_mode->ToValue()); |
| 1181 | 1182 |
| 1182 bool success = false; | 1183 bool success = false; |
| 1183 std::string error; | 1184 std::string error; |
| 1184 CallSetDisplayUnitInfo(base::Int64ToString(id), info, &success, &error); | 1185 CallSetDisplayUnitInfo(base::Int64ToString(id), info, &success, &error); |
| 1185 ASSERT_TRUE(success); | 1186 ASSERT_TRUE(success); |
| 1186 | 1187 |
| 1187 // Verify that other_mode now matches the active mode. | 1188 // Verify that other_mode now matches the active mode. |
| 1188 active_mode = GetDisplayManager()->GetActiveModeForDisplayId(id); | 1189 active_mode = GetDisplayManager()->GetActiveModeForDisplayId(id); |
| 1189 EXPECT_TRUE(active_mode.IsEquivalent(other_mode_ash)); | 1190 EXPECT_TRUE(active_mode->IsEquivalent(other_mode_ash)); |
| 1190 } | 1191 } |
| 1191 | 1192 |
| 1192 } // namespace | 1193 } // namespace |
| 1193 } // namespace extensions | 1194 } // namespace extensions |
| OLD | NEW |