| 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 "chrome/browser/ui/views/location_bar/icon_label_bubble_view.h" | 5 #include "chrome/browser/ui/views/location_bar/icon_label_bubble_view.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "ui/views/controls/image_view.h" | 9 #include "ui/views/controls/image_view.h" |
| 10 #include "ui/views/test/views_test_base.h" | 10 #include "ui/views/test/views_test_base.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 return SHRINKING; | 52 return SHRINKING; |
| 53 return STEADY; | 53 return STEADY; |
| 54 } | 54 } |
| 55 | 55 |
| 56 protected: | 56 protected: |
| 57 // IconLabelBubbleView: | 57 // IconLabelBubbleView: |
| 58 SkColor GetTextColor() const override { return kTestColor; } | 58 SkColor GetTextColor() const override { return kTestColor; } |
| 59 SkColor GetBorderColor() const override { return kTestColor; } | 59 SkColor GetBorderColor() const override { return kTestColor; } |
| 60 | 60 |
| 61 bool ShouldShowBackground() const override { | 61 bool ShouldShowBackground() const override { |
| 62 return !IsShrinking() || label()->width() > 0; | 62 return !IsShrinking() || |
| 63 (width() >= MinimumWidthForImageWithBackgroundShown()); |
| 63 } | 64 } |
| 64 | 65 |
| 65 double WidthMultiplier() const override { | 66 double WidthMultiplier() const override { |
| 66 const double kOpenFraction = | 67 const double kOpenFraction = |
| 67 static_cast<double>(kOpenTimeMS) / kAnimationDurationMS; | 68 static_cast<double>(kOpenTimeMS) / kAnimationDurationMS; |
| 68 double fraction = value_ / (double)kNumberOfSteps; | 69 double fraction = value_ / (double)kNumberOfSteps; |
| 69 switch (state()) { | 70 switch (state()) { |
| 70 case GROWING: | 71 case GROWING: |
| 71 return fraction / kOpenFraction; | 72 return fraction / kOpenFraction; |
| 72 case STEADY: | 73 case STEADY: |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 // The animation is first growing the bubble from zero, then keeping its size | 209 // The animation is first growing the bubble from zero, then keeping its size |
| 209 // constant and finally shrinking it down to its minimum size which is the image | 210 // constant and finally shrinking it down to its minimum size which is the image |
| 210 // size. | 211 // size. |
| 211 // Various step sizes during animation simulate different possible timing. | 212 // Various step sizes during animation simulate different possible timing. |
| 212 TEST_F(IconLabelBubbleViewTest, AnimateLayout) { | 213 TEST_F(IconLabelBubbleViewTest, AnimateLayout) { |
| 213 VerifyWithAnimationStep(1); | 214 VerifyWithAnimationStep(1); |
| 214 VerifyWithAnimationStep(5); | 215 VerifyWithAnimationStep(5); |
| 215 VerifyWithAnimationStep(10); | 216 VerifyWithAnimationStep(10); |
| 216 VerifyWithAnimationStep(25); | 217 VerifyWithAnimationStep(25); |
| 217 } | 218 } |
| OLD | NEW |