| 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/display/display_manager.h" | 6 #include "ash/display/display_manager.h" |
| 6 #include "ash/screen_util.h" | 7 #include "ash/screen_util.h" |
| 7 #include "ash/shelf/shelf.h" | 8 #include "ash/shelf/shelf.h" |
| 8 #include "ash/shelf/shelf_layout_manager.h" | 9 #include "ash/shelf/shelf_layout_manager.h" |
| 9 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 10 #include "ash/system/toast/toast_manager.h" | 11 #include "ash/system/toast/toast_manager.h" |
| 11 #include "ash/test/ash_test_base.h" | 12 #include "ash/test/ash_test_base.h" |
| 12 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 14 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 15 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 | 200 |
| 200 ShowToast("DUMMY", ToastData::kInfiniteDuration); | 201 ShowToast("DUMMY", ToastData::kInfiniteDuration); |
| 201 EXPECT_EQ(1, GetToastSerial()); | 202 EXPECT_EQ(1, GetToastSerial()); |
| 202 | 203 |
| 203 gfx::Rect toast_bounds = GetCurrentWidget()->GetWindowBoundsInScreen(); | 204 gfx::Rect toast_bounds = GetCurrentWidget()->GetWindowBoundsInScreen(); |
| 204 gfx::Rect root_bounds = | 205 gfx::Rect root_bounds = |
| 205 ScreenUtil::GetShelfDisplayBoundsInRoot(Shell::GetPrimaryRootWindow()); | 206 ScreenUtil::GetShelfDisplayBoundsInRoot(Shell::GetPrimaryRootWindow()); |
| 206 | 207 |
| 207 EXPECT_TRUE(toast_bounds.Intersects(shelf->user_work_area_bounds())); | 208 EXPECT_TRUE(toast_bounds.Intersects(shelf->user_work_area_bounds())); |
| 208 EXPECT_NEAR(root_bounds.CenterPoint().x(), toast_bounds.CenterPoint().x(), 1); | 209 EXPECT_NEAR(root_bounds.CenterPoint().x(), toast_bounds.CenterPoint().x(), 1); |
| 209 EXPECT_EQ(root_bounds.bottom() - ShelfLayoutManager::kAutoHideSize - 5, | 210 EXPECT_EQ(root_bounds.bottom() - kShelfAutoHideSize - 5, |
| 210 toast_bounds.bottom()); | 211 toast_bounds.bottom()); |
| 211 } | 212 } |
| 212 | 213 |
| 213 TEST_F(ToastManagerTest, PositionWithHiddenBottomShelf) { | 214 TEST_F(ToastManagerTest, PositionWithHiddenBottomShelf) { |
| 214 ShelfLayoutManager* shelf = | 215 ShelfLayoutManager* shelf = |
| 215 Shelf::ForPrimaryDisplay()->shelf_layout_manager(); | 216 Shelf::ForPrimaryDisplay()->shelf_layout_manager(); |
| 216 SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); | 217 SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
| 217 SetShelfAlignment(SHELF_ALIGNMENT_BOTTOM); | 218 SetShelfAlignment(SHELF_ALIGNMENT_BOTTOM); |
| 218 SetShelfState(ash::SHELF_HIDDEN); | 219 SetShelfState(ash::SHELF_HIDDEN); |
| 219 | 220 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 EXPECT_EQ("TEXT3", GetCurrentText()); | 309 EXPECT_EQ("TEXT3", GetCurrentText()); |
| 309 // Cancel the shown toast. | 310 // Cancel the shown toast. |
| 310 CancelToast(id3); | 311 CancelToast(id3); |
| 311 // Confirm that the shown toast disappears. | 312 // Confirm that the shown toast disappears. |
| 312 EXPECT_FALSE(GetCurrentOverlay()); | 313 EXPECT_FALSE(GetCurrentOverlay()); |
| 313 // Confirm that only 1 toast is shown. | 314 // Confirm that only 1 toast is shown. |
| 314 EXPECT_EQ(2, GetToastSerial()); | 315 EXPECT_EQ(2, GetToastSerial()); |
| 315 } | 316 } |
| 316 | 317 |
| 317 } // namespace ash | 318 } // namespace ash |
| OLD | NEW |