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/shell.h" |
| 8 #include "base/run_loop.h" |
| 9 #include "chrome/browser/chromeos/login/test/oobe_base_test.h" |
| 10 #include "chrome/browser/lifetime/application_lifetime.h" |
| 11 #include "chromeos/chromeos_switches.h" |
| 12 #include "ui/display/display.h" |
| 13 #include "ui/display/manager/display_manager.h" |
| 14 #include "ui/display/manager/managed_display_info.h" |
| 15 #include "ui/display/screen.h" |
| 16 #include "ui/display/test/display_manager_test_api.h" |
| 17 |
| 18 namespace chromeos { |
| 19 |
| 20 namespace { |
| 21 |
| 22 class OobeDisplayChooserTest : public OobeBaseTest { |
| 23 public: |
| 24 OobeDisplayChooserTest() {} |
| 25 ~OobeDisplayChooserTest() override {} |
| 26 |
| 27 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 28 command_line->AppendSwitch(switches::kOobeSkipPostLogin); |
| 29 |
| 30 OobeBaseTest::SetUpCommandLine(command_line); |
| 31 } |
| 32 |
| 33 private: |
| 34 DISALLOW_COPY_AND_ASSIGN(OobeDisplayChooserTest); |
| 35 }; |
| 36 |
| 37 display::DisplayManager* display_manager() { |
| 38 return ash::Shell::Get()->display_manager(); |
| 39 } |
| 40 |
| 41 int64_t GetPrimaryDisplayId() { |
| 42 return display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 43 } |
| 44 |
| 45 } // namespace |
| 46 |
| 47 // Test that display removal does not trigger CHECK in |
| 48 // WindowTreeHostManager::GetPrimaryDisplayId(). |
| 49 IN_PROC_BROWSER_TEST_F(OobeDisplayChooserTest, |
| 50 RemovingPrimaryDisplaySanityCheck) { |
| 51 display::ManagedDisplayInfo info1(1, "x-1", false); |
| 52 info1.SetBounds(gfx::Rect(0, 0, 1280, 800)); |
| 53 display::ManagedDisplayInfo info2(2, "x-2", false); |
| 54 std::vector<display::ManagedDisplayInfo> info_list; |
| 55 info2.SetBounds(gfx::Rect(0, 1280, 1280, 800)); |
| 56 info_list.push_back(info1); |
| 57 info_list.push_back(info2); |
| 58 |
| 59 display_manager()->OnNativeDisplaysChanged(info_list); |
| 60 base::RunLoop().RunUntilIdle(); |
| 61 EXPECT_EQ(1, GetPrimaryDisplayId()); |
| 62 |
| 63 info_list.erase(info_list.begin()); |
| 64 display_manager()->OnNativeDisplaysChanged(info_list); |
| 65 base::RunLoop().RunUntilIdle(); |
| 66 EXPECT_EQ(2, GetPrimaryDisplayId()); |
| 67 } |
| 68 |
| 69 } // namespace chromeos |
OLD | NEW |