| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/display/display_preferences.h" | 5 #include "chrome/browser/chromeos/display/display_preferences.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/display/display_controller.h" | 10 #include "ash/display/display_controller.h" |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 EXPECT_EQ("top, 20", GetRegisteredDisplayLayoutStr(id1, id2)); | 192 EXPECT_EQ("top, 20", GetRegisteredDisplayLayoutStr(id1, id2)); |
| 193 EXPECT_EQ("left, 30", GetRegisteredDisplayLayoutStr(id1, dummy_id)); | 193 EXPECT_EQ("left, 30", GetRegisteredDisplayLayoutStr(id1, dummy_id)); |
| 194 } | 194 } |
| 195 | 195 |
| 196 TEST_F(DisplayPreferencesTest, BasicStores) { | 196 TEST_F(DisplayPreferencesTest, BasicStores) { |
| 197 ash::DisplayController* display_controller = | 197 ash::DisplayController* display_controller = |
| 198 ash::Shell::GetInstance()->display_controller(); | 198 ash::Shell::GetInstance()->display_controller(); |
| 199 ash::DisplayManager* display_manager = | 199 ash::DisplayManager* display_manager = |
| 200 ash::Shell::GetInstance()->display_manager(); | 200 ash::Shell::GetInstance()->display_manager(); |
| 201 | 201 |
| 202 UpdateDisplay("200x200*2, 400x300#400x400|300x200"); | 202 UpdateDisplay("200x200*2, 400x300#400x400|300x200*1.25"); |
| 203 int64 id1 = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id(); | 203 int64 id1 = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id(); |
| 204 gfx::Display::SetInternalDisplayId(id1); | 204 gfx::Display::SetInternalDisplayId(id1); |
| 205 int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); | 205 int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); |
| 206 int64 dummy_id = id2 + 1; | 206 int64 dummy_id = id2 + 1; |
| 207 ASSERT_NE(id1, dummy_id); | 207 ASSERT_NE(id1, dummy_id); |
| 208 std::vector<ui::ColorCalibrationProfile> profiles; | 208 std::vector<ui::ColorCalibrationProfile> profiles; |
| 209 profiles.push_back(ui::COLOR_PROFILE_STANDARD); | 209 profiles.push_back(ui::COLOR_PROFILE_STANDARD); |
| 210 profiles.push_back(ui::COLOR_PROFILE_DYNAMIC); | 210 profiles.push_back(ui::COLOR_PROFILE_DYNAMIC); |
| 211 profiles.push_back(ui::COLOR_PROFILE_MOVIE); | 211 profiles.push_back(ui::COLOR_PROFILE_MOVIE); |
| 212 profiles.push_back(ui::COLOR_PROFILE_READING); | 212 profiles.push_back(ui::COLOR_PROFILE_READING); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 EXPECT_FALSE(property->GetInteger("insets_top", &top)); | 285 EXPECT_FALSE(property->GetInteger("insets_top", &top)); |
| 286 EXPECT_FALSE(property->GetInteger("insets_left", &left)); | 286 EXPECT_FALSE(property->GetInteger("insets_left", &left)); |
| 287 EXPECT_FALSE(property->GetInteger("insets_bottom", &bottom)); | 287 EXPECT_FALSE(property->GetInteger("insets_bottom", &bottom)); |
| 288 EXPECT_FALSE(property->GetInteger("insets_right", &right)); | 288 EXPECT_FALSE(property->GetInteger("insets_right", &right)); |
| 289 | 289 |
| 290 // |id2| doesn't have the color_profile because it doesn't have 'dynamic' in | 290 // |id2| doesn't have the color_profile because it doesn't have 'dynamic' in |
| 291 // its available list. | 291 // its available list. |
| 292 EXPECT_FALSE(property->GetString("color_profile_name", &color_profile)); | 292 EXPECT_FALSE(property->GetString("color_profile_name", &color_profile)); |
| 293 | 293 |
| 294 // Resolution is saved only when the resolution is set | 294 // Resolution is saved only when the resolution is set |
| 295 // by DisplayManager::SetDisplayResolution | 295 // by DisplayManager::SetDisplayMode |
| 296 width = 0; | 296 width = 0; |
| 297 height = 0; | 297 height = 0; |
| 298 EXPECT_FALSE(property->GetInteger("width", &width)); | 298 EXPECT_FALSE(property->GetInteger("width", &width)); |
| 299 EXPECT_FALSE(property->GetInteger("height", &height)); | 299 EXPECT_FALSE(property->GetInteger("height", &height)); |
| 300 | 300 |
| 301 display_manager->SetDisplayResolution(id2, gfx::Size(300, 200)); | 301 ash::DisplayMode mode(gfx::Size(300, 200), 60.0f, false, true); |
| 302 mode.device_scale_factor = 1.25f; |
| 303 display_manager->SetDisplayMode(id2, mode); |
| 302 | 304 |
| 303 display_controller->SetPrimaryDisplayId(id2); | 305 display_controller->SetPrimaryDisplayId(id2); |
| 304 | 306 |
| 305 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id1), &property)); | 307 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id1), &property)); |
| 306 width = 0; | 308 width = 0; |
| 307 height = 0; | 309 height = 0; |
| 308 // Internal display shouldn't store its resolution. | 310 // Internal display shouldn't store its resolution. |
| 309 EXPECT_FALSE(property->GetInteger("width", &width)); | 311 EXPECT_FALSE(property->GetInteger("width", &width)); |
| 310 EXPECT_FALSE(property->GetInteger("height", &height)); | 312 EXPECT_FALSE(property->GetInteger("height", &height)); |
| 311 | 313 |
| 312 // External display's resolution must be stored this time because | 314 // External display's resolution must be stored this time because |
| 313 // it's not best. | 315 // it's not best. |
| 316 int device_scale_factor = 0; |
| 314 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id2), &property)); | 317 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id2), &property)); |
| 315 EXPECT_TRUE(property->GetInteger("width", &width)); | 318 EXPECT_TRUE(property->GetInteger("width", &width)); |
| 316 EXPECT_TRUE(property->GetInteger("height", &height)); | 319 EXPECT_TRUE(property->GetInteger("height", &height)); |
| 320 EXPECT_TRUE(property->GetInteger( |
| 321 "device-scale-factor", &device_scale_factor)); |
| 317 EXPECT_EQ(300, width); | 322 EXPECT_EQ(300, width); |
| 318 EXPECT_EQ(200, height); | 323 EXPECT_EQ(200, height); |
| 324 EXPECT_EQ(1250, device_scale_factor); |
| 319 | 325 |
| 320 // The layout remains the same. | 326 // The layout remains the same. |
| 321 EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); | 327 EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); |
| 322 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*layout_value, | 328 EXPECT_TRUE(ash::DisplayLayout::ConvertFromValue(*layout_value, |
| 323 &stored_layout)); | 329 &stored_layout)); |
| 324 EXPECT_EQ(layout.position, stored_layout.position); | 330 EXPECT_EQ(layout.position, stored_layout.position); |
| 325 EXPECT_EQ(layout.offset, stored_layout.offset); | 331 EXPECT_EQ(layout.offset, stored_layout.offset); |
| 326 EXPECT_EQ(id2, stored_layout.primary_id); | 332 EXPECT_EQ(id2, stored_layout.primary_id); |
| 327 | 333 |
| 328 mirrored = true; | 334 mirrored = true; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 357 // External display's selected resolution must not change | 363 // External display's selected resolution must not change |
| 358 // by mirroring. | 364 // by mirroring. |
| 359 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id2), &property)); | 365 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id2), &property)); |
| 360 EXPECT_TRUE(property->GetInteger("width", &width)); | 366 EXPECT_TRUE(property->GetInteger("width", &width)); |
| 361 EXPECT_TRUE(property->GetInteger("height", &height)); | 367 EXPECT_TRUE(property->GetInteger("height", &height)); |
| 362 EXPECT_EQ(300, width); | 368 EXPECT_EQ(300, width); |
| 363 EXPECT_EQ(200, height); | 369 EXPECT_EQ(200, height); |
| 364 | 370 |
| 365 // Set new display's selected resolution. | 371 // Set new display's selected resolution. |
| 366 display_manager->RegisterDisplayProperty( | 372 display_manager->RegisterDisplayProperty( |
| 367 id2 + 1, gfx::Display::ROTATE_0, 1.0f, NULL, gfx::Size(500, 400), | 373 id2 + 1, gfx::Display::ROTATE_0, 1.0f, NULL, gfx::Size(500, 400), 1.0f, |
| 368 ui::COLOR_PROFILE_STANDARD); | 374 ui::COLOR_PROFILE_STANDARD); |
| 369 | 375 |
| 370 UpdateDisplay("200x200*2, 600x500#600x500|500x400"); | 376 UpdateDisplay("200x200*2, 600x500#600x500|500x400"); |
| 371 | 377 |
| 372 // Update key as the 2nd display gets new id. | 378 // Update key as the 2nd display gets new id. |
| 373 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); | 379 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); |
| 374 key = base::Int64ToString(id1) + "," + base::Int64ToString(id2); | 380 key = base::Int64ToString(id1) + "," + base::Int64ToString(id2); |
| 375 EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); | 381 EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); |
| 376 EXPECT_TRUE(layout_value->GetString(kPositionKey, &position)); | 382 EXPECT_TRUE(layout_value->GetString(kPositionKey, &position)); |
| 377 EXPECT_EQ("right", position); | 383 EXPECT_EQ("right", position); |
| 378 EXPECT_TRUE(layout_value->GetInteger(kOffsetKey, &offset)); | 384 EXPECT_TRUE(layout_value->GetInteger(kOffsetKey, &offset)); |
| 379 EXPECT_EQ(0, offset); | 385 EXPECT_EQ(0, offset); |
| 380 mirrored = true; | 386 mirrored = true; |
| 381 EXPECT_TRUE(layout_value->GetBoolean(kMirroredKey, &mirrored)); | 387 EXPECT_TRUE(layout_value->GetBoolean(kMirroredKey, &mirrored)); |
| 382 EXPECT_FALSE(mirrored); | 388 EXPECT_FALSE(mirrored); |
| 383 EXPECT_TRUE(layout_value->GetString(kPrimaryIdKey, &primary_id_str)); | 389 EXPECT_TRUE(layout_value->GetString(kPrimaryIdKey, &primary_id_str)); |
| 384 EXPECT_EQ(base::Int64ToString(id1), primary_id_str); | 390 EXPECT_EQ(base::Int64ToString(id1), primary_id_str); |
| 385 | 391 |
| 386 // Best resolution should not be saved. | 392 // Best resolution should not be saved. |
| 387 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id2), &property)); | 393 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id2), &property)); |
| 388 EXPECT_FALSE(property->GetInteger("width", &width)); | 394 EXPECT_FALSE(property->GetInteger("width", &width)); |
| 389 EXPECT_FALSE(property->GetInteger("height", &height)); | 395 EXPECT_FALSE(property->GetInteger("height", &height)); |
| 390 | 396 |
| 391 // Set yet another new display's selected resolution. | 397 // Set yet another new display's selected resolution. |
| 392 display_manager->RegisterDisplayProperty( | 398 display_manager->RegisterDisplayProperty( |
| 393 id2 + 1, gfx::Display::ROTATE_0, 1.0f, NULL, gfx::Size(500, 400), | 399 id2 + 1, gfx::Display::ROTATE_0, 1.0f, NULL, gfx::Size(500, 400), 1.0f, |
| 394 ui::COLOR_PROFILE_STANDARD); | 400 ui::COLOR_PROFILE_STANDARD); |
| 395 // Disconnect 2nd display first to generate new id for external display. | 401 // Disconnect 2nd display first to generate new id for external display. |
| 396 UpdateDisplay("200x200*2"); | 402 UpdateDisplay("200x200*2"); |
| 397 UpdateDisplay("200x200*2, 500x400#600x500|500x400%60.0f"); | 403 UpdateDisplay("200x200*2, 500x400#600x500|500x400%60.0f"); |
| 398 // Update key as the 2nd display gets new id. | 404 // Update key as the 2nd display gets new id. |
| 399 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); | 405 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); |
| 400 key = base::Int64ToString(id1) + "," + base::Int64ToString(id2); | 406 key = base::Int64ToString(id1) + "," + base::Int64ToString(id2); |
| 401 EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); | 407 EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); |
| 402 EXPECT_TRUE(layout_value->GetString(kPositionKey, &position)); | 408 EXPECT_TRUE(layout_value->GetString(kPositionKey, &position)); |
| 403 EXPECT_EQ("right", position); | 409 EXPECT_EQ("right", position); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 | 451 |
| 446 // Revert the change. When timeout, 2nd button is revert. | 452 // Revert the change. When timeout, 2nd button is revert. |
| 447 message_center::MessageCenter::Get()->ClickOnNotificationButton( | 453 message_center::MessageCenter::Get()->ClickOnNotificationButton( |
| 448 ResolutionNotificationController::kNotificationId, 1); | 454 ResolutionNotificationController::kNotificationId, 1); |
| 449 RunAllPendingInMessageLoop(); | 455 RunAllPendingInMessageLoop(); |
| 450 EXPECT_FALSE( | 456 EXPECT_FALSE( |
| 451 message_center::MessageCenter::Get()->FindVisibleNotificationById( | 457 message_center::MessageCenter::Get()->FindVisibleNotificationById( |
| 452 ResolutionNotificationController::kNotificationId)); | 458 ResolutionNotificationController::kNotificationId)); |
| 453 | 459 |
| 454 // Once the notification is removed, the specified resolution will be stored | 460 // Once the notification is removed, the specified resolution will be stored |
| 455 // by SetDisplayResolution. | 461 // by SetDisplayMode. |
| 456 ash::Shell::GetInstance()->display_manager()->SetDisplayResolution( | 462 ash::Shell::GetInstance()->display_manager()->SetDisplayMode( |
| 457 id, gfx::Size(300, 200)); | 463 id, ash::DisplayMode(gfx::Size(300, 200), 60.0f, false, true)); |
| 458 UpdateDisplay("300x200#500x400|400x300|300x200"); | 464 UpdateDisplay("300x200#500x400|400x300|300x200"); |
| 459 | 465 |
| 460 property = NULL; | 466 property = NULL; |
| 461 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id), &property)); | 467 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id), &property)); |
| 462 EXPECT_TRUE(property->GetInteger("width", &width)); | 468 EXPECT_TRUE(property->GetInteger("width", &width)); |
| 463 EXPECT_TRUE(property->GetInteger("height", &height)); | 469 EXPECT_TRUE(property->GetInteger("height", &height)); |
| 464 EXPECT_EQ(300, width); | 470 EXPECT_EQ(300, width); |
| 465 EXPECT_EQ(200, height); | 471 EXPECT_EQ(200, height); |
| 466 } | 472 } |
| 467 | 473 |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 local_state()->GetDictionary(prefs::kDisplayProperties); | 669 local_state()->GetDictionary(prefs::kDisplayProperties); |
| 664 const base::DictionaryValue* property = NULL; | 670 const base::DictionaryValue* property = NULL; |
| 665 EXPECT_TRUE(properties->GetDictionary( | 671 EXPECT_TRUE(properties->GetDictionary( |
| 666 base::Int64ToString(gfx::Display::InternalDisplayId()), &property)); | 672 base::Int64ToString(gfx::Display::InternalDisplayId()), &property)); |
| 667 int rotation = -1; | 673 int rotation = -1; |
| 668 EXPECT_TRUE(property->GetInteger("rotation", &rotation)); | 674 EXPECT_TRUE(property->GetInteger("rotation", &rotation)); |
| 669 EXPECT_EQ(gfx::Display::ROTATE_0, rotation); | 675 EXPECT_EQ(gfx::Display::ROTATE_0, rotation); |
| 670 } | 676 } |
| 671 | 677 |
| 672 } // namespace chromeos | 678 } // namespace chromeos |
| OLD | NEW |