| 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 "ash/display/display_configuration_controller.h" |
| 8 #include "ash/shell.h" |
| 9 #include "ash/test/ash_test_base.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "ui/display/display.h" |
| 12 #include "ui/display/display_observer.h" |
| 13 #include "ui/display/manager/display_manager.h" |
| 14 #include "ui/display/screen.h" |
| 15 #include "ui/display/test/display_manager_test_api.h" |
| 16 |
| 17 namespace chromeos { |
| 18 |
| 19 namespace { |
| 20 |
| 21 class OobeDisplayChooserTest : public ash::test::AshTestBase { |
| 22 public: |
| 23 OobeDisplayChooserTest() : ash::test::AshTestBase() {} |
| 24 |
| 25 void SetUp() override { |
| 26 ash::test::AshTestBase::SetUp(); |
| 27 display_manager_test_api_.reset( |
| 28 new display::test::DisplayManagerTestApi(display_manager())); |
| 29 } |
| 30 |
| 31 void EnableTouch(int64_t id) { |
| 32 display_manager_test_api_->SetTouchSupport( |
| 33 id, display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE); |
| 34 } |
| 35 |
| 36 void DisableTouch(int64_t id) { |
| 37 display_manager_test_api_->SetTouchSupport( |
| 38 id, display::Display::TouchSupport::TOUCH_SUPPORT_UNAVAILABLE); |
| 39 } |
| 40 |
| 41 int64_t GetPrimaryDisplay() { |
| 42 return display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 43 } |
| 44 |
| 45 private: |
| 46 std::unique_ptr<display::test::DisplayManagerTestApi> |
| 47 display_manager_test_api_; |
| 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(OobeDisplayChooserTest); |
| 50 }; |
| 51 |
| 52 } // namespace |
| 53 |
| 54 TEST_F(OobeDisplayChooserTest, PreferTouchAsPrimary) { |
| 55 OobeDisplayChooser display_chooser; |
| 56 |
| 57 UpdateDisplay("3000x2000,800x600"); |
| 58 display::DisplayIdList ids = display_manager()->GetCurrentDisplayIdList(); |
| 59 DisableTouch(ids[0]); |
| 60 EnableTouch(ids[1]); |
| 61 |
| 62 EXPECT_EQ(ids[0], GetPrimaryDisplay()); |
| 63 display_chooser.TryToPlaceUiOnTouchDisplay(); |
| 64 |
| 65 EXPECT_EQ(ids[1], GetPrimaryDisplay()); |
| 66 } |
| 67 |
| 68 TEST_F(OobeDisplayChooserTest, AddingSecondTouchDisplayShouldbeNOP) { |
| 69 OobeDisplayChooser display_chooser; |
| 70 |
| 71 UpdateDisplay("3000x2000,800x600"); |
| 72 display::DisplayIdList ids = display_manager()->GetCurrentDisplayIdList(); |
| 73 EnableTouch(ids[0]); |
| 74 EnableTouch(ids[1]); |
| 75 |
| 76 EXPECT_EQ(ids[0], GetPrimaryDisplay()); |
| 77 display_chooser.TryToPlaceUiOnTouchDisplay(); |
| 78 |
| 79 EXPECT_EQ(ids[0], GetPrimaryDisplay()); |
| 80 } |
| 81 |
| 82 } // namespace chromeos |
| OLD | NEW |