| 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 19 matching lines...) Expand all Loading... |
| 30 : IconLabelBubbleView(0, font_list, color, false), value_(0) { | 30 : IconLabelBubbleView(0, font_list, color, false), value_(0) { |
| 31 GetImageView()->SetImageSize(gfx::Size(kImageSize, kImageSize)); | 31 GetImageView()->SetImageSize(gfx::Size(kImageSize, kImageSize)); |
| 32 SetLabel(base::ASCIIToUTF16("Label")); | 32 SetLabel(base::ASCIIToUTF16("Label")); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void SetCurrentAnimationValue(int value) { | 35 void SetCurrentAnimationValue(int value) { |
| 36 value_ = value; | 36 value_ = value; |
| 37 SizeToPreferredSize(); | 37 SizeToPreferredSize(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 int width() { return bounds().width(); } | 40 int width() const { return bounds().width(); } |
| 41 bool IsLabelVisible() const { return label()->visible(); } | 41 bool IsLabelVisible() const { return label()->visible(); } |
| 42 void SetLabelVisible(bool visible) { label()->SetVisible(visible); } | 42 void SetLabelVisible(bool visible) { label()->SetVisible(visible); } |
| 43 const gfx::Rect& GetLabelBounds() const { return label()->bounds(); } | 43 const gfx::Rect& GetLabelBounds() const { return label()->bounds(); } |
| 44 | 44 |
| 45 State state() const { | 45 State state() const { |
| 46 const double kOpenFraction = | 46 const double kOpenFraction = |
| 47 static_cast<double>(kOpenTimeMS) / kAnimationDurationMS; | 47 static_cast<double>(kOpenTimeMS) / kAnimationDurationMS; |
| 48 double state = value_ / (double)kNumberOfSteps; | 48 double state = value_ / (double)kNumberOfSteps; |
| 49 if (state < kOpenFraction) | 49 if (state < kOpenFraction) |
| 50 return GROWING; | 50 return GROWING; |
| (...skipping 157 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 | 208 // 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 | 209 // constant and finally shrinking it down to its minimum size which is the image |
| 210 // size. | 210 // size. |
| 211 // Various step sizes during animation simulate different possible timing. | 211 // Various step sizes during animation simulate different possible timing. |
| 212 TEST_F(IconLabelBubbleViewTest, AnimateLayout) { | 212 TEST_F(IconLabelBubbleViewTest, AnimateLayout) { |
| 213 VerifyWithAnimationStep(1); | 213 VerifyWithAnimationStep(1); |
| 214 VerifyWithAnimationStep(5); | 214 VerifyWithAnimationStep(5); |
| 215 VerifyWithAnimationStep(10); | 215 VerifyWithAnimationStep(10); |
| 216 VerifyWithAnimationStep(25); | 216 VerifyWithAnimationStep(25); |
| 217 } | 217 } |
| OLD | NEW |