| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "services/view_manager/animation_runner.h" | 5 #include "services/view_manager/animation_runner.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "mojo/converters/geometry/geometry_type_converters.h" | 8 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 9 #include "mojo/services/view_manager/public/interfaces/view_manager_constants.mo
jom.h" | 9 #include "mojo/services/view_manager/public/interfaces/view_manager_constants.mo
jom.h" |
| 10 #include "services/view_manager/animation_runner_observer.h" | 10 #include "services/view_manager/animation_runner_observer.h" |
| 11 #include "services/view_manager/scheduled_animation_group.h" | 11 #include "services/view_manager/scheduled_animation_group.h" |
| 12 #include "services/view_manager/server_view.h" | 12 #include "services/view_manager/server_view.h" |
| 13 #include "services/view_manager/test_server_view_delegate.h" | 13 #include "services/view_manager/test_server_view_delegate.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 using base::TimeDelta; | 16 using base::TimeDelta; |
| 17 using mojo::ANIMATION_PROPERTY_NONE; | 17 using mojo::AnimationProperty::NONE; |
| 18 using mojo::ANIMATION_PROPERTY_OPACITY; | 18 using mojo::AnimationProperty::OPACITY; |
| 19 using mojo::ANIMATION_PROPERTY_TRANSFORM; | 19 using mojo::AnimationProperty::TRANSFORM; |
| 20 using mojo::ANIMATION_TWEEN_TYPE_LINEAR; | 20 using mojo::AnimationTweenType::LINEAR; |
| 21 using mojo::AnimationElement; | 21 using mojo::AnimationElement; |
| 22 using mojo::AnimationGroup; | 22 using mojo::AnimationGroup; |
| 23 using mojo::AnimationProperty; | 23 using mojo::AnimationProperty; |
| 24 using mojo::AnimationSequence; | 24 using mojo::AnimationSequence; |
| 25 using mojo::AnimationTweenType; | 25 using mojo::AnimationTweenType; |
| 26 using mojo::AnimationValue; | 26 using mojo::AnimationValue; |
| 27 using mojo::AnimationValuePtr; | 27 using mojo::AnimationValuePtr; |
| 28 using mojo::Transform; | 28 using mojo::Transform; |
| 29 | 29 |
| 30 namespace view_manager { | 30 namespace view_manager { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 element.tween_type = tween_type; | 99 element.tween_type = tween_type; |
| 100 element.start_value = start_value.Pass(); | 100 element.start_value = start_value.Pass(); |
| 101 element.target_value = target_value.Pass(); | 101 element.target_value = target_value.Pass(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void AddOpacityElement(AnimationGroup* group, | 104 void AddOpacityElement(AnimationGroup* group, |
| 105 TimeDelta time, | 105 TimeDelta time, |
| 106 AnimationValuePtr start_value, | 106 AnimationValuePtr start_value, |
| 107 AnimationValuePtr target_value) { | 107 AnimationValuePtr target_value) { |
| 108 AddElement(group, time, start_value.Pass(), target_value.Pass(), | 108 AddElement(group, time, start_value.Pass(), target_value.Pass(), |
| 109 ANIMATION_PROPERTY_OPACITY, ANIMATION_TWEEN_TYPE_LINEAR); | 109 AnimationProperty::OPACITY, AnimationTweenType::LINEAR); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void AddTransformElement(AnimationGroup* group, | 112 void AddTransformElement(AnimationGroup* group, |
| 113 TimeDelta time, | 113 TimeDelta time, |
| 114 AnimationValuePtr start_value, | 114 AnimationValuePtr start_value, |
| 115 AnimationValuePtr target_value) { | 115 AnimationValuePtr target_value) { |
| 116 AddElement(group, time, start_value.Pass(), target_value.Pass(), | 116 AddElement(group, time, start_value.Pass(), target_value.Pass(), |
| 117 ANIMATION_PROPERTY_TRANSFORM, ANIMATION_TWEEN_TYPE_LINEAR); | 117 AnimationProperty::TRANSFORM, AnimationTweenType::LINEAR); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void AddPauseElement(AnimationGroup* group, TimeDelta time) { | 120 void AddPauseElement(AnimationGroup* group, TimeDelta time) { |
| 121 AddElement(group, time, AnimationValuePtr(), AnimationValuePtr(), | 121 AddElement(group, time, AnimationValuePtr(), AnimationValuePtr(), |
| 122 ANIMATION_PROPERTY_NONE, ANIMATION_TWEEN_TYPE_LINEAR); | 122 AnimationProperty::NONE, AnimationTweenType::LINEAR); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void InitGroupForView(AnimationGroup* group, | 125 void InitGroupForView(AnimationGroup* group, |
| 126 const ViewId& id, | 126 const ViewId& id, |
| 127 int cycle_count) { | 127 int cycle_count) { |
| 128 group->view_id = ViewIdToTransportId(id); | 128 group->view_id = ViewIdToTransportId(id); |
| 129 group->sequences.push_back(AnimationSequence::New()); | 129 group->sequences.push_back(AnimationSequence::New()); |
| 130 group->sequences[group->sequences.size() - 1]->cycle_count = cycle_count; | 130 group->sequences[group->sequences.size() - 1]->cycle_count = cycle_count; |
| 131 } | 131 } |
| 132 | 132 |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 | 489 |
| 490 gfx::Transform done_transform; | 490 gfx::Transform done_transform; |
| 491 done_transform.Scale(2, 4); | 491 done_transform.Scale(2, 4); |
| 492 AddTransformElement(&group, TimeDelta::FromMicroseconds(500), | 492 AddTransformElement(&group, TimeDelta::FromMicroseconds(500), |
| 493 AnimationValuePtr(), | 493 AnimationValuePtr(), |
| 494 TransformAnimationValue(done_transform)); | 494 TransformAnimationValue(done_transform)); |
| 495 | 495 |
| 496 ScheduleForSingleView(&view, &group, initial_time_); | 496 ScheduleForSingleView(&view, &group, initial_time_); |
| 497 | 497 |
| 498 // Schedule() again, this time without animating opacity. | 498 // Schedule() again, this time without animating opacity. |
| 499 group.sequences[0]->elements[0]->property = ANIMATION_PROPERTY_NONE; | 499 group.sequences[0]->elements[0]->property = AnimationProperty::NONE; |
| 500 ScheduleForSingleView(&view, &group, initial_time_); | 500 ScheduleForSingleView(&view, &group, initial_time_); |
| 501 | 501 |
| 502 // Opacity should go to final value. | 502 // Opacity should go to final value. |
| 503 EXPECT_EQ(.5f, view.opacity()); | 503 EXPECT_EQ(.5f, view.opacity()); |
| 504 // Transform shouldn't have changed since newly scheduled animation also has | 504 // Transform shouldn't have changed since newly scheduled animation also has |
| 505 // transform in it. | 505 // transform in it. |
| 506 EXPECT_TRUE(view.transform().IsIdentity()); | 506 EXPECT_TRUE(view.transform().IsIdentity()); |
| 507 } | 507 } |
| 508 | 508 |
| 509 // Opacity from 1 to .5 over 1000 of v1 and v2 transform to 2x,4x over 500. | 509 // Opacity from 1 to .5 over 1000 of v1 and v2 transform to 2x,4x over 500. |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 ASSERT_EQ(0u, runner_observer_.changes()->size()); | 631 ASSERT_EQ(0u, runner_observer_.changes()->size()); |
| 632 | 632 |
| 633 // Animate to end. | 633 // Animate to end. |
| 634 runner_.Tick(initial_time_ + TimeDelta::FromMicroseconds(2000)); | 634 runner_.Tick(initial_time_ + TimeDelta::FromMicroseconds(2000)); |
| 635 ASSERT_EQ(1u, runner_observer_.changes()->size()); | 635 ASSERT_EQ(1u, runner_observer_.changes()->size()); |
| 636 EXPECT_EQ("done", runner_observer_.changes()->at(0)); | 636 EXPECT_EQ("done", runner_observer_.changes()->at(0)); |
| 637 EXPECT_EQ(animation_id2, runner_observer_.change_ids()->at(0)); | 637 EXPECT_EQ(animation_id2, runner_observer_.change_ids()->at(0)); |
| 638 } | 638 } |
| 639 | 639 |
| 640 } // namespace view_manager | 640 } // namespace view_manager |
| OLD | NEW |