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 "ui/message_center/views/bounded_label.h" | 5 #include "ui/message_center/views/bounded_label.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 class BoundedLabelTest : public testing::Test { | 23 class BoundedLabelTest : public testing::Test { |
24 public: | 24 public: |
25 BoundedLabelTest() { | 25 BoundedLabelTest() { |
26 digit_pixels_ = gfx::GetStringWidth(base::UTF8ToUTF16("0"), font_list_); | 26 digit_pixels_ = gfx::GetStringWidth(base::UTF8ToUTF16("0"), font_list_); |
27 space_pixels_ = gfx::GetStringWidth(base::UTF8ToUTF16(" "), font_list_); | 27 space_pixels_ = gfx::GetStringWidth(base::UTF8ToUTF16(" "), font_list_); |
28 ellipsis_pixels_ = gfx::GetStringWidth(base::UTF8ToUTF16("\xE2\x80\xA6"), | 28 ellipsis_pixels_ = gfx::GetStringWidth(base::UTF8ToUTF16("\xE2\x80\xA6"), |
29 font_list_); | 29 font_list_); |
30 } | 30 } |
31 | 31 |
32 virtual ~BoundedLabelTest() {} | 32 ~BoundedLabelTest() override {} |
33 | 33 |
34 // Replaces all occurences of three periods ("...") in the specified string | 34 // Replaces all occurences of three periods ("...") in the specified string |
35 // with an ellipses character (UTF8 "\xE2\x80\xA6") and returns a string16 | 35 // with an ellipses character (UTF8 "\xE2\x80\xA6") and returns a string16 |
36 // with the results. This allows test strings to be specified as ASCII const | 36 // with the results. This allows test strings to be specified as ASCII const |
37 // char* strings, making tests more readable and easier to write. | 37 // char* strings, making tests more readable and easier to write. |
38 base::string16 ToString(const char* string) { | 38 base::string16 ToString(const char* string) { |
39 const base::string16 periods = base::UTF8ToUTF16("..."); | 39 const base::string16 periods = base::UTF8ToUTF16("..."); |
40 const base::string16 ellipses = base::UTF8ToUTF16("\xE2\x80\xA6"); | 40 const base::string16 ellipses = base::UTF8ToUTF16("\xE2\x80\xA6"); |
41 base::string16 result = base::UTF8ToUTF16(string); | 41 base::string16 result = base::UTF8ToUTF16(string); |
42 ReplaceSubstringsAfterOffset(&result, 0, periods, ellipses); | 42 ReplaceSubstringsAfterOffset(&result, 0, periods, ellipses); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 | 211 |
212 // TODO(dharcourt): Add test cases to verify that: | 212 // TODO(dharcourt): Add test cases to verify that: |
213 // - SetMaxLines() affects the return values of some methods but not others. | 213 // - SetMaxLines() affects the return values of some methods but not others. |
214 // - Bound changes affects GetPreferredLines(), GetTextSize(), and | 214 // - Bound changes affects GetPreferredLines(), GetTextSize(), and |
215 // GetWrappedText() return values. | 215 // GetWrappedText() return values. |
216 // - GetTextFlags are as expected. | 216 // - GetTextFlags are as expected. |
217 | 217 |
218 } // namespace test | 218 } // namespace test |
219 | 219 |
220 } // namespace message_center | 220 } // namespace message_center |
OLD | NEW |