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

Side by Side Diff: ui/compositor/layer_animator_unittest.cc

Issue 2854653003: [Night Light] Backend ui::Layer work (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « ui/compositor/layer_animator.cc ('k') | ui/compositor/test/test_layer_animation_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/compositor/layer_animator.h" 5 #include "ui/compositor/layer_animator.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 2233 matching lines...) Expand 10 before | Expand all | Expand 10 after
2244 EXPECT_EQ(ColorToString(middle_color), 2244 EXPECT_EQ(ColorToString(middle_color),
2245 ColorToString(delegate.GetColorForAnimation())); 2245 ColorToString(delegate.GetColorForAnimation()));
2246 2246
2247 animator->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); 2247 animator->Step(start_time + base::TimeDelta::FromMilliseconds(1000));
2248 2248
2249 EXPECT_FALSE(animator->is_animating()); 2249 EXPECT_FALSE(animator->is_animating());
2250 EXPECT_EQ(ColorToString(target_color), 2250 EXPECT_EQ(ColorToString(target_color),
2251 ColorToString(delegate.GetColorForAnimation())); 2251 ColorToString(delegate.GetColorForAnimation()));
2252 } 2252 }
2253 2253
2254 // Verifies temperature property is modified appropriately.
2255 TEST(LayerAnimatorTest, Temperature) {
2256 TestLayerAnimationDelegate delegate;
2257 scoped_refptr<LayerAnimator> animator(CreateDefaultTestAnimator(&delegate));
2258
2259 float start_temperature = 0.0f;
2260 float middle_temperature = 0.5f;
2261 float target_temperature = 1.0f;
2262
2263 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
2264
2265 delegate.SetTemperatureFromAnimation(start_temperature);
2266
2267 animator->ScheduleAnimation(new LayerAnimationSequence(
2268 LayerAnimationElement::CreateTemperatureElement(target_temperature,
2269 delta)));
2270
2271 EXPECT_TRUE(animator->is_animating());
2272 EXPECT_EQ(start_temperature, delegate.GetTemperatureFromAnimation());
2273
2274 base::TimeTicks start_time = animator->last_step_time();
2275
2276 animator->Step(start_time + base::TimeDelta::FromMilliseconds(500));
2277
2278 EXPECT_TRUE(animator->is_animating());
2279 EXPECT_EQ(middle_temperature, delegate.GetTemperatureFromAnimation());
2280
2281 animator->Step(start_time + base::TimeDelta::FromMilliseconds(1000));
2282
2283 EXPECT_FALSE(animator->is_animating());
2284 EXPECT_EQ(target_temperature, delegate.GetTemperatureFromAnimation());
2285 }
2286
2254 // Verifies SchedulePauseForProperties(). 2287 // Verifies SchedulePauseForProperties().
2255 TEST(LayerAnimatorTest, SchedulePauseForProperties) { 2288 TEST(LayerAnimatorTest, SchedulePauseForProperties) {
2256 scoped_refptr<LayerAnimator> animator(CreateDefaultTestAnimator()); 2289 scoped_refptr<LayerAnimator> animator(CreateDefaultTestAnimator());
2257 animator->set_preemption_strategy(LayerAnimator::ENQUEUE_NEW_ANIMATION); 2290 animator->set_preemption_strategy(LayerAnimator::ENQUEUE_NEW_ANIMATION);
2258 animator->SchedulePauseForProperties( 2291 animator->SchedulePauseForProperties(
2259 base::TimeDelta::FromMilliseconds(100), 2292 base::TimeDelta::FromMilliseconds(100),
2260 LayerAnimationElement::TRANSFORM | LayerAnimationElement::BOUNDS); 2293 LayerAnimationElement::TRANSFORM | LayerAnimationElement::BOUNDS);
2261 EXPECT_TRUE(animator->IsAnimatingProperty(LayerAnimationElement::TRANSFORM)); 2294 EXPECT_TRUE(animator->IsAnimatingProperty(LayerAnimationElement::TRANSFORM));
2262 EXPECT_TRUE(animator->IsAnimatingProperty(LayerAnimationElement::BOUNDS)); 2295 EXPECT_TRUE(animator->IsAnimatingProperty(LayerAnimationElement::BOUNDS));
2263 EXPECT_FALSE(animator->IsAnimatingProperty(LayerAnimationElement::OPACITY)); 2296 EXPECT_FALSE(animator->IsAnimatingProperty(LayerAnimationElement::OPACITY));
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
2951 EXPECT_EQ(observer.last_ended_sequence(), nullptr); 2984 EXPECT_EQ(observer.last_ended_sequence(), nullptr);
2952 EXPECT_EQ(observer.last_detached_sequence(), first_sequence); 2985 EXPECT_EQ(observer.last_detached_sequence(), first_sequence);
2953 2986
2954 EXPECT_TRUE(observer.AbortedEpochIsBeforeDetachedEpoch()); 2987 EXPECT_TRUE(observer.AbortedEpochIsBeforeDetachedEpoch());
2955 EXPECT_TRUE(observer.AbortedEpochIsBeforeStartedEpoch()); 2988 EXPECT_TRUE(observer.AbortedEpochIsBeforeStartedEpoch());
2956 EXPECT_TRUE(observer.AttachedEpochIsBeforeScheduledEpoch()); 2989 EXPECT_TRUE(observer.AttachedEpochIsBeforeScheduledEpoch());
2957 EXPECT_TRUE(observer.ScheduledEpochIsBeforeStartedEpoch()); 2990 EXPECT_TRUE(observer.ScheduledEpochIsBeforeStartedEpoch());
2958 } 2991 }
2959 2992
2960 } // namespace ui 2993 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/layer_animator.cc ('k') | ui/compositor/test/test_layer_animation_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698