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/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 void TearDownOnMainThread() override { | |
| 34 base::ThreadTaskRunnerHandle::Get()->PostTask( | |
| 35 FROM_HERE, base::Bind(&chrome::AttemptExit)); | |
|
oshima
2017/05/23 14:45:39
Do you know why you need this?
Felix Ekblom
2017/05/23 15:40:02
No, and I don't strictly know _if_ I need it. It l
| |
| 36 content::RunMessageLoop(); | |
| 37 | |
| 38 OobeBaseTest::TearDownOnMainThread(); | |
| 39 } | |
| 40 | |
| 41 private: | |
| 42 DISALLOW_COPY_AND_ASSIGN(OobeDisplayChooserTest); | |
| 43 }; | |
| 44 | |
| 45 display::DisplayManager* display_manager() { | |
| 46 return ash::Shell::Get()->display_manager(); | |
| 47 } | |
| 48 | |
| 49 int64_t GetPrimaryDisplay() { | |
| 50 return display::Screen::GetScreen()->GetPrimaryDisplay().id(); | |
| 51 } | |
| 52 | |
| 53 } // namespace | |
| 54 | |
| 55 // Test that display removal does not trigger CHECK in | |
| 56 // WindowTreeHostManager::GetPrimaryDisplayId(). | |
| 57 IN_PROC_BROWSER_TEST_F(OobeDisplayChooserTest, | |
| 58 RemovingPrimaryDisplaySanityCheck) { | |
| 59 display::ManagedDisplayInfo info1(1, "x-1", false); | |
| 60 info1.SetBounds(gfx::Rect(0, 0, 1280, 800)); | |
| 61 display::ManagedDisplayInfo info2(2, "x-2", false); | |
| 62 std::vector<display::ManagedDisplayInfo> info_list; | |
| 63 info2.SetBounds(gfx::Rect(0, 1280, 1280, 800)); | |
| 64 info_list.push_back(info1); | |
| 65 info_list.push_back(info2); | |
| 66 | |
| 67 display_manager()->OnNativeDisplaysChanged(info_list); | |
| 68 base::RunLoop().RunUntilIdle(); | |
| 69 EXPECT_EQ(1, GetPrimaryDisplay()); | |
| 70 | |
| 71 info_list.erase(info_list.begin()); | |
| 72 display_manager()->OnNativeDisplaysChanged(info_list); | |
| 73 base::RunLoop().RunUntilIdle(); | |
| 74 EXPECT_EQ(2, GetPrimaryDisplay()); | |
| 75 } | |
| 76 | |
| 77 } // namespace chromeos | |
| OLD | NEW |