Skip to content

Commit

Permalink
libtxt: specifically request the Roboto font in tests and benchmarks (f…
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-simmons authored Feb 14, 2018
1 parent 7a6d12f commit 468935e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions third_party/txt/benchmarks/paint_record_benchmarks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace txt {

static void BM_PaintRecordInit(benchmark::State& state) {
TextStyle style;
style.font_family = "Roboto";

SkPaint paint;
paint.setAntiAlias(true);
Expand Down
9 changes: 9 additions & 0 deletions third_party/txt/benchmarks/paragraph_benchmarks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ static void BM_ParagraphShortLayout(benchmark::State& state) {
txt::ParagraphStyle paragraph_style;

txt::TextStyle text_style;
text_style.font_family = "Roboto";
text_style.color = SK_ColorBLACK;
txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection());

Expand Down Expand Up @@ -83,6 +84,7 @@ static void BM_ParagraphLongLayout(benchmark::State& state) {
txt::ParagraphStyle paragraph_style;

txt::TextStyle text_style;
text_style.font_family = "Roboto";
text_style.color = SK_ColorBLACK;

txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection());
Expand Down Expand Up @@ -125,6 +127,7 @@ static void BM_ParagraphJustifyLayout(benchmark::State& state) {
paragraph_style.text_align = TextAlign::justify;

txt::TextStyle text_style;
text_style.font_family = "Roboto";
text_style.color = SK_ColorBLACK;

txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection());
Expand All @@ -149,6 +152,7 @@ static void BM_ParagraphManyStylesLayout(benchmark::State& state) {
txt::ParagraphStyle paragraph_style;

txt::TextStyle text_style;
text_style.font_family = "Roboto";
text_style.color = SK_ColorBLACK;
txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection());
for (int i = 0; i < 1000; ++i) {
Expand All @@ -173,6 +177,7 @@ static void BM_ParagraphTextBigO(benchmark::State& state) {
txt::ParagraphStyle paragraph_style;

txt::TextStyle text_style;
text_style.font_family = "Roboto";
text_style.color = SK_ColorBLACK;

txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection());
Expand Down Expand Up @@ -201,6 +206,7 @@ static void BM_ParagraphStylesBigO(benchmark::State& state) {
txt::ParagraphStyle paragraph_style;

txt::TextStyle text_style;
text_style.font_family = "Roboto";
text_style.color = SK_ColorBLACK;

txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection());
Expand Down Expand Up @@ -230,6 +236,7 @@ static void BM_ParagraphPaintSimple(benchmark::State& state) {
txt::ParagraphStyle paragraph_style;

txt::TextStyle text_style;
text_style.font_family = "Roboto";
text_style.color = SK_ColorBLACK;
txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection());
builder.PushStyle(text_style);
Expand Down Expand Up @@ -276,6 +283,7 @@ static void BM_ParagraphPaintLarge(benchmark::State& state) {
txt::ParagraphStyle paragraph_style;

txt::TextStyle text_style;
text_style.font_family = "Roboto";
text_style.color = SK_ColorBLACK;
txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection());
builder.PushStyle(text_style);
Expand Down Expand Up @@ -306,6 +314,7 @@ static void BM_ParagraphPaintDecoration(benchmark::State& state) {
txt::ParagraphStyle paragraph_style;

txt::TextStyle text_style;
text_style.font_family = "Roboto";
text_style.decoration = TextDecoration(0x1 | 0x2 | 0x4);
text_style.decoration_style = TextDecorationStyle(kSolid);
text_style.color = SK_ColorBLACK;
Expand Down
19 changes: 16 additions & 3 deletions third_party/txt/tests/paragraph_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ TEST_F(ParagraphTest, SimpleParagraph) {
txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection());

txt::TextStyle text_style;
text_style.font_family = "Roboto";
text_style.color = SK_ColorBLACK;
builder.PushStyle(text_style);
builder.AddText(u16_text);
Expand Down Expand Up @@ -72,6 +73,7 @@ TEST_F(ParagraphTest, SimpleRedParagraph) {
txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection());

txt::TextStyle text_style;
text_style.font_family = "Roboto";
text_style.color = SK_ColorRED;
builder.PushStyle(text_style);

Expand Down Expand Up @@ -137,6 +139,7 @@ TEST_F(ParagraphTest, RainbowParagraph) {
text_style2.word_spacing = 30;
text_style2.font_weight = txt::FontWeight::w600;
text_style2.color = SK_ColorGREEN;
text_style2.font_family = "Roboto";
text_style2.decoration = txt::TextDecoration(0x1 | 0x2 | 0x4);
text_style2.decoration_color = SK_ColorBLACK;
builder.PushStyle(text_style2);
Expand Down Expand Up @@ -195,11 +198,9 @@ TEST_F(ParagraphTest, DefaultStyleParagraph) {
icu_text.getBuffer() + icu_text.length());

txt::ParagraphStyle paragraph_style;
paragraph_style.font_family = "Roboto";
txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection());

txt::TextStyle text_style;
text_style.color = SK_ColorRED;

builder.AddText(u16_text);

builder.Pop();
Expand Down Expand Up @@ -284,6 +285,7 @@ TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(LeftAlignParagraph)) {
txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection());

txt::TextStyle text_style;
text_style.font_family = "Roboto";
text_style.font_size = 26;
text_style.letter_spacing = 1;
text_style.word_spacing = 5;
Expand Down Expand Up @@ -380,6 +382,7 @@ TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(RightAlignParagraph)) {
txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection());

txt::TextStyle text_style;
text_style.font_family = "Roboto";
text_style.font_size = 26;
text_style.letter_spacing = 1;
text_style.word_spacing = 5;
Expand Down Expand Up @@ -483,6 +486,7 @@ TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(CenterAlignParagraph)) {
txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection());

txt::TextStyle text_style;
text_style.font_family = "Roboto";
text_style.font_size = 26;
text_style.letter_spacing = 1;
text_style.word_spacing = 5;
Expand Down Expand Up @@ -588,6 +592,7 @@ TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(JustifyAlignParagraph)) {
txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection());

txt::TextStyle text_style;
text_style.font_family = "Roboto";
text_style.font_size = 26;
text_style.letter_spacing = 0;
text_style.word_spacing = 5;
Expand Down Expand Up @@ -654,6 +659,7 @@ TEST_F(ParagraphTest, DecorationsParagraph) {
txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection());

txt::TextStyle text_style;
text_style.font_family = "Roboto";
text_style.font_size = 26;
text_style.letter_spacing = 0;
text_style.word_spacing = 5;
Expand Down Expand Up @@ -728,6 +734,7 @@ TEST_F(ParagraphTest, ItalicsParagraph) {
txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection());

txt::TextStyle text_style;
text_style.font_family = "Roboto";
text_style.color = SK_ColorRED;
text_style.font_size = 10;
builder.PushStyle(text_style);
Expand Down Expand Up @@ -862,6 +869,7 @@ TEST_F(ParagraphTest, GetGlyphPositionAtCoordinateParagraph) {
txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection());

txt::TextStyle text_style;
text_style.font_family = "Roboto";
text_style.font_size = 50;
text_style.letter_spacing = 1;
text_style.word_spacing = 5;
Expand Down Expand Up @@ -929,6 +937,7 @@ TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(GetRectsForRangeParagraph)) {
txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection());

