| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "services/view_manager/scheduled_animation_group.h" |
| 6 |
| 7 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 8 #include "mojo/services/public/interfaces/view_manager/view_manager_constants.mo
jom.h" |
| 9 #include "services/view_manager/server_view.h" |
| 10 #include "services/view_manager/test_server_view_delegate.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 |
| 13 namespace mojo { |
| 14 namespace service { |
| 15 namespace { |
| 16 |
| 17 bool IsAnimationGroupValid(const AnimationGroup& transport_group) { |
| 18 TestServerViewDelegate view_delegate; |
| 19 ServerView view(&view_delegate, ViewId()); |
| 20 scoped_ptr<ScheduledAnimationGroup> group(ScheduledAnimationGroup::Create( |
| 21 &view, base::TimeTicks::Now(), 1, transport_group)); |
| 22 return group.get() != nullptr; |
| 23 } |
| 24 |
| 25 } // namespace |
| 26 |
| 27 TEST(ScheduledAnimationGroupTest, IsAnimationGroupValid) { |
| 28 AnimationGroup group; |
| 29 |
| 30 // AnimationGroup with no sequences is not valid. |
| 31 EXPECT_FALSE(IsAnimationGroupValid(group)); |
| 32 |
| 33 group.sequences.push_back(AnimationSequence::New()); |
| 34 |
| 35 // Sequence with no elements is not valid. |
| 36 EXPECT_FALSE(IsAnimationGroupValid(group)); |
| 37 |
| 38 AnimationSequence& sequence = *(group.sequences[0]); |
| 39 sequence.elements.push_back(AnimationElement::New()); |
| 40 AnimationElement& element = *(sequence.elements[0]); |
| 41 element.property = ANIMATION_PROPERTY_OPACITY; |
| 42 element.tween_type = ANIMATION_TWEEN_TYPE_LINEAR; |
| 43 |
| 44 // Element with no target_value is not valid. |
| 45 EXPECT_FALSE(IsAnimationGroupValid(group)); |
| 46 |
| 47 // Opacity must be between 0 and 1. |
| 48 element.target_value = AnimationValue::New(); |
| 49 element.target_value->float_value = 2.5f; |
| 50 EXPECT_FALSE(IsAnimationGroupValid(group)); |
| 51 |
| 52 element.target_value->float_value = .5f; |
| 53 EXPECT_TRUE(IsAnimationGroupValid(group)); |
| 54 |
| 55 // Bogus start value. |
| 56 element.start_value = AnimationValue::New(); |
| 57 element.start_value->float_value = 2.5f; |
| 58 EXPECT_FALSE(IsAnimationGroupValid(group)); |
| 59 |
| 60 element.start_value->float_value = .5f; |
| 61 EXPECT_TRUE(IsAnimationGroupValid(group)); |
| 62 |
| 63 // Bogus transform. |
| 64 element.property = ANIMATION_PROPERTY_TRANSFORM; |
| 65 EXPECT_FALSE(IsAnimationGroupValid(group)); |
| 66 element.start_value->transform = Transform::From(gfx::Transform()); |
| 67 EXPECT_FALSE(IsAnimationGroupValid(group)); |
| 68 element.target_value->transform = Transform::From(gfx::Transform()); |
| 69 EXPECT_TRUE(IsAnimationGroupValid(group)); |
| 70 |
| 71 // Add another empty sequence, should be invalid again. |
| 72 group.sequences.push_back(AnimationSequence::New()); |
| 73 EXPECT_FALSE(IsAnimationGroupValid(group)); |
| 74 |
| 75 AnimationSequence& sequence2 = *(group.sequences[1]); |
| 76 sequence2.elements.push_back(AnimationElement::New()); |
| 77 AnimationElement& element2 = *(sequence2.elements[0]); |
| 78 element2.property = ANIMATION_PROPERTY_OPACITY; |
| 79 element2.tween_type = ANIMATION_TWEEN_TYPE_LINEAR; |
| 80 |
| 81 // Element with no target_value is not valid. |
| 82 EXPECT_FALSE(IsAnimationGroupValid(group)); |
| 83 |
| 84 element2.property = ANIMATION_PROPERTY_NONE; |
| 85 EXPECT_TRUE(IsAnimationGroupValid(group)); |
| 86 } |
| 87 |
| 88 } // namespace service |
| 89 } // namespace mojo |
| OLD | NEW |