| OLD | NEW |
| 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" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // Observer that caches alpha values for the last observation. | 30 // Observer that caches alpha values for the last observation. |
| 31 class TestShelfBackgroundObserver : public ShelfBackgroundAnimatorObserver { | 31 class TestShelfBackgroundObserver : public ShelfBackgroundAnimatorObserver { |
| 32 public: | 32 public: |
| 33 TestShelfBackgroundObserver() {} | 33 TestShelfBackgroundObserver() {} |
| 34 ~TestShelfBackgroundObserver() override {} | 34 ~TestShelfBackgroundObserver() override {} |
| 35 | 35 |
| 36 int opaque_background_alpha() const { return opaque_background_alpha_; } | 36 int opaque_background_alpha() const { return opaque_background_alpha_; } |
| 37 | 37 |
| 38 int item_background_alpha() const { return item_background_alpha_; } | 38 int item_background_alpha() const { return item_background_alpha_; } |
| 39 | 39 |
| 40 int asset_background_alpha() const { return asset_background_alpha_; } | |
| 41 | |
| 42 // ShelfBackgroundObserver: | 40 // ShelfBackgroundObserver: |
| 43 void UpdateShelfOpaqueBackground(int alpha) override; | 41 void UpdateShelfOpaqueBackground(int alpha) override; |
| 44 void UpdateShelfAssetBackground(int alpha) override; | |
| 45 void UpdateShelfItemBackground(int alpha) override; | 42 void UpdateShelfItemBackground(int alpha) override; |
| 46 | 43 |
| 47 private: | 44 private: |
| 48 int opaque_background_alpha_ = 0; | 45 int opaque_background_alpha_ = 0; |
| 49 int item_background_alpha_ = 0; | 46 int item_background_alpha_ = 0; |
| 50 int asset_background_alpha_ = 0; | |
| 51 | 47 |
| 52 DISALLOW_COPY_AND_ASSIGN(TestShelfBackgroundObserver); | 48 DISALLOW_COPY_AND_ASSIGN(TestShelfBackgroundObserver); |
| 53 }; | 49 }; |
| 54 | 50 |
| 55 void TestShelfBackgroundObserver::UpdateShelfOpaqueBackground(int alpha) { | 51 void TestShelfBackgroundObserver::UpdateShelfOpaqueBackground(int alpha) { |
| 56 opaque_background_alpha_ = alpha; | 52 opaque_background_alpha_ = alpha; |
| 57 } | 53 } |
| 58 | 54 |
| 59 void TestShelfBackgroundObserver::UpdateShelfAssetBackground(int alpha) { | |
| 60 asset_background_alpha_ = alpha; | |
| 61 } | |
| 62 | |
| 63 void TestShelfBackgroundObserver::UpdateShelfItemBackground(int alpha) { | 55 void TestShelfBackgroundObserver::UpdateShelfItemBackground(int alpha) { |
| 64 item_background_alpha_ = alpha; | 56 item_background_alpha_ = alpha; |
| 65 } | 57 } |
| 66 | 58 |
| 67 } // namespace | 59 } // namespace |
| 68 | 60 |
| 69 // Provides internal access to a ShelfBackgroundAnimator instance. | 61 // Provides internal access to a ShelfBackgroundAnimator instance. |
| 70 class ShelfBackgroundAnimatorTestApi { | 62 class ShelfBackgroundAnimatorTestApi { |
| 71 public: | 63 public: |
| 72 explicit ShelfBackgroundAnimatorTestApi(ShelfBackgroundAnimator* animator) | 64 explicit ShelfBackgroundAnimatorTestApi(ShelfBackgroundAnimator* animator) |
| 73 : animator_(animator) {} | 65 : animator_(animator) {} |
| 74 | 66 |
| 75 ~ShelfBackgroundAnimatorTestApi() {} | 67 ~ShelfBackgroundAnimatorTestApi() {} |
| 76 | 68 |
| 77 ShelfBackgroundType previous_background_type() const { | 69 ShelfBackgroundType previous_background_type() const { |
| 78 return animator_->previous_background_type_; | 70 return animator_->previous_background_type_; |
| 79 } | 71 } |
| 80 | 72 |
| 81 BackgroundAnimator* opaque_background_animator() const { | 73 BackgroundAnimator* opaque_background_animator() const { |
| 82 return animator_->opaque_background_animator_.get(); | 74 return animator_->opaque_background_animator_.get(); |
| 83 } | 75 } |
| 84 | 76 |
| 85 BackgroundAnimator* asset_background_animator() const { | |
| 86 return animator_->asset_background_animator_.get(); | |
| 87 } | |
| 88 | |
| 89 BackgroundAnimator* item_background_animator() const { | 77 BackgroundAnimator* item_background_animator() const { |
| 90 return animator_->item_background_animator_.get(); | 78 return animator_->item_background_animator_.get(); |
| 91 } | 79 } |
| 92 | 80 |
| 93 bool can_reuse_animators() const { return animator_->can_reuse_animators_; } | 81 bool can_reuse_animators() const { return animator_->can_reuse_animators_; } |
| 94 | 82 |
| 95 private: | 83 private: |
| 96 // The instance to provide internal access to. | 84 // The instance to provide internal access to. |
| 97 ShelfBackgroundAnimator* animator_; | 85 ShelfBackgroundAnimator* animator_; |
| 98 | 86 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 expected_translucent_alpha_ = GetShelfConstant(SHELF_BACKGROUND_ALPHA); | 153 expected_translucent_alpha_ = GetShelfConstant(SHELF_BACKGROUND_ALPHA); |
| 166 } | 154 } |
| 167 | 155 |
| 168 void ShelfBackgroundAnimatorTestBase::PaintBackground( | 156 void ShelfBackgroundAnimatorTestBase::PaintBackground( |
| 169 ShelfBackgroundType background_type) { | 157 ShelfBackgroundType background_type) { |
| 170 animator_->PaintBackground(background_type, BACKGROUND_CHANGE_IMMEDIATE); | 158 animator_->PaintBackground(background_type, BACKGROUND_CHANGE_IMMEDIATE); |
| 171 } | 159 } |
| 172 | 160 |
| 173 void ShelfBackgroundAnimatorTestBase::SetAlphaValuesOnObserver(int alpha) { | 161 void ShelfBackgroundAnimatorTestBase::SetAlphaValuesOnObserver(int alpha) { |
| 174 observer_.UpdateShelfOpaqueBackground(alpha); | 162 observer_.UpdateShelfOpaqueBackground(alpha); |
| 175 observer_.UpdateShelfAssetBackground(alpha); | |
| 176 observer_.UpdateShelfItemBackground(alpha); | 163 observer_.UpdateShelfItemBackground(alpha); |
| 177 } | 164 } |
| 178 | 165 |
| 179 void ShelfBackgroundAnimatorTestBase::CompleteAnimations() { | 166 void ShelfBackgroundAnimatorTestBase::CompleteAnimations() { |
| 180 task_runner_->FastForwardUntilNoTasksRemain(); | 167 task_runner_->FastForwardUntilNoTasksRemain(); |
| 181 } | 168 } |
| 182 | 169 |
| 183 class ShelfBackgroundAnimatorNonMDTest | 170 class ShelfBackgroundAnimatorNonMDTest |
| 184 : public ShelfBackgroundAnimatorTestBase { | 171 : public ShelfBackgroundAnimatorTestBase { |
| 185 public: | 172 public: |
| 186 ShelfBackgroundAnimatorNonMDTest() {} | 173 ShelfBackgroundAnimatorNonMDTest() {} |
| 187 ~ShelfBackgroundAnimatorNonMDTest() override {} | 174 ~ShelfBackgroundAnimatorNonMDTest() override {} |
| 188 | 175 |
| 189 MaterialDesignController::Mode GetMaterialDesignMode() override { | 176 MaterialDesignController::Mode GetMaterialDesignMode() override { |
| 190 return MaterialDesignController::NON_MATERIAL; | 177 return MaterialDesignController::NON_MATERIAL; |
| 191 } | 178 } |
| 192 | 179 |
| 193 private: | 180 private: |
| 194 DISALLOW_COPY_AND_ASSIGN(ShelfBackgroundAnimatorNonMDTest); | 181 DISALLOW_COPY_AND_ASSIGN(ShelfBackgroundAnimatorNonMDTest); |
| 195 }; | 182 }; |
| 196 | 183 |
| 197 // Verify the alpha values for the SHELF_BACKGROUND_DEFAULT state. | 184 // Verify the alpha values for the SHELF_BACKGROUND_DEFAULT state. |
| 198 TEST_F(ShelfBackgroundAnimatorNonMDTest, DefaultBackground) { | 185 TEST_F(ShelfBackgroundAnimatorNonMDTest, DefaultBackground) { |
| 199 PaintBackground(SHELF_BACKGROUND_DEFAULT); | 186 PaintBackground(SHELF_BACKGROUND_DEFAULT); |
| 200 | 187 |
| 201 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, animator_->target_background_type()); | 188 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, animator_->target_background_type()); |
| 202 EXPECT_EQ(0, observer_.opaque_background_alpha()); | 189 EXPECT_EQ(0, observer_.opaque_background_alpha()); |
| 203 EXPECT_EQ(0, observer_.asset_background_alpha()); | |
| 204 EXPECT_EQ(expected_translucent_alpha(), observer_.item_background_alpha()); | 190 EXPECT_EQ(expected_translucent_alpha(), observer_.item_background_alpha()); |
| 205 } | 191 } |
| 206 | 192 |
| 207 // Verify the alpha values for the SHELF_BACKGROUND_OVERLAP state. | 193 // Verify the alpha values for the SHELF_BACKGROUND_OVERLAP state. |
| 208 TEST_F(ShelfBackgroundAnimatorNonMDTest, OverlapBackground) { | 194 TEST_F(ShelfBackgroundAnimatorNonMDTest, OverlapBackground) { |
| 209 PaintBackground(SHELF_BACKGROUND_OVERLAP); | 195 PaintBackground(SHELF_BACKGROUND_OVERLAP); |
| 210 | 196 |
| 211 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, animator_->target_background_type()); | 197 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, animator_->target_background_type()); |
| 212 EXPECT_EQ(0, observer_.opaque_background_alpha()); | 198 EXPECT_EQ(0, observer_.opaque_background_alpha()); |
| 213 EXPECT_EQ(expected_translucent_alpha(), observer_.asset_background_alpha()); | |
| 214 EXPECT_EQ(expected_translucent_alpha(), observer_.item_background_alpha()); | 199 EXPECT_EQ(expected_translucent_alpha(), observer_.item_background_alpha()); |
| 215 } | 200 } |
| 216 | 201 |
| 217 // Verify the alpha values for the SHELF_BACKGROUND_MAXIMIZED state. | 202 // Verify the alpha values for the SHELF_BACKGROUND_MAXIMIZED state. |
| 218 TEST_F(ShelfBackgroundAnimatorNonMDTest, MaximizedBackground) { | 203 TEST_F(ShelfBackgroundAnimatorNonMDTest, MaximizedBackground) { |
| 219 PaintBackground(SHELF_BACKGROUND_MAXIMIZED); | 204 PaintBackground(SHELF_BACKGROUND_MAXIMIZED); |
| 220 | 205 |
| 221 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, animator_->target_background_type()); | 206 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, animator_->target_background_type()); |
| 222 EXPECT_EQ(kMaxAlpha, observer_.opaque_background_alpha()); | 207 EXPECT_EQ(kMaxAlpha, observer_.opaque_background_alpha()); |
| 223 EXPECT_EQ(expected_translucent_alpha(), observer_.asset_background_alpha()); | |
| 224 EXPECT_EQ(kMaxAlpha, observer_.item_background_alpha()); | 208 EXPECT_EQ(kMaxAlpha, observer_.item_background_alpha()); |
| 225 } | 209 } |
| 226 | 210 |
| 227 class ShelfBackgroundAnimatorMDTest : public ShelfBackgroundAnimatorTestBase { | 211 class ShelfBackgroundAnimatorMDTest : public ShelfBackgroundAnimatorTestBase { |
| 228 public: | 212 public: |
| 229 ShelfBackgroundAnimatorMDTest() {} | 213 ShelfBackgroundAnimatorMDTest() {} |
| 230 ~ShelfBackgroundAnimatorMDTest() override {} | 214 ~ShelfBackgroundAnimatorMDTest() override {} |
| 231 | 215 |
| 232 MaterialDesignController::Mode GetMaterialDesignMode() override { | 216 MaterialDesignController::Mode GetMaterialDesignMode() override { |
| 233 return MaterialDesignController::MATERIAL_EXPERIMENTAL; | 217 return MaterialDesignController::MATERIAL_EXPERIMENTAL; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 } | 260 } |
| 277 | 261 |
| 278 // Verify observers are updated with the current values when they are added. | 262 // Verify observers are updated with the current values when they are added. |
| 279 TEST_F(ShelfBackgroundAnimatorMDTest, ObserversUpdatedWhenAdded) { | 263 TEST_F(ShelfBackgroundAnimatorMDTest, ObserversUpdatedWhenAdded) { |
| 280 animator_->RemoveObserver(&observer_); | 264 animator_->RemoveObserver(&observer_); |
| 281 SetAlphaValuesOnObserver(kDummyAlpha); | 265 SetAlphaValuesOnObserver(kDummyAlpha); |
| 282 | 266 |
| 283 animator_->AddObserver(&observer_); | 267 animator_->AddObserver(&observer_); |
| 284 | 268 |
| 285 EXPECT_NE(observer_.opaque_background_alpha(), kDummyAlpha); | 269 EXPECT_NE(observer_.opaque_background_alpha(), kDummyAlpha); |
| 286 EXPECT_NE(observer_.asset_background_alpha(), kDummyAlpha); | |
| 287 EXPECT_NE(observer_.item_background_alpha(), kDummyAlpha); | 270 EXPECT_NE(observer_.item_background_alpha(), kDummyAlpha); |
| 288 } | 271 } |
| 289 | 272 |
| 290 // Verify the alpha values for the SHELF_BACKGROUND_DEFAULT state. | 273 // Verify the alpha values for the SHELF_BACKGROUND_DEFAULT state. |
| 291 TEST_F(ShelfBackgroundAnimatorMDTest, DefaultBackground) { | 274 TEST_F(ShelfBackgroundAnimatorMDTest, DefaultBackground) { |
| 292 PaintBackground(SHELF_BACKGROUND_DEFAULT); | 275 PaintBackground(SHELF_BACKGROUND_DEFAULT); |
| 293 | 276 |
| 294 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, animator_->target_background_type()); | 277 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, animator_->target_background_type()); |
| 295 EXPECT_EQ(0, observer_.opaque_background_alpha()); | 278 EXPECT_EQ(0, observer_.opaque_background_alpha()); |
| 296 EXPECT_EQ(0, observer_.asset_background_alpha()); | |
| 297 EXPECT_EQ(expected_translucent_alpha(), observer_.item_background_alpha()); | 279 EXPECT_EQ(expected_translucent_alpha(), observer_.item_background_alpha()); |
| 298 } | 280 } |
| 299 | 281 |
| 300 // Verify the alpha values for the SHELF_BACKGROUND_OVERLAP state. | 282 // Verify the alpha values for the SHELF_BACKGROUND_OVERLAP state. |
| 301 TEST_F(ShelfBackgroundAnimatorMDTest, OverlapBackground) { | 283 TEST_F(ShelfBackgroundAnimatorMDTest, OverlapBackground) { |
| 302 PaintBackground(SHELF_BACKGROUND_OVERLAP); | 284 PaintBackground(SHELF_BACKGROUND_OVERLAP); |
| 303 | 285 |
| 304 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, animator_->target_background_type()); | 286 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, animator_->target_background_type()); |
| 305 EXPECT_EQ(expected_translucent_alpha(), observer_.opaque_background_alpha()); | 287 EXPECT_EQ(expected_translucent_alpha(), observer_.opaque_background_alpha()); |
| 306 EXPECT_EQ(0, observer_.asset_background_alpha()); | |
| 307 EXPECT_EQ(0, observer_.item_background_alpha()); | 288 EXPECT_EQ(0, observer_.item_background_alpha()); |
| 308 } | 289 } |
| 309 | 290 |
| 310 // Verify the alpha values for the SHELF_BACKGROUND_MAXIMIZED state. | 291 // Verify the alpha values for the SHELF_BACKGROUND_MAXIMIZED state. |
| 311 TEST_F(ShelfBackgroundAnimatorMDTest, MaximizedBackground) { | 292 TEST_F(ShelfBackgroundAnimatorMDTest, MaximizedBackground) { |
| 312 PaintBackground(SHELF_BACKGROUND_MAXIMIZED); | 293 PaintBackground(SHELF_BACKGROUND_MAXIMIZED); |
| 313 | 294 |
| 314 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, animator_->target_background_type()); | 295 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, animator_->target_background_type()); |
| 315 EXPECT_EQ(kMaxAlpha, observer_.opaque_background_alpha()); | 296 EXPECT_EQ(kMaxAlpha, observer_.opaque_background_alpha()); |
| 316 EXPECT_EQ(0, observer_.asset_background_alpha()); | |
| 317 EXPECT_EQ(0, observer_.item_background_alpha()); | 297 EXPECT_EQ(0, observer_.item_background_alpha()); |
| 318 } | 298 } |
| 319 | 299 |
| 320 // Verify that existing animators are used when animating to the previous state. | 300 // Verify that existing animators are used when animating to the previous state. |
| 321 TEST_F(ShelfBackgroundAnimatorMDTest, ExistingAnimatorsAreReused) { | 301 TEST_F(ShelfBackgroundAnimatorMDTest, ExistingAnimatorsAreReused) { |
| 322 PaintBackground(SHELF_BACKGROUND_DEFAULT); | 302 PaintBackground(SHELF_BACKGROUND_DEFAULT); |
| 323 PaintBackground(SHELF_BACKGROUND_MAXIMIZED); | 303 PaintBackground(SHELF_BACKGROUND_MAXIMIZED); |
| 324 EXPECT_TRUE(test_api_->can_reuse_animators()); | 304 EXPECT_TRUE(test_api_->can_reuse_animators()); |
| 325 | 305 |
| 326 const BackgroundAnimator* opaque_animator = | 306 const BackgroundAnimator* opaque_animator = |
| 327 test_api_->opaque_background_animator(); | 307 test_api_->opaque_background_animator(); |
| 328 const BackgroundAnimator* asset_animator = | |
| 329 test_api_->asset_background_animator(); | |
| 330 const BackgroundAnimator* item_animator = | 308 const BackgroundAnimator* item_animator = |
| 331 test_api_->item_background_animator(); | 309 test_api_->item_background_animator(); |
| 332 | 310 |
| 333 PaintBackground(SHELF_BACKGROUND_DEFAULT); | 311 PaintBackground(SHELF_BACKGROUND_DEFAULT); |
| 334 | 312 |
| 335 EXPECT_EQ(opaque_animator, test_api_->opaque_background_animator()); | 313 EXPECT_EQ(opaque_animator, test_api_->opaque_background_animator()); |
| 336 EXPECT_EQ(asset_animator, test_api_->asset_background_animator()); | |
| 337 EXPECT_EQ(item_animator, test_api_->item_background_animator()); | 314 EXPECT_EQ(item_animator, test_api_->item_background_animator()); |
| 338 } | 315 } |
| 339 | 316 |
| 340 // Verify that existing animators are not re-used when the previous animation | 317 // Verify that existing animators are not re-used when the previous animation |
| 341 // didn't complete. | 318 // didn't complete. |
| 342 TEST_F(ShelfBackgroundAnimatorMDTest, | 319 TEST_F(ShelfBackgroundAnimatorMDTest, |
| 343 ExistingAnimatorsNotReusedWhenPreviousAnimationsDontComplete) { | 320 ExistingAnimatorsNotReusedWhenPreviousAnimationsDontComplete) { |
| 344 EXPECT_NE(SHELF_BACKGROUND_OVERLAP, test_api_->previous_background_type()); | 321 EXPECT_NE(SHELF_BACKGROUND_OVERLAP, test_api_->previous_background_type()); |
| 345 animator_->PaintBackground(SHELF_BACKGROUND_OVERLAP, | 322 animator_->PaintBackground(SHELF_BACKGROUND_OVERLAP, |
| 346 BACKGROUND_CHANGE_ANIMATE); | 323 BACKGROUND_CHANGE_ANIMATE); |
| 347 animator_->PaintBackground(SHELF_BACKGROUND_MAXIMIZED, | 324 animator_->PaintBackground(SHELF_BACKGROUND_MAXIMIZED, |
| 348 BACKGROUND_CHANGE_ANIMATE); | 325 BACKGROUND_CHANGE_ANIMATE); |
| 349 EXPECT_FALSE(test_api_->can_reuse_animators()); | 326 EXPECT_FALSE(test_api_->can_reuse_animators()); |
| 350 | 327 |
| 351 const BackgroundAnimator* opaque_animator = | 328 const BackgroundAnimator* opaque_animator = |
| 352 test_api_->opaque_background_animator(); | 329 test_api_->opaque_background_animator(); |
| 353 const BackgroundAnimator* asset_animator = | |
| 354 test_api_->asset_background_animator(); | |
| 355 const BackgroundAnimator* item_animator = | 330 const BackgroundAnimator* item_animator = |
| 356 test_api_->item_background_animator(); | 331 test_api_->item_background_animator(); |
| 357 | 332 |
| 358 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, test_api_->previous_background_type()); | 333 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, test_api_->previous_background_type()); |
| 359 animator_->PaintBackground(SHELF_BACKGROUND_OVERLAP, | 334 animator_->PaintBackground(SHELF_BACKGROUND_OVERLAP, |
| 360 BACKGROUND_CHANGE_ANIMATE); | 335 BACKGROUND_CHANGE_ANIMATE); |
| 361 | 336 |
| 362 EXPECT_NE(opaque_animator, test_api_->opaque_background_animator()); | 337 EXPECT_NE(opaque_animator, test_api_->opaque_background_animator()); |
| 363 EXPECT_NE(asset_animator, test_api_->asset_background_animator()); | |
| 364 EXPECT_NE(item_animator, test_api_->item_background_animator()); | 338 EXPECT_NE(item_animator, test_api_->item_background_animator()); |
| 365 } | 339 } |
| 366 | 340 |
| 367 // Verify that existing animators are not re-used when the target background | 341 // Verify that existing animators are not re-used when the target background |
| 368 // isn't the same as the previous background. | 342 // isn't the same as the previous background. |
| 369 TEST_F(ShelfBackgroundAnimatorMDTest, | 343 TEST_F(ShelfBackgroundAnimatorMDTest, |
| 370 ExistingAnimatorsNotReusedWhenTargetBackgroundNotPreviousBackground) { | 344 ExistingAnimatorsNotReusedWhenTargetBackgroundNotPreviousBackground) { |
| 371 PaintBackground(SHELF_BACKGROUND_DEFAULT); | 345 PaintBackground(SHELF_BACKGROUND_DEFAULT); |
| 372 PaintBackground(SHELF_BACKGROUND_MAXIMIZED); | 346 PaintBackground(SHELF_BACKGROUND_MAXIMIZED); |
| 373 EXPECT_TRUE(test_api_->can_reuse_animators()); | 347 EXPECT_TRUE(test_api_->can_reuse_animators()); |
| 374 | 348 |
| 375 const BackgroundAnimator* opaque_animator = | 349 const BackgroundAnimator* opaque_animator = |
| 376 test_api_->opaque_background_animator(); | 350 test_api_->opaque_background_animator(); |
| 377 const BackgroundAnimator* asset_animator = | |
| 378 test_api_->asset_background_animator(); | |
| 379 const BackgroundAnimator* item_animator = | 351 const BackgroundAnimator* item_animator = |
| 380 test_api_->item_background_animator(); | 352 test_api_->item_background_animator(); |
| 381 | 353 |
| 382 EXPECT_NE(SHELF_BACKGROUND_OVERLAP, test_api_->previous_background_type()); | 354 EXPECT_NE(SHELF_BACKGROUND_OVERLAP, test_api_->previous_background_type()); |
| 383 PaintBackground(SHELF_BACKGROUND_OVERLAP); | 355 PaintBackground(SHELF_BACKGROUND_OVERLAP); |
| 384 | 356 |
| 385 EXPECT_NE(opaque_animator, test_api_->opaque_background_animator()); | 357 EXPECT_NE(opaque_animator, test_api_->opaque_background_animator()); |
| 386 EXPECT_NE(asset_animator, test_api_->asset_background_animator()); | |
| 387 EXPECT_NE(item_animator, test_api_->item_background_animator()); | 358 EXPECT_NE(item_animator, test_api_->item_background_animator()); |
| 388 } | 359 } |
| 389 | 360 |
| 390 // Verify animators are not re-used after snapping to the same background type. | 361 // Verify animators are not re-used after snapping to the same background type. |
| 391 TEST_F(ShelfBackgroundAnimatorMDTest, | 362 TEST_F(ShelfBackgroundAnimatorMDTest, |
| 392 ExistingAnimatorsNotUsedWhenSnappingToSameTargetBackground) { | 363 ExistingAnimatorsNotUsedWhenSnappingToSameTargetBackground) { |
| 393 PaintBackground(SHELF_BACKGROUND_DEFAULT); | 364 PaintBackground(SHELF_BACKGROUND_DEFAULT); |
| 394 PaintBackground(SHELF_BACKGROUND_DEFAULT); | 365 PaintBackground(SHELF_BACKGROUND_DEFAULT); |
| 395 | 366 |
| 396 EXPECT_FALSE(test_api_->can_reuse_animators()); | 367 EXPECT_FALSE(test_api_->can_reuse_animators()); |
| 397 } | 368 } |
| 398 | 369 |
| 399 // Verify observers are always notified, even when alpha values don't change. | 370 // Verify observers are always notified, even when alpha values don't change. |
| 400 TEST_F(ShelfBackgroundAnimatorMDTest, | 371 TEST_F(ShelfBackgroundAnimatorMDTest, |
| 401 ObserversAreNotifiedWhenSnappingToSameTargetBackground) { | 372 ObserversAreNotifiedWhenSnappingToSameTargetBackground) { |
| 402 PaintBackground(SHELF_BACKGROUND_DEFAULT); | 373 PaintBackground(SHELF_BACKGROUND_DEFAULT); |
| 403 SetAlphaValuesOnObserver(kDummyAlpha); | 374 SetAlphaValuesOnObserver(kDummyAlpha); |
| 404 PaintBackground(SHELF_BACKGROUND_DEFAULT); | 375 PaintBackground(SHELF_BACKGROUND_DEFAULT); |
| 405 | 376 |
| 406 EXPECT_NE(observer_.opaque_background_alpha(), kDummyAlpha); | 377 EXPECT_NE(observer_.opaque_background_alpha(), kDummyAlpha); |
| 407 EXPECT_NE(observer_.asset_background_alpha(), kDummyAlpha); | |
| 408 EXPECT_NE(observer_.item_background_alpha(), kDummyAlpha); | 378 EXPECT_NE(observer_.item_background_alpha(), kDummyAlpha); |
| 409 } | 379 } |
| 410 | 380 |
| 411 } // namespace ash | 381 } // namespace ash |
| OLD | NEW |