public:
WindowAnimationsTest() {}
- virtual void TearDown() OVERRIDE {
- AshTestBase::TearDown();
- }
+ void TearDown() override { AshTestBase::TearDown(); }
private:
DISALLOW_COPY_AND_ASSIGN(WindowAnimationsTest);
protected:
// ui::LayerAnimationObserver:
- virtual void OnLayerAnimationScheduled(
- ui::LayerAnimationSequence* sequence) OVERRIDE {
+ void OnLayerAnimationScheduled(
+ ui::LayerAnimationSequence* sequence) override {
duration_ = animator_->GetTransitionDuration();
animator_->RemoveObserver(this);
}
- virtual void OnLayerAnimationEnded(
- ui::LayerAnimationSequence* sequence) OVERRIDE {}
- virtual void OnLayerAnimationAborted(
- ui::LayerAnimationSequence* sequence) OVERRIDE {}
+ void OnLayerAnimationEnded(ui::LayerAnimationSequence* sequence) override {}
+ void OnLayerAnimationAborted(ui::LayerAnimationSequence* sequence) override {}
private:
ui::LayerAnimator* animator_;
base::TimeDelta::FromSeconds(1));
}
+// Tests that when crossfading from a window which has a transform that the
+// crossfade starts from this transformed size rather than snapping the window
+// to an identity transform and crossfading from there.
+TEST_F(WindowAnimationsTest, CrossFadeToBoundsFromTransform) {
+ ui::ScopedAnimationDurationScaleMode test_duration_mode(
+ ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
+
+ scoped_ptr<Window> window(CreateTestWindowInShellWithId(0));
+ window->SetBounds(gfx::Rect(10, 10, 320, 240));
+ gfx::Transform half_size;
+ half_size.Translate(10, 10);
+ half_size.Scale(0.5f, 0.5f);
+ window->SetTransform(half_size);
+ 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.
+ GetWindowState(window.get())->SetBoundsDirectCrossFade(
+ 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("10,10 320x240", old_layer->bounds().ToString());
+ EXPECT_EQ(half_size, old_layer->transform());
+
+ // New layer animates in from the old window's transformed size to the
+ // identity transform.
+ EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity());
+ // Set up the transform necessary to start at the old windows transformed
+ // position.
+ gfx::Transform quarter_size_shifted;
+ quarter_size_shifted.Translate(20, 20);
+ quarter_size_shifted.Scale(0.25f, 0.25f);
+ EXPECT_EQ(quarter_size_shifted, window->layer()->transform());
+ EXPECT_EQ(gfx::Transform(), window->layer()->GetTargetTransform());
+}
+
} // namespace wm
TEST_F(WindowAnimationsTest, LockAnimationDuration) {