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

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 lock screen, app windows Created 8 years, 6 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 | « ash/wm/window_animations.cc ('k') | ash/wm/workspace/workspace.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..0b1b37728bd0233560574efd1035ca7da84f8ad3 100644
--- a/ash/wm/window_animations_unittest.cc
+++ b/ash/wm/window_animations_unittest.cc
@@ -12,12 +12,15 @@
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animator.h"
+using aura::Window;
+using ui::Layer;
+
namespace ash {
namespace internal {
-typedef ash::test::AshTestBase WindowAnimationsWorkspaceTest;
+typedef ash::test::AshTestBase WindowAnimationsTest;
-TEST_F(WindowAnimationsWorkspaceTest, HideShow) {
+TEST_F(WindowAnimationsTest, HideShow) {
aura::Window* default_container =
ash::Shell::GetInstance()->GetContainer(
internal::kShellWindowId_DefaultContainer);
@@ -54,7 +57,7 @@ TEST_F(WindowAnimationsWorkspaceTest, HideShow) {
EXPECT_TRUE(window->layer()->visible());
}
-TEST_F(WindowAnimationsWorkspaceTest, ShowHide) {
+TEST_F(WindowAnimationsTest, ShowHide) {
aura::Window* default_container =
ash::Shell::GetInstance()->GetContainer(
internal::kShellWindowId_DefaultContainer);
@@ -91,7 +94,7 @@ TEST_F(WindowAnimationsWorkspaceTest, ShowHide) {
EXPECT_FALSE(window->layer()->visible());
}
-TEST_F(WindowAnimationsWorkspaceTest, LayerTargetVisibility) {
+TEST_F(WindowAnimationsTest, LayerTargetVisibility) {
aura::Window* default_container =
ash::Shell::GetInstance()->GetContainer(
internal::kShellWindowId_DefaultContainer);
@@ -107,5 +110,54 @@ TEST_F(WindowAnimationsWorkspaceTest, LayerTargetVisibility) {
EXPECT_TRUE(window->layer()->GetTargetVisibility());
}
+TEST_F(WindowAnimationsTest, 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
« no previous file with comments | « ash/wm/window_animations.cc ('k') | ash/wm/workspace/workspace.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698