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/display/display_manager.h" | 7 #include "ash/display/display_manager.h" |
8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
9 #include "ash/shelf/shelf_layout_manager.h" | 9 #include "ash/shelf/shelf_layout_manager.h" |
10 #include "ash/shelf/shelf_widget.h" | 10 #include "ash/shelf/shelf_widget.h" |
11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
12 #include "ash/test/ash_test_base.h" | 12 #include "ash/test/ash_test_base.h" |
13 #include "ash/test/display_manager_test_api.h" | |
14 #include "ash/wm/window_util.h" | 13 #include "ash/wm/window_util.h" |
15 #include "ui/aura/env.h" | 14 #include "ui/aura/env.h" |
16 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
17 #include "ui/aura/window_event_dispatcher.h" | 16 #include "ui/aura/window_event_dispatcher.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 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 EXPECT_EQ( | 110 EXPECT_EQ( |
112 "650,50 100x100", | 111 "650,50 100x100", |
113 ScreenUtil::ConvertRectToScreen( | 112 ScreenUtil::ConvertRectToScreen( |
114 secondary->GetNativeView(), gfx::Rect(40, 40, 100, 100)).ToString()); | 113 secondary->GetNativeView(), gfx::Rect(40, 40, 100, 100)).ToString()); |
115 } | 114 } |
116 | 115 |
117 TEST_F(ScreenUtilTest, ShelfDisplayBoundsInUnifiedDesktop) { | 116 TEST_F(ScreenUtilTest, ShelfDisplayBoundsInUnifiedDesktop) { |
118 if (!SupportsMultipleDisplays()) | 117 if (!SupportsMultipleDisplays()) |
119 return; | 118 return; |
120 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 119 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
121 DisplayManagerTestApi test_api(display_manager); | 120 display_manager->SetDefaultMultiDisplayMode(DisplayManager::UNIFIED); |
122 test_api.SetDefaultMultiDisplayMode(DisplayManager::UNIFIED); | |
123 display_manager->SetMultiDisplayMode(DisplayManager::UNIFIED); | 121 display_manager->SetMultiDisplayMode(DisplayManager::UNIFIED); |
124 | 122 |
125 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( | 123 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( |
126 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100)); | 124 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100)); |
127 | 125 |
128 UpdateDisplay("500x400"); | 126 UpdateDisplay("500x400"); |
129 EXPECT_EQ("0,0 500x400", ScreenUtil::GetShelfDisplayBoundsInScreen( | 127 EXPECT_EQ("0,0 500x400", ScreenUtil::GetShelfDisplayBoundsInScreen( |
130 widget->GetNativeWindow()).ToString()); | 128 widget->GetNativeWindow()).ToString()); |
131 | 129 |
132 UpdateDisplay("500x400,600x400"); | 130 UpdateDisplay("500x400,600x400"); |
133 EXPECT_EQ("0,0 500x400", ScreenUtil::GetShelfDisplayBoundsInScreen( | 131 EXPECT_EQ("0,0 500x400", ScreenUtil::GetShelfDisplayBoundsInScreen( |
134 widget->GetNativeWindow()).ToString()); | 132 widget->GetNativeWindow()).ToString()); |
135 | 133 |
136 // Move to the 2nd physical display. Shelf's display still should be | 134 // Move to the 2nd physical display. Shelf's display still should be |
137 // the first. | 135 // the first. |
138 widget->SetBounds(gfx::Rect(800, 0, 100, 100)); | 136 widget->SetBounds(gfx::Rect(800, 0, 100, 100)); |
139 ASSERT_EQ("800,0 100x100", widget->GetWindowBoundsInScreen().ToString()); | 137 ASSERT_EQ("800,0 100x100", widget->GetWindowBoundsInScreen().ToString()); |
140 | 138 |
141 EXPECT_EQ("0,0 500x400", ScreenUtil::GetShelfDisplayBoundsInScreen( | 139 EXPECT_EQ("0,0 500x400", ScreenUtil::GetShelfDisplayBoundsInScreen( |
142 widget->GetNativeWindow()).ToString()); | 140 widget->GetNativeWindow()).ToString()); |
143 | 141 |
144 UpdateDisplay("600x500"); | 142 UpdateDisplay("600x500"); |
145 EXPECT_EQ("0,0 600x500", ScreenUtil::GetShelfDisplayBoundsInScreen( | 143 EXPECT_EQ("0,0 600x500", ScreenUtil::GetShelfDisplayBoundsInScreen( |
146 widget->GetNativeWindow()).ToString()); | 144 widget->GetNativeWindow()).ToString()); |
147 } | 145 } |
148 | 146 |
149 } // namespace test | 147 } // namespace test |
150 } // namespace ash | 148 } // namespace ash |
OLD | NEW |