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

Side by Side Diff: ui/gfx/render_text_unittest.cc

Issue 867003002: Cache gfx::RenderText instances in views::Label. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 5 years, 10 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
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 "ui/gfx/render_text.h" 5 #include "ui/gfx/render_text.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/i18n/break_iterator.h" 10 #include "base/i18n/break_iterator.h"
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 643
644 expected.clear(); 644 expected.clear();
645 expected.push_back(SelectionModel(4, CURSOR_FORWARD)); 645 expected.push_back(SelectionModel(4, CURSOR_FORWARD));
646 // The cursor hops over the elided text to preceeding text. 646 // The cursor hops over the elided text to preceeding text.
647 expected.push_back(SelectionModel(1, CURSOR_FORWARD)); 647 expected.push_back(SelectionModel(1, CURSOR_FORWARD));
648 expected.push_back(SelectionModel(0, CURSOR_FORWARD)); 648 expected.push_back(SelectionModel(0, CURSOR_FORWARD));
649 expected.push_back(SelectionModel(0, CURSOR_BACKWARD)); 649 expected.push_back(SelectionModel(0, CURSOR_BACKWARD));
650 RunMoveCursorLeftRightTest(render_text.get(), expected, CURSOR_RIGHT); 650 RunMoveCursorLeftRightTest(render_text.get(), expected, CURSOR_RIGHT);
651 } 651 }
652 652
653 TEST_F(RenderTextTest, AccessibleText) {
msw 2015/02/25 23:54:26 nit: update naming and comments below to reflect G
Jun Mukai 2015/02/26 01:40:25 This test case was also removed since the method w
654 scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
655 render_text->SetText(WideToUTF16(L"abcdefghi"));
656 EXPECT_EQ(WideToUTF16(L"abcdefghi"), render_text->GetAccessibleText());
657
658 // Elide the text. GetDisplayText() will return the elided text, but
659 // GetAccessibleText() should return the un-elided one.
660 render_text->SetElideBehavior(ELIDE_TAIL);
661 gfx::Size string_size = render_text->GetStringSize();
662 string_size.set_width(string_size.width() / 2);
663 render_text->SetDisplayRect(gfx::Rect(string_size));
664 EXPECT_NE(WideToUTF16(L"abcdefghi"), render_text->GetDisplayText());
665 EXPECT_EQ(WideToUTF16(L"abcdefghi"), render_text->GetAccessibleText());
666
667 // When obscured, GetAccessibleText() should not return the original value.
668 render_text->SetObscured(true);
669 EXPECT_EQ(WideToUTF16(L"*********"), render_text->GetAccessibleText());
670 }
671
653 TEST_F(RenderTextTest, GetDisplayTextDirection) { 672 TEST_F(RenderTextTest, GetDisplayTextDirection) {
654 struct { 673 struct {
655 const wchar_t* text; 674 const wchar_t* text;
656 const base::i18n::TextDirection text_direction; 675 const base::i18n::TextDirection text_direction;
657 } cases[] = { 676 } cases[] = {
658 // Blank strings and those with no/weak directionality default to LTR. 677 // Blank strings and those with no/weak directionality default to LTR.
659 { L"", base::i18n::LEFT_TO_RIGHT }, 678 { L"", base::i18n::LEFT_TO_RIGHT },
660 { kWeak, base::i18n::LEFT_TO_RIGHT }, 679 { kWeak, base::i18n::LEFT_TO_RIGHT },
661 // Strings that begin with strong LTR characters. 680 // Strings that begin with strong LTR characters.
662 { kLtr, base::i18n::LEFT_TO_RIGHT }, 681 { kLtr, base::i18n::LEFT_TO_RIGHT },
(...skipping 1939 matching lines...) Expand 10 before | Expand all | Expand 10 after
2602 EXPECT_LT(220U, color_utils::GetLuminanceForColor(color)) << string; 2621 EXPECT_LT(220U, color_utils::GetLuminanceForColor(color)) << string;
2603 for (int x = 1; x < kTestWidth; ++x) { 2622 for (int x = 1; x < kTestWidth; ++x) {
2604 color = buffer[width + x + y * kCanvasSize.width()]; 2623 color = buffer[width + x + y * kCanvasSize.width()];
2605 EXPECT_EQ(SK_ColorWHITE, color) << string; 2624 EXPECT_EQ(SK_ColorWHITE, color) << string;
2606 } 2625 }
2607 } 2626 }
2608 } 2627 }
2609 } 2628 }
2610 2629
2611 } // namespace gfx 2630 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698