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

Unified Diff: ui/views/corewm/window_animations_unittest.cc

Issue 12342028: make menus, bubbles, etc. top level windows on aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 9 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 | « ui/views/corewm/window_animations.cc ('k') | ui/views/views.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/corewm/window_animations_unittest.cc
diff --git a/ui/views/corewm/window_animations_unittest.cc b/ui/views/corewm/window_animations_unittest.cc
index 16647479a1234b0d0f7a3ab73178aa9dde8ff6ef..7db9a30b455ee25cc1b373b28c791dc5df4f497a 100644
--- a/ui/views/corewm/window_animations_unittest.cc
+++ b/ui/views/corewm/window_animations_unittest.cc
@@ -5,6 +5,7 @@
#include "ui/views/corewm/window_animations.h"
#include "base/time.h"
+#include "ui/aura/client/animation_host.h"
#include "ui/aura/test/aura_test_base.h"
#include "ui/aura/test/test_windows.h"
#include "ui/aura/window.h"
@@ -31,41 +32,6 @@ class WindowAnimationsTest : public aura::test::AuraTestBase {
DISALLOW_COPY_AND_ASSIGN(WindowAnimationsTest);
};
-TEST_F(WindowAnimationsTest, HideShowBrightnessGrayscaleAnimation) {
- scoped_ptr<aura::Window> window(
- aura::test::CreateTestWindowWithId(0, NULL));
- window->Show();
- EXPECT_TRUE(window->layer()->visible());
-
- // Hiding.
- SetWindowVisibilityAnimationType(
- window.get(),
- WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE);
- AnimateOnChildWindowVisibilityChanged(window.get(), false);
- EXPECT_EQ(0.0f, window->layer()->GetTargetOpacity());
- EXPECT_FALSE(window->layer()->GetTargetVisibility());
- EXPECT_FALSE(window->layer()->visible());
-
- // Showing.
- SetWindowVisibilityAnimationType(
- window.get(),
- WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE);
- AnimateOnChildWindowVisibilityChanged(window.get(), true);
- EXPECT_EQ(0.0f, window->layer()->GetTargetBrightness());
- EXPECT_EQ(0.0f, window->layer()->GetTargetGrayscale());
- EXPECT_TRUE(window->layer()->visible());
-
- // Stays shown.
- ui::AnimationContainerElement* element =
- static_cast<ui::AnimationContainerElement*>(
- window->layer()->GetAnimator());
- element->Step(base::TimeTicks::Now() +
- base::TimeDelta::FromSeconds(5));
- EXPECT_EQ(0.0f, window->layer()->GetTargetBrightness());
- EXPECT_EQ(0.0f, window->layer()->GetTargetGrayscale());
- EXPECT_TRUE(window->layer()->visible());
-}
-
TEST_F(WindowAnimationsTest, LayerTargetVisibility) {
scoped_ptr<aura::Window> window(
aura::test::CreateTestWindowWithId(0, NULL));
@@ -79,60 +45,40 @@ TEST_F(WindowAnimationsTest, LayerTargetVisibility) {
EXPECT_TRUE(window->layer()->GetTargetVisibility());
}
-TEST_F(WindowAnimationsTest, CrossFadeToBounds) {
- ui::ScopedAnimationDurationScaleMode normal_duration_mode(
- ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
+// A simple AnimationHost implementation for the NotifyHideCompleted test.
+class NotifyHideCompletedAnimationHost : public aura::client::AnimationHost {
+ public:
+ NotifyHideCompletedAnimationHost() : hide_completed_(false) {}
+ virtual ~NotifyHideCompletedAnimationHost() {}
- scoped_ptr<Window> window(
- aura::test::CreateTestWindowWithId(0, NULL));
- window->SetBounds(gfx::Rect(5, 10, 320, 240));
- window->Show();
+ // Overridden from TestWindowDelegate:
+ virtual void OnWindowHidingAnimationCompleted() OVERRIDE {
+ hide_completed_ = true;
+ }
+
+ virtual void SetHostTransitionBounds(const gfx::Rect& bounds) OVERRIDE {}
+
+ bool hide_completed() const { return hide_completed_; }
+
+ private:
+ bool hide_completed_;
+
+ DISALLOW_COPY_AND_ASSIGN(NotifyHideCompletedAnimationHost);
+};
- 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());
- gfx::Transform grow_transform;
- grow_transform.Translate(-5.f, -10.f);
- grow_transform.Scale(640.f / 320.f, 480.f / 240.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(gfx::Transform(), window->layer()->GetTargetTransform());
-
- // Run the animations to completion.
- static_cast<ui::AnimationContainerElement*>(old_layer->GetAnimator())->Step(
- base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1));
- static_cast<ui::AnimationContainerElement*>(window->layer()->GetAnimator())->
- Step(base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1));
-
- // 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());
- gfx::Transform shrink_transform;
- shrink_transform.Translate(5.f, 10.f);
- shrink_transform.Scale(320.f / 640.f, 240.f / 480.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(gfx::Transform(), window->layer()->GetTargetTransform());
-
- static_cast<ui::AnimationContainerElement*>(old_layer->GetAnimator())->Step(
- base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1));
- static_cast<ui::AnimationContainerElement*>(window->layer()->GetAnimator())->
- Step(base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1));
+TEST_F(WindowAnimationsTest, NotifyHideCompleted) {
+ NotifyHideCompletedAnimationHost animation_host;
+ scoped_ptr<aura::Window> window(aura::test::CreateTestWindowWithId(0, NULL));
+ aura::client::SetAnimationHost(window.get(), &animation_host);
+ views::corewm::SetWindowVisibilityAnimationType(
+ window.get(), WINDOW_VISIBILITY_ANIMATION_TYPE_FADE);
+ AnimateOnChildWindowVisibilityChanged(window.get(), true);
+ EXPECT_TRUE(window->layer()->visible());
+
+ EXPECT_FALSE(animation_host.hide_completed());
+ AnimateOnChildWindowVisibilityChanged(window.get(), false);
+ EXPECT_TRUE(animation_host.hide_completed());
}
-} // namespace internal
-} // namespace ash
+} // namespace corewm
+} // namespace views
« no previous file with comments | « ui/views/corewm/window_animations.cc ('k') | ui/views/views.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698