summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-30 14:59:38 +0000
committerjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-30 14:59:38 +0000
commitc41f5f4305fcac07b94d7f9100db49dc57edf806 (patch)
tree69038353f79f1dc5809f4c0fd0c578c0bd039231
parent9333526c498584579f0ecb82a6097e40c3a05cd7 (diff)
downloadchromium_src-c41f5f4305fcac07b94d7f9100db49dc57edf806.zip
chromium_src-c41f5f4305fcac07b94d7f9100db49dc57edf806.tar.gz
chromium_src-c41f5f4305fcac07b94d7f9100db49dc57edf806.tar.bz2
Reland: Introduce NON_ZERO_DURATION for animation unit tests
Animations are usually disabled in unit tests for performance. However, to test the animation system itself some tests request "normal" durations. Under some conditions (remote desktop, animation disabled for accessibility) the "normal" duration could still be zero. This was causing test failures and use-after-frees in ash_unittests on the drmemory bots and for developers using remote desktop. Introduce NON_ZERO_DURATION to signal that animation must be enabled and the duration must be non-zero, but other than that can be as short as possible. (Original patch https://codereview.chromium.org/420013002/ was correlated with app_list_unittests failures in AppListMainViewTest.DragLastItemFromFolderAndDropAtLastSlot AppListViewTestAura.ReshowWithOpenFolder but testing locally and on the try bots can't repro it, so calling it flake.) BUG=397478, 396969 TEST=ash_unittests on drmemory, Windows and Chrome OS bots TBR=oshima@chromium.org Review URL: https://codereview.chromium.org/426973002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@286517 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/desktop_background/desktop_background_controller_unittest.cc15
-rw-r--r--ash/shelf/shelf_layout_manager_unittest.cc4
-rw-r--r--ash/wm/overview/window_selector_unittest.cc12
-rw-r--r--ash/wm/window_animations_unittest.cc11
-rw-r--r--ash/wm/workspace_controller_unittest.cc4
-rw-r--r--content/browser/web_contents/aura/window_slider_unittest.cc3
-rw-r--r--tools/valgrind/drmemory/suppressions.txt18
-rw-r--r--tools/valgrind/gtest_exclude/ash_unittests.gtest-drmemory_win32.txt6
-rw-r--r--ui/app_list/views/folder_header_view.cc6
-rw-r--r--ui/aura/window_unittest.cc20
-rw-r--r--ui/compositor/layer_animation_element.cc16
-rw-r--r--ui/compositor/layer_animator_unittest.cc4
-rw-r--r--ui/compositor/scoped_animation_duration_scale_mode.h4
-rw-r--r--ui/keyboard/keyboard_controller_unittest.cc4
-rw-r--r--ui/views/controls/textfield/textfield.cc1
-rw-r--r--ui/views/widget/widget_unittest.cc2
-rw-r--r--ui/wm/core/visibility_controller_unittest.cc4
-rw-r--r--ui/wm/core/window_animations.cc22
18 files changed, 79 insertions, 77 deletions
diff --git a/ash/desktop_background/desktop_background_controller_unittest.cc b/ash/desktop_background/desktop_background_controller_unittest.cc
index fa2e2a4..8751a18 100644
--- a/ash/desktop_background/desktop_background_controller_unittest.cc
+++ b/ash/desktop_background/desktop_background_controller_unittest.cc
@@ -68,7 +68,8 @@ void RunAnimationForWidget(views::Widget* widget) {
class DesktopBackgroundControllerTest : public test::AshTestBase {
public:
DesktopBackgroundControllerTest()
- : controller_(NULL) {
+ : controller_(NULL),
+ wallpaper_delegate_(NULL) {
}
virtual ~DesktopBackgroundControllerTest() {}
@@ -149,8 +150,8 @@ TEST_F(DesktopBackgroundControllerTest, BasicReparenting) {
TEST_F(DesktopBackgroundControllerTest, ControllerOwnership) {
// We cannot short-circuit animations for this test.
- ui::ScopedAnimationDurationScaleMode normal_duration_mode(
- ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
+ ui::ScopedAnimationDurationScaleMode test_duration_mode(
+ ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
// Create wallpaper and background view.
DesktopBackgroundController* controller =
@@ -181,8 +182,8 @@ TEST_F(DesktopBackgroundControllerTest, ControllerOwnership) {
// move all desktop views if there are more than one.
TEST_F(DesktopBackgroundControllerTest, BackgroundMovementDuringUnlock) {
// We cannot short-circuit animations for this test.
- ui::ScopedAnimationDurationScaleMode normal_duration_mode(
- ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
+ ui::ScopedAnimationDurationScaleMode test_duration_mode(
+ ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
// Reset wallpaper state, see ControllerOwnership above.
DesktopBackgroundController* controller =
@@ -229,8 +230,8 @@ TEST_F(DesktopBackgroundControllerTest, BackgroundMovementDuringUnlock) {
// animation and replace current wallpaper before next animation starts.
TEST_F(DesktopBackgroundControllerTest, ChangeWallpaperQuick) {
// We cannot short-circuit animations for this test.
- ui::ScopedAnimationDurationScaleMode normal_duration_mode(
- ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
+ ui::ScopedAnimationDurationScaleMode test_duration_mode(
+ ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
// Reset wallpaper state, see ControllerOwnership above.
DesktopBackgroundController* controller =
diff --git a/ash/shelf/shelf_layout_manager_unittest.cc b/ash/shelf/shelf_layout_manager_unittest.cc
index 8167b29..d033960 100644
--- a/ash/shelf/shelf_layout_manager_unittest.cc
+++ b/ash/shelf/shelf_layout_manager_unittest.cc
@@ -1668,7 +1668,7 @@ TEST_F(ShelfLayoutManagerTest, ShelfAnimatesWhenGestureComplete) {
{
// Enable animations so that we can make sure that they occur.
ui::ScopedAnimationDurationScaleMode regular_animations(
- ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
+ ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
gfx::Rect shelf_bounds_in_screen =
@@ -1697,7 +1697,7 @@ TEST_F(ShelfLayoutManagerTest, ShelfAnimatesWhenGestureComplete) {
{
// Enable the animations so that we can make sure they do occur.
ui::ScopedAnimationDurationScaleMode regular_animations(
- ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
+ ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
gfx::Point start =
GetShelfWidget()->GetWindowBoundsInScreen().CenterPoint();
diff --git a/ash/wm/overview/window_selector_unittest.cc b/ash/wm/overview/window_selector_unittest.cc
index c53664c..55c3f02 100644
--- a/ash/wm/overview/window_selector_unittest.cc
+++ b/ash/wm/overview/window_selector_unittest.cc
@@ -458,15 +458,15 @@ TEST_F(WindowSelectorTest, DISABLED_MinimizedWindowVisibility) {
EXPECT_FALSE(window1->IsVisible());
EXPECT_FALSE(window1->layer()->GetTargetVisibility());
{
- ui::ScopedAnimationDurationScaleMode normal_duration_mode(
- ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
+ ui::ScopedAnimationDurationScaleMode test_duration_mode(
+ ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
ToggleOverview();
EXPECT_TRUE(window1->IsVisible());
EXPECT_TRUE(window1->layer()->GetTargetVisibility());
}
{
- ui::ScopedAnimationDurationScaleMode normal_duration_mode(
- ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
+ ui::ScopedAnimationDurationScaleMode test_duration_mode(
+ ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
ToggleOverview();
EXPECT_FALSE(window1->IsVisible());
EXPECT_FALSE(window1->layer()->GetTargetVisibility());
@@ -561,8 +561,8 @@ TEST_F(WindowSelectorTest, QuickReentryRestoresInitialTransform) {
// animating when we reenter. We cannot short circuit animations for this but
// we also don't have to wait for them to complete.
{
- ui::ScopedAnimationDurationScaleMode normal_duration_mode(
- ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
+ ui::ScopedAnimationDurationScaleMode test_duration_mode(
+ ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
ToggleOverview();
ToggleOverview();
}
diff --git a/ash/wm/window_animations_unittest.cc b/ash/wm/window_animations_unittest.cc
index 0e1a4d8..4e4c518 100644
--- a/ash/wm/window_animations_unittest.cc
+++ b/ash/wm/window_animations_unittest.cc
@@ -65,6 +65,9 @@ class MinimizeAnimationObserver : public ui::LayerAnimationObserver {
};
TEST_F(WindowAnimationsTest, HideShowBrightnessGrayscaleAnimation) {
+ ui::ScopedAnimationDurationScaleMode test_duration_mode(
+ ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
+
scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
window->Show();
EXPECT_TRUE(window->layer()->visible());
@@ -110,8 +113,8 @@ TEST_F(WindowAnimationsTest, LayerTargetVisibility) {
namespace wm {
TEST_F(WindowAnimationsTest, CrossFadeToBounds) {
- ui::ScopedAnimationDurationScaleMode normal_duration_mode(
- ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
+ ui::ScopedAnimationDurationScaleMode test_duration_mode(
+ ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
scoped_ptr<Window> window(CreateTestWindowInShellWithId(0));
window->SetBounds(gfx::Rect(5, 10, 320, 240));
@@ -168,8 +171,8 @@ TEST_F(WindowAnimationsTest, CrossFadeToBounds) {
} // namespace wm
TEST_F(WindowAnimationsTest, LockAnimationDuration) {
- ui::ScopedAnimationDurationScaleMode normal_duration_mode(
- ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
+ ui::ScopedAnimationDurationScaleMode test_duration_mode(
+ ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
scoped_ptr<Window> window(CreateTestWindowInShellWithId(0));
Layer* layer = window->layer();
diff --git a/ash/wm/workspace_controller_unittest.cc b/ash/wm/workspace_controller_unittest.cc
index e00390e..77f001f 100644
--- a/ash/wm/workspace_controller_unittest.cc
+++ b/ash/wm/workspace_controller_unittest.cc
@@ -1203,8 +1203,8 @@ TEST_F(WorkspaceControllerTest, NormToMaxToNormRepositionsRemaining) {
// Test that animations are triggered.
TEST_F(WorkspaceControllerTest, AnimatedNormToMaxToNormRepositionsRemaining) {
- ui::ScopedAnimationDurationScaleMode normal_duration_mode(
- ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
+ ui::ScopedAnimationDurationScaleMode test_duration_mode(
+ ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0));
window1->Hide();
window1->SetBounds(gfx::Rect(16, 32, 640, 320));
diff --git a/content/browser/web_contents/aura/window_slider_unittest.cc b/content/browser/web_contents/aura/window_slider_unittest.cc
index da9d1c6..a65a127 100644
--- a/content/browser/web_contents/aura/window_slider_unittest.cc
+++ b/content/browser/web_contents/aura/window_slider_unittest.cc
@@ -589,7 +589,8 @@ TEST_F(WindowSliderTest, SwipeDuringSwipeAnimation) {
WindowSliderDelegateTest slider_delegate;
new WindowSlider(&slider_delegate, root_window(), window.get());
- ui::ScopedAnimationDurationScaleMode normal_duration_(
+ // This test uses explicit durations so needs a normal duration.
+ ui::ScopedAnimationDurationScaleMode normal_duration(
ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
ui::LayerAnimator* animator = window->layer()->GetAnimator();
animator->set_disable_timer_for_test(true);
diff --git a/tools/valgrind/drmemory/suppressions.txt b/tools/valgrind/drmemory/suppressions.txt
index d969db7..aaec4a9 100644
--- a/tools/valgrind/drmemory/suppressions.txt
+++ b/tools/valgrind/drmemory/suppressions.txt
@@ -638,21 +638,3 @@ KERNEL32.dll!CreateWaitableTimerW
UNADDRESSABLE ACCESS
name=http://code.google.com/p/dynamorio/issues/detail?id=1443
dynamorio.dll!*
-
-UNADDRESSABLE ACCESS
-name=http://crbug.com/397124
-...
-*!ash::wm::WindowAnimationsTest_CrossFadeToBounds_Test::TestBody
-
-# Unfortunately there's some FPO and the TestBody is skipped:
-UNADDRESSABLE ACCESS
-name=http://crbug.com/397124_b
-compositor.dll!ui::Layer::GetTargetOpacity
-*!testing::internal::HandleExceptionsInMethodIfSupported<>
-
-# Unfortunately there's some FPO and the TestBody is skipped:
-UNADDRESSABLE ACCESS
-name=http://crbug.com/397124_c
-compositor.dll!ui::Layer::SetAnimator
-compositor.dll!ui::Layer::GetAnimator
-*!testing::internal::HandleExceptionsInMethodIfSupported<>
diff --git a/tools/valgrind/gtest_exclude/ash_unittests.gtest-drmemory_win32.txt b/tools/valgrind/gtest_exclude/ash_unittests.gtest-drmemory_win32.txt
deleted file mode 100644
index 470e16a..0000000
--- a/tools/valgrind/gtest_exclude/ash_unittests.gtest-drmemory_win32.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-# http://crbug.com/396969
-DesktopBackgroundControllerTest.*
-# http://crbug.com/397478
-WindowAnimationsTest.HideShowBrightnessGrayscaleAnimation
-WindowAnimationsTest.LockAnimationDuration
-WorkspaceControllerTest.AnimatedNormToMaxToNormRepositionsRemaining
diff --git a/ui/app_list/views/folder_header_view.cc b/ui/app_list/views/folder_header_view.cc
index 9c78b91..19ef48d 100644
--- a/ui/app_list/views/folder_header_view.cc
+++ b/ui/app_list/views/folder_header_view.cc
@@ -162,9 +162,9 @@ void FolderHeaderView::Layout() {
back_button_->SetBoundsRect(back_bounds);
gfx::Rect text_bounds(rect);
- base::string16 text = folder_item_->name().empty()
- ? folder_name_placeholder_text_
- : base::UTF8ToUTF16(folder_item_->name());
+ base::string16 text = folder_item_ && !folder_item_->name().empty()
+ ? base::UTF8ToUTF16(folder_item_->name())
+ : folder_name_placeholder_text_;
int text_width =
gfx::Canvas::GetStringWidth(text, folder_name_view_->GetFontList()) +
folder_name_view_->GetCaretBounds().width();
diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc
index ae548c4..69f7ff9 100644
--- a/ui/aura/window_unittest.cc
+++ b/ui/aura/window_unittest.cc
@@ -1623,8 +1623,8 @@ TEST_F(WindowTest, OwnedProperty) {
TEST_F(WindowTest, SetBoundsInternalShouldCheckTargetBounds) {
// We cannot short-circuit animations in this test.
- ui::ScopedAnimationDurationScaleMode normal_duration_mode(
- ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
+ ui::ScopedAnimationDurationScaleMode test_duration_mode(
+ ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
scoped_ptr<Window> w1(
CreateTestWindowWithBounds(gfx::Rect(0, 0, 100, 100), root_window()));
@@ -2242,8 +2242,8 @@ TEST_F(WindowTest, RootWindowSetWhenReparenting) {
parent1.AddChild(&child);
// We need animations to start in order to observe the bounds changes.
- ui::ScopedAnimationDurationScaleMode animation_duration_mode(
- ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
+ ui::ScopedAnimationDurationScaleMode test_duration_mode(
+ ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
ui::ScopedLayerAnimationSettings settings1(child.layer()->GetAnimator());
settings1.SetTransitionDuration(base::TimeDelta::FromMilliseconds(100));
gfx::Rect new_bounds(gfx::Rect(35, 35, 50, 50));
@@ -2357,8 +2357,8 @@ TEST_F(WindowTest, DelegateNotifiedAsBoundsChange) {
BoundsChangeDelegate delegate;
// We cannot short-circuit animations in this test.
- ui::ScopedAnimationDurationScaleMode normal_duration_mode(
- ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
+ ui::ScopedAnimationDurationScaleMode test_duration_mode(
+ ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
scoped_ptr<Window> window(
CreateTestWindowWithDelegate(&delegate, 1,
@@ -2392,8 +2392,8 @@ TEST_F(WindowTest, DelegateNotifiedAsBoundsChangeInHiddenLayer) {
BoundsChangeDelegate delegate;
// We cannot short-circuit animations in this test.
- ui::ScopedAnimationDurationScaleMode normal_duration_mode(
- ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
+ ui::ScopedAnimationDurationScaleMode test_duration_mode(
+ ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
scoped_ptr<Window> window(
CreateTestWindowWithDelegate(&delegate, 1,
@@ -3395,8 +3395,8 @@ class TestLayerAnimationObserver : public ui::LayerAnimationObserver {
}
TEST_F(WindowTest, WindowDestroyCompletesAnimations) {
- ui::ScopedAnimationDurationScaleMode normal_duration_mode(
- ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
+ ui::ScopedAnimationDurationScaleMode test_duration_mode(
+ ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
scoped_refptr<ui::LayerAnimator> animator =
ui::LayerAnimator::CreateImplicitAnimator();
TestLayerAnimationObserver observer;
diff --git a/ui/compositor/layer_animation_element.cc b/ui/compositor/layer_animation_element.cc
index c25e4a1..ade7765 100644
--- a/ui/compositor/layer_animation_element.cc
+++ b/ui/compositor/layer_animation_element.cc
@@ -20,11 +20,11 @@ namespace ui {
namespace {
-// The factor by which duration is scaled up or down when
-// ScopedAnimationDurationScaleMode::duration_scale_mode() is SLOW_DURATION or
-// FAST_DURATION.
-const int kSlowDurationScaleFactor = 4;
-const int kFastDurationScaleFactor = 4;
+// The factor by which duration is scaled up or down when using
+// ScopedAnimationDurationScaleMode.
+const int kSlowDurationScaleMultiplier = 4;
+const int kFastDurationScaleDivisor = 4;
+const int kNonZeroDurationScaleDivisor = 20;
// Pause -----------------------------------------------------------------------
class Pause : public LayerAnimationElement {
@@ -761,9 +761,11 @@ base::TimeDelta LayerAnimationElement::GetEffectiveDuration(
case ScopedAnimationDurationScaleMode::NORMAL_DURATION:
return duration;
case ScopedAnimationDurationScaleMode::FAST_DURATION:
- return duration / kFastDurationScaleFactor;
+ return duration / kFastDurationScaleDivisor;
case ScopedAnimationDurationScaleMode::SLOW_DURATION:
- return duration * kSlowDurationScaleFactor;
+ return duration * kSlowDurationScaleMultiplier;
+ case ScopedAnimationDurationScaleMode::NON_ZERO_DURATION:
+ return duration / kNonZeroDurationScaleDivisor;
case ScopedAnimationDurationScaleMode::ZERO_DURATION:
return base::TimeDelta();
default:
diff --git a/ui/compositor/layer_animator_unittest.cc b/ui/compositor/layer_animator_unittest.cc
index 3ae8c2b..c72eab9 100644
--- a/ui/compositor/layer_animator_unittest.cc
+++ b/ui/compositor/layer_animator_unittest.cc
@@ -2000,8 +2000,8 @@ TEST(LayerAnimatorTest, CallbackDeletesAnimationInProgress) {
// tests the behavior when the OnLayerAnimationAborted() callback causes
// all of the animator's other animations to be deleted.
TEST(LayerAnimatorTest, ObserverDeletesAnimationsOnAbort) {
- ScopedAnimationDurationScaleMode normal_duration_mode(
- ScopedAnimationDurationScaleMode::NORMAL_DURATION);
+ ScopedAnimationDurationScaleMode test_duration_mode(
+ ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
scoped_refptr<LayerAnimator> animator(new TestLayerAnimator());
animator->set_disable_timer_for_test(true);
TestLayerAnimationDelegate delegate;
diff --git a/ui/compositor/scoped_animation_duration_scale_mode.h b/ui/compositor/scoped_animation_duration_scale_mode.h
index a0ac5d3..9444651 100644
--- a/ui/compositor/scoped_animation_duration_scale_mode.h
+++ b/ui/compositor/scoped_animation_duration_scale_mode.h
@@ -17,6 +17,10 @@ class COMPOSITOR_EXPORT ScopedAnimationDurationScaleMode {
NORMAL_DURATION,
FAST_DURATION,
SLOW_DURATION,
+ // A very short but guaranteed non-zero duration for individual tests that
+ // need to assert things about animations after creating them.
+ NON_ZERO_DURATION,
+ // Animations complete immediately after being created. Used by most tests.
ZERO_DURATION
};
diff --git a/ui/keyboard/keyboard_controller_unittest.cc b/ui/keyboard/keyboard_controller_unittest.cc
index 7f97a5f..9a68561 100644
--- a/ui/keyboard/keyboard_controller_unittest.cc
+++ b/ui/keyboard/keyboard_controller_unittest.cc
@@ -471,8 +471,8 @@ class KeyboardControllerAnimationTest : public KeyboardControllerTest,
virtual void SetUp() OVERRIDE {
// We cannot short-circuit animations for this test.
- ui::ScopedAnimationDurationScaleMode normal_duration_mode(
- ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
+ ui::ScopedAnimationDurationScaleMode test_duration_mode(
+ ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
KeyboardControllerTest::SetUp();
diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc
index c26fe36..e05f969 100644
--- a/ui/views/controls/textfield/textfield.cc
+++ b/ui/views/controls/textfield/textfield.cc
@@ -70,6 +70,7 @@ int GetDragSelectionDelay() {
case ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION: return 100;
case ui::ScopedAnimationDurationScaleMode::FAST_DURATION: return 25;
case ui::ScopedAnimationDurationScaleMode::SLOW_DURATION: return 400;
+ case ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION: return 1;
case ui::ScopedAnimationDurationScaleMode::ZERO_DURATION: return 0;
}
return 100;
diff --git a/ui/views/widget/widget_unittest.cc b/ui/views/widget/widget_unittest.cc
index f6d1ea2..232064f 100644
--- a/ui/views/widget/widget_unittest.cc
+++ b/ui/views/widget/widget_unittest.cc
@@ -1856,7 +1856,7 @@ TEST_F(WidgetTest, CloseWidgetWhileAnimating) {
// Normal animations for tests have ZERO_DURATION, make sure we are actually
// animating the movement.
ui::ScopedAnimationDurationScaleMode animation_scale_mode(
- ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
+ ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
ui::ScopedLayerAnimationSettings animation_settings(
widget->GetLayer()->GetAnimator());
animation_settings.AddObserver(&animation_observer);
diff --git a/ui/wm/core/visibility_controller_unittest.cc b/ui/wm/core/visibility_controller_unittest.cc
index 5825d495..01731ef 100644
--- a/ui/wm/core/visibility_controller_unittest.cc
+++ b/ui/wm/core/visibility_controller_unittest.cc
@@ -22,8 +22,8 @@ typedef aura::test::AuraTestBase VisibilityControllerTest;
// ignored.
TEST_F(VisibilityControllerTest, AnimateTransparencyToZeroAndHideHides) {
// We cannot disable animations for this test.
- ui::ScopedAnimationDurationScaleMode normal_duration_mode(
- ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
+ ui::ScopedAnimationDurationScaleMode test_duration_mode(
+ ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
VisibilityController controller;
aura::client::SetVisibilityClient(root_window(), &controller);
diff --git a/ui/wm/core/window_animations.cc b/ui/wm/core/window_animations.cc
index 22fd43d..8284990 100644
--- a/ui/wm/core/window_animations.cc
+++ b/ui/wm/core/window_animations.cc
@@ -26,6 +26,7 @@
#include "ui/compositor/layer_animation_sequence.h"
#include "ui/compositor/layer_animator.h"
#include "ui/compositor/layer_tree_owner.h"
+#include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/gfx/animation/animation.h"
#include "ui/gfx/interpolated_transform.h"
@@ -649,10 +650,23 @@ bool AnimateWindow(aura::Window* window, WindowAnimationType type) {
}
bool WindowAnimationsDisabled(aura::Window* window) {
- return (!gfx::Animation::ShouldRenderRichAnimation() || (window &&
- window->GetProperty(aura::client::kAnimationsDisabledKey)) ||
- CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kWindowAnimationsDisabled));
+ // Individual windows can choose to skip animations.
+ if (window && window->GetProperty(aura::client::kAnimationsDisabledKey))
+ return true;
+
+ // Animations can be disabled globally for testing.
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kWindowAnimationsDisabled))
+ return true;
+
+ // Tests of animations themselves should still run even if the machine is
+ // being accessed via Remote Desktop.
+ if (ui::ScopedAnimationDurationScaleMode::duration_scale_mode() ==
+ ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION)
+ return false;
+
+ // Let the user decide whether or not to play the animation.
+ return !gfx::Animation::ShouldRenderRichAnimation();
}
} // namespace wm