Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/oobe_display_chooser_browsertest.cc

Issue 2885153004: React to primary display change instead of removal (Closed)
Patch Set: Add browser test to verify that the change caught the issue Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 // If the login display is still showing, exit gracefully.
35 if (LoginDisplayHost::default_host()) {
jdufault 2017/05/23 01:44:31 Shouldn't this be consistent every test run?
Felix Ekblom 2017/05/23 06:47:25 You're right, this extra complexity originating fr
36 base::ThreadTaskRunnerHandle::Get()->PostTask(
37 FROM_HERE, base::Bind(&chrome::AttemptExit));
38 content::RunMessageLoop();
39 }
40
41 OobeBaseTest::TearDownOnMainThread();
42 }
43
44 private:
45 DISALLOW_COPY_AND_ASSIGN(OobeDisplayChooserTest);
46 };
47
48 display::DisplayManager* display_manager() {
49 return ash::Shell::Get()->display_manager();
50 }
51
52 int64_t GetPrimaryDisplay() {
53 return display::Screen::GetScreen()->GetPrimaryDisplay().id();
54 }
55
56 } // namespace
57
58 // Test that display removal does not trigger CHECK in
59 // WindowTreeHostManager::GetPrimaryDisplayId().
60 IN_PROC_BROWSER_TEST_F(OobeDisplayChooserTest,
61 RemovingPrimaryDisplaySanityCheck) {
62 display::ManagedDisplayInfo info1(1, "x-1", false);
63 info1.SetBounds(gfx::Rect(0, 0, 1280, 800));
64 display::ManagedDisplayInfo info2(2, "x-2", false);
65 std::vector<display::ManagedDisplayInfo> info_list;
66 info2.SetBounds(gfx::Rect(0, 1280, 1280, 800));
67 info_list.push_back(info1);
68 info_list.push_back(info2);
69
70 display_manager()->OnNativeDisplaysChanged(info_list);
71 base::RunLoop().RunUntilIdle();
72 EXPECT_EQ(1, GetPrimaryDisplay());
73
74 info_list.erase(info_list.begin());
75 display_manager()->OnNativeDisplaysChanged(info_list);
76 base::RunLoop().RunUntilIdle();
77 EXPECT_EQ(2, GetPrimaryDisplay());
78 }
79
80 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698