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

Side by Side Diff: ash/display/display_manager_unittest.cc

Issue 2540383002: Updates display manager and display preferences to handle touch calibration data. (Closed)
Patch Set: Merge with ToT Created 4 years 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/display/display_preferences.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ui/display/manager/display_manager.h" 5 #include "ui/display/manager/display_manager.h"
6 6
7 #include "ash/accelerators/accelerator_commands_aura.h" 7 #include "ash/accelerators/accelerator_commands_aura.h"
8 #include "ash/common/material_design/material_design_controller.h" 8 #include "ash/common/material_design/material_design_controller.h"
9 #include "ash/common/wm/window_state.h" 9 #include "ash/common/wm/window_state.h"
10 #include "ash/display/display_configuration_controller.h" 10 #include "ash/display/display_configuration_controller.h"
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(1, 0, 0, 0)); 621 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(1, 0, 0, 0));
622 EXPECT_EQ(1u, changed().size()); 622 EXPECT_EQ(1u, changed().size());
623 EXPECT_EQ(display2_id, changed()[0].id()); 623 EXPECT_EQ(display2_id, changed()[0].id());
624 624
625 reset(); 625 reset();
626 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(0, 0, 0, 0)); 626 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(0, 0, 0, 0));
627 EXPECT_EQ(1u, changed().size()); 627 EXPECT_EQ(1u, changed().size());
628 EXPECT_EQ(display2_id, changed()[0].id()); 628 EXPECT_EQ(display2_id, changed()[0].id());
629 } 629 }
630 630
631 #if defined(OS_CHROMEOS)
632 TEST_P(DisplayManagerTest, TouchCalibrationTest) {
633 if (!SupportsMultipleDisplays())
634 return;
635
636 UpdateDisplay("0+0-500x500,0+501-1024x600");
637 reset();
638
639 ASSERT_EQ(2u, display_manager()->GetNumDisplays());
640 const display::ManagedDisplayInfo display_info1 = GetDisplayInfoAt(0);
641 const display::ManagedDisplayInfo display_info2 = GetDisplayInfoAt(1);
642
643 EXPECT_FALSE(display_info2.has_touch_calibration_data());
644
645 display::TouchCalibrationData::CalibrationPointPairQuad point_pair_quad = {
646 {std::make_pair(gfx::Point(50, 50), gfx::Point(43, 51)),
647 std::make_pair(gfx::Point(950, 50), gfx::Point(975, 45)),
648 std::make_pair(gfx::Point(50, 550), gfx::Point(48, 534)),
649 std::make_pair(gfx::Point(950, 550), gfx::Point(967, 574))}};
650 gfx::Size bounds_at_calibration(display_info2.size_in_pixel());
651 const display::TouchCalibrationData touch_data(point_pair_quad,
652 bounds_at_calibration);
653
654 // Set the touch calibration data for the secondary display.
655 display_manager()->SetTouchCalibrationData(
656 display_info2.id(), point_pair_quad, bounds_at_calibration);
657
658 display::ManagedDisplayInfo updated_display_info2 = GetDisplayInfoAt(1);
659 EXPECT_TRUE(updated_display_info2.has_touch_calibration_data());
660 EXPECT_EQ(touch_data, updated_display_info2.GetTouchCalibrationData());
661
662 // Clearing touch calibration data from the secondary display.
663 display_manager()->ClearTouchCalibrationData(display_info2.id());
664 updated_display_info2 = GetDisplayInfoAt(1);
665 EXPECT_FALSE(updated_display_info2.has_touch_calibration_data());
666
667 // Make sure that SetTouchCalibrationData() is idempotent.
668 display::TouchCalibrationData::CalibrationPointPairQuad point_pair_quad_2 =
669 point_pair_quad;
670 point_pair_quad_2[1] =
671 std::make_pair(gfx::Point(950, 50), gfx::Point(975, 53));
672 display::TouchCalibrationData touch_data_2(point_pair_quad_2,
673 bounds_at_calibration);
674 display_manager()->SetTouchCalibrationData(
675 display_info2.id(), point_pair_quad_2, bounds_at_calibration);
676
677 updated_display_info2 = GetDisplayInfoAt(1);
678 EXPECT_TRUE(updated_display_info2.has_touch_calibration_data());
679 EXPECT_EQ(touch_data_2, updated_display_info2.GetTouchCalibrationData());
680
681 display_manager()->SetTouchCalibrationData(
682 display_info2.id(), point_pair_quad, bounds_at_calibration);
683 EXPECT_TRUE(updated_display_info2.has_touch_calibration_data());
684 EXPECT_EQ(touch_data_2, updated_display_info2.GetTouchCalibrationData());
685
686 // Recreate a new 2nd display. It won't apply the touhc calibration data
687 // because the new display has a different ID.
688 UpdateDisplay("0+0-500x500");
689 UpdateDisplay("0+0-500x500,0+501-400x400");
690 EXPECT_FALSE(GetDisplayInfoAt(1).has_touch_calibration_data());
691
692 // Recreate the displays with the same ID. It should apply the touch
693 // calibration associated data.
694 UpdateDisplay("0+0-500x500");
695 std::vector<display::ManagedDisplayInfo> display_info_list;
696 display_info_list.push_back(display_info1);
697 display_info_list.push_back(display_info2);
698 display_manager()->OnNativeDisplaysChanged(display_info_list);
699 updated_display_info2 = GetDisplayInfoAt(1);
700
701 EXPECT_FALSE(updated_display_info2.has_touch_calibration_data());
702 EXPECT_EQ(touch_data, updated_display_info2.GetTouchCalibrationData());
703 }
704 #endif // defined(OS_CHROMEOS)
705
631 #if !defined(OS_WIN) 706 #if !defined(OS_WIN)
632 // Disabled on windows because of http://crbug.com/650326. 707 // Disabled on windows because of http://crbug.com/650326.
633 TEST_P(DisplayManagerTest, TestDeviceScaleOnlyChange) { 708 TEST_P(DisplayManagerTest, TestDeviceScaleOnlyChange) {
634 UpdateDisplay("1000x600"); 709 UpdateDisplay("1000x600");
635 aura::WindowTreeHost* host = Shell::GetPrimaryRootWindow()->GetHost(); 710 aura::WindowTreeHost* host = Shell::GetPrimaryRootWindow()->GetHost();
636 EXPECT_EQ(1, host->compositor()->device_scale_factor()); 711 EXPECT_EQ(1, host->compositor()->device_scale_factor());
637 EXPECT_EQ("1000x600", 712 EXPECT_EQ("1000x600",
638 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); 713 Shell::GetPrimaryRootWindow()->bounds().size().ToString());
639 EXPECT_EQ("1 0 0", GetCountSummary()); 714 EXPECT_EQ("1 0 0", GetCountSummary());
640 715
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after
1464 // the internal display. 1539 // the internal display.
1465 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScalingNoOverride) { 1540 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScalingNoOverride) {
1466 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1541 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1467 1542
1468 display_id++; 1543 display_id++;
1469 display::test::ScopedSetInternalDisplayId set_internal(display_manager(), 1544 display::test::ScopedSetInternalDisplayId set_internal(display_manager(),
1470 display_id); 1545 display_id);
1471 const gfx::Insets dummy_overscan_insets; 1546 const gfx::Insets dummy_overscan_insets;
1472 display_manager()->RegisterDisplayProperty( 1547 display_manager()->RegisterDisplayProperty(
1473 display_id, display::Display::ROTATE_0, 1.0f, &dummy_overscan_insets, 1548 display_id, display::Display::ROTATE_0, 1.0f, &dummy_overscan_insets,
1474 gfx::Size(), 1.0f, ui::ColorCalibrationProfile()); 1549 gfx::Size(), 1.0f, ui::ColorCalibrationProfile(), nullptr);
1475 1550
1476 // Setup the display modes with UI-scale. 1551 // Setup the display modes with UI-scale.
1477 display::ManagedDisplayInfo native_display_info = 1552 display::ManagedDisplayInfo native_display_info =
1478 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080)); 1553 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080));
1479 native_display_info.set_device_scale_factor(1.25); 1554 native_display_info.set_device_scale_factor(1.25);
1480 1555
1481 const scoped_refptr<display::ManagedDisplayMode>& base_mode( 1556 const scoped_refptr<display::ManagedDisplayMode>& base_mode(
1482 new display::ManagedDisplayMode(gfx::Size(1920, 1080), 60.0f, false, 1557 new display::ManagedDisplayMode(gfx::Size(1920, 1080), 60.0f, false,
1483 false)); 1558 false));
1484 display::ManagedDisplayInfo::ManagedDisplayModeList mode_list = 1559 display::ManagedDisplayInfo::ManagedDisplayModeList mode_list =
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after
2422 2497
2423 ASSERT_DOUBLE_EQ( 2498 ASSERT_DOUBLE_EQ(
2424 1.25f, 2499 1.25f,
2425 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 2500 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
2426 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); 2501 EXPECT_TRUE(IsTextSubpixelPositioningEnabled());
2427 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); 2502 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
2428 } 2503 }
2429 2504
2430 TEST_P(DisplayManagerTest, CheckInitializationOfRotationProperty) { 2505 TEST_P(DisplayManagerTest, CheckInitializationOfRotationProperty) {
2431 int64_t id = display_manager()->GetDisplayAt(0).id(); 2506 int64_t id = display_manager()->GetDisplayAt(0).id();
2432 display_manager()->RegisterDisplayProperty(id, display::Display::ROTATE_90, 2507 display_manager()->RegisterDisplayProperty(
2433 1.0f, nullptr, gfx::Size(), 1.0f, 2508 id, display::Display::ROTATE_90, 1.0f, nullptr, gfx::Size(), 1.0f,
2434 ui::COLOR_PROFILE_STANDARD); 2509 ui::COLOR_PROFILE_STANDARD, nullptr);
2435 2510
2436 const display::ManagedDisplayInfo& info = 2511 const display::ManagedDisplayInfo& info =
2437 display_manager()->GetDisplayInfo(id); 2512 display_manager()->GetDisplayInfo(id);
2438 2513
2439 EXPECT_EQ(display::Display::ROTATE_90, 2514 EXPECT_EQ(display::Display::ROTATE_90,
2440 info.GetRotation(display::Display::ROTATION_SOURCE_USER)); 2515 info.GetRotation(display::Display::ROTATION_SOURCE_USER));
2441 EXPECT_EQ(display::Display::ROTATE_90, 2516 EXPECT_EQ(display::Display::ROTATE_90,
2442 info.GetRotation(display::Display::ROTATION_SOURCE_ACTIVE)); 2517 info.GetRotation(display::Display::ROTATION_SOURCE_ACTIVE));
2443 } 2518 }
2444 2519
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2482 const display::DisplayLayout& stored = 2557 const display::DisplayLayout& stored =
2483 layout_store->GetRegisteredDisplayLayout(list); 2558 layout_store->GetRegisteredDisplayLayout(list);
2484 2559
2485 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id); 2560 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id);
2486 EXPECT_EQ(id2, stored.placement_list[0].display_id); 2561 EXPECT_EQ(id2, stored.placement_list[0].display_id);
2487 } 2562 }
2488 2563
2489 #endif // OS_CHROMEOS 2564 #endif // OS_CHROMEOS
2490 2565
2491 } // namespace ash 2566 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/display/display_preferences.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698