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

Side by Side Diff: ash/tooltips/tooltip_controller_unittest.cc

Issue 9808009: Build fix: I have tried this test on win_aura trybots several times and it passes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "ash/shell.h" 5 #include "ash/shell.h"
6 #include "ash/test/ash_test_base.h" 6 #include "ash/test/ash_test_base.h"
7 #include "ash/tooltips/tooltip_controller.h" 7 #include "ash/tooltips/tooltip_controller.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "ui/aura/client/tooltip_client.h" 9 #include "ui/aura/client/tooltip_client.h"
10 #include "ui/aura/root_window.h" 10 #include "ui/aura/root_window.h"
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 tooltip.append(ASCIIToUTF16("This is part of the tooltip")); 267 tooltip.append(ASCIIToUTF16("This is part of the tooltip"));
268 tooltip.insert(tooltip.length() / 2, ASCIIToUTF16("\n")); 268 tooltip.insert(tooltip.length() / 2, ASCIIToUTF16("\n"));
269 tooltip_len = tooltip.length(); 269 tooltip_len = tooltip.length();
270 TrimTooltipToFit(&tooltip, &max_width, &line_count, 0, 0); 270 TrimTooltipToFit(&tooltip, &max_width, &line_count, 0, 0);
271 EXPECT_NEAR(max_pixel_width, max_width, error_in_pixel_width); 271 EXPECT_NEAR(max_pixel_width, max_width, error_in_pixel_width);
272 EXPECT_EQ(expect_lines, line_count); 272 EXPECT_EQ(expect_lines, line_count);
273 // We may have inserted the line break above near a space which will get 273 // We may have inserted the line break above near a space which will get
274 // trimmed. Hence we may be off by 1 in the final tooltip length calculation. 274 // trimmed. Hence we may be off by 1 in the final tooltip length calculation.
275 EXPECT_NEAR(tooltip_len + expect_lines - 2, tooltip.length(), 1); 275 EXPECT_NEAR(tooltip_len + expect_lines - 2, tooltip.length(), 1);
276 276
277 #if !defined(OS_WIN)
277 // Tooltip with really long word gets elided. 278 // Tooltip with really long word gets elided.
278 tooltip.clear(); 279 tooltip.clear();
279 max_width = line_count = -1; 280 max_width = line_count = -1;
280 tooltip = UTF8ToUTF16(std::string('a', max_pixel_width)); 281 tooltip = UTF8ToUTF16(std::string('a', max_pixel_width));
281 TrimTooltipToFit(&tooltip, &max_width, &line_count, 0, 0); 282 TrimTooltipToFit(&tooltip, &max_width, &line_count, 0, 0);
282 EXPECT_NEAR(max_pixel_width, max_width, 5); 283 EXPECT_NEAR(max_pixel_width, max_width, 5);
283 EXPECT_EQ(1, line_count); 284 EXPECT_EQ(1, line_count);
284 EXPECT_EQ(ui::ElideText(UTF8ToUTF16(std::string('a', max_pixel_width)), font, 285 EXPECT_EQ(ui::ElideText(UTF8ToUTF16(std::string('a', max_pixel_width)), font,
285 max_pixel_width, ui::ELIDE_AT_END), tooltip); 286 max_pixel_width, ui::ELIDE_AT_END), tooltip);
287 #endif
286 288
287 // Normal small tooltip should stay as is. 289 // Normal small tooltip should stay as is.
288 tooltip.clear(); 290 tooltip.clear();
289 max_width = line_count = -1; 291 max_width = line_count = -1;
290 tooltip = ASCIIToUTF16("Small Tooltip"); 292 tooltip = ASCIIToUTF16("Small Tooltip");
291 TrimTooltipToFit(&tooltip, &max_width, &line_count, 0, 0); 293 TrimTooltipToFit(&tooltip, &max_width, &line_count, 0, 0);
292 EXPECT_EQ(font.GetStringWidth(ASCIIToUTF16("Small Tooltip")), max_width); 294 EXPECT_EQ(font.GetStringWidth(ASCIIToUTF16("Small Tooltip")), max_width);
293 EXPECT_EQ(1, line_count); 295 EXPECT_EQ(1, line_count);
294 EXPECT_EQ(ASCIIToUTF16("Small Tooltip"), tooltip); 296 EXPECT_EQ(ASCIIToUTF16("Small Tooltip"), tooltip);
295 297
(...skipping 14 matching lines...) Expand all
310 max_width = line_count = -1; 312 max_width = line_count = -1;
311 tooltip = ASCIIToUTF16("Small Tool t\tip"); 313 tooltip = ASCIIToUTF16("Small Tool t\tip");
312 TrimTooltipToFit(&tooltip, &max_width, &line_count, 0, 0); 314 TrimTooltipToFit(&tooltip, &max_width, &line_count, 0, 0);
313 EXPECT_EQ(font.GetStringWidth(ASCIIToUTF16("Small Tool t\tip")), max_width); 315 EXPECT_EQ(font.GetStringWidth(ASCIIToUTF16("Small Tool t\tip")), max_width);
314 EXPECT_EQ(1, line_count); 316 EXPECT_EQ(1, line_count);
315 EXPECT_EQ(ASCIIToUTF16("Small Tool t\tip"), tooltip); 317 EXPECT_EQ(ASCIIToUTF16("Small Tool t\tip"), tooltip);
316 } 318 }
317 319
318 } // namespace test 320 } // namespace test
319 } // namespace ash 321 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698