| 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/system/toast/toast_manager.h" | 5 #include "ash/system/toast/toast_manager.h" |
| 6 |
| 7 #include "ash/public/cpp/config.h" |
| 6 #include "ash/shelf/shelf_constants.h" | 8 #include "ash/shelf/shelf_constants.h" |
| 7 #include "ash/shelf/wm_shelf.h" | 9 #include "ash/shelf/wm_shelf.h" |
| 8 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 9 #include "ash/shell_port.h" | |
| 10 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
| 11 #include "ash/wm/wm_screen_util.h" | 12 #include "ash/wm/wm_screen_util.h" |
| 12 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 13 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 14 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 16 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 17 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 17 #include "ui/display/manager/display_manager.h" | 18 #include "ui/display/manager/display_manager.h" |
| 18 #include "ui/views/widget/widget.h" | 19 #include "ui/views/widget/widget.h" |
| 19 | 20 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 123 |
| 123 EXPECT_FALSE(GetCurrentWidget()->GetLayer()->GetAnimator()->is_animating()); | 124 EXPECT_FALSE(GetCurrentWidget()->GetLayer()->GetAnimator()->is_animating()); |
| 124 | 125 |
| 125 ClickDismissButton(); | 126 ClickDismissButton(); |
| 126 | 127 |
| 127 EXPECT_EQ(nullptr, GetCurrentOverlay()); | 128 EXPECT_EQ(nullptr, GetCurrentOverlay()); |
| 128 } | 129 } |
| 129 | 130 |
| 130 TEST_F(ToastManagerTest, ShowAndCloseManuallyDuringAnimation) { | 131 TEST_F(ToastManagerTest, ShowAndCloseManuallyDuringAnimation) { |
| 131 // TODO: gets wedged running animator. http://crbug.com/698016. | 132 // TODO: gets wedged running animator. http://crbug.com/698016. |
| 132 if (ShellPort::Get()->IsRunningInMash()) | 133 if (Shell::GetAshConfig() == Config::MASH) |
| 133 return; | 134 return; |
| 134 | 135 |
| 135 ui::ScopedAnimationDurationScaleMode slow_animation_duration( | 136 ui::ScopedAnimationDurationScaleMode slow_animation_duration( |
| 136 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION); | 137 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION); |
| 137 | 138 |
| 138 ShowToast("DUMMY", ToastData::kInfiniteDuration); | 139 ShowToast("DUMMY", ToastData::kInfiniteDuration); |
| 139 EXPECT_TRUE(GetCurrentWidget()->GetLayer()->GetAnimator()->is_animating()); | 140 EXPECT_TRUE(GetCurrentWidget()->GetLayer()->GetAnimator()->is_animating()); |
| 140 base::RunLoop().RunUntilIdle(); | 141 base::RunLoop().RunUntilIdle(); |
| 141 | 142 |
| 142 EXPECT_EQ(1, GetToastSerial()); | 143 EXPECT_EQ(1, GetToastSerial()); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 | 254 |
| 254 gfx::Rect shelf_bounds = shelf->GetIdealBounds(); | 255 gfx::Rect shelf_bounds = shelf->GetIdealBounds(); |
| 255 EXPECT_FALSE(toast_bounds.Intersects(shelf_bounds)); | 256 EXPECT_FALSE(toast_bounds.Intersects(shelf_bounds)); |
| 256 EXPECT_NEAR( | 257 EXPECT_NEAR( |
| 257 shelf_bounds.right() + (root_bounds.width() - shelf_bounds.width()) / 2.0, | 258 shelf_bounds.right() + (root_bounds.width() - shelf_bounds.width()) / 2.0, |
| 258 precise_toast_bounds.CenterPoint().x(), 1.f /* accepted error */); | 259 precise_toast_bounds.CenterPoint().x(), 1.f /* accepted error */); |
| 259 } | 260 } |
| 260 | 261 |
| 261 TEST_F(ToastManagerTest, PositionWithUnifiedDesktop) { | 262 TEST_F(ToastManagerTest, PositionWithUnifiedDesktop) { |
| 262 // TODO: needs unified mode. http://crbug.com/698024. | 263 // TODO: needs unified mode. http://crbug.com/698024. |
| 263 if (ShellPort::Get()->IsRunningInMash()) | 264 if (Shell::GetAshConfig() == Config::MASH) |
| 264 return; | 265 return; |
| 265 | 266 |
| 266 display_manager()->SetUnifiedDesktopEnabled(true); | 267 display_manager()->SetUnifiedDesktopEnabled(true); |
| 267 UpdateDisplay("1000x500,0+600-100x500"); | 268 UpdateDisplay("1000x500,0+600-100x500"); |
| 268 | 269 |
| 269 WmShelf* shelf = GetPrimaryShelf(); | 270 WmShelf* shelf = GetPrimaryShelf(); |
| 270 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->GetAlignment()); | 271 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->GetAlignment()); |
| 271 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 272 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
| 272 | 273 |
| 273 ShowToast("DUMMY", ToastData::kInfiniteDuration); | 274 ShowToast("DUMMY", ToastData::kInfiniteDuration); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 304 EXPECT_EQ(base::ASCIIToUTF16("TEXT3"), GetCurrentText()); | 305 EXPECT_EQ(base::ASCIIToUTF16("TEXT3"), GetCurrentText()); |
| 305 // Cancel the shown toast. | 306 // Cancel the shown toast. |
| 306 CancelToast(id3); | 307 CancelToast(id3); |
| 307 // Confirm that the shown toast disappears. | 308 // Confirm that the shown toast disappears. |
| 308 EXPECT_FALSE(GetCurrentOverlay()); | 309 EXPECT_FALSE(GetCurrentOverlay()); |
| 309 // Confirm that only 1 toast is shown. | 310 // Confirm that only 1 toast is shown. |
| 310 EXPECT_EQ(2, GetToastSerial()); | 311 EXPECT_EQ(2, GetToastSerial()); |
| 311 } | 312 } |
| 312 | 313 |
| 313 } // namespace ash | 314 } // namespace ash |
| OLD | NEW |