| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "third_party/skia/include/core/SkColor.h" | 11 #include "third_party/skia/include/core/SkColor.h" |
| 12 #include "ui/gfx/font_list.h" | 12 #include "ui/gfx/font_list.h" |
| 13 #include "ui/views/border.h" | 13 #include "ui/views/border.h" |
| 14 #include "ui/views/controls/link.h" | 14 #include "ui/views/controls/link.h" |
| 15 #include "ui/views/controls/styled_label.h" | 15 #include "ui/views/controls/styled_label.h" |
| 16 #include "ui/views/controls/styled_label_listener.h" | 16 #include "ui/views/controls/styled_label_listener.h" |
| 17 #include "ui/views/test/views_test_base.h" | 17 #include "ui/views/test/views_test_base.h" |
| 18 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
| 19 | 19 |
| 20 using base::ASCIIToUTF16; | 20 using base::ASCIIToUTF16; |
| 21 | 21 |
| 22 namespace views { | 22 namespace views { |
| 23 | 23 |
| 24 class StyledLabelTest : public ViewsTestBase, public StyledLabelListener { | 24 class StyledLabelTest : public ViewsTestBase, public StyledLabelListener { |
| 25 public: | 25 public: |
| 26 StyledLabelTest() {} | 26 StyledLabelTest() {} |
| 27 ~StyledLabelTest() override {} | 27 ~StyledLabelTest() override {} |
| 28 | 28 |
| 29 // StyledLabelListener implementation. | 29 // StyledLabelListener implementation. |
| 30 void StyledLabelLinkClicked(const gfx::Range& range, | 30 void StyledLabelLinkClicked(StyledLabel* label, |
| 31 const gfx::Range& range, |
| 31 int event_flags) override {} | 32 int event_flags) override {} |
| 32 | 33 |
| 33 protected: | 34 protected: |
| 34 StyledLabel* styled() { return styled_.get(); } | 35 StyledLabel* styled() { return styled_.get(); } |
| 35 | 36 |
| 36 void InitStyledLabel(const std::string& ascii_text) { | 37 void InitStyledLabel(const std::string& ascii_text) { |
| 37 styled_.reset(new StyledLabel(ASCIIToUTF16(ascii_text), this)); | 38 styled_.reset(new StyledLabel(ASCIIToUTF16(ascii_text), this)); |
| 38 styled_->set_owned_by_client(); | 39 styled_->set_owned_by_client(); |
| 39 } | 40 } |
| 40 | 41 |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 // all controls should be recreated | 487 // all controls should be recreated |
| 487 styled()->SetText(another_text); | 488 styled()->SetText(another_text); |
| 488 int updated_height = styled()->GetHeightForWidth(styled()->width()); | 489 int updated_height = styled()->GetHeightForWidth(styled()->width()); |
| 489 EXPECT_NE(updated_height, real_height); | 490 EXPECT_NE(updated_height, real_height); |
| 490 View* first_child_after_text_update = styled()->has_children() ? | 491 View* first_child_after_text_update = styled()->has_children() ? |
| 491 styled()->child_at(0) : nullptr; | 492 styled()->child_at(0) : nullptr; |
| 492 EXPECT_NE(first_child_after_text_update, first_child_after_layout); | 493 EXPECT_NE(first_child_after_text_update, first_child_after_layout); |
| 493 } | 494 } |
| 494 | 495 |
| 495 } // namespace views | 496 } // namespace views |
| OLD | NEW |