| 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/display/display_manager.h" | 5 #include "ash/display/display_manager.h" |
| 6 #include "ash/screen_util.h" | 6 #include "ash/screen_util.h" |
| 7 #include "ash/shelf/shelf.h" | 7 #include "ash/shelf/shelf.h" |
| 8 #include "ash/shelf/shelf_constants.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" |
| 15 | 16 |
| 16 namespace ash { | 17 namespace ash { |
| 17 | 18 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 | 191 |
| 191 ShowToast("DUMMY", kLongLongDuration /* prevent timeout */); | 192 ShowToast("DUMMY", kLongLongDuration /* prevent timeout */); |
| 192 EXPECT_EQ(1, GetToastSerial()); | 193 EXPECT_EQ(1, GetToastSerial()); |
| 193 | 194 |
| 194 gfx::Rect toast_bounds = GetCurrentWidget()->GetWindowBoundsInScreen(); | 195 gfx::Rect toast_bounds = GetCurrentWidget()->GetWindowBoundsInScreen(); |
| 195 gfx::Rect root_bounds = | 196 gfx::Rect root_bounds = |
| 196 ScreenUtil::GetShelfDisplayBoundsInRoot(Shell::GetPrimaryRootWindow()); | 197 ScreenUtil::GetShelfDisplayBoundsInRoot(Shell::GetPrimaryRootWindow()); |
| 197 | 198 |
| 198 EXPECT_TRUE(toast_bounds.Intersects(shelf->user_work_area_bounds())); | 199 EXPECT_TRUE(toast_bounds.Intersects(shelf->user_work_area_bounds())); |
| 199 EXPECT_NEAR(root_bounds.CenterPoint().x(), toast_bounds.CenterPoint().x(), 1); | 200 EXPECT_NEAR(root_bounds.CenterPoint().x(), toast_bounds.CenterPoint().x(), 1); |
| 200 EXPECT_EQ(root_bounds.bottom() - ShelfLayoutManager::kAutoHideSize - 5, | 201 EXPECT_EQ(root_bounds.bottom() - kAutoHideSize - 5, toast_bounds.bottom()); |
| 201 toast_bounds.bottom()); | |
| 202 } | 202 } |
| 203 | 203 |
| 204 TEST_F(ToastManagerTest, PositionWithHiddenBottomShelf) { | 204 TEST_F(ToastManagerTest, PositionWithHiddenBottomShelf) { |
| 205 ShelfLayoutManager* shelf = | 205 ShelfLayoutManager* shelf = |
| 206 Shelf::ForPrimaryDisplay()->shelf_layout_manager(); | 206 Shelf::ForPrimaryDisplay()->shelf_layout_manager(); |
| 207 SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); | 207 SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
| 208 SetShelfAlignment(wm::SHELF_ALIGNMENT_BOTTOM); | 208 SetShelfAlignment(wm::SHELF_ALIGNMENT_BOTTOM); |
| 209 SetShelfState(ash::SHELF_HIDDEN); | 209 SetShelfState(ash::SHELF_HIDDEN); |
| 210 | 210 |
| 211 ShowToast("DUMMY", kLongLongDuration /* prevent timeout */); | 211 ShowToast("DUMMY", kLongLongDuration /* prevent timeout */); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 EXPECT_EQ("TEXT3", GetCurrentText()); | 299 EXPECT_EQ("TEXT3", GetCurrentText()); |
| 300 // Cancel the shown toast. | 300 // Cancel the shown toast. |
| 301 CancelToast(id3); | 301 CancelToast(id3); |
| 302 // Confirm that the shown toast disappears. | 302 // Confirm that the shown toast disappears. |
| 303 EXPECT_FALSE(GetCurrentOverlay()); | 303 EXPECT_FALSE(GetCurrentOverlay()); |
| 304 // Confirm that only 1 toast is shown. | 304 // Confirm that only 1 toast is shown. |
| 305 EXPECT_EQ(2, GetToastSerial()); | 305 EXPECT_EQ(2, GetToastSerial()); |
| 306 } | 306 } |
| 307 | 307 |
| 308 } // namespace ash | 308 } // namespace ash |
| OLD | NEW |