| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.h" |
| 6 |
| 7 #include <memory> |
| 8 |
| 9 #include "ash/display/display_configuration_controller.h" |
| 10 #include "ash/shell.h" |
| 11 #include "ash/test/ash_test_base.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "ui/display/display.h" |
| 14 #include "ui/display/display_observer.h" |
| 15 #include "ui/display/manager/display_manager.h" |
| 16 #include "ui/display/screen.h" |
| 17 #include "ui/display/test/display_manager_test_api.h" |
| 18 |
| 19 namespace chromeos { |
| 20 |
| 21 namespace { |
| 22 |
| 23 class OobeDisplayChooserTest : public ash::test::AshTestBase { |
| 24 public: |
| 25 OobeDisplayChooserTest() : ash::test::AshTestBase() {} |
| 26 |
| 27 void SetUp() override { |
| 28 ash::test::AshTestBase::SetUp(); |
| 29 display_manager_test_api_.reset( |
| 30 new display::test::DisplayManagerTestApi(display_manager())); |
| 31 } |
| 32 |
| 33 void EnableTouch(int64_t id) { |
| 34 display_manager_test_api_->SetTouchSupport( |
| 35 id, display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE); |
| 36 } |
| 37 |
| 38 void DisableTouch(int64_t id) { |
| 39 display_manager_test_api_->SetTouchSupport( |
| 40 id, display::Display::TouchSupport::TOUCH_SUPPORT_UNAVAILABLE); |
| 41 } |
| 42 |
| 43 int64_t GetPrimaryDisplay() { |
| 44 return display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 45 } |
| 46 |
| 47 private: |
| 48 std::unique_ptr<display::test::DisplayManagerTestApi> |
| 49 display_manager_test_api_; |
| 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(OobeDisplayChooserTest); |
| 52 }; |
| 53 |
| 54 } // namespace |
| 55 |
| 56 TEST_F(OobeDisplayChooserTest, PreferTouchAsPrimary) { |
| 57 OobeDisplayChooser display_chooser; |
| 58 |
| 59 UpdateDisplay("3000x2000,800x600"); |
| 60 display::DisplayIdList ids = display_manager()->GetCurrentDisplayIdList(); |
| 61 DisableTouch(ids[0]); |
| 62 EnableTouch(ids[1]); |
| 63 |
| 64 EXPECT_EQ(ids[0], GetPrimaryDisplay()); |
| 65 display_chooser.TryToPlaceUiOnTouchDisplay(); |
| 66 |
| 67 EXPECT_EQ(ids[1], GetPrimaryDisplay()); |
| 68 } |
| 69 |
| 70 TEST_F(OobeDisplayChooserTest, AddingSecondTouchDisplayShouldbeNOP) { |
| 71 OobeDisplayChooser display_chooser; |
| 72 |
| 73 UpdateDisplay("3000x2000,800x600"); |
| 74 display::DisplayIdList ids = display_manager()->GetCurrentDisplayIdList(); |
| 75 EnableTouch(ids[0]); |
| 76 EnableTouch(ids[1]); |
| 77 |
| 78 EXPECT_EQ(ids[0], GetPrimaryDisplay()); |
| 79 display_chooser.TryToPlaceUiOnTouchDisplay(); |
| 80 |
| 81 EXPECT_EQ(ids[0], GetPrimaryDisplay()); |
| 82 } |
| 83 |
| 84 } // namespace chromeos |
| OLD | NEW |