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

Side by Side Diff: chrome/browser/ui/views/location_bar/icon_label_bubble_view_unittest.cc

Issue 2348853004: Remove non-md code in location bar (Views). (Closed)
Patch Set: images Created 4 years, 3 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 "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"
11 11
12 namespace { 12 namespace {
13 13
14 const int kStayOpenTimeMS = 100; 14 const int kStayOpenTimeMS = 100;
15 const int kOpenTimeMS = 100; 15 const int kOpenTimeMS = 100;
16 const int kAnimationDurationMS = (kOpenTimeMS * 2) + kStayOpenTimeMS; 16 const int kAnimationDurationMS = (kOpenTimeMS * 2) + kStayOpenTimeMS;
17 const int kImageSize = 15; 17 const int kImageSize = 15;
18 const SkColor kTestColor = SkColorSetRGB(64, 64, 64); 18 const SkColor kTestColor = SkColorSetRGB(64, 64, 64);
19 const int kNumberOfSteps = 300; 19 const int kNumberOfSteps = 300;
20 20
21 class TestIconLabelBubbleView : public IconLabelBubbleView { 21 class TestIconLabelBubbleView : public IconLabelBubbleView {
22 public: 22 public:
23 enum State { 23 enum State {
24 GROWING, 24 GROWING,
25 STEADY, 25 STEADY,
26 SHRINKING, 26 SHRINKING,
27 }; 27 };
28 28
29 TestIconLabelBubbleView(const gfx::FontList& font_list, SkColor color) 29 explicit TestIconLabelBubbleView(const gfx::FontList& font_list)
30 : IconLabelBubbleView(0, font_list, color, false), value_(0) { 30 : IconLabelBubbleView(0, font_list, 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() const { return bounds().width(); } 40 int width() const { return bounds().width(); }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 minimum_size_reached_(false), 97 minimum_size_reached_(false),
98 previous_width_(0), 98 previous_width_(0),
99 initial_image_x_(0) {} 99 initial_image_x_(0) {}
100 ~IconLabelBubbleViewTest() override {} 100 ~IconLabelBubbleViewTest() override {}
101 101
102 protected: 102 protected:
103 // views::ViewsTestBase: 103 // views::ViewsTestBase:
104 void SetUp() override { 104 void SetUp() override {
105 views::ViewsTestBase::SetUp(); 105 views::ViewsTestBase::SetUp();
106 gfx::FontList font_list; 106 gfx::FontList font_list;
107 view_.reset(new TestIconLabelBubbleView(font_list, kTestColor)); 107 view_.reset(new TestIconLabelBubbleView(font_list));
108 } 108 }
109 109
110 void VerifyWithAnimationStep(int step) { 110 void VerifyWithAnimationStep(int step) {
111 Reset(); 111 Reset();
112 for (int value = 0; value < kNumberOfSteps; value += step) { 112 for (int value = 0; value < kNumberOfSteps; value += step) {
113 SetValue(value); 113 SetValue(value);
114 VerifyAnimationStep(); 114 VerifyAnimationStep();
115 } 115 }
116 view_->SetLabelVisible(false); 116 view_->SetLabelVisible(false);
117 } 117 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 // 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
210 // 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
211 // size. 211 // size.
212 // Various step sizes during animation simulate different possible timing. 212 // Various step sizes during animation simulate different possible timing.
213 TEST_F(IconLabelBubbleViewTest, AnimateLayout) { 213 TEST_F(IconLabelBubbleViewTest, AnimateLayout) {
214 VerifyWithAnimationStep(1); 214 VerifyWithAnimationStep(1);
215 VerifyWithAnimationStep(5); 215 VerifyWithAnimationStep(5);
216 VerifyWithAnimationStep(10); 216 VerifyWithAnimationStep(10);
217 VerifyWithAnimationStep(25); 217 VerifyWithAnimationStep(25);
218 } 218 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698