txt::TextStyle text_style;
text_style.font_family = "Roboto";
text_style.font_size = 50;
text_style.letter_spacing = 0;
text_style.font_weight = FontWeight::w500;
Expand Down Expand Up @@ -1054,6 +1063,7 @@ TEST_F(ParagraphTest, GetWordBoundaryParagraph) {
txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection());

txt::TextStyle text_style;
text_style.font_family = "Roboto";
text_style.font_size = 52;
text_style.letter_spacing = 1.19039;
text_style.word_spacing = 5;
Expand Down Expand Up @@ -1159,6 +1169,7 @@ TEST_F(ParagraphTest, SpacingParagraph) {
txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection());

txt::TextStyle text_style;
text_style.font_family = "Roboto";
text_style.font_size = 50;
text_style.letter_spacing = 20;
text_style.word_spacing = 0;
Expand Down Expand Up @@ -1320,6 +1331,7 @@ TEST_F(ParagraphTest, KernScaleParagraph) {

TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(NewlineParagraph)) {
txt::ParagraphStyle paragraph_style;
paragraph_style.font_family = "Roboto";
paragraph_style.break_strategy = minikin::kBreakStrategy_HighQuality;

txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection());
Expand Down Expand Up @@ -1520,6 +1532,7 @@ TEST_F(ParagraphTest, Ellipsize) {
txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection());

txt::TextStyle text_style;
text_style.font_family = "Roboto";
text_style.color = SK_ColorBLACK;
builder.PushStyle(text_style);
builder.AddText(u16_text);
Expand Down

0 comments on commit 468935e

Please sign in to comment.