| 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 "ui/compositor/scoped_animation_duration_scale_mode.h" | 14 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 14 | 15 |
| 15 namespace ash { | 16 namespace ash { |
| 16 | 17 |
| 17 // Long duration so the timeout doesn't occur. | 18 // Long duration so the timeout doesn't occur. |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 181 |
| 181 manager()->Show("DUMMY", kLongLongDuration /* prevent timeout */); | 182 manager()->Show("DUMMY", kLongLongDuration /* prevent timeout */); |
| 182 EXPECT_EQ(1, GetToastId()); | 183 EXPECT_EQ(1, GetToastId()); |
| 183 | 184 |
| 184 gfx::Rect toast_bounds = GetCurrentWidget()->GetWindowBoundsInScreen(); | 185 gfx::Rect toast_bounds = GetCurrentWidget()->GetWindowBoundsInScreen(); |
| 185 gfx::Rect root_bounds = | 186 gfx::Rect root_bounds = |
| 186 ScreenUtil::GetShelfDisplayBoundsInRoot(Shell::GetPrimaryRootWindow()); | 187 ScreenUtil::GetShelfDisplayBoundsInRoot(Shell::GetPrimaryRootWindow()); |
| 187 | 188 |
| 188 EXPECT_TRUE(toast_bounds.Intersects(shelf->user_work_area_bounds())); | 189 EXPECT_TRUE(toast_bounds.Intersects(shelf->user_work_area_bounds())); |
| 189 EXPECT_NEAR(root_bounds.CenterPoint().x(), toast_bounds.CenterPoint().x(), 1); | 190 EXPECT_NEAR(root_bounds.CenterPoint().x(), toast_bounds.CenterPoint().x(), 1); |
| 190 EXPECT_EQ(root_bounds.bottom() - ShelfLayoutManager::kAutoHideSize - 5, | 191 EXPECT_EQ(root_bounds.bottom() - kAutoHideSize - 5, toast_bounds.bottom()); |
| 191 toast_bounds.bottom()); | |
| 192 } | 192 } |
| 193 | 193 |
| 194 TEST_F(ToastManagerTest, PositionWithHiddenBottomShelf) { | 194 TEST_F(ToastManagerTest, PositionWithHiddenBottomShelf) { |
| 195 ShelfLayoutManager* shelf = | 195 ShelfLayoutManager* shelf = |
| 196 Shelf::ForPrimaryDisplay()->shelf_layout_manager(); | 196 Shelf::ForPrimaryDisplay()->shelf_layout_manager(); |
| 197 SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); | 197 SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
| 198 SetShelfAlignment(wm::SHELF_ALIGNMENT_BOTTOM); | 198 SetShelfAlignment(wm::SHELF_ALIGNMENT_BOTTOM); |
| 199 SetShelfState(ash::SHELF_HIDDEN); | 199 SetShelfState(ash::SHELF_HIDDEN); |
| 200 | 200 |
| 201 manager()->Show("DUMMY", kLongLongDuration /* prevent timeout */); | 201 manager()->Show("DUMMY", kLongLongDuration /* prevent timeout */); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 // doesn't return correct value. | 266 // doesn't return correct value. |
| 267 gfx::Rect shelf_bounds = shelf->GetIdealBounds(); | 267 gfx::Rect shelf_bounds = shelf->GetIdealBounds(); |
| 268 EXPECT_FALSE(toast_bounds.Intersects(shelf_bounds)); | 268 EXPECT_FALSE(toast_bounds.Intersects(shelf_bounds)); |
| 269 EXPECT_EQ(shelf_bounds.y() - 5, toast_bounds.bottom()); | 269 EXPECT_EQ(shelf_bounds.y() - 5, toast_bounds.bottom()); |
| 270 EXPECT_EQ(root_bounds.bottom() - shelf_bounds.height() - 5, | 270 EXPECT_EQ(root_bounds.bottom() - shelf_bounds.height() - 5, |
| 271 toast_bounds.bottom()); | 271 toast_bounds.bottom()); |
| 272 } | 272 } |
| 273 } | 273 } |
| 274 | 274 |
| 275 } // namespace ash | 275 } // namespace ash |
| OLD | NEW |