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

Side by Side Diff: ash/common/shelf/shelf_background_animator_unittest.cc

Issue 2679333002: [ash-md] Remove the number of animators used for the Shelf animations. (Closed)
Patch Set: Addressed review comments and updated ShelfBackgroundAnimator::animator_ lifetime. Created 3 years, 10 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ash/common/shelf/shelf_background_animator.h" 5 #include "ash/common/shelf/shelf_background_animator.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "ash/common/shelf/shelf_background_animator_observer.h" 9 #include "ash/common/shelf/shelf_background_animator_observer.h"
10 #include "ash/common/shelf/shelf_constants.h" 10 #include "ash/common/shelf/shelf_constants.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/test/test_mock_time_task_runner.h" 13 #include "base/test/test_mock_time_task_runner.h"
14 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/thread_task_runner_handle.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "ui/gfx/animation/animation_change_type.h"
17 #include "ui/gfx/animation/slide_animation.h"
16 18
17 namespace ash { 19 namespace ash {
18 namespace { 20 namespace {
19 21
20 const int kMaxAlpha = 255; 22 const int kMaxAlpha = 255;
21 23
22 // A valid alpha value that is distinct from any final animation state values. 24 // A valid alpha value that is distinct from any final animation state values.
23 // Used to check if alpha values are changed during animations. 25 // Used to check if alpha values are changed during animations.
24 const int kDummyAlpha = 111; 26 const int kDummyAlpha = 111;
25 27
26 // Observer that caches alpha values for the last observation. 28 // Observer that caches alpha values for the last observation.
27 class TestShelfBackgroundObserver : public ShelfBackgroundAnimatorObserver { 29 class TestShelfBackgroundObserver : public ShelfBackgroundAnimatorObserver {
28 public: 30 public:
29 TestShelfBackgroundObserver() {} 31 TestShelfBackgroundObserver() {}
30 ~TestShelfBackgroundObserver() override {} 32 ~TestShelfBackgroundObserver() override {}
31 33
32 int opaque_background_alpha() const { return opaque_background_alpha_; } 34 int background_alpha() const { return background_alpha_; }
33 35
34 int item_background_alpha() const { return item_background_alpha_; } 36 int item_background_alpha() const { return item_background_alpha_; }
35 37
36 // ShelfBackgroundObserver: 38 // ShelfBackgroundObserver:
37 void UpdateShelfOpaqueBackground(int alpha) override; 39 void UpdateShelfBackground(int alpha) override;
38 void UpdateShelfItemBackground(int alpha) override; 40 void UpdateShelfItemBackground(int alpha) override;
39 41
40 private: 42 private:
41 int opaque_background_alpha_ = 0; 43 int background_alpha_ = 0;
42 int item_background_alpha_ = 0; 44 int item_background_alpha_ = 0;
43 45
44 DISALLOW_COPY_AND_ASSIGN(TestShelfBackgroundObserver); 46 DISALLOW_COPY_AND_ASSIGN(TestShelfBackgroundObserver);
45 }; 47 };
46 48
47 void TestShelfBackgroundObserver::UpdateShelfOpaqueBackground(int alpha) { 49 void TestShelfBackgroundObserver::UpdateShelfBackground(int alpha) {
48 opaque_background_alpha_ = alpha; 50 background_alpha_ = alpha;
49 } 51 }
50 52
51 void TestShelfBackgroundObserver::UpdateShelfItemBackground(int alpha) { 53 void TestShelfBackgroundObserver::UpdateShelfItemBackground(int alpha) {
52 item_background_alpha_ = alpha; 54 item_background_alpha_ = alpha;
53 } 55 }
54 56
55 } // namespace 57 } // namespace
56 58
57 // Provides internal access to a ShelfBackgroundAnimator instance. 59 // Provides internal access to a ShelfBackgroundAnimator instance.
58 class ShelfBackgroundAnimatorTestApi { 60 class ShelfBackgroundAnimatorTestApi {
59 public: 61 public:
60 explicit ShelfBackgroundAnimatorTestApi(ShelfBackgroundAnimator* animator) 62 explicit ShelfBackgroundAnimatorTestApi(ShelfBackgroundAnimator* animator)
61 : animator_(animator) {} 63 : animator_(animator) {}
62 64
63 ~ShelfBackgroundAnimatorTestApi() {} 65 ~ShelfBackgroundAnimatorTestApi() {}
64 66
65 ShelfBackgroundType previous_background_type() const { 67 ShelfBackgroundType previous_background_type() const {
66 return animator_->previous_background_type_; 68 return animator_->previous_background_type_;
67 } 69 }
68 70
69 BackgroundAnimator* opaque_background_animator() const { 71 gfx::SlideAnimation* animator() const { return animator_->animator_.get(); }
70 return animator_->opaque_background_animator_.get();
71 }
72
73 BackgroundAnimator* item_background_animator() const {
74 return animator_->item_background_animator_.get();
75 }
76
77 bool can_reuse_animators() const { return animator_->can_reuse_animators_; }
78 72
79 private: 73 private:
80 // The instance to provide internal access to. 74 // The instance to provide internal access to.
81 ShelfBackgroundAnimator* animator_; 75 ShelfBackgroundAnimator* animator_;
82 76
83 DISALLOW_COPY_AND_ASSIGN(ShelfBackgroundAnimatorTestApi); 77 DISALLOW_COPY_AND_ASSIGN(ShelfBackgroundAnimatorTestApi);
84 }; 78 };
85 79
86 class ShelfBackgroundAnimatorTest : public testing::Test { 80 class ShelfBackgroundAnimatorTest : public testing::Test {
87 public: 81 public:
88 ShelfBackgroundAnimatorTest() {} 82 ShelfBackgroundAnimatorTest() {}
89 ~ShelfBackgroundAnimatorTest() override {} 83 ~ShelfBackgroundAnimatorTest() override {}
90 84
91 // testing::Test: 85 // testing::Test:
92 void SetUp() override; 86 void SetUp() override;
93 87
94 protected: 88 protected:
95 // Convenience wrapper for |animator_|'s PaintBackground() that always uses 89 // Convenience wrapper for |animator_|'s PaintBackground().
96 // BACKGROUND_CHANGE_IMMEDIATE. 90 void PaintBackground(ShelfBackgroundType background_type,
97 void PaintBackground(ShelfBackgroundType background_type); 91 gfx::AnimationChangeType change_type =
92 gfx::AnimationChangeType::IMMEDIATE);
98 93
99 // Set all of the alpha values for the |observer_|. 94 // Set all of the alpha values for the |observer_|.
100 void SetAlphaValuesOnObserver(int alpha); 95 void SetAlphaValuesOnObserver(int alpha);
101 96
102 // Completes all the animations. 97 // Completes all the animations.
103 void CompleteAnimations(); 98 void CompleteAnimations();
104 99
105 TestShelfBackgroundObserver observer_; 100 TestShelfBackgroundObserver observer_;
106 101
107 // Test target. 102 // Test target.
(...skipping 16 matching lines...) Expand all
124 task_runner_handle_.reset(new base::ThreadTaskRunnerHandle(task_runner_)); 119 task_runner_handle_.reset(new base::ThreadTaskRunnerHandle(task_runner_));
125 120
126 animator_.reset( 121 animator_.reset(
127 new ShelfBackgroundAnimator(SHELF_BACKGROUND_DEFAULT, nullptr)); 122 new ShelfBackgroundAnimator(SHELF_BACKGROUND_DEFAULT, nullptr));
128 animator_->AddObserver(&observer_); 123 animator_->AddObserver(&observer_);
129 124
130 test_api_.reset(new ShelfBackgroundAnimatorTestApi(animator_.get())); 125 test_api_.reset(new ShelfBackgroundAnimatorTestApi(animator_.get()));
131 } 126 }
132 127
133 void ShelfBackgroundAnimatorTest::PaintBackground( 128 void ShelfBackgroundAnimatorTest::PaintBackground(
134 ShelfBackgroundType background_type) { 129 ShelfBackgroundType background_type,
135 animator_->PaintBackground(background_type, BACKGROUND_CHANGE_IMMEDIATE); 130 gfx::AnimationChangeType change_type) {
131 animator_->PaintBackground(background_type, change_type);
136 } 132 }
137 133
138 void ShelfBackgroundAnimatorTest::SetAlphaValuesOnObserver(int alpha) { 134 void ShelfBackgroundAnimatorTest::SetAlphaValuesOnObserver(int alpha) {
139 observer_.UpdateShelfOpaqueBackground(alpha); 135 observer_.UpdateShelfBackground(alpha);
140 observer_.UpdateShelfItemBackground(alpha); 136 observer_.UpdateShelfItemBackground(alpha);
141 } 137 }
142 138
143 void ShelfBackgroundAnimatorTest::CompleteAnimations() { 139 void ShelfBackgroundAnimatorTest::CompleteAnimations() {
144 task_runner_->FastForwardUntilNoTasksRemain(); 140 task_runner_->FastForwardUntilNoTasksRemain();
145 } 141 }
146 142
147 // Verify the |previous_background_type_| and |target_background_type_| values 143 // Verify the |previous_background_type_| and |target_background_type_| values
148 // when animating to the same target type multiple times. 144 // when animating to the same target type multiple times.
149 TEST_F(ShelfBackgroundAnimatorTest, BackgroundTypesWhenAnimatingToSameTarget) { 145 TEST_F(ShelfBackgroundAnimatorTest, BackgroundTypesWhenAnimatingToSameTarget) {
150 PaintBackground(SHELF_BACKGROUND_MAXIMIZED); 146 PaintBackground(SHELF_BACKGROUND_MAXIMIZED);
151 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, animator_->target_background_type()); 147 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, animator_->target_background_type());
152 148
153 PaintBackground(SHELF_BACKGROUND_DEFAULT); 149 PaintBackground(SHELF_BACKGROUND_DEFAULT);
154 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, animator_->target_background_type()); 150 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, animator_->target_background_type());
155 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, test_api_->previous_background_type()); 151 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, test_api_->previous_background_type());
156 152
157 PaintBackground(SHELF_BACKGROUND_DEFAULT); 153 PaintBackground(SHELF_BACKGROUND_DEFAULT);
158 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, animator_->target_background_type()); 154 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, animator_->target_background_type());
159 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, test_api_->previous_background_type()); 155 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, test_api_->previous_background_type());
160 } 156 }
161 157
162 // Verify subsequent calls to PaintBackground() using the 158 // Verify subsequent calls to PaintBackground() using the
163 // BACKGROUND_CHANGE_ANIMATE change type are ignored. 159 // gfx::AnimationChangeType::ANIMATE change type are ignored.
164 TEST_F(ShelfBackgroundAnimatorTest, 160 TEST_F(ShelfBackgroundAnimatorTest,
165 MultipleAnimateCallsToSameTargetAreIgnored) { 161 MultipleAnimateCallsToSameTargetAreIgnored) {
166 PaintBackground(SHELF_BACKGROUND_MAXIMIZED); 162 PaintBackground(SHELF_BACKGROUND_MAXIMIZED);
167 SetAlphaValuesOnObserver(kDummyAlpha); 163 SetAlphaValuesOnObserver(kDummyAlpha);
168 animator_->PaintBackground(SHELF_BACKGROUND_DEFAULT, 164 animator_->PaintBackground(SHELF_BACKGROUND_DEFAULT,
169 BACKGROUND_CHANGE_ANIMATE); 165 gfx::AnimationChangeType::ANIMATE);
170 CompleteAnimations(); 166 CompleteAnimations();
171 167
172 EXPECT_NE(observer_.opaque_background_alpha(), kDummyAlpha); 168 EXPECT_NE(observer_.background_alpha(), kDummyAlpha);
173 EXPECT_NE(observer_.item_background_alpha(), kDummyAlpha); 169 EXPECT_NE(observer_.item_background_alpha(), kDummyAlpha);
174 170
175 SetAlphaValuesOnObserver(kDummyAlpha); 171 SetAlphaValuesOnObserver(kDummyAlpha);
176 animator_->PaintBackground(SHELF_BACKGROUND_DEFAULT, 172 animator_->PaintBackground(SHELF_BACKGROUND_DEFAULT,
177 BACKGROUND_CHANGE_ANIMATE); 173 gfx::AnimationChangeType::ANIMATE);
178 CompleteAnimations(); 174 CompleteAnimations();
179 175
180 EXPECT_EQ(observer_.opaque_background_alpha(), kDummyAlpha); 176 EXPECT_EQ(observer_.background_alpha(), kDummyAlpha);
181 EXPECT_EQ(observer_.item_background_alpha(), kDummyAlpha); 177 EXPECT_EQ(observer_.item_background_alpha(), kDummyAlpha);
182 } 178 }
183 179
184 // Verify observers are updated with the current values when they are added. 180 // Verify observers are updated with the current values when they are added.
185 TEST_F(ShelfBackgroundAnimatorTest, ObserversUpdatedWhenAdded) { 181 TEST_F(ShelfBackgroundAnimatorTest, ObserversUpdatedWhenAdded) {
186 animator_->RemoveObserver(&observer_); 182 animator_->RemoveObserver(&observer_);
187 SetAlphaValuesOnObserver(kDummyAlpha); 183 SetAlphaValuesOnObserver(kDummyAlpha);
188 184
189 animator_->AddObserver(&observer_); 185 animator_->AddObserver(&observer_);
190 186
191 EXPECT_NE(observer_.opaque_background_alpha(), kDummyAlpha); 187 EXPECT_NE(observer_.background_alpha(), kDummyAlpha);
192 EXPECT_NE(observer_.item_background_alpha(), kDummyAlpha); 188 EXPECT_NE(observer_.item_background_alpha(), kDummyAlpha);
193 } 189 }
194 190
195 // Verify the alpha values for the SHELF_BACKGROUND_DEFAULT state. 191 // Verify the alpha values for the SHELF_BACKGROUND_DEFAULT state.
196 TEST_F(ShelfBackgroundAnimatorTest, DefaultBackground) { 192 TEST_F(ShelfBackgroundAnimatorTest, DefaultBackground) {
197 PaintBackground(SHELF_BACKGROUND_DEFAULT); 193 PaintBackground(SHELF_BACKGROUND_DEFAULT);
198 194
199 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, animator_->target_background_type()); 195 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, animator_->target_background_type());
200 EXPECT_EQ(0, observer_.opaque_background_alpha()); 196 EXPECT_EQ(0, observer_.background_alpha());
201 EXPECT_EQ(kShelfTranslucentAlpha, observer_.item_background_alpha()); 197 EXPECT_EQ(kShelfTranslucentAlpha, observer_.item_background_alpha());
202 } 198 }
203 199
204 // Verify the alpha values for the SHELF_BACKGROUND_OVERLAP state. 200 // Verify the alpha values for the SHELF_BACKGROUND_OVERLAP state.
205 TEST_F(ShelfBackgroundAnimatorTest, OverlapBackground) { 201 TEST_F(ShelfBackgroundAnimatorTest, OverlapBackground) {
206 PaintBackground(SHELF_BACKGROUND_OVERLAP); 202 PaintBackground(SHELF_BACKGROUND_OVERLAP);
207 203
208 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, animator_->target_background_type()); 204 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, animator_->target_background_type());
209 EXPECT_EQ(kShelfTranslucentAlpha, observer_.opaque_background_alpha()); 205 EXPECT_EQ(kShelfTranslucentAlpha, observer_.background_alpha());
210 EXPECT_EQ(0, observer_.item_background_alpha()); 206 EXPECT_EQ(0, observer_.item_background_alpha());
211 } 207 }
212 208
213 // Verify the alpha values for the SHELF_BACKGROUND_MAXIMIZED state. 209 // Verify the alpha values for the SHELF_BACKGROUND_MAXIMIZED state.
214 TEST_F(ShelfBackgroundAnimatorTest, MaximizedBackground) { 210 TEST_F(ShelfBackgroundAnimatorTest, MaximizedBackground) {
215 PaintBackground(SHELF_BACKGROUND_MAXIMIZED); 211 PaintBackground(SHELF_BACKGROUND_MAXIMIZED);
216 212
217 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, animator_->target_background_type()); 213 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, animator_->target_background_type());
218 EXPECT_EQ(kMaxAlpha, observer_.opaque_background_alpha()); 214 EXPECT_EQ(kMaxAlpha, observer_.background_alpha());
219 EXPECT_EQ(0, observer_.item_background_alpha()); 215 EXPECT_EQ(0, observer_.item_background_alpha());
220 } 216 }
221 217
222 // Verify that existing animators are used when animating to the previous state. 218 TEST_F(ShelfBackgroundAnimatorTest,
223 TEST_F(ShelfBackgroundAnimatorTest, ExistingAnimatorsAreReused) { 219 AnimatorIsDetroyedWhenCompletingSuccessfully) {
224 PaintBackground(SHELF_BACKGROUND_DEFAULT); 220 PaintBackground(SHELF_BACKGROUND_OVERLAP, gfx::AnimationChangeType::ANIMATE);
225 PaintBackground(SHELF_BACKGROUND_MAXIMIZED); 221 EXPECT_NE(nullptr, test_api_->animator());
James Cook 2017/02/10 21:17:34 nit: It's pretty common to EXPECT_TRUE(pointer) an
bruthig 2017/02/10 22:45:36 Done.
226 EXPECT_TRUE(test_api_->can_reuse_animators()); 222 CompleteAnimations();
227 223 EXPECT_EQ(nullptr, test_api_->animator());
228 const BackgroundAnimator* opaque_animator =
229 test_api_->opaque_background_animator();
230 const BackgroundAnimator* item_animator =
231 test_api_->item_background_animator();
232
233 PaintBackground(SHELF_BACKGROUND_DEFAULT);
234
235 EXPECT_EQ(opaque_animator, test_api_->opaque_background_animator());
236 EXPECT_EQ(item_animator, test_api_->item_background_animator());
237 } 224 }
238 225
239 // Verify that existing animators are not re-used when the previous animation
240 // didn't complete.
241 TEST_F(ShelfBackgroundAnimatorTest, 226 TEST_F(ShelfBackgroundAnimatorTest,
242 ExistingAnimatorsNotReusedWhenPreviousAnimationsDontComplete) { 227 AnimatorDestroyedWhenChangingBackgroundImmedidately) {
James Cook 2017/02/10 21:17:34 nit: Immediately
bruthig 2017/02/10 22:45:36 Done.
243 EXPECT_NE(SHELF_BACKGROUND_OVERLAP, test_api_->previous_background_type()); 228 PaintBackground(SHELF_BACKGROUND_OVERLAP, gfx::AnimationChangeType::ANIMATE);
244 animator_->PaintBackground(SHELF_BACKGROUND_OVERLAP, 229 EXPECT_NE(nullptr, test_api_->animator());
245 BACKGROUND_CHANGE_ANIMATE);
246 animator_->PaintBackground(SHELF_BACKGROUND_MAXIMIZED,
247 BACKGROUND_CHANGE_ANIMATE);
248 EXPECT_FALSE(test_api_->can_reuse_animators());
249 230
250 const BackgroundAnimator* opaque_animator = 231 PaintBackground(SHELF_BACKGROUND_OVERLAP,
251 test_api_->opaque_background_animator(); 232 gfx::AnimationChangeType::IMMEDIATE);
252 const BackgroundAnimator* item_animator = 233 EXPECT_EQ(nullptr, test_api_->animator());
253 test_api_->item_background_animator();
254
255 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, test_api_->previous_background_type());
256 animator_->PaintBackground(SHELF_BACKGROUND_OVERLAP,
257 BACKGROUND_CHANGE_ANIMATE);
258
259 EXPECT_NE(opaque_animator, test_api_->opaque_background_animator());
260 EXPECT_NE(item_animator, test_api_->item_background_animator());
261 } 234 }
262 235
263 // Verify that existing animators are not re-used when the target background 236 // Verify that existing animator is used when animating to the previous state.
264 // isn't the same as the previous background.
265 TEST_F(ShelfBackgroundAnimatorTest, 237 TEST_F(ShelfBackgroundAnimatorTest,
266 ExistingAnimatorsNotReusedWhenTargetBackgroundNotPreviousBackground) { 238 ExistingAnimatorIsReusedWhenAnimatingToPreviousState) {
267 PaintBackground(SHELF_BACKGROUND_DEFAULT); 239 PaintBackground(SHELF_BACKGROUND_DEFAULT, gfx::AnimationChangeType::ANIMATE);
268 PaintBackground(SHELF_BACKGROUND_MAXIMIZED); 240 PaintBackground(SHELF_BACKGROUND_MAXIMIZED,
269 EXPECT_TRUE(test_api_->can_reuse_animators()); 241 gfx::AnimationChangeType::ANIMATE);
270 242
271 const BackgroundAnimator* opaque_animator = 243 const gfx::SlideAnimation* animator = test_api_->animator();
272 test_api_->opaque_background_animator(); 244 EXPECT_NE(nullptr, animator);
273 const BackgroundAnimator* item_animator = 245
274 test_api_->item_background_animator(); 246 PaintBackground(SHELF_BACKGROUND_DEFAULT, gfx::AnimationChangeType::ANIMATE);
247
248 EXPECT_EQ(animator, test_api_->animator());
249 }
250
251 // Verify that existing animator is not re-used when the target background isn't
252 // the same as the previous background.
253 TEST_F(ShelfBackgroundAnimatorTest,
254 ExistingAnimatorNotReusedWhenTargetBackgroundNotPreviousBackground) {
255 PaintBackground(SHELF_BACKGROUND_DEFAULT, gfx::AnimationChangeType::ANIMATE);
256 PaintBackground(SHELF_BACKGROUND_MAXIMIZED,
257 gfx::AnimationChangeType::ANIMATE);
258
259 const gfx::SlideAnimation* animator = test_api_->animator();
260 EXPECT_NE(nullptr, animator);
275 261
276 EXPECT_NE(SHELF_BACKGROUND_OVERLAP, test_api_->previous_background_type()); 262 EXPECT_NE(SHELF_BACKGROUND_OVERLAP, test_api_->previous_background_type());
277 PaintBackground(SHELF_BACKGROUND_OVERLAP); 263 PaintBackground(SHELF_BACKGROUND_OVERLAP, gfx::AnimationChangeType::ANIMATE);
278 264
279 EXPECT_NE(opaque_animator, test_api_->opaque_background_animator()); 265 EXPECT_NE(animator, test_api_->animator());
280 EXPECT_NE(item_animator, test_api_->item_background_animator());
281 } 266 }
282 267
283 // Verify animators are not re-used after snapping to the same background type.
284 TEST_F(ShelfBackgroundAnimatorTest, 268 TEST_F(ShelfBackgroundAnimatorTest,
285 ExistingAnimatorsNotUsedWhenSnappingToSameTargetBackground) { 269 AnimationProgressesToTargetWhenStoppingUnfinishedAnimator) {
286 PaintBackground(SHELF_BACKGROUND_DEFAULT); 270 PaintBackground(SHELF_BACKGROUND_OVERLAP, gfx::AnimationChangeType::ANIMATE);
287 PaintBackground(SHELF_BACKGROUND_DEFAULT);
288 271
289 EXPECT_FALSE(test_api_->can_reuse_animators()); 272 EXPECT_NE(kShelfTranslucentAlpha, observer_.background_alpha());
273 EXPECT_NE(0, observer_.item_background_alpha());
274
275 test_api_->animator()->Stop();
276
277 EXPECT_EQ(kShelfTranslucentAlpha, observer_.background_alpha());
278 EXPECT_EQ(0, observer_.item_background_alpha());
290 } 279 }
291 280
292 // Verify observers are always notified, even when alpha values don't change. 281 // Verify observers are always notified, even when alpha values don't change.
293 TEST_F(ShelfBackgroundAnimatorTest, 282 TEST_F(ShelfBackgroundAnimatorTest,
294 ObserversAreNotifiedWhenSnappingToSameTargetBackground) { 283 ObserversAreNotifiedWhenSnappingToSameTargetBackground) {
295 PaintBackground(SHELF_BACKGROUND_DEFAULT); 284 PaintBackground(SHELF_BACKGROUND_DEFAULT);
296 SetAlphaValuesOnObserver(kDummyAlpha); 285 SetAlphaValuesOnObserver(kDummyAlpha);
297 PaintBackground(SHELF_BACKGROUND_DEFAULT); 286 PaintBackground(SHELF_BACKGROUND_DEFAULT);
298 287
299 EXPECT_NE(observer_.opaque_background_alpha(), kDummyAlpha); 288 EXPECT_NE(observer_.background_alpha(), kDummyAlpha);
300 EXPECT_NE(observer_.item_background_alpha(), kDummyAlpha); 289 EXPECT_NE(observer_.item_background_alpha(), kDummyAlpha);
301 } 290 }
302 291
303 } // namespace ash 292 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698