Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1981)

Unified Diff: ash/system/toast/toast_manager_unittest.cc

Issue 1841563003: ARC Toast: Prevent onClosed event from being called multiple times (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ash/system/toast/toast_overlay.h » ('j') | ash/system/toast/toast_overlay.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/toast/toast_manager_unittest.cc
diff --git a/ash/system/toast/toast_manager_unittest.cc b/ash/system/toast/toast_manager_unittest.cc
index 99d4ad0b2b92e1ac14614216654f5f00d8cf6839..0aa8c6a76ad63381584349c19ecbd2fbaa759cb8 100644
--- a/ash/system/toast/toast_manager_unittest.cc
+++ b/ash/system/toast/toast_manager_unittest.cc
@@ -10,6 +10,8 @@
#include "ash/system/toast/toast_manager.h"
#include "ash/test/ash_test_base.h"
#include "base/run_loop.h"
+#include "ui/compositor/scoped_animation_duration_scale_mode.h"
+#include "ui/compositor/scoped_layer_animation_settings.h"
namespace ash {
@@ -35,6 +37,8 @@ class ToastManagerTest : public test::AshTestBase {
manager_->ResetToastIdForTesting();
EXPECT_EQ(0, GetToastId());
+ test_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode(
+ ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION));
}
protected:
@@ -78,6 +82,8 @@ class ToastManagerTest : public test::AshTestBase {
private:
ToastManager* manager_ = nullptr;
+ scoped_ptr<ui::ScopedAnimationDurationScaleMode> test_duration_mode_;
+
DISALLOW_COPY_AND_ASSIGN(ToastManagerTest);
};
@@ -97,6 +103,26 @@ TEST_F(ToastManagerTest, ShowAndCloseManually) {
EXPECT_EQ(1, GetToastId());
+ while (GetCurrentWidget()->GetLayer()->GetAnimator()->is_animating())
+ base::RunLoop().RunUntilIdle();
+
+ ClickDismissButton();
+
+ while (GetCurrentOverlay() != nullptr)
+ base::RunLoop().RunUntilIdle();
+}
+
+TEST_F(ToastManagerTest, ShowAndCloseManuallyDuringAnimation) {
+ ui::ScopedAnimationDurationScaleMode slow_animation_duration(
+ ui::ScopedAnimationDurationScaleMode::SLOW_DURATION);
+
+ manager()->Show("DUMMY", kLongLongDuration /* prevent timeout */);
+ base::RunLoop().RunUntilIdle();
+
+ EXPECT_EQ(1, GetToastId());
+ EXPECT_TRUE(GetCurrentWidget()->GetLayer()->GetAnimator()->is_animating());
+
+ // Close it during animation.
ClickDismissButton();
while (GetCurrentOverlay() != nullptr)
« no previous file with comments | « no previous file | ash/system/toast/toast_overlay.h » ('j') | ash/system/toast/toast_overlay.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698