| 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 "ui/gfx/render_text.h" | 5 #include "ui/gfx/render_text.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 render_text->RenderText::SetObscuredRevealIndex(2); | 642 render_text->RenderText::SetObscuredRevealIndex(2); |
| 643 EXPECT_EQ(ASCIIToUTF16("*h***"), render_text->GetDisplayText()); | 643 EXPECT_EQ(ASCIIToUTF16("*h***"), render_text->GetDisplayText()); |
| 644 render_text->RenderText::SetObscuredRevealIndex(5); | 644 render_text->RenderText::SetObscuredRevealIndex(5); |
| 645 const base::char16 valid_expect_5_and_6[] = | 645 const base::char16 valid_expect_5_and_6[] = |
| 646 {'*', '*', '*', '*', 0xD800, 0xDC00, 0}; | 646 {'*', '*', '*', '*', 0xD800, 0xDC00, 0}; |
| 647 EXPECT_EQ(valid_expect_5_and_6, render_text->GetDisplayText()); | 647 EXPECT_EQ(valid_expect_5_and_6, render_text->GetDisplayText()); |
| 648 render_text->RenderText::SetObscuredRevealIndex(6); | 648 render_text->RenderText::SetObscuredRevealIndex(6); |
| 649 EXPECT_EQ(valid_expect_5_and_6, render_text->GetDisplayText()); | 649 EXPECT_EQ(valid_expect_5_and_6, render_text->GetDisplayText()); |
| 650 } | 650 } |
| 651 | 651 |
| 652 TEST_F(RenderTextTest, ObscuredEmoji) { |
| 653 // Ensures text itemization doesn't crash on obscured multi-char glyphs. |
| 654 std::unique_ptr<RenderText> render_text(RenderText::CreateInstance()); |
| 655 render_text->SetObscured(true); |
| 656 gfx::Canvas canvas; |
| 657 // Test the "Grinning face with smiling eyes" character followed by 'y'. |
| 658 render_text->SetText(UTF8ToUTF16("\xF0\x9F\x98\x81y")); |
| 659 render_text->Draw(&canvas); |
| 660 // Test two "Camera" characters in a row. |
| 661 render_text->SetText(UTF8ToUTF16("\xF0\x9F\x93\xB7\xF0\x9F\x93\xB7")); |
| 662 render_text->Draw(&canvas); |
| 663 } |
| 664 |
| 652 // TODO(PORT): Fails for RenderTextMac. | 665 // TODO(PORT): Fails for RenderTextMac. |
| 653 #if !defined(OS_MACOSX) | 666 #if !defined(OS_MACOSX) |
| 654 | 667 |
| 655 TEST_F(RenderTextTest, ElidedText) { | 668 TEST_F(RenderTextTest, ElidedText) { |
| 656 // TODO(skanuj) : Add more test cases for following | 669 // TODO(skanuj) : Add more test cases for following |
| 657 // - RenderText styles. | 670 // - RenderText styles. |
| 658 // - Cross interaction of truncate, elide and obscure. | 671 // - Cross interaction of truncate, elide and obscure. |
| 659 // - ElideText tests from text_elider.cc. | 672 // - ElideText tests from text_elider.cc. |
| 660 struct { | 673 struct { |
| 661 const wchar_t* text; | 674 const wchar_t* text; |
| (...skipping 2737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3399 EXPECT_FALSE(backend.paint().isLCDRenderText()); | 3412 EXPECT_FALSE(backend.paint().isLCDRenderText()); |
| 3400 backend.GetHarfbuzzRunList()->runs()[0]->render_params.subpixel_rendering = | 3413 backend.GetHarfbuzzRunList()->runs()[0]->render_params.subpixel_rendering = |
| 3401 FontRenderParams::SUBPIXEL_RENDERING_RGB; | 3414 FontRenderParams::SUBPIXEL_RENDERING_RGB; |
| 3402 backend.DrawVisualText(); | 3415 backend.DrawVisualText(); |
| 3403 #endif | 3416 #endif |
| 3404 EXPECT_FALSE(backend.paint().isLCDRenderText()); | 3417 EXPECT_FALSE(backend.paint().isLCDRenderText()); |
| 3405 } | 3418 } |
| 3406 } | 3419 } |
| 3407 | 3420 |
| 3408 } // namespace gfx | 3421 } // namespace gfx |
| OLD | NEW |