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

Side by Side Diff: services/view_manager/scheduled_animation_group_unittest.cc

Issue 1375313006: For c++, Generate enum classes instead of enum from mojom. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 2 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 unified diff | Download patch
OLDNEW
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/scheduled_animation_group.h" 5 #include "services/view_manager/scheduled_animation_group.h"
6 6
7 #include "mojo/converters/geometry/geometry_type_converters.h" 7 #include "mojo/converters/geometry/geometry_type_converters.h"
8 #include "mojo/services/view_manager/public/interfaces/animations.mojom.h" 8 #include "mojo/services/view_manager/public/interfaces/animations.mojom.h"
9 #include "services/view_manager/server_view.h" 9 #include "services/view_manager/server_view.h"
10 #include "services/view_manager/test_server_view_delegate.h" 10 #include "services/view_manager/test_server_view_delegate.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 using mojo::ANIMATION_PROPERTY_NONE; 13 using mojo::AnimationProperty;
14 using mojo::ANIMATION_PROPERTY_OPACITY; 14 using mojo::AnimationTweenType;
15 using mojo::ANIMATION_PROPERTY_TRANSFORM;
16 using mojo::ANIMATION_TWEEN_TYPE_LINEAR;
17 using mojo::AnimationGroup; 15 using mojo::AnimationGroup;
18 using mojo::AnimationSequence; 16 using mojo::AnimationSequence;
19 using mojo::AnimationElement; 17 using mojo::AnimationElement;
20 using mojo::AnimationValue; 18 using mojo::AnimationValue;
21 19
22 namespace view_manager { 20 namespace view_manager {
23 namespace { 21 namespace {
24 22
25 bool IsAnimationGroupValid(const AnimationGroup& transport_group) { 23 bool IsAnimationGroupValid(const AnimationGroup& transport_group) {
26 TestServerViewDelegate view_delegate; 24 TestServerViewDelegate view_delegate;
(...skipping 12 matching lines...) Expand all
39 EXPECT_FALSE(IsAnimationGroupValid(group)); 37 EXPECT_FALSE(IsAnimationGroupValid(group));
40 38
41 group.sequences.push_back(AnimationSequence::New()); 39 group.sequences.push_back(AnimationSequence::New());
42 40
43 // Sequence with no elements is not valid. 41 // Sequence with no elements is not valid.
44 EXPECT_FALSE(IsAnimationGroupValid(group)); 42 EXPECT_FALSE(IsAnimationGroupValid(group));
45 43
46 AnimationSequence& sequence = *(group.sequences[0]); 44 AnimationSequence& sequence = *(group.sequences[0]);
47 sequence.elements.push_back(AnimationElement::New()); 45 sequence.elements.push_back(AnimationElement::New());
48 AnimationElement& element = *(sequence.elements[0]); 46 AnimationElement& element = *(sequence.elements[0]);
49 element.property = ANIMATION_PROPERTY_OPACITY; 47 element.property = AnimationProperty::OPACITY;
50 element.tween_type = ANIMATION_TWEEN_TYPE_LINEAR; 48 element.tween_type = AnimationTweenType::LINEAR;
51 49
52 // Element with no target_value is not valid. 50 // Element with no target_value is not valid.
53 EXPECT_FALSE(IsAnimationGroupValid(group)); 51 EXPECT_FALSE(IsAnimationGroupValid(group));
54 52
55 // Opacity must be between 0 and 1. 53 // Opacity must be between 0 and 1.
56 element.target_value = AnimationValue::New(); 54 element.target_value = AnimationValue::New();
57 element.target_value->float_value = 2.5f; 55 element.target_value->float_value = 2.5f;
58 EXPECT_FALSE(IsAnimationGroupValid(group)); 56 EXPECT_FALSE(IsAnimationGroupValid(group));
59 57
60 element.target_value->float_value = .5f; 58 element.target_value->float_value = .5f;
61 EXPECT_TRUE(IsAnimationGroupValid(group)); 59 EXPECT_TRUE(IsAnimationGroupValid(group));
62 60
63 // Bogus start value. 61 // Bogus start value.
64 element.start_value = AnimationValue::New(); 62 element.start_value = AnimationValue::New();
65 element.start_value->float_value = 2.5f; 63 element.start_value->float_value = 2.5f;
66 EXPECT_FALSE(IsAnimationGroupValid(group)); 64 EXPECT_FALSE(IsAnimationGroupValid(group));
67 65
68 element.start_value->float_value = .5f; 66 element.start_value->float_value = .5f;
69 EXPECT_TRUE(IsAnimationGroupValid(group)); 67 EXPECT_TRUE(IsAnimationGroupValid(group));
70 68
71 // Bogus transform. 69 // Bogus transform.
72 element.property = ANIMATION_PROPERTY_TRANSFORM; 70 element.property = AnimationProperty::TRANSFORM;
73 EXPECT_FALSE(IsAnimationGroupValid(group)); 71 EXPECT_FALSE(IsAnimationGroupValid(group));
74 element.start_value->transform = mojo::Transform::From(gfx::Transform()); 72 element.start_value->transform = mojo::Transform::From(gfx::Transform());
75 EXPECT_FALSE(IsAnimationGroupValid(group)); 73 EXPECT_FALSE(IsAnimationGroupValid(group));
76 element.target_value->transform = mojo::Transform::From(gfx::Transform()); 74 element.target_value->transform = mojo::Transform::From(gfx::Transform());
77 EXPECT_TRUE(IsAnimationGroupValid(group)); 75 EXPECT_TRUE(IsAnimationGroupValid(group));
78 76
79 // Add another empty sequence, should be invalid again. 77 // Add another empty sequence, should be invalid again.
80 group.sequences.push_back(AnimationSequence::New()); 78 group.sequences.push_back(AnimationSequence::New());
81 EXPECT_FALSE(IsAnimationGroupValid(group)); 79 EXPECT_FALSE(IsAnimationGroupValid(group));
82 80
83 AnimationSequence& sequence2 = *(group.sequences[1]); 81 AnimationSequence& sequence2 = *(group.sequences[1]);
84 sequence2.elements.push_back(AnimationElement::New()); 82 sequence2.elements.push_back(AnimationElement::New());
85 AnimationElement& element2 = *(sequence2.elements[0]); 83 AnimationElement& element2 = *(sequence2.elements[0]);
86 element2.property = ANIMATION_PROPERTY_OPACITY; 84 element2.property = AnimationProperty::OPACITY;
87 element2.tween_type = ANIMATION_TWEEN_TYPE_LINEAR; 85 element2.tween_type = AnimationTweenType::LINEAR;
88 86
89 // Element with no target_value is not valid. 87 // Element with no target_value is not valid.
90 EXPECT_FALSE(IsAnimationGroupValid(group)); 88 EXPECT_FALSE(IsAnimationGroupValid(group));
91 89
92 element2.property = ANIMATION_PROPERTY_NONE; 90 element2.property = AnimationProperty::NONE;
93 EXPECT_TRUE(IsAnimationGroupValid(group)); 91 EXPECT_TRUE(IsAnimationGroupValid(group));
94 } 92 }
95 93
96 } // namespace view_manager 94 } // namespace view_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698