James Cook | 40f7d75 | 2018-05-25 18:21:58 | [diff] [blame] | 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 "ash/shell_state.h" |
| 6 | |
| 7 | #include <stdint.h> |
| 8 | |
James Cook | 40f7d75 | 2018-05-25 18:21:58 | [diff] [blame] | 9 | #include "ash/scoped_root_window_for_new_windows.h" |
| 10 | #include "ash/shell.h" |
| 11 | #include "ash/test/ash_test_base.h" |
James Cook | 7363ebc | 2018-08-10 21:17:24 | [diff] [blame] | 12 | #include "ui/display/display.h" |
James Cook | 40f7d75 | 2018-05-25 18:21:58 | [diff] [blame] | 13 | #include "ui/display/manager/display_manager.h" |
James Cook | 7363ebc | 2018-08-10 21:17:24 | [diff] [blame] | 14 | #include "ui/display/screen.h" |
James Cook | 40f7d75 | 2018-05-25 18:21:58 | [diff] [blame] | 15 | |
| 16 | namespace ash { |
| 17 | namespace { |
| 18 | |
James Cook | 40f7d75 | 2018-05-25 18:21:58 | [diff] [blame] | 19 | using ShellStateTest = AshTestBase; |
| 20 | |
James Cook | 7363ebc | 2018-08-10 21:17:24 | [diff] [blame] | 21 | TEST_F(ShellStateTest, GetDisplayForNewWindows) { |
James Cook | 40f7d75 | 2018-05-25 18:21:58 | [diff] [blame] | 22 | UpdateDisplay("1024x768,800x600"); |
| 23 | const int64_t primary_display_id = display_manager()->GetDisplayAt(0).id(); |
| 24 | const int64_t secondary_display_id = display_manager()->GetDisplayAt(1).id(); |
| 25 | |
James Cook | 7363ebc | 2018-08-10 21:17:24 | [diff] [blame] | 26 | display::Screen* screen = display::Screen::GetScreen(); |
| 27 | EXPECT_EQ(primary_display_id, screen->GetDisplayForNewWindows().id()); |
James Cook | 40f7d75 | 2018-05-25 18:21:58 | [diff] [blame] | 28 | |
| 29 | // Setting a root window for new windows notifies the client. |
| 30 | ScopedRootWindowForNewWindows scoped_root(Shell::GetAllRootWindows()[1]); |
James Cook | 7363ebc | 2018-08-10 21:17:24 | [diff] [blame] | 31 | EXPECT_EQ(secondary_display_id, screen->GetDisplayForNewWindows().id()); |
James Cook | 40f7d75 | 2018-05-25 18:21:58 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | } // namespace |
| 35 | } // namespace ash |