OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/screen_util.h" | 5 #include "ash/screen_util.h" |
6 | 6 |
7 #include "ash/common/wm/wm_screen_util.h" | 7 #include "ash/common/wm/wm_screen_util.h" |
8 #include "ash/common/wm_lookup.h" | 8 #include "ash/common/wm_lookup.h" |
9 #include "ash/common/wm_window.h" | 9 #include "ash/common/wm_window.h" |
10 #include "ash/display/display_manager.h" | |
11 #include "ash/shell.h" | 10 #include "ash/shell.h" |
12 #include "ash/test/ash_md_test_base.h" | 11 #include "ash/test/ash_md_test_base.h" |
13 #include "ash/test/display_manager_test_api.h" | |
14 #include "ash/wm/window_util.h" | 12 #include "ash/wm/window_util.h" |
15 #include "ui/aura/env.h" | 13 #include "ui/aura/env.h" |
16 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
17 #include "ui/aura/window_event_dispatcher.h" | 15 #include "ui/aura/window_event_dispatcher.h" |
| 16 #include "ui/display/manager/display_manager.h" |
18 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
19 #include "ui/views/widget/widget_delegate.h" | 18 #include "ui/views/widget/widget_delegate.h" |
20 | 19 |
21 namespace ash { | 20 namespace ash { |
22 namespace test { | 21 namespace test { |
23 | 22 |
24 using ScreenUtilTest = AshMDTestBase; | 23 using ScreenUtilTest = AshMDTestBase; |
25 | 24 |
26 INSTANTIATE_TEST_CASE_P( | 25 INSTANTIATE_TEST_CASE_P( |
27 /* prefix intentionally left blank due to only one parameterization */, | 26 /* prefix intentionally left blank due to only one parameterization */, |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 .ToString()); | 118 .ToString()); |
120 EXPECT_EQ("650,50 100x100", | 119 EXPECT_EQ("650,50 100x100", |
121 ScreenUtil::ConvertRectToScreen(secondary->GetNativeView(), | 120 ScreenUtil::ConvertRectToScreen(secondary->GetNativeView(), |
122 gfx::Rect(40, 40, 100, 100)) | 121 gfx::Rect(40, 40, 100, 100)) |
123 .ToString()); | 122 .ToString()); |
124 } | 123 } |
125 | 124 |
126 TEST_P(ScreenUtilTest, ShelfDisplayBoundsInUnifiedDesktop) { | 125 TEST_P(ScreenUtilTest, ShelfDisplayBoundsInUnifiedDesktop) { |
127 if (!SupportsMultipleDisplays()) | 126 if (!SupportsMultipleDisplays()) |
128 return; | 127 return; |
129 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | |
130 | 128 |
131 display_manager->SetUnifiedDesktopEnabled(true); | 129 display_manager()->SetUnifiedDesktopEnabled(true); |
132 | 130 |
133 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( | 131 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( |
134 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100)); | 132 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100)); |
135 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget); | 133 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget); |
136 | 134 |
137 UpdateDisplay("500x400"); | 135 UpdateDisplay("500x400"); |
138 EXPECT_EQ("0,0 500x400", wm::GetDisplayBoundsWithShelf(window).ToString()); | 136 EXPECT_EQ("0,0 500x400", wm::GetDisplayBoundsWithShelf(window).ToString()); |
139 | 137 |
140 UpdateDisplay("500x400,600x400"); | 138 UpdateDisplay("500x400,600x400"); |
141 EXPECT_EQ("0,0 500x400", wm::GetDisplayBoundsWithShelf(window).ToString()); | 139 EXPECT_EQ("0,0 500x400", wm::GetDisplayBoundsWithShelf(window).ToString()); |
142 | 140 |
143 // Move to the 2nd physical display. Shelf's display still should be | 141 // Move to the 2nd physical display. Shelf's display still should be |
144 // the first. | 142 // the first. |
145 widget->SetBounds(gfx::Rect(800, 0, 100, 100)); | 143 widget->SetBounds(gfx::Rect(800, 0, 100, 100)); |
146 ASSERT_EQ("800,0 100x100", widget->GetWindowBoundsInScreen().ToString()); | 144 ASSERT_EQ("800,0 100x100", widget->GetWindowBoundsInScreen().ToString()); |
147 | 145 |
148 EXPECT_EQ("0,0 500x400", wm::GetDisplayBoundsWithShelf(window).ToString()); | 146 EXPECT_EQ("0,0 500x400", wm::GetDisplayBoundsWithShelf(window).ToString()); |
149 | 147 |
150 UpdateDisplay("600x500"); | 148 UpdateDisplay("600x500"); |
151 EXPECT_EQ("0,0 600x500", wm::GetDisplayBoundsWithShelf(window).ToString()); | 149 EXPECT_EQ("0,0 600x500", wm::GetDisplayBoundsWithShelf(window).ToString()); |
152 } | 150 } |
153 | 151 |
154 } // namespace test | 152 } // namespace test |
155 } // namespace ash | 153 } // namespace ash |
OLD | NEW |