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

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

Powered by Google App Engine
This is Rietveld 408576698