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 #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 Loading... |
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 Loading... |
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 |
OLD | NEW |