Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: chrome/browser/chromeos/display/display_preferences_unittest.cc

Issue 2613493002: Fix namespace for src/ui/display/. (Closed)
Patch Set: Rebase. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 ash::WindowTreeHostManager* window_tree_host_manager = 261 ash::WindowTreeHostManager* window_tree_host_manager =
262 ash::Shell::GetInstance()->window_tree_host_manager(); 262 ash::Shell::GetInstance()->window_tree_host_manager();
263 263
264 UpdateDisplay("200x200*2, 400x300#400x400|300x200*1.25"); 264 UpdateDisplay("200x200*2, 400x300#400x400|300x200*1.25");
265 int64_t id1 = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 265 int64_t id1 = display::Screen::GetScreen()->GetPrimaryDisplay().id();
266 display::test::ScopedSetInternalDisplayId set_internal(display_manager(), 266 display::test::ScopedSetInternalDisplayId set_internal(display_manager(),
267 id1); 267 id1);
268 int64_t id2 = display_manager()->GetSecondaryDisplay().id(); 268 int64_t id2 = display_manager()->GetSecondaryDisplay().id();
269 int64_t dummy_id = id2 + 1; 269 int64_t dummy_id = id2 + 1;
270 ASSERT_NE(id1, dummy_id); 270 ASSERT_NE(id1, dummy_id);
271 std::vector<ui::ColorCalibrationProfile> profiles; 271 std::vector<display::ColorCalibrationProfile> profiles;
272 profiles.push_back(ui::COLOR_PROFILE_STANDARD); 272 profiles.push_back(display::COLOR_PROFILE_STANDARD);
273 profiles.push_back(ui::COLOR_PROFILE_DYNAMIC); 273 profiles.push_back(display::COLOR_PROFILE_DYNAMIC);
274 profiles.push_back(ui::COLOR_PROFILE_MOVIE); 274 profiles.push_back(display::COLOR_PROFILE_MOVIE);
275 profiles.push_back(ui::COLOR_PROFILE_READING); 275 profiles.push_back(display::COLOR_PROFILE_READING);
276 // Allows only |id1|. 276 // Allows only |id1|.
277 display::test::DisplayManagerTestApi(display_manager()) 277 display::test::DisplayManagerTestApi(display_manager())
278 .SetAvailableColorProfiles(id1, profiles); 278 .SetAvailableColorProfiles(id1, profiles);
279 display_manager()->SetColorCalibrationProfile(id1, ui::COLOR_PROFILE_DYNAMIC); 279 display_manager()->SetColorCalibrationProfile(id1,
280 display_manager()->SetColorCalibrationProfile(id2, ui::COLOR_PROFILE_DYNAMIC); 280 display::COLOR_PROFILE_DYNAMIC);
281 display_manager()->SetColorCalibrationProfile(id2,
282 display::COLOR_PROFILE_DYNAMIC);
281 283
282 LoggedInAsUser(); 284 LoggedInAsUser();
283 285
284 display_manager()->SetLayoutForCurrentDisplays( 286 display_manager()->SetLayoutForCurrentDisplays(
285 display::test::CreateDisplayLayout(display_manager(), 287 display::test::CreateDisplayLayout(display_manager(),
286 display::DisplayPlacement::TOP, 10)); 288 display::DisplayPlacement::TOP, 10));
287 const display::DisplayLayout& layout = 289 const display::DisplayLayout& layout =
288 display_manager()->GetCurrentDisplayLayout(); 290 display_manager()->GetCurrentDisplayLayout();
289 EXPECT_EQ(display::DisplayPlacement::TOP, layout.placement_list[0].position); 291 EXPECT_EQ(display::DisplayPlacement::TOP, layout.placement_list[0].position);
290 EXPECT_EQ(10, layout.placement_list[0].offset); 292 EXPECT_EQ(10, layout.placement_list[0].offset);
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 // by mirroring. 504 // by mirroring.
503 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id2), &property)); 505 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id2), &property));
504 EXPECT_TRUE(property->GetInteger("width", &width)); 506 EXPECT_TRUE(property->GetInteger("width", &width));
505 EXPECT_TRUE(property->GetInteger("height", &height)); 507 EXPECT_TRUE(property->GetInteger("height", &height));
506 EXPECT_EQ(300, width); 508 EXPECT_EQ(300, width);
507 EXPECT_EQ(200, height); 509 EXPECT_EQ(200, height);
508 510
509 // Set new display's selected resolution. 511 // Set new display's selected resolution.
510 display_manager()->RegisterDisplayProperty( 512 display_manager()->RegisterDisplayProperty(
511 id2 + 1, display::Display::ROTATE_0, 1.0f, nullptr, gfx::Size(500, 400), 513 id2 + 1, display::Display::ROTATE_0, 1.0f, nullptr, gfx::Size(500, 400),
512 1.0f, ui::COLOR_PROFILE_STANDARD, nullptr); 514 1.0f, display::COLOR_PROFILE_STANDARD, nullptr);
513 515
514 UpdateDisplay("200x200*2, 600x500#600x500|500x400"); 516 UpdateDisplay("200x200*2, 600x500#600x500|500x400");
515 517
516 // Update key as the 2nd display gets new id. 518 // Update key as the 2nd display gets new id.
517 id2 = display_manager()->GetSecondaryDisplay().id(); 519 id2 = display_manager()->GetSecondaryDisplay().id();
518 key = base::Int64ToString(id1) + "," + base::Int64ToString(id2); 520 key = base::Int64ToString(id1) + "," + base::Int64ToString(id2);
519 EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); 521 EXPECT_TRUE(displays->GetDictionary(key, &layout_value));
520 EXPECT_TRUE(layout_value->GetString(kPositionKey, &position)); 522 EXPECT_TRUE(layout_value->GetString(kPositionKey, &position));
521 EXPECT_EQ("right", position); 523 EXPECT_EQ("right", position);
522 EXPECT_TRUE(layout_value->GetInteger(kOffsetKey, &offset)); 524 EXPECT_TRUE(layout_value->GetInteger(kOffsetKey, &offset));
523 EXPECT_EQ(0, offset); 525 EXPECT_EQ(0, offset);
524 mirrored = true; 526 mirrored = true;
525 EXPECT_TRUE(layout_value->GetBoolean(kMirroredKey, &mirrored)); 527 EXPECT_TRUE(layout_value->GetBoolean(kMirroredKey, &mirrored));
526 EXPECT_FALSE(mirrored); 528 EXPECT_FALSE(mirrored);
527 EXPECT_TRUE(layout_value->GetString(kPrimaryIdKey, &primary_id_str)); 529 EXPECT_TRUE(layout_value->GetString(kPrimaryIdKey, &primary_id_str));
528 EXPECT_EQ(base::Int64ToString(id1), primary_id_str); 530 EXPECT_EQ(base::Int64ToString(id1), primary_id_str);
529 531
530 // Best resolution should not be saved. 532 // Best resolution should not be saved.
531 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id2), &property)); 533 EXPECT_TRUE(properties->GetDictionary(base::Int64ToString(id2), &property));
532 EXPECT_FALSE(property->GetInteger("width", &width)); 534 EXPECT_FALSE(property->GetInteger("width", &width));
533 EXPECT_FALSE(property->GetInteger("height", &height)); 535 EXPECT_FALSE(property->GetInteger("height", &height));
534 536
535 // Set yet another new display's selected resolution. 537 // Set yet another new display's selected resolution.
536 display_manager()->RegisterDisplayProperty( 538 display_manager()->RegisterDisplayProperty(
537 id2 + 1, display::Display::ROTATE_0, 1.0f, nullptr, gfx::Size(500, 400), 539 id2 + 1, display::Display::ROTATE_0, 1.0f, nullptr, gfx::Size(500, 400),
538 1.0f, ui::COLOR_PROFILE_STANDARD, nullptr); 540 1.0f, display::COLOR_PROFILE_STANDARD, nullptr);
539 // Disconnect 2nd display first to generate new id for external display. 541 // Disconnect 2nd display first to generate new id for external display.
540 UpdateDisplay("200x200*2"); 542 UpdateDisplay("200x200*2");
541 UpdateDisplay("200x200*2, 500x400#600x500|500x400%60.0f"); 543 UpdateDisplay("200x200*2, 500x400#600x500|500x400%60.0f");
542 // Update key as the 2nd display gets new id. 544 // Update key as the 2nd display gets new id.
543 id2 = display_manager()->GetSecondaryDisplay().id(); 545 id2 = display_manager()->GetSecondaryDisplay().id();
544 key = base::Int64ToString(id1) + "," + base::Int64ToString(id2); 546 key = base::Int64ToString(id1) + "," + base::Int64ToString(id2);
545 EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); 547 EXPECT_TRUE(displays->GetDictionary(key, &layout_value));
546 EXPECT_TRUE(layout_value->GetString(kPositionKey, &position)); 548 EXPECT_TRUE(layout_value->GetString(kPositionKey, &position));
547 EXPECT_EQ("right", position); 549 EXPECT_EQ("right", position);
548 EXPECT_TRUE(layout_value->GetInteger(kOffsetKey, &offset)); 550 EXPECT_TRUE(layout_value->GetInteger(kOffsetKey, &offset));
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 TEST_F(DisplayPreferencesTest, RestoreColorProfiles) { 684 TEST_F(DisplayPreferencesTest, RestoreColorProfiles) {
683 int64_t id1 = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 685 int64_t id1 = display::Screen::GetScreen()->GetPrimaryDisplay().id();
684 686
685 StoreColorProfile(id1, "dynamic"); 687 StoreColorProfile(id1, "dynamic");
686 688
687 LoggedInAsUser(); 689 LoggedInAsUser();
688 LoadDisplayPreferences(false); 690 LoadDisplayPreferences(false);
689 691
690 // id1's available color profiles list is empty, means somehow the color 692 // id1's available color profiles list is empty, means somehow the color
691 // profile suport is temporary in trouble. 693 // profile suport is temporary in trouble.
692 EXPECT_NE(ui::COLOR_PROFILE_DYNAMIC, 694 EXPECT_NE(display::COLOR_PROFILE_DYNAMIC,
693 display_manager()->GetDisplayInfo(id1).color_profile()); 695 display_manager()->GetDisplayInfo(id1).color_profile());
694 696
695 // Once the profile is supported, the color profile should be restored. 697 // Once the profile is supported, the color profile should be restored.
696 std::vector<ui::ColorCalibrationProfile> profiles; 698 std::vector<display::ColorCalibrationProfile> profiles;
697 profiles.push_back(ui::COLOR_PROFILE_STANDARD); 699 profiles.push_back(display::COLOR_PROFILE_STANDARD);
698 profiles.push_back(ui::COLOR_PROFILE_DYNAMIC); 700 profiles.push_back(display::COLOR_PROFILE_DYNAMIC);
699 profiles.push_back(ui::COLOR_PROFILE_MOVIE); 701 profiles.push_back(display::COLOR_PROFILE_MOVIE);
700 profiles.push_back(ui::COLOR_PROFILE_READING); 702 profiles.push_back(display::COLOR_PROFILE_READING);
701 display::test::DisplayManagerTestApi( 703 display::test::DisplayManagerTestApi(
702 ash::Shell::GetInstance()->display_manager()) 704 ash::Shell::GetInstance()->display_manager())
703 .SetAvailableColorProfiles(id1, profiles); 705 .SetAvailableColorProfiles(id1, profiles);
704 706
705 LoadDisplayPreferences(false); 707 LoadDisplayPreferences(false);
706 EXPECT_EQ(ui::COLOR_PROFILE_DYNAMIC, 708 EXPECT_EQ(display::COLOR_PROFILE_DYNAMIC,
707 display_manager()->GetDisplayInfo(id1).color_profile()); 709 display_manager()->GetDisplayInfo(id1).color_profile());
708 } 710 }
709 711
710 TEST_F(DisplayPreferencesTest, DontStoreInGuestMode) { 712 TEST_F(DisplayPreferencesTest, DontStoreInGuestMode) {
711 ash::WindowTreeHostManager* window_tree_host_manager = 713 ash::WindowTreeHostManager* window_tree_host_manager =
712 ash::Shell::GetInstance()->window_tree_host_manager(); 714 ash::Shell::GetInstance()->window_tree_host_manager();
713 715
714 UpdateDisplay("200x200*2,200x200"); 716 UpdateDisplay("200x200*2,200x200");
715 717
716 LoggedInAsGuest(); 718 LoggedInAsGuest();
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
1154 1156
1155 EXPECT_EQ(gfx::Rect(0, 0, 200, 200), 1157 EXPECT_EQ(gfx::Rect(0, 0, 200, 200),
1156 display_manager()->GetDisplayForId(list[0]).bounds()); 1158 display_manager()->GetDisplayForId(list[0]).bounds());
1157 EXPECT_EQ(gfx::Rect(-200, 0, 200, 200), 1159 EXPECT_EQ(gfx::Rect(-200, 0, 200, 200),
1158 display_manager()->GetDisplayForId(list[1]).bounds()); 1160 display_manager()->GetDisplayForId(list[1]).bounds());
1159 EXPECT_EQ(gfx::Rect(-100, 200, 300, 300), 1161 EXPECT_EQ(gfx::Rect(-100, 200, 300, 300),
1160 display_manager()->GetDisplayForId(list[2]).bounds()); 1162 display_manager()->GetDisplayForId(list[2]).bounds());
1161 } 1163 }
1162 1164
1163 } // namespace chromeos 1165 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/display/display_preferences.cc ('k') | chrome/browser/chromeos/display/output_protection_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698