Chromium Code Reviews| 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 class OobeDisplayChooserTest : public ash::test::AshTestBase { | |
|
jdufault
2017/05/08 17:44:58
Put test fixture in anonymous namespace.
| |
| 20 protected: | |
|
jdufault
2017/05/08 17:44:58
protected => public/private, add DISALLOW_COPY_AND
| |
| 21 void SetUp() override { | |
| 22 ash::test::AshTestBase::SetUp(); | |
| 23 display_manager_test_api_.reset( | |
| 24 new display::test::DisplayManagerTestApi(display_manager())); | |
| 25 } | |
| 26 | |
| 27 void TearDown() override { ash::test::AshTestBase::TearDown(); } | |
|
jdufault
2017/05/08 17:44:58
Remove?
| |
| 28 | |
| 29 void EnableTouch(int64_t id) { | |
| 30 display_manager_test_api_->SetTouchSupport( | |
| 31 id, display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE); | |
| 32 } | |
| 33 | |
| 34 void DisableTouch(int64_t id) { | |
| 35 display_manager_test_api_->SetTouchSupport( | |
| 36 id, display::Display::TouchSupport::TOUCH_SUPPORT_UNAVAILABLE); | |
| 37 } | |
| 38 | |
| 39 int64_t GetPrimaryDisplay() { | |
| 40 return display::Screen::GetScreen()->GetPrimaryDisplay().id(); | |
| 41 } | |
| 42 | |
| 43 std::unique_ptr<display::test::DisplayManagerTestApi> | |
| 44 display_manager_test_api_; | |
| 45 }; | |
| 46 | |
| 47 TEST_F(OobeDisplayChooserTest, PreferTouchAsPrimary) { | |
| 48 std::unique_ptr<OobeDisplayChooser> display_chooser( | |
| 49 OobeDisplayChooser::CreateDefault()); | |
| 50 | |
| 51 UpdateDisplay("3000x2000,800x600"); | |
| 52 auto ids = display_manager()->GetCurrentDisplayIdList(); | |
| 53 DisableTouch(ids[0]); | |
| 54 EnableTouch(ids[1]); | |
| 55 | |
| 56 EXPECT_EQ(ids[0], GetPrimaryDisplay()); | |
| 57 display_chooser->TryToPlaceUIOnTouchDisplay(); | |
| 58 | |
| 59 EXPECT_EQ(ids[1], GetPrimaryDisplay()); | |
| 60 } | |
| 61 | |
| 62 TEST_F(OobeDisplayChooserTest, AddingSecondTouchDisplayShouldbeNOP) { | |
| 63 std::unique_ptr<OobeDisplayChooser> display_chooser( | |
| 64 OobeDisplayChooser::CreateDefault()); | |
| 65 | |
| 66 UpdateDisplay("3000x2000,800x600"); | |
| 67 auto ids = display_manager()->GetCurrentDisplayIdList(); | |
| 68 EnableTouch(ids[0]); | |
| 69 EnableTouch(ids[1]); | |
| 70 | |
| 71 EXPECT_EQ(ids[0], GetPrimaryDisplay()); | |
| 72 display_chooser->TryToPlaceUIOnTouchDisplay(); | |
| 73 | |
| 74 EXPECT_EQ(ids[0], GetPrimaryDisplay()); | |
| 75 } | |
| 76 | |
| 77 TEST_F(OobeDisplayChooserTest, PreferTouchAsPrimaryOnDisplayAdded) { | |
| 78 std::unique_ptr<OobeDisplayChooser> display_chooser( | |
| 79 OobeDisplayChooser::CreateDefault()); | |
| 80 UpdateDisplay("3000x2000,800x600"); | |
| 81 auto ids = display_manager()->GetCurrentDisplayIdList(); | |
|
jdufault
2017/05/08 17:44:58
nit: auto type is not obvious (for this entire fil
| |
| 82 DisableTouch(ids[0]); | |
| 83 EnableTouch(ids[1]); | |
| 84 | |
| 85 EXPECT_EQ(ids[0], GetPrimaryDisplay()); | |
| 86 display_chooser->OnDisplayAdded(display_manager()->GetDisplayForId(ids[1])); | |
| 87 | |
| 88 EXPECT_EQ(ids[1], GetPrimaryDisplay()); | |
| 89 } | |
| 90 | |
| 91 TEST_F(OobeDisplayChooserTest, | |
| 92 AddingSecondTouchDisplayShouldbeNOPOnDisplayAdded) { | |
| 93 std::unique_ptr<OobeDisplayChooser> display_chooser( | |
| 94 OobeDisplayChooser::CreateDefault()); | |
| 95 UpdateDisplay("3000x2000,800x600,800x600"); | |
| 96 auto ids = display_manager()->GetCurrentDisplayIdList(); | |
| 97 DisableTouch(ids[0]); | |
| 98 EnableTouch(ids[1]); | |
| 99 EnableTouch(ids[2]); | |
| 100 ash::Shell::Get()->display_configuration_controller()->SetPrimaryDisplayId( | |
| 101 ids[1]); | |
| 102 | |
| 103 EXPECT_EQ(ids[1], GetPrimaryDisplay()); | |
| 104 display_chooser->OnDisplayAdded(display_manager()->GetDisplayForId(ids[2])); | |
| 105 EXPECT_EQ(ids[1], GetPrimaryDisplay()); | |
| 106 } | |
| 107 | |
| 108 } // namespace chromeos | |
| OLD | NEW |