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

Unified Diff: ash/wm/window_animations_unittest.cc

Issue 10444014: ash: Improved window maximize/restore animations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix workspace mgr, remove ignore_window, cleanup Created 8 years, 7 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
Index: ash/wm/window_animations_unittest.cc
diff --git a/ash/wm/window_animations_unittest.cc b/ash/wm/window_animations_unittest.cc
index 3e4a6234267e045e1e777b812b4eb26d9015e041..51d9c5d1dc8014fd8fe7b881d4b85a440c07a665 100644
--- a/ash/wm/window_animations_unittest.cc
+++ b/ash/wm/window_animations_unittest.cc
@@ -12,6 +12,9 @@
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animator.h"
+using aura::Window;
+using ui::Layer;
+
namespace ash {
namespace internal {
@@ -107,5 +110,54 @@ TEST_F(WindowAnimationsWorkspaceTest, LayerTargetVisibility) {
EXPECT_TRUE(window->layer()->GetTargetVisibility());
}
+TEST_F(WindowAnimationsWorkspaceTest, CrossFadeToBounds) {
+ Window* default_container =
+ ash::Shell::GetInstance()->GetContainer(
+ internal::kShellWindowId_DefaultContainer);
+ scoped_ptr<Window> window(
+ aura::test::CreateTestWindowWithId(0, default_container));
+ window->SetBounds(gfx::Rect(5, 10, 320, 240));
+ window->Show();
+
+ Layer* old_layer = window->layer();
+ EXPECT_EQ(1.0f, old_layer->GetTargetOpacity());
+
+ // Cross fade to a larger size, as in a maximize animation.
+ CrossFadeToBounds(window.get(), gfx::Rect(0, 0, 640, 480));
+ // Window's layer has been replaced.
+ EXPECT_NE(old_layer, window->layer());
+ // Original layer stays opaque and stretches to new size.
+ EXPECT_EQ(1.0f, old_layer->GetTargetOpacity());
+ EXPECT_EQ("5,10 320x240", old_layer->bounds().ToString());
+ ui::Transform grow_transform;
+ grow_transform.ConcatScale(640.f / 320.f, 480.f / 240.f);
+ grow_transform.ConcatTranslate(-5.f, -10.f);
+ EXPECT_EQ(grow_transform, old_layer->GetTargetTransform());
+ // New layer animates in to the identity transform.
+ EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity());
+ EXPECT_EQ(ui::Transform(), window->layer()->GetTargetTransform());
+
+ // Allow the animation observer to delete itself.
+ RunAllPendingInMessageLoop();
+
+ // Cross fade to a smaller size, as in a restore animation.
+ old_layer = window->layer();
+ CrossFadeToBounds(window.get(), gfx::Rect(5, 10, 320, 240));
+ // Again, window layer has been replaced.
+ EXPECT_NE(old_layer, window->layer());
+ // Original layer fades out and stretches down to new size.
+ EXPECT_EQ(0.0f, old_layer->GetTargetOpacity());
+ EXPECT_EQ("0,0 640x480", old_layer->bounds().ToString());
+ ui::Transform shrink_transform;
+ shrink_transform.ConcatScale(320.f / 640.f, 240.f / 480.f);
+ shrink_transform.ConcatTranslate(5.f, 10.f);
+ EXPECT_EQ(shrink_transform, old_layer->GetTargetTransform());
+ // New layer animates in to the identity transform.
+ EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity());
+ EXPECT_EQ(ui::Transform(), window->layer()->GetTargetTransform());
+
+ RunAllPendingInMessageLoop();
+}
+
} // namespace internal
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698