OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/common/shelf/shelf_constants.h" | 5 #include "ash/common/shelf/shelf_constants.h" |
6 #include "ash/common/shelf/wm_shelf.h" | 6 #include "ash/common/shelf/wm_shelf.h" |
7 #include "ash/common/system/toast/toast_manager.h" | 7 #include "ash/common/system/toast/toast_manager.h" |
8 #include "ash/common/wm/wm_screen_util.h" | 8 #include "ash/common/wm/wm_screen_util.h" |
9 #include "ash/common/wm_shell.h" | 9 #include "ash/common/wm_shell.h" |
10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 | 226 |
227 gfx::Rect toast_bounds = GetCurrentWidget()->GetWindowBoundsInScreen(); | 227 gfx::Rect toast_bounds = GetCurrentWidget()->GetWindowBoundsInScreen(); |
228 gfx::RectF precise_toast_bounds(toast_bounds); | 228 gfx::RectF precise_toast_bounds(toast_bounds); |
229 gfx::Rect root_bounds = wm::GetDisplayBoundsWithShelf(shelf->GetWindow()); | 229 gfx::Rect root_bounds = wm::GetDisplayBoundsWithShelf(shelf->GetWindow()); |
230 | 230 |
231 EXPECT_TRUE(toast_bounds.Intersects(shelf->GetUserWorkAreaBounds())); | 231 EXPECT_TRUE(toast_bounds.Intersects(shelf->GetUserWorkAreaBounds())); |
232 EXPECT_EQ(root_bounds.bottom() - 5, toast_bounds.bottom()); | 232 EXPECT_EQ(root_bounds.bottom() - 5, toast_bounds.bottom()); |
233 | 233 |
234 gfx::Rect shelf_bounds = shelf->GetIdealBounds(); | 234 gfx::Rect shelf_bounds = shelf->GetIdealBounds(); |
235 EXPECT_FALSE(toast_bounds.Intersects(shelf_bounds)); | 235 EXPECT_FALSE(toast_bounds.Intersects(shelf_bounds)); |
236 EXPECT_EQ(round(shelf_bounds.right() + | 236 EXPECT_NEAR( |
237 (root_bounds.width() - shelf_bounds.width()) / 2.0), | 237 shelf_bounds.right() + (root_bounds.width() - shelf_bounds.width()) / 2.0, |
238 round(precise_toast_bounds.CenterPoint().x())); | 238 precise_toast_bounds.CenterPoint().x(), 1.f /* accepted error */); |
239 } | 239 } |
240 | 240 |
241 TEST_F(ToastManagerTest, PositionWithUnifiedDesktop) { | 241 TEST_F(ToastManagerTest, PositionWithUnifiedDesktop) { |
242 if (!SupportsMultipleDisplays()) | 242 if (!SupportsMultipleDisplays()) |
243 return; | 243 return; |
244 | 244 |
245 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 245 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
246 display_manager->SetUnifiedDesktopEnabled(true); | 246 display_manager->SetUnifiedDesktopEnabled(true); |
247 UpdateDisplay("1000x500,0+600-100x500"); | 247 UpdateDisplay("1000x500,0+600-100x500"); |
248 | 248 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 EXPECT_EQ(base::ASCIIToUTF16("TEXT3"), GetCurrentText()); | 284 EXPECT_EQ(base::ASCIIToUTF16("TEXT3"), GetCurrentText()); |
285 // Cancel the shown toast. | 285 // Cancel the shown toast. |
286 CancelToast(id3); | 286 CancelToast(id3); |
287 // Confirm that the shown toast disappears. | 287 // Confirm that the shown toast disappears. |
288 EXPECT_FALSE(GetCurrentOverlay()); | 288 EXPECT_FALSE(GetCurrentOverlay()); |
289 // Confirm that only 1 toast is shown. | 289 // Confirm that only 1 toast is shown. |
290 EXPECT_EQ(2, GetToastSerial()); | 290 EXPECT_EQ(2, GetToastSerial()); |
291 } | 291 } |
292 | 292 |
293 } // namespace ash | 293 } // namespace ash |
OLD | NEW |