| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 "%d,%d,%d,%d", insets.top, insets.left, insets.bottom, insets.right); | 77 "%d,%d,%d,%d", insets.top, insets.left, insets.bottom, insets.right); |
| 78 } | 78 } |
| 79 | 79 |
| 80 std::string SystemInfoDisplayBoundsToString( | 80 std::string SystemInfoDisplayBoundsToString( |
| 81 const api::system_display::Bounds& bounds) const { | 81 const api::system_display::Bounds& bounds) const { |
| 82 // Order to match gfx::Rect::ToString(). | 82 // Order to match gfx::Rect::ToString(). |
| 83 return base::StringPrintf( | 83 return base::StringPrintf( |
| 84 "%d,%d %dx%d", bounds.left, bounds.top, bounds.width, bounds.height); | 84 "%d,%d %dx%d", bounds.left, bounds.top, bounds.width, bounds.height); |
| 85 } | 85 } |
| 86 | 86 |
| 87 DisplayUnitInfoList GetAllDisplaysInfo() { |
| 88 return DisplayInfoProvider::Get()->GetAllDisplaysInfo( |
| 89 false /* single unified */); |
| 90 } |
| 91 |
| 87 private: | 92 private: |
| 88 DISALLOW_COPY_AND_ASSIGN(DisplayInfoProviderChromeosTest); | 93 DISALLOW_COPY_AND_ASSIGN(DisplayInfoProviderChromeosTest); |
| 89 }; | 94 }; |
| 90 | 95 |
| 91 TEST_F(DisplayInfoProviderChromeosTest, GetBasic) { | 96 TEST_F(DisplayInfoProviderChromeosTest, GetBasic) { |
| 92 UpdateDisplay("500x600,400x520"); | 97 UpdateDisplay("500x600,400x520"); |
| 93 DisplayUnitInfoList result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 98 DisplayUnitInfoList result = GetAllDisplaysInfo(); |
| 94 | 99 |
| 95 ASSERT_EQ(2u, result.size()); | 100 ASSERT_EQ(2u, result.size()); |
| 96 | 101 |
| 97 int64_t display_id; | 102 int64_t display_id; |
| 98 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id)) | 103 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id)) |
| 99 << "Display id must be convertable to integer: " << result[0].id; | 104 << "Display id must be convertable to integer: " << result[0].id; |
| 100 | 105 |
| 101 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; | 106 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; |
| 102 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds)); | 107 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds)); |
| 103 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan)); | 108 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan)); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 124 EXPECT_EQ(96, result[1].dpi_y); | 129 EXPECT_EQ(96, result[1].dpi_y); |
| 125 EXPECT_TRUE(result[1].mirroring_source_id.empty()); | 130 EXPECT_TRUE(result[1].mirroring_source_id.empty()); |
| 126 EXPECT_TRUE(result[1].is_enabled); | 131 EXPECT_TRUE(result[1].is_enabled); |
| 127 } | 132 } |
| 128 | 133 |
| 129 TEST_F(DisplayInfoProviderChromeosTest, GetWithUnifiedDesktop) { | 134 TEST_F(DisplayInfoProviderChromeosTest, GetWithUnifiedDesktop) { |
| 130 UpdateDisplay("500x600,400x520"); | 135 UpdateDisplay("500x600,400x520"); |
| 131 | 136 |
| 132 // Check initial state. | 137 // Check initial state. |
| 133 EXPECT_FALSE(GetDisplayManager()->IsInUnifiedMode()); | 138 EXPECT_FALSE(GetDisplayManager()->IsInUnifiedMode()); |
| 134 DisplayUnitInfoList result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 139 DisplayUnitInfoList result = GetAllDisplaysInfo(); |
| 135 | 140 |
| 136 ASSERT_EQ(2u, result.size()); | 141 ASSERT_EQ(2u, result.size()); |
| 137 | 142 |
| 138 int64_t display_id; | 143 int64_t display_id; |
| 139 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id)) | 144 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id)) |
| 140 << "Display id must be convertable to integer: " << result[0].id; | 145 << "Display id must be convertable to integer: " << result[0].id; |
| 141 | 146 |
| 142 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; | 147 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; |
| 143 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds)); | 148 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds)); |
| 144 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan)); | 149 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan)); |
| 145 EXPECT_EQ(0, result[0].rotation); | 150 EXPECT_EQ(0, result[0].rotation); |
| 146 EXPECT_TRUE(result[0].is_primary); | 151 EXPECT_TRUE(result[0].is_primary); |
| 152 EXPECT_FALSE(result[0].is_unified); |
| 147 EXPECT_EQ(96, result[0].dpi_x); | 153 EXPECT_EQ(96, result[0].dpi_x); |
| 148 EXPECT_EQ(96, result[0].dpi_y); | 154 EXPECT_EQ(96, result[0].dpi_y); |
| 149 EXPECT_TRUE(result[0].mirroring_source_id.empty()); | 155 EXPECT_TRUE(result[0].mirroring_source_id.empty()); |
| 150 EXPECT_TRUE(result[0].is_enabled); | 156 EXPECT_TRUE(result[0].is_enabled); |
| 151 | 157 |
| 152 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id)) | 158 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id)) |
| 153 << "Display id must be convertable to integer: " << result[0].id; | 159 << "Display id must be convertable to integer: " << result[0].id; |
| 154 | 160 |
| 155 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; | 161 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; |
| 156 EXPECT_EQ(GetDisplayManager()->GetDisplayNameForId(display_id), | 162 EXPECT_EQ(GetDisplayManager()->GetDisplayNameForId(display_id), |
| 157 result[1].name); | 163 result[1].name); |
| 158 | 164 |
| 159 // Initial multipple display configuration. | 165 // Initial multipple display configuration. |
| 160 EXPECT_EQ("500,0 400x520", SystemInfoDisplayBoundsToString(result[1].bounds)); | 166 EXPECT_EQ("500,0 400x520", SystemInfoDisplayBoundsToString(result[1].bounds)); |
| 161 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1].overscan)); | 167 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1].overscan)); |
| 162 EXPECT_EQ(0, result[1].rotation); | 168 EXPECT_EQ(0, result[1].rotation); |
| 163 EXPECT_FALSE(result[1].is_primary); | 169 EXPECT_FALSE(result[1].is_primary); |
| 170 EXPECT_FALSE(result[0].is_unified); |
| 164 EXPECT_EQ(96, result[1].dpi_x); | 171 EXPECT_EQ(96, result[1].dpi_x); |
| 165 EXPECT_EQ(96, result[1].dpi_y); | 172 EXPECT_EQ(96, result[1].dpi_y); |
| 166 EXPECT_TRUE(result[1].mirroring_source_id.empty()); | 173 EXPECT_TRUE(result[1].mirroring_source_id.empty()); |
| 167 EXPECT_TRUE(result[1].is_enabled); | 174 EXPECT_TRUE(result[1].is_enabled); |
| 168 | 175 |
| 169 // Enable unified. | 176 // Enable unified. |
| 170 GetDisplayManager()->SetUnifiedDesktopEnabled(true); | 177 GetDisplayManager()->SetUnifiedDesktopEnabled(true); |
| 171 EXPECT_TRUE(GetDisplayManager()->IsInUnifiedMode()); | 178 EXPECT_TRUE(GetDisplayManager()->IsInUnifiedMode()); |
| 172 | 179 |
| 173 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 180 result = GetAllDisplaysInfo(); |
| 174 | 181 |
| 175 ASSERT_EQ(2u, result.size()); | 182 ASSERT_EQ(2u, result.size()); |
| 176 | 183 |
| 177 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id)) | 184 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id)) |
| 178 << "Display id must be convertable to integer: " << result[0].id; | 185 << "Display id must be convertable to integer: " << result[0].id; |
| 179 | 186 |
| 180 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds)); | 187 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds)); |
| 181 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan)); | 188 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan)); |
| 182 EXPECT_EQ(0, result[0].rotation); | 189 EXPECT_EQ(0, result[0].rotation); |
| 183 EXPECT_TRUE(result[0].is_primary); | 190 EXPECT_TRUE(result[0].is_primary); |
| 191 EXPECT_TRUE(result[0].is_unified); |
| 184 EXPECT_EQ(96, result[0].dpi_x); | 192 EXPECT_EQ(96, result[0].dpi_x); |
| 185 EXPECT_EQ(96, result[0].dpi_y); | 193 EXPECT_EQ(96, result[0].dpi_y); |
| 186 EXPECT_TRUE(result[0].mirroring_source_id.empty()); | 194 EXPECT_TRUE(result[0].mirroring_source_id.empty()); |
| 187 EXPECT_TRUE(result[0].is_enabled); | 195 EXPECT_TRUE(result[0].is_enabled); |
| 188 | 196 |
| 189 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id)) | 197 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id)) |
| 190 << "Display id must be convertable to integer: " << result[0].id; | 198 << "Display id must be convertable to integer: " << result[0].id; |
| 191 | 199 |
| 192 EXPECT_EQ(GetDisplayManager()->GetDisplayNameForId(display_id), | 200 EXPECT_EQ(GetDisplayManager()->GetDisplayNameForId(display_id), |
| 193 result[1].name); | 201 result[1].name); |
| 194 | 202 |
| 195 // After enabling unified the second display is scaled to meet the height for | 203 // After enabling unified the second display is scaled to meet the height for |
| 196 // the first. Which also affects the DPI below. | 204 // the first. Which also affects the DPI below. |
| 197 EXPECT_EQ("500,0 461x600", SystemInfoDisplayBoundsToString(result[1].bounds)); | 205 EXPECT_EQ("500,0 461x600", SystemInfoDisplayBoundsToString(result[1].bounds)); |
| 198 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1].overscan)); | 206 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1].overscan)); |
| 199 EXPECT_EQ(0, result[1].rotation); | 207 EXPECT_EQ(0, result[1].rotation); |
| 200 EXPECT_FALSE(result[1].is_primary); | 208 EXPECT_FALSE(result[1].is_primary); |
| 209 EXPECT_TRUE(result[1].is_unified); |
| 201 EXPECT_FLOAT_EQ(111, round(result[1].dpi_x)); | 210 EXPECT_FLOAT_EQ(111, round(result[1].dpi_x)); |
| 202 EXPECT_FLOAT_EQ(111, round(result[1].dpi_y)); | 211 EXPECT_FLOAT_EQ(111, round(result[1].dpi_y)); |
| 203 EXPECT_TRUE(result[1].mirroring_source_id.empty()); | 212 EXPECT_TRUE(result[1].mirroring_source_id.empty()); |
| 204 EXPECT_TRUE(result[1].is_enabled); | 213 EXPECT_TRUE(result[1].is_enabled); |
| 205 | 214 |
| 206 // Disable unified and check that once again it matches initial situation. | 215 // Disable unified and check that once again it matches initial situation. |
| 207 GetDisplayManager()->SetUnifiedDesktopEnabled(false); | 216 GetDisplayManager()->SetUnifiedDesktopEnabled(false); |
| 208 EXPECT_FALSE(GetDisplayManager()->IsInUnifiedMode()); | 217 EXPECT_FALSE(GetDisplayManager()->IsInUnifiedMode()); |
| 209 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 218 result = GetAllDisplaysInfo(); |
| 210 | 219 |
| 211 ASSERT_EQ(2u, result.size()); | 220 ASSERT_EQ(2u, result.size()); |
| 212 | 221 |
| 222 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id)) |
| 223 << "Display id must be convertable to integer: " << result[0].id; |
| 224 |
| 225 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; |
| 226 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds)); |
| 227 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan)); |
| 228 EXPECT_EQ(0, result[0].rotation); |
| 229 EXPECT_TRUE(result[0].is_primary); |
| 230 EXPECT_FALSE(result[0].is_unified); |
| 231 EXPECT_EQ(96, result[0].dpi_x); |
| 232 EXPECT_EQ(96, result[0].dpi_y); |
| 233 EXPECT_TRUE(result[0].mirroring_source_id.empty()); |
| 234 EXPECT_TRUE(result[0].is_enabled); |
| 235 |
| 236 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id)) |
| 237 << "Display id must be convertable to integer: " << result[0].id; |
| 238 |
| 239 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; |
| 240 EXPECT_EQ(GetDisplayManager()->GetDisplayNameForId(display_id), |
| 241 result[1].name); |
| 242 EXPECT_EQ("500,0 400x520", SystemInfoDisplayBoundsToString(result[1].bounds)); |
| 243 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1].overscan)); |
| 244 EXPECT_EQ(0, result[1].rotation); |
| 245 EXPECT_FALSE(result[1].is_primary); |
| 246 EXPECT_FALSE(result[1].is_unified); |
| 247 EXPECT_EQ(96, result[1].dpi_x); |
| 248 EXPECT_EQ(96, result[1].dpi_y); |
| 249 EXPECT_TRUE(result[1].mirroring_source_id.empty()); |
| 250 EXPECT_TRUE(result[1].is_enabled); |
| 251 } |
| 252 |
| 253 TEST_F(DisplayInfoProviderChromeosTest, GetWithUnifiedDesktopForSettings) { |
| 254 UpdateDisplay("500x600,400x520"); |
| 255 |
| 256 // Check initial state. |
| 257 EXPECT_FALSE(GetDisplayManager()->IsInUnifiedMode()); |
| 258 DisplayUnitInfoList result = |
| 259 DisplayInfoProvider::Get()->GetAllDisplaysInfo(true /* single unifed */); |
| 260 |
| 261 ASSERT_EQ(2u, result.size()); |
| 262 |
| 263 int64_t display_id; |
| 264 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id)) |
| 265 << "Display id must be convertable to integer: " << result[0].id; |
| 266 |
| 267 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; |
| 268 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds)); |
| 269 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan)); |
| 270 EXPECT_EQ(0, result[0].rotation); |
| 271 EXPECT_TRUE(result[0].is_primary); |
| 272 EXPECT_FALSE(result[0].is_unified); |
| 273 EXPECT_EQ(96, result[0].dpi_x); |
| 274 EXPECT_EQ(96, result[0].dpi_y); |
| 275 EXPECT_TRUE(result[0].mirroring_source_id.empty()); |
| 276 EXPECT_TRUE(result[0].is_enabled); |
| 277 |
| 278 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id)) |
| 279 << "Display id must be convertable to integer: " << result[0].id; |
| 280 |
| 281 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; |
| 282 EXPECT_EQ(GetDisplayManager()->GetDisplayNameForId(display_id), |
| 283 result[1].name); |
| 284 |
| 285 // Initial multipple display configuration. |
| 286 EXPECT_EQ("500,0 400x520", SystemInfoDisplayBoundsToString(result[1].bounds)); |
| 287 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1].overscan)); |
| 288 EXPECT_EQ(0, result[1].rotation); |
| 289 EXPECT_FALSE(result[1].is_primary); |
| 290 EXPECT_FALSE(result[0].is_unified); |
| 291 EXPECT_EQ(96, result[1].dpi_x); |
| 292 EXPECT_EQ(96, result[1].dpi_y); |
| 293 EXPECT_TRUE(result[1].mirroring_source_id.empty()); |
| 294 EXPECT_TRUE(result[1].is_enabled); |
| 295 |
| 296 // Enable unified. |
| 297 GetDisplayManager()->SetUnifiedDesktopEnabled(true); |
| 298 EXPECT_TRUE(GetDisplayManager()->IsInUnifiedMode()); |
| 299 |
| 300 // For settings, GetAllDisplaysInfo will return a single unified display. The |
| 301 // second display will be scaled to match the height of the first, so the |
| 302 // height will be 600 and the new width will be 500 + [400 * 600/520 = 461] = |
| 303 // 961. |
| 304 result = GetAllDisplaysInfo(); |
| 305 ASSERT_EQ(1u, result.size()); |
| 306 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id)) |
| 307 << "Display id must be convertable to integer: " << result[0].id; |
| 308 |
| 309 EXPECT_EQ("0,0 961x600", SystemInfoDisplayBoundsToString(result[0].bounds)); |
| 310 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan)); |
| 311 EXPECT_EQ(0, result[0].rotation); |
| 312 EXPECT_TRUE(result[0].is_primary); |
| 313 EXPECT_TRUE(result[0].is_unified); |
| 314 EXPECT_EQ(96, result[0].dpi_x); |
| 315 EXPECT_EQ(96, result[0].dpi_y); |
| 316 EXPECT_TRUE(result[0].mirroring_source_id.empty()); |
| 317 EXPECT_TRUE(result[0].is_enabled); |
| 318 |
| 319 // Disable unified and check that once again it matches initial situation. |
| 320 GetDisplayManager()->SetUnifiedDesktopEnabled(false); |
| 321 EXPECT_FALSE(GetDisplayManager()->IsInUnifiedMode()); |
| 322 result = GetAllDisplaysInfo(); |
| 323 |
| 324 ASSERT_EQ(2u, result.size()); |
| 325 |
| 213 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id)) | 326 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id)) |
| 214 << "Display id must be convertable to integer: " << result[0].id; | 327 << "Display id must be convertable to integer: " << result[0].id; |
| 215 | 328 |
| 216 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; | 329 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; |
| 217 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds)); | 330 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds)); |
| 218 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan)); | 331 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan)); |
| 219 EXPECT_EQ(0, result[0].rotation); | 332 EXPECT_EQ(0, result[0].rotation); |
| 220 EXPECT_TRUE(result[0].is_primary); | 333 EXPECT_TRUE(result[0].is_primary); |
| 334 EXPECT_FALSE(result[0].is_unified); |
| 221 EXPECT_EQ(96, result[0].dpi_x); | 335 EXPECT_EQ(96, result[0].dpi_x); |
| 222 EXPECT_EQ(96, result[0].dpi_y); | 336 EXPECT_EQ(96, result[0].dpi_y); |
| 223 EXPECT_TRUE(result[0].mirroring_source_id.empty()); | 337 EXPECT_TRUE(result[0].mirroring_source_id.empty()); |
| 224 EXPECT_TRUE(result[0].is_enabled); | 338 EXPECT_TRUE(result[0].is_enabled); |
| 225 | 339 |
| 226 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id)) | 340 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id)) |
| 227 << "Display id must be convertable to integer: " << result[0].id; | 341 << "Display id must be convertable to integer: " << result[0].id; |
| 228 | 342 |
| 229 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; | 343 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; |
| 230 EXPECT_EQ(GetDisplayManager()->GetDisplayNameForId(display_id), | 344 EXPECT_EQ(GetDisplayManager()->GetDisplayNameForId(display_id), |
| 231 result[1].name); | 345 result[1].name); |
| 232 EXPECT_EQ("500,0 400x520", SystemInfoDisplayBoundsToString(result[1].bounds)); | 346 EXPECT_EQ("500,0 400x520", SystemInfoDisplayBoundsToString(result[1].bounds)); |
| 233 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1].overscan)); | 347 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1].overscan)); |
| 234 EXPECT_EQ(0, result[1].rotation); | 348 EXPECT_EQ(0, result[1].rotation); |
| 235 EXPECT_FALSE(result[1].is_primary); | 349 EXPECT_FALSE(result[1].is_primary); |
| 350 EXPECT_FALSE(result[1].is_unified); |
| 236 EXPECT_EQ(96, result[1].dpi_x); | 351 EXPECT_EQ(96, result[1].dpi_x); |
| 237 EXPECT_EQ(96, result[1].dpi_y); | 352 EXPECT_EQ(96, result[1].dpi_y); |
| 238 EXPECT_TRUE(result[1].mirroring_source_id.empty()); | 353 EXPECT_TRUE(result[1].mirroring_source_id.empty()); |
| 239 EXPECT_TRUE(result[1].is_enabled); | 354 EXPECT_TRUE(result[1].is_enabled); |
| 240 } | 355 } |
| 241 | 356 |
| 242 TEST_F(DisplayInfoProviderChromeosTest, GetRotation) { | 357 TEST_F(DisplayInfoProviderChromeosTest, GetRotation) { |
| 243 UpdateDisplay("500x600/r"); | 358 UpdateDisplay("500x600/r"); |
| 244 DisplayUnitInfoList result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 359 DisplayUnitInfoList result = GetAllDisplaysInfo(); |
| 245 | 360 |
| 246 ASSERT_EQ(1u, result.size()); | 361 ASSERT_EQ(1u, result.size()); |
| 247 | 362 |
| 248 int64_t display_id; | 363 int64_t display_id; |
| 249 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id)) | 364 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id)) |
| 250 << "Display id must be convertable to integer: " << result[0].id; | 365 << "Display id must be convertable to integer: " << result[0].id; |
| 251 | 366 |
| 252 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; | 367 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; |
| 253 EXPECT_EQ("0,0 600x500", SystemInfoDisplayBoundsToString(result[0].bounds)); | 368 EXPECT_EQ("0,0 600x500", SystemInfoDisplayBoundsToString(result[0].bounds)); |
| 254 EXPECT_EQ(90, result[0].rotation); | 369 EXPECT_EQ(90, result[0].rotation); |
| 255 | 370 |
| 256 GetDisplayManager()->SetDisplayRotation( | 371 GetDisplayManager()->SetDisplayRotation( |
| 257 display_id, display::Display::ROTATE_270, | 372 display_id, display::Display::ROTATE_270, |
| 258 display::Display::ROTATION_SOURCE_ACTIVE); | 373 display::Display::ROTATION_SOURCE_ACTIVE); |
| 259 | 374 |
| 260 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 375 result = GetAllDisplaysInfo(); |
| 261 | 376 |
| 262 ASSERT_EQ(1u, result.size()); | 377 ASSERT_EQ(1u, result.size()); |
| 263 | 378 |
| 264 EXPECT_EQ(base::Int64ToString(display_id), result[0].id); | 379 EXPECT_EQ(base::Int64ToString(display_id), result[0].id); |
| 265 EXPECT_EQ("0,0 600x500", SystemInfoDisplayBoundsToString(result[0].bounds)); | 380 EXPECT_EQ("0,0 600x500", SystemInfoDisplayBoundsToString(result[0].bounds)); |
| 266 EXPECT_EQ(270, result[0].rotation); | 381 EXPECT_EQ(270, result[0].rotation); |
| 267 | 382 |
| 268 GetDisplayManager()->SetDisplayRotation( | 383 GetDisplayManager()->SetDisplayRotation( |
| 269 display_id, display::Display::ROTATE_180, | 384 display_id, display::Display::ROTATE_180, |
| 270 display::Display::ROTATION_SOURCE_ACTIVE); | 385 display::Display::ROTATION_SOURCE_ACTIVE); |
| 271 | 386 |
| 272 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 387 result = GetAllDisplaysInfo(); |
| 273 | 388 |
| 274 ASSERT_EQ(1u, result.size()); | 389 ASSERT_EQ(1u, result.size()); |
| 275 | 390 |
| 276 EXPECT_EQ(base::Int64ToString(display_id), result[0].id); | 391 EXPECT_EQ(base::Int64ToString(display_id), result[0].id); |
| 277 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds)); | 392 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds)); |
| 278 EXPECT_EQ(180, result[0].rotation); | 393 EXPECT_EQ(180, result[0].rotation); |
| 279 | 394 |
| 280 GetDisplayManager()->SetDisplayRotation( | 395 GetDisplayManager()->SetDisplayRotation( |
| 281 display_id, display::Display::ROTATE_0, | 396 display_id, display::Display::ROTATE_0, |
| 282 display::Display::ROTATION_SOURCE_ACTIVE); | 397 display::Display::ROTATION_SOURCE_ACTIVE); |
| 283 | 398 |
| 284 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 399 result = GetAllDisplaysInfo(); |
| 285 | 400 |
| 286 ASSERT_EQ(1u, result.size()); | 401 ASSERT_EQ(1u, result.size()); |
| 287 | 402 |
| 288 EXPECT_EQ(base::Int64ToString(display_id), result[0].id); | 403 EXPECT_EQ(base::Int64ToString(display_id), result[0].id); |
| 289 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds)); | 404 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds)); |
| 290 EXPECT_EQ(0, result[0].rotation); | 405 EXPECT_EQ(0, result[0].rotation); |
| 291 } | 406 } |
| 292 | 407 |
| 293 TEST_F(DisplayInfoProviderChromeosTest, GetDPI) { | 408 TEST_F(DisplayInfoProviderChromeosTest, GetDPI) { |
| 294 UpdateDisplay("500x600,400x520*2"); | 409 UpdateDisplay("500x600,400x520*2"); |
| 295 DisplayUnitInfoList result; | 410 DisplayUnitInfoList result; |
| 296 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 411 result = GetAllDisplaysInfo(); |
| 297 | 412 |
| 298 ASSERT_EQ(2u, result.size()); | 413 ASSERT_EQ(2u, result.size()); |
| 299 | 414 |
| 300 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds)); | 415 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds)); |
| 301 EXPECT_EQ(96, result[0].dpi_x); | 416 EXPECT_EQ(96, result[0].dpi_x); |
| 302 EXPECT_EQ(96, result[0].dpi_y); | 417 EXPECT_EQ(96, result[0].dpi_y); |
| 303 | 418 |
| 304 EXPECT_EQ("500,0 200x260", SystemInfoDisplayBoundsToString(result[1].bounds)); | 419 EXPECT_EQ("500,0 200x260", SystemInfoDisplayBoundsToString(result[1].bounds)); |
| 305 // DPI should be 96 (native dpi) * 200 (display) / 400 (native) when ui scale | 420 // DPI should be 96 (native dpi) * 200 (display) / 400 (native) when ui scale |
| 306 // is 2. | 421 // is 2. |
| 307 EXPECT_EQ(96 / 2, result[1].dpi_x); | 422 EXPECT_EQ(96 / 2, result[1].dpi_x); |
| 308 EXPECT_EQ(96 / 2, result[1].dpi_y); | 423 EXPECT_EQ(96 / 2, result[1].dpi_y); |
| 309 | 424 |
| 310 SwapPrimaryDisplay(); | 425 SwapPrimaryDisplay(); |
| 311 | 426 |
| 312 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 427 result = GetAllDisplaysInfo(); |
| 313 | 428 |
| 314 ASSERT_EQ(2u, result.size()); | 429 ASSERT_EQ(2u, result.size()); |
| 315 | 430 |
| 316 EXPECT_EQ("-500,0 500x600", | 431 EXPECT_EQ("-500,0 500x600", |
| 317 SystemInfoDisplayBoundsToString(result[0].bounds)); | 432 SystemInfoDisplayBoundsToString(result[0].bounds)); |
| 318 EXPECT_EQ(96, result[0].dpi_x); | 433 EXPECT_EQ(96, result[0].dpi_x); |
| 319 EXPECT_EQ(96, result[0].dpi_y); | 434 EXPECT_EQ(96, result[0].dpi_y); |
| 320 | 435 |
| 321 EXPECT_EQ("0,0 200x260", SystemInfoDisplayBoundsToString(result[1].bounds)); | 436 EXPECT_EQ("0,0 200x260", SystemInfoDisplayBoundsToString(result[1].bounds)); |
| 322 EXPECT_EQ(96 / 2, result[1].dpi_x); | 437 EXPECT_EQ(96 / 2, result[1].dpi_x); |
| 323 EXPECT_EQ(96 / 2, result[1].dpi_y); | 438 EXPECT_EQ(96 / 2, result[1].dpi_y); |
| 324 } | 439 } |
| 325 | 440 |
| 326 TEST_F(DisplayInfoProviderChromeosTest, GetVisibleArea) { | 441 TEST_F(DisplayInfoProviderChromeosTest, GetVisibleArea) { |
| 327 UpdateDisplay("640x720*2/o, 400x520/o"); | 442 UpdateDisplay("640x720*2/o, 400x520/o"); |
| 328 DisplayUnitInfoList result; | 443 DisplayUnitInfoList result; |
| 329 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 444 result = GetAllDisplaysInfo(); |
| 330 | 445 |
| 331 ASSERT_EQ(2u, result.size()); | 446 ASSERT_EQ(2u, result.size()); |
| 332 | 447 |
| 333 int64_t display_id; | 448 int64_t display_id; |
| 334 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id)) | 449 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id)) |
| 335 << "Display id must be convertable to integer: " << result[1].id; | 450 << "Display id must be convertable to integer: " << result[1].id; |
| 336 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; | 451 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; |
| 337 | 452 |
| 338 // Default overscan is 5%. | 453 // Default overscan is 5%. |
| 339 EXPECT_EQ("304,0 380x494", SystemInfoDisplayBoundsToString(result[1].bounds)); | 454 EXPECT_EQ("304,0 380x494", SystemInfoDisplayBoundsToString(result[1].bounds)); |
| 340 EXPECT_EQ("13,10,13,10", SystemInfoDisplayInsetsToString(result[1].overscan)); | 455 EXPECT_EQ("13,10,13,10", SystemInfoDisplayInsetsToString(result[1].overscan)); |
| 341 | 456 |
| 342 GetDisplayManager()->SetOverscanInsets(display_id, | 457 GetDisplayManager()->SetOverscanInsets(display_id, |
| 343 gfx::Insets(20, 30, 50, 60)); | 458 gfx::Insets(20, 30, 50, 60)); |
| 344 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 459 result = GetAllDisplaysInfo(); |
| 345 | 460 |
| 346 ASSERT_EQ(2u, result.size()); | 461 ASSERT_EQ(2u, result.size()); |
| 347 | 462 |
| 348 EXPECT_EQ(base::Int64ToString(display_id), result[1].id); | 463 EXPECT_EQ(base::Int64ToString(display_id), result[1].id); |
| 349 EXPECT_EQ("304,0 310x450", SystemInfoDisplayBoundsToString(result[1].bounds)); | 464 EXPECT_EQ("304,0 310x450", SystemInfoDisplayBoundsToString(result[1].bounds)); |
| 350 EXPECT_EQ("20,30,50,60", SystemInfoDisplayInsetsToString(result[1].overscan)); | 465 EXPECT_EQ("20,30,50,60", SystemInfoDisplayInsetsToString(result[1].overscan)); |
| 351 | 466 |
| 352 // Set insets for the primary screen. Note that it has 2x scale. | 467 // Set insets for the primary screen. Note that it has 2x scale. |
| 353 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id)) | 468 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id)) |
| 354 << "Display id must be convertable to integer: " << result[0].id; | 469 << "Display id must be convertable to integer: " << result[0].id; |
| 355 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; | 470 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; |
| 356 | 471 |
| 357 EXPECT_EQ("0,0 304x342", SystemInfoDisplayBoundsToString(result[0].bounds)); | 472 EXPECT_EQ("0,0 304x342", SystemInfoDisplayBoundsToString(result[0].bounds)); |
| 358 EXPECT_EQ("9,8,9,8", SystemInfoDisplayInsetsToString(result[0].overscan)); | 473 EXPECT_EQ("9,8,9,8", SystemInfoDisplayInsetsToString(result[0].overscan)); |
| 359 | 474 |
| 360 GetDisplayManager()->SetOverscanInsets(display_id, | 475 GetDisplayManager()->SetOverscanInsets(display_id, |
| 361 gfx::Insets(10, 20, 30, 40)); | 476 gfx::Insets(10, 20, 30, 40)); |
| 362 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 477 result = GetAllDisplaysInfo(); |
| 363 | 478 |
| 364 ASSERT_EQ(2u, result.size()); | 479 ASSERT_EQ(2u, result.size()); |
| 365 | 480 |
| 366 EXPECT_EQ(base::Int64ToString(display_id), result[0].id); | 481 EXPECT_EQ(base::Int64ToString(display_id), result[0].id); |
| 367 EXPECT_EQ("0,0 260x320", SystemInfoDisplayBoundsToString(result[0].bounds)); | 482 EXPECT_EQ("0,0 260x320", SystemInfoDisplayBoundsToString(result[0].bounds)); |
| 368 EXPECT_EQ("10,20,30,40", SystemInfoDisplayInsetsToString(result[0].overscan)); | 483 EXPECT_EQ("10,20,30,40", SystemInfoDisplayInsetsToString(result[0].overscan)); |
| 369 } | 484 } |
| 370 | 485 |
| 371 TEST_F(DisplayInfoProviderChromeosTest, GetMirroring) { | 486 TEST_F(DisplayInfoProviderChromeosTest, GetMirroring) { |
| 372 UpdateDisplay("600x600, 400x520/o"); | 487 UpdateDisplay("600x600, 400x520/o"); |
| 373 DisplayUnitInfoList result; | 488 DisplayUnitInfoList result; |
| 374 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 489 result = GetAllDisplaysInfo(); |
| 375 | 490 |
| 376 ASSERT_EQ(2u, result.size()); | 491 ASSERT_EQ(2u, result.size()); |
| 377 | 492 |
| 378 int64_t display_id_primary; | 493 int64_t display_id_primary; |
| 379 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id_primary)) | 494 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id_primary)) |
| 380 << "Display id must be convertable to integer: " << result[0].id; | 495 << "Display id must be convertable to integer: " << result[0].id; |
| 381 ASSERT_TRUE(DisplayExists(display_id_primary)) << display_id_primary | 496 ASSERT_TRUE(DisplayExists(display_id_primary)) << display_id_primary |
| 382 << " not found"; | 497 << " not found"; |
| 383 | 498 |
| 384 int64_t display_id_secondary; | 499 int64_t display_id_secondary; |
| 385 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id_secondary)) | 500 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id_secondary)) |
| 386 << "Display id must be convertable to integer: " << result[1].id; | 501 << "Display id must be convertable to integer: " << result[1].id; |
| 387 ASSERT_TRUE(DisplayExists(display_id_secondary)) << display_id_secondary | 502 ASSERT_TRUE(DisplayExists(display_id_secondary)) << display_id_secondary |
| 388 << " not found"; | 503 << " not found"; |
| 389 | 504 |
| 390 ASSERT_FALSE(GetDisplayManager()->IsInMirrorMode()); | 505 ASSERT_FALSE(GetDisplayManager()->IsInMirrorMode()); |
| 391 EXPECT_TRUE(result[0].mirroring_source_id.empty()); | 506 EXPECT_TRUE(result[0].mirroring_source_id.empty()); |
| 392 EXPECT_TRUE(result[1].mirroring_source_id.empty()); | 507 EXPECT_TRUE(result[1].mirroring_source_id.empty()); |
| 393 | 508 |
| 394 GetDisplayManager()->SetMirrorMode(true); | 509 GetDisplayManager()->SetMirrorMode(true); |
| 395 ASSERT_TRUE(GetDisplayManager()->IsInMirrorMode()); | 510 ASSERT_TRUE(GetDisplayManager()->IsInMirrorMode()); |
| 396 | 511 |
| 397 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 512 result = GetAllDisplaysInfo(); |
| 398 | 513 |
| 399 ASSERT_EQ(1u, result.size()); | 514 ASSERT_EQ(1u, result.size()); |
| 400 EXPECT_EQ(base::Int64ToString(display_id_primary), result[0].id); | 515 EXPECT_EQ(base::Int64ToString(display_id_primary), result[0].id); |
| 401 EXPECT_EQ(base::Int64ToString(display_id_secondary), | 516 EXPECT_EQ(base::Int64ToString(display_id_secondary), |
| 402 result[0].mirroring_source_id); | 517 result[0].mirroring_source_id); |
| 403 | 518 |
| 404 GetDisplayManager()->SetMirrorMode(false); | 519 GetDisplayManager()->SetMirrorMode(false); |
| 405 ASSERT_FALSE(GetDisplayManager()->IsInMirrorMode()); | 520 ASSERT_FALSE(GetDisplayManager()->IsInMirrorMode()); |
| 406 | 521 |
| 407 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 522 result = GetAllDisplaysInfo(); |
| 408 | 523 |
| 409 ASSERT_EQ(2u, result.size()); | 524 ASSERT_EQ(2u, result.size()); |
| 410 EXPECT_EQ(base::Int64ToString(display_id_primary), result[0].id); | 525 EXPECT_EQ(base::Int64ToString(display_id_primary), result[0].id); |
| 411 EXPECT_TRUE(result[0].mirroring_source_id.empty()); | 526 EXPECT_TRUE(result[0].mirroring_source_id.empty()); |
| 412 EXPECT_EQ(base::Int64ToString(display_id_secondary), result[1].id); | 527 EXPECT_EQ(base::Int64ToString(display_id_secondary), result[1].id); |
| 413 EXPECT_TRUE(result[1].mirroring_source_id.empty()); | 528 EXPECT_TRUE(result[1].mirroring_source_id.empty()); |
| 414 } | 529 } |
| 415 | 530 |
| 416 TEST_F(DisplayInfoProviderChromeosTest, GetBounds) { | 531 TEST_F(DisplayInfoProviderChromeosTest, GetBounds) { |
| 417 UpdateDisplay("600x600, 400x520"); | 532 UpdateDisplay("600x600, 400x520"); |
| 418 GetDisplayManager()->SetLayoutForCurrentDisplays( | 533 GetDisplayManager()->SetLayoutForCurrentDisplays( |
| 419 display::test::CreateDisplayLayout(display_manager(), | 534 display::test::CreateDisplayLayout(display_manager(), |
| 420 display::DisplayPlacement::LEFT, -40)); | 535 display::DisplayPlacement::LEFT, -40)); |
| 421 | 536 |
| 422 DisplayUnitInfoList result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 537 DisplayUnitInfoList result = GetAllDisplaysInfo(); |
| 423 | 538 |
| 424 ASSERT_EQ(2u, result.size()); | 539 ASSERT_EQ(2u, result.size()); |
| 425 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds)); | 540 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds)); |
| 426 EXPECT_EQ("-400,-40 400x520", | 541 EXPECT_EQ("-400,-40 400x520", |
| 427 SystemInfoDisplayBoundsToString(result[1].bounds)); | 542 SystemInfoDisplayBoundsToString(result[1].bounds)); |
| 428 | 543 |
| 429 GetDisplayManager()->SetLayoutForCurrentDisplays( | 544 GetDisplayManager()->SetLayoutForCurrentDisplays( |
| 430 display::test::CreateDisplayLayout(display_manager(), | 545 display::test::CreateDisplayLayout(display_manager(), |
| 431 display::DisplayPlacement::TOP, 40)); | 546 display::DisplayPlacement::TOP, 40)); |
| 432 | 547 |
| 433 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 548 result = GetAllDisplaysInfo(); |
| 434 | 549 |
| 435 ASSERT_EQ(2u, result.size()); | 550 ASSERT_EQ(2u, result.size()); |
| 436 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds)); | 551 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds)); |
| 437 EXPECT_EQ("40,-520 400x520", | 552 EXPECT_EQ("40,-520 400x520", |
| 438 SystemInfoDisplayBoundsToString(result[1].bounds)); | 553 SystemInfoDisplayBoundsToString(result[1].bounds)); |
| 439 | 554 |
| 440 GetDisplayManager()->SetLayoutForCurrentDisplays( | 555 GetDisplayManager()->SetLayoutForCurrentDisplays( |
| 441 display::test::CreateDisplayLayout( | 556 display::test::CreateDisplayLayout( |
| 442 display_manager(), display::DisplayPlacement::BOTTOM, 80)); | 557 display_manager(), display::DisplayPlacement::BOTTOM, 80)); |
| 443 | 558 |
| 444 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 559 result = GetAllDisplaysInfo(); |
| 445 ASSERT_EQ(2u, result.size()); | 560 ASSERT_EQ(2u, result.size()); |
| 446 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds)); | 561 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds)); |
| 447 EXPECT_EQ("80,600 400x520", | 562 EXPECT_EQ("80,600 400x520", |
| 448 SystemInfoDisplayBoundsToString(result[1].bounds)); | 563 SystemInfoDisplayBoundsToString(result[1].bounds)); |
| 449 } | 564 } |
| 450 | 565 |
| 451 TEST_F(DisplayInfoProviderChromeosTest, Layout) { | 566 TEST_F(DisplayInfoProviderChromeosTest, Layout) { |
| 452 UpdateDisplay("500x400,500x400,500x400"); | 567 UpdateDisplay("500x400,500x400,500x400"); |
| 453 | 568 |
| 454 DisplayUnitInfoList displays = | 569 DisplayUnitInfoList displays = GetAllDisplaysInfo(); |
| 455 DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | |
| 456 std::string primary_id = displays[0].id; | 570 std::string primary_id = displays[0].id; |
| 457 ASSERT_EQ(3u, displays.size()); | 571 ASSERT_EQ(3u, displays.size()); |
| 458 | 572 |
| 459 DisplayLayoutList layout = DisplayInfoProvider::Get()->GetDisplayLayout(); | 573 DisplayLayoutList layout = DisplayInfoProvider::Get()->GetDisplayLayout(); |
| 460 | 574 |
| 461 ASSERT_EQ(2u, layout.size()); | 575 ASSERT_EQ(2u, layout.size()); |
| 462 | 576 |
| 463 // Confirm layout. | 577 // Confirm layout. |
| 464 EXPECT_EQ(displays[1].id, layout[0].id); | 578 EXPECT_EQ(displays[1].id, layout[0].id); |
| 465 EXPECT_EQ(primary_id, layout[0].parent_id); | 579 EXPECT_EQ(primary_id, layout[0].parent_id); |
| (...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1147 CallSetDisplayUnitInfo( | 1261 CallSetDisplayUnitInfo( |
| 1148 base::Int64ToString(internal_display_id), info, &success, &error); | 1262 base::Int64ToString(internal_display_id), info, &success, &error); |
| 1149 | 1263 |
| 1150 ASSERT_FALSE(success); | 1264 ASSERT_FALSE(success); |
| 1151 EXPECT_EQ("Overscan changes not allowed for the internal monitor.", error); | 1265 EXPECT_EQ("Overscan changes not allowed for the internal monitor.", error); |
| 1152 } | 1266 } |
| 1153 | 1267 |
| 1154 TEST_F(DisplayInfoProviderChromeosTest, DisplayMode) { | 1268 TEST_F(DisplayInfoProviderChromeosTest, DisplayMode) { |
| 1155 UpdateDisplay("1200x600,600x1000"); | 1269 UpdateDisplay("1200x600,600x1000"); |
| 1156 | 1270 |
| 1157 DisplayUnitInfoList result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 1271 DisplayUnitInfoList result = GetAllDisplaysInfo(); |
| 1158 ASSERT_GE(result.size(), 1u); | 1272 ASSERT_GE(result.size(), 1u); |
| 1159 const api::system_display::DisplayUnitInfo& primary_info = result[0]; | 1273 const api::system_display::DisplayUnitInfo& primary_info = result[0]; |
| 1160 // Ensure that we have two modes for the primary display so that we can | 1274 // Ensure that we have two modes for the primary display so that we can |
| 1161 // test chaning modes. | 1275 // test chaning modes. |
| 1162 ASSERT_GE(primary_info.modes.size(), 2u); | 1276 ASSERT_GE(primary_info.modes.size(), 2u); |
| 1163 | 1277 |
| 1164 // Get the currently active mode and one other mode to switch to. | 1278 // Get the currently active mode and one other mode to switch to. |
| 1165 int64_t id; | 1279 int64_t id; |
| 1166 base::StringToInt64(primary_info.id, &id); | 1280 base::StringToInt64(primary_info.id, &id); |
| 1167 scoped_refptr<display::ManagedDisplayMode> active_mode = | 1281 scoped_refptr<display::ManagedDisplayMode> active_mode = |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1449 EXPECT_EQ(pairs.pair1.touch_point.y, data.point_pairs[0].second.y()); | 1563 EXPECT_EQ(pairs.pair1.touch_point.y, data.point_pairs[0].second.y()); |
| 1450 EXPECT_EQ(pairs.pair2.touch_point.y, data.point_pairs[1].second.y()); | 1564 EXPECT_EQ(pairs.pair2.touch_point.y, data.point_pairs[1].second.y()); |
| 1451 EXPECT_EQ(pairs.pair3.touch_point.y, data.point_pairs[2].second.y()); | 1565 EXPECT_EQ(pairs.pair3.touch_point.y, data.point_pairs[2].second.y()); |
| 1452 EXPECT_EQ(pairs.pair4.touch_point.y, data.point_pairs[3].second.y()); | 1566 EXPECT_EQ(pairs.pair4.touch_point.y, data.point_pairs[3].second.y()); |
| 1453 | 1567 |
| 1454 EXPECT_EQ(bounds.width, data.bounds.width()); | 1568 EXPECT_EQ(bounds.width, data.bounds.width()); |
| 1455 EXPECT_EQ(bounds.height, data.bounds.height()); | 1569 EXPECT_EQ(bounds.height, data.bounds.height()); |
| 1456 } | 1570 } |
| 1457 } // namespace | 1571 } // namespace |
| 1458 } // namespace extensions | 1572 } // namespace extensions |
| OLD | NEW |