diff options
author | varunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-22 06:38:19 +0000 |
---|---|---|
committer | varunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-22 06:38:19 +0000 |
commit | 50cf0ca00aab33701ddcf6711a2e997f3d2ee931 (patch) | |
tree | beb03dd9190a894c713284b46d753ed32ac4c6c6 /ash/tooltips/tooltip_controller_unittest.cc | |
parent | 9e6baed5c4ae29bba801385f0b01fdf7f3ccd6a4 (diff) | |
download | chromium_src-50cf0ca00aab33701ddcf6711a2e997f3d2ee931.zip chromium_src-50cf0ca00aab33701ddcf6711a2e997f3d2ee931.tar.gz chromium_src-50cf0ca00aab33701ddcf6711a2e997f3d2ee931.tar.bz2 |
Revert 128177 - aura: Really long tooltips should be wrapped not truncated.
Broker build again! :(
BUG=119083
TEST=manual
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=127975
Review URL: http://codereview.chromium.org/9796004
TBR=varunjain@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9836002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128178 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/tooltips/tooltip_controller_unittest.cc')
-rw-r--r-- | ash/tooltips/tooltip_controller_unittest.cc | 107 |
1 files changed, 0 insertions, 107 deletions
diff --git a/ash/tooltips/tooltip_controller_unittest.cc b/ash/tooltips/tooltip_controller_unittest.cc index d78b02c..f07dfd5 100644 --- a/ash/tooltips/tooltip_controller_unittest.cc +++ b/ash/tooltips/tooltip_controller_unittest.cc @@ -10,9 +10,6 @@ #include "ui/aura/root_window.h" #include "ui/aura/test/event_generator.h" #include "ui/aura/window.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/base/text/text_elider.h" -#include "ui/gfx/font.h" #include "ui/gfx/point.h" #include "ui/views/view.h" #include "ui/views/widget/widget.h" @@ -74,11 +71,6 @@ ash::internal::TooltipController* GetController() { aura::client::GetTooltipClient(Shell::GetRootWindow())); } -gfx::Font GetDefaultFont() { - return ui::ResourceBundle::GetSharedInstance().GetFont( - ui::ResourceBundle::BaseFont); -} - } // namespace class TooltipControllerTest : public AshTestBase { @@ -102,15 +94,6 @@ class TooltipControllerTest : public AshTestBase { return GetController()->IsTooltipVisible(); } - void TrimTooltipToFit(string16* text, - int* max_width, - int* line_count, - int x, - int y) { - ash::internal::TooltipController::TrimTooltipToFit(text, max_width, - line_count, x, y); - } - private: DISALLOW_COPY_AND_ASSIGN(TooltipControllerTest); }; @@ -225,95 +208,5 @@ TEST_F(TooltipControllerTest, EnableOrDisableTooltips) { EXPECT_TRUE(IsTooltipVisible()); } -TEST_F(TooltipControllerTest, TrimTooltipToFitTests) { - string16 tooltip; - int max_width, line_count, expect_lines; - int max_pixel_width = 400; // copied from constants in tooltip_controller.cc - int max_lines = 10; // copied from constants in tooltip_controller.cc - gfx::Font font = GetDefaultFont(); - size_t tooltip_len; - - // Error in computed size vs. expected size should not be greater than the - // size of the longest word. - int error_in_pixel_width = font.GetStringWidth(ASCIIToUTF16("tooltip")); - - // Long tooltips should wrap to next line - tooltip.clear(); - max_width = line_count = -1; - expect_lines = 3; - for (; font.GetStringWidth(tooltip) <= (expect_lines - 1) * max_pixel_width;) - tooltip.append(ASCIIToUTF16("This is part of the tooltip")); - tooltip_len = tooltip.length(); - TrimTooltipToFit(&tooltip, &max_width, &line_count, 0, 0); - EXPECT_NEAR(max_pixel_width, max_width, error_in_pixel_width); - EXPECT_EQ(expect_lines, line_count); - EXPECT_EQ(tooltip_len + expect_lines - 1, tooltip.length()); - - // More than |max_lines| lines should get truncated at 10 lines. - tooltip.clear(); - max_width = line_count = -1; - expect_lines = 13; - for (; font.GetStringWidth(tooltip) <= (expect_lines - 1) * max_pixel_width;) - tooltip.append(ASCIIToUTF16("This is part of the tooltip")); - TrimTooltipToFit(&tooltip, &max_width, &line_count, 0, 0); - EXPECT_NEAR(max_pixel_width, max_width, error_in_pixel_width); - EXPECT_EQ(max_lines, line_count); - - // Long multi line tooltips should wrap individual lines. - tooltip.clear(); - max_width = line_count = -1; - expect_lines = 4; - for (; font.GetStringWidth(tooltip) <= (expect_lines - 2) * max_pixel_width;) - tooltip.append(ASCIIToUTF16("This is part of the tooltip")); - tooltip.insert(tooltip.length() / 2, ASCIIToUTF16("\n")); - tooltip_len = tooltip.length(); - TrimTooltipToFit(&tooltip, &max_width, &line_count, 0, 0); - EXPECT_NEAR(max_pixel_width, max_width, error_in_pixel_width); - EXPECT_EQ(expect_lines, line_count); - // We may have inserted the line break above near a space which will get - // trimmed. Hence we may be off by 1 in the final tooltip length calculation. - EXPECT_NEAR(tooltip_len + expect_lines - 2, tooltip.length(), 1); - - // Tooltip with really long word gets elided. - tooltip.clear(); - max_width = line_count = -1; - tooltip = UTF8ToUTF16(std::string('a', max_pixel_width)); - TrimTooltipToFit(&tooltip, &max_width, &line_count, 0, 0); - EXPECT_NEAR(max_pixel_width, max_width, 5); - EXPECT_EQ(1, line_count); - EXPECT_EQ(ui::ElideText(tooltip, font, max_pixel_width, ui::ELIDE_AT_END), - tooltip); - - // Normal small tooltip should stay as is. - tooltip.clear(); - max_width = line_count = -1; - tooltip = ASCIIToUTF16("Small Tooltip"); - TrimTooltipToFit(&tooltip, &max_width, &line_count, 0, 0); - EXPECT_EQ(font.GetStringWidth(ASCIIToUTF16("Small Tooltip")), max_width); - EXPECT_EQ(1, line_count); - EXPECT_EQ(ASCIIToUTF16("Small Tooltip"), tooltip); - - // Normal small multi-line tooltip should stay as is. - tooltip.clear(); - max_width = line_count = -1; - tooltip = ASCIIToUTF16("Multi line\nTooltip"); - TrimTooltipToFit(&tooltip, &max_width, &line_count, 0, 0); - int expected_width = font.GetStringWidth(ASCIIToUTF16("Multi line")); - expected_width = std::max(expected_width, - font.GetStringWidth(ASCIIToUTF16("Tooltip"))); - EXPECT_EQ(expected_width, max_width); - EXPECT_EQ(2, line_count); - EXPECT_EQ(ASCIIToUTF16("Multi line\nTooltip"), tooltip); - - // Whitespaces in tooltips are preserved. - tooltip.clear(); - max_width = line_count = -1; - tooltip = ASCIIToUTF16("Small Tool t\tip"); - TrimTooltipToFit(&tooltip, &max_width, &line_count, 0, 0); - EXPECT_EQ(font.GetStringWidth(ASCIIToUTF16("Small Tool t\tip")), max_width); - EXPECT_EQ(1, line_count); - EXPECT_EQ(ASCIIToUTF16("Small Tool t\tip"), tooltip); -} - } // namespace test } // namespace ash |