| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Unit tests for eliding and formatting utility functions. | 5 // Unit tests for eliding and formatting utility functions. | 
| 6 | 6 | 
| 7 #include "ui/gfx/text_elider.h" | 7 #include "ui/gfx/text_elider.h" | 
| 8 | 8 | 
| 9 #include <vector> | 9 #include <vector> | 
| 10 | 10 | 
| (...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 776   for (size_t i = 0; i < arraysize(cases); ++i) { | 776   for (size_t i = 0; i < arraysize(cases); ++i) { | 
| 777     std::vector<base::string16> lines; | 777     std::vector<base::string16> lines; | 
| 778     EXPECT_EQ(cases[i].truncated_x ? INSUFFICIENT_SPACE_HORIZONTAL : 0, | 778     EXPECT_EQ(cases[i].truncated_x ? INSUFFICIENT_SPACE_HORIZONTAL : 0, | 
| 779               ElideRectangleText(UTF8ToUTF16(cases[i].input), | 779               ElideRectangleText(UTF8ToUTF16(cases[i].input), | 
| 780                                  font_list, | 780                                  font_list, | 
| 781                                  cases[i].available_pixel_width, | 781                                  cases[i].available_pixel_width, | 
| 782                                  kAvailableHeight, | 782                                  kAvailableHeight, | 
| 783                                  cases[i].wrap_behavior, | 783                                  cases[i].wrap_behavior, | 
| 784                                  &lines)); | 784                                  &lines)); | 
| 785     std::string expected_output(cases[i].output); | 785     std::string expected_output(cases[i].output); | 
| 786     ReplaceSubstringsAfterOffset(&expected_output, 0, "...", kEllipsis); | 786     base::ReplaceSubstringsAfterOffset(&expected_output, 0, "...", kEllipsis); | 
| 787     const std::string result = UTF16ToUTF8(JoinString(lines, '|')); | 787     const std::string result = UTF16ToUTF8(JoinString(lines, '|')); | 
| 788     EXPECT_EQ(expected_output, result) << "Case " << i << " failed!"; | 788     EXPECT_EQ(expected_output, result) << "Case " << i << " failed!"; | 
| 789   } | 789   } | 
| 790 } | 790 } | 
| 791 | 791 | 
| 792 // This test is to make sure that the width of each wrapped line does not | 792 // This test is to make sure that the width of each wrapped line does not | 
| 793 // exceed the available width. On some platform like Mac, this test used to | 793 // exceed the available width. On some platform like Mac, this test used to | 
| 794 // fail because the truncated integer width is returned for the string | 794 // fail because the truncated integer width is returned for the string | 
| 795 // and the accumulation of the truncated values causes the elide function | 795 // and the accumulation of the truncated values causes the elide function | 
| 796 // to wrap incorrectly. | 796 // to wrap incorrectly. | 
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1111   // Test adds ... at right spot within a word. | 1111   // Test adds ... at right spot within a word. | 
| 1112   EXPECT_EQ(L"f\x2026", UTF16ToWide(TruncateString(string, 2, | 1112   EXPECT_EQ(L"f\x2026", UTF16ToWide(TruncateString(string, 2, | 
| 1113                                                    CHARACTER_BREAK))); | 1113                                                    CHARACTER_BREAK))); | 
| 1114 | 1114 | 
| 1115   // Test removes trailing whitespace if break falls between words. | 1115   // Test removes trailing whitespace if break falls between words. | 
| 1116   EXPECT_EQ(L"foooooey\x2026", UTF16ToWide(TruncateString(string, 12, | 1116   EXPECT_EQ(L"foooooey\x2026", UTF16ToWide(TruncateString(string, 12, | 
| 1117                                                           CHARACTER_BREAK))); | 1117                                                           CHARACTER_BREAK))); | 
| 1118 } | 1118 } | 
| 1119 | 1119 | 
| 1120 }  // namespace gfx | 1120 }  // namespace gfx | 
| OLD | NEW | 
|---|