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

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

Issue 2734333005: RenderTextMac: Fix crash when passed an invalid font. (Closed)
Patch Set: Nits. Created 3 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
« no previous file with comments | « ui/gfx/render_text_mac.mm ('k') | 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 "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 4331 matching lines...) Expand 10 before | Expand all | Expand 10 after
4342 4342
4343 render_text->SelectRange(line_char_range[i]); 4343 render_text->SelectRange(line_char_range[i]);
4344 EXPECT_EQ(expected_line_bounds, GetSelectionBoundsUnion()); 4344 EXPECT_EQ(expected_line_bounds, GetSelectionBoundsUnion());
4345 } 4345 }
4346 4346
4347 // Test complete bounds. 4347 // Test complete bounds.
4348 render_text->SelectAll(false); 4348 render_text->SelectAll(false);
4349 EXPECT_EQ(expected_total_bounds, GetSelectionBoundsUnion()); 4349 EXPECT_EQ(expected_total_bounds, GetSelectionBoundsUnion());
4350 } 4350 }
4351 4351
4352 // Tests that RenderText doesn't crash even if it's passed an invalid font. Test
4353 // for crbug.com/668058.
4354 TEST_P(RenderTextTest, InvalidFont) {
4355 // TODO(crbug.com/699820): This crashes with RenderTextHarfBuzz on Mac.
4356 #if defined(OS_MACOSX)
4357 if (GetParam() == RENDER_TEXT_HARFBUZZ)
4358 return;
4359 #endif
4360 const std::string font_name = "invalid_font";
4361 const int kFontSize = 13;
4362 RenderText* render_text = GetRenderText();
4363 render_text->SetFontList(FontList(Font(font_name, kFontSize)));
4364 render_text->SetText(ASCIIToUTF16("abc"));
4365
4366 DrawVisualText();
4367 }
4368
4352 // Prefix for test instantiations intentionally left blank since each test 4369 // Prefix for test instantiations intentionally left blank since each test
4353 // fixture class has a single parameterization. 4370 // fixture class has a single parameterization.
4354 #if defined(OS_MACOSX) 4371 #if defined(OS_MACOSX)
4355 INSTANTIATE_TEST_CASE_P(, 4372 INSTANTIATE_TEST_CASE_P(,
4356 RenderTextTest, 4373 RenderTextTest,
4357 ::testing::Values(RENDER_TEXT_HARFBUZZ, 4374 ::testing::Values(RENDER_TEXT_HARFBUZZ,
4358 RENDER_TEXT_MAC), 4375 RENDER_TEXT_MAC),
4359 PrintRenderTextBackend()); 4376 PrintRenderTextBackend());
4360 INSTANTIATE_TEST_CASE_P(, 4377 INSTANTIATE_TEST_CASE_P(,
4361 RenderTextMacTest, 4378 RenderTextMacTest,
4362 ::testing::Values(RENDER_TEXT_MAC), 4379 ::testing::Values(RENDER_TEXT_MAC),
4363 PrintRenderTextBackend()); 4380 PrintRenderTextBackend());
4364 #else 4381 #else
4365 INSTANTIATE_TEST_CASE_P(, 4382 INSTANTIATE_TEST_CASE_P(,
4366 RenderTextTest, 4383 RenderTextTest,
4367 ::testing::Values(RENDER_TEXT_HARFBUZZ), 4384 ::testing::Values(RENDER_TEXT_HARFBUZZ),
4368 PrintRenderTextBackend()); 4385 PrintRenderTextBackend());
4369 #endif 4386 #endif
4370 4387
4371 INSTANTIATE_TEST_CASE_P(, 4388 INSTANTIATE_TEST_CASE_P(,
4372 RenderTextHarfBuzzTest, 4389 RenderTextHarfBuzzTest,
4373 ::testing::Values(RENDER_TEXT_HARFBUZZ), 4390 ::testing::Values(RENDER_TEXT_HARFBUZZ),
4374 PrintRenderTextBackend()); 4391 PrintRenderTextBackend());
4375 4392
4376 } // namespace gfx 4393 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/render_text_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698