| 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/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 EXPECT_EQ(1, GetToastSerial()); | 121 EXPECT_EQ(1, GetToastSerial()); |
| 122 | 122 |
| 123 EXPECT_FALSE(GetCurrentWidget()->GetLayer()->GetAnimator()->is_animating()); | 123 EXPECT_FALSE(GetCurrentWidget()->GetLayer()->GetAnimator()->is_animating()); |
| 124 | 124 |
| 125 ClickDismissButton(); | 125 ClickDismissButton(); |
| 126 | 126 |
| 127 EXPECT_EQ(nullptr, GetCurrentOverlay()); | 127 EXPECT_EQ(nullptr, GetCurrentOverlay()); |
| 128 } | 128 } |
| 129 | 129 |
| 130 TEST_F(ToastManagerTest, ShowAndCloseManuallyDuringAnimation) { | 130 TEST_F(ToastManagerTest, ShowAndCloseManuallyDuringAnimation) { |
| 131 // TODO: gets wedged running animator. http://crbug.com/698016. |
| 132 if (WmShell::Get()->IsRunningInMash()) |
| 133 return; |
| 134 |
| 131 ui::ScopedAnimationDurationScaleMode slow_animation_duration( | 135 ui::ScopedAnimationDurationScaleMode slow_animation_duration( |
| 132 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION); | 136 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION); |
| 133 | 137 |
| 134 ShowToast("DUMMY", ToastData::kInfiniteDuration); | 138 ShowToast("DUMMY", ToastData::kInfiniteDuration); |
| 135 EXPECT_TRUE(GetCurrentWidget()->GetLayer()->GetAnimator()->is_animating()); | 139 EXPECT_TRUE(GetCurrentWidget()->GetLayer()->GetAnimator()->is_animating()); |
| 136 base::RunLoop().RunUntilIdle(); | 140 base::RunLoop().RunUntilIdle(); |
| 137 | 141 |
| 138 EXPECT_EQ(1, GetToastSerial()); | 142 EXPECT_EQ(1, GetToastSerial()); |
| 139 EXPECT_TRUE(GetCurrentWidget()->GetLayer()->GetAnimator()->is_animating()); | 143 EXPECT_TRUE(GetCurrentWidget()->GetLayer()->GetAnimator()->is_animating()); |
| 140 | 144 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 EXPECT_EQ(root_bounds.bottom() - 5, toast_bounds.bottom()); | 252 EXPECT_EQ(root_bounds.bottom() - 5, toast_bounds.bottom()); |
| 249 | 253 |
| 250 gfx::Rect shelf_bounds = shelf->GetIdealBounds(); | 254 gfx::Rect shelf_bounds = shelf->GetIdealBounds(); |
| 251 EXPECT_FALSE(toast_bounds.Intersects(shelf_bounds)); | 255 EXPECT_FALSE(toast_bounds.Intersects(shelf_bounds)); |
| 252 EXPECT_NEAR( | 256 EXPECT_NEAR( |
| 253 shelf_bounds.right() + (root_bounds.width() - shelf_bounds.width()) / 2.0, | 257 shelf_bounds.right() + (root_bounds.width() - shelf_bounds.width()) / 2.0, |
| 254 precise_toast_bounds.CenterPoint().x(), 1.f /* accepted error */); | 258 precise_toast_bounds.CenterPoint().x(), 1.f /* accepted error */); |
| 255 } | 259 } |
| 256 | 260 |
| 257 TEST_F(ToastManagerTest, PositionWithUnifiedDesktop) { | 261 TEST_F(ToastManagerTest, PositionWithUnifiedDesktop) { |
| 262 // TODO: needs unified mode. http://crbug.com/698024. |
| 263 if (WmShell::Get()->IsRunningInMash()) |
| 264 return; |
| 265 |
| 258 display_manager()->SetUnifiedDesktopEnabled(true); | 266 display_manager()->SetUnifiedDesktopEnabled(true); |
| 259 UpdateDisplay("1000x500,0+600-100x500"); | 267 UpdateDisplay("1000x500,0+600-100x500"); |
| 260 | 268 |
| 261 WmShelf* shelf = GetPrimaryShelf(); | 269 WmShelf* shelf = GetPrimaryShelf(); |
| 262 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->GetAlignment()); | 270 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->GetAlignment()); |
| 263 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 271 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
| 264 | 272 |
| 265 ShowToast("DUMMY", ToastData::kInfiniteDuration); | 273 ShowToast("DUMMY", ToastData::kInfiniteDuration); |
| 266 EXPECT_EQ(1, GetToastSerial()); | 274 EXPECT_EQ(1, GetToastSerial()); |
| 267 | 275 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 296 EXPECT_EQ(base::ASCIIToUTF16("TEXT3"), GetCurrentText()); | 304 EXPECT_EQ(base::ASCIIToUTF16("TEXT3"), GetCurrentText()); |
| 297 // Cancel the shown toast. | 305 // Cancel the shown toast. |
| 298 CancelToast(id3); | 306 CancelToast(id3); |
| 299 // Confirm that the shown toast disappears. | 307 // Confirm that the shown toast disappears. |
| 300 EXPECT_FALSE(GetCurrentOverlay()); | 308 EXPECT_FALSE(GetCurrentOverlay()); |
| 301 // Confirm that only 1 toast is shown. | 309 // Confirm that only 1 toast is shown. |
| 302 EXPECT_EQ(2, GetToastSerial()); | 310 EXPECT_EQ(2, GetToastSerial()); |
| 303 } | 311 } |
| 304 | 312 |
| 305 } // namespace ash | 313 } // namespace ash |
| OLD | NEW |