From ce80240ee21e3aabf2ba74f03b83cb6410acc8b7 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 9 Aug 2012 19:14:56 -0700 Subject: [PATCH] servo: Reenable some text tests Source-Repo: https://github.com/servo/servo Source-Revision: fb5a2cc2384d5536858c3e364e13f93a84c44f88 --- servo/src/servo/text/font.rs | 28 +++++++++++++--------------- servo/src/servo/text/shaper.rs | 11 +++++++---- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/servo/src/servo/text/font.rs b/servo/src/servo/text/font.rs index ed32f13a4c4b..fe5624a39fe8 100644 --- a/servo/src/servo/text/font.rs +++ b/servo/src/servo/text/font.rs @@ -5,6 +5,7 @@ import vec_to_ptr = vec::unsafe::to_ptr; import libc::{ c_int, c_double, c_ulong }; import ptr::{ null, addr_of }; import native_font::NativeFont; +import font_library::FontLibrary; // FIXME (rust 2708): convert this to a class @@ -37,46 +38,43 @@ class Font { } } -fn create_test_font() -> @Font { - import font_library::FontLibrary; - - let flib = FontLibrary(); - return flib.get_test_font(); -} - fn test_font_bin() -> ~[u8] { #include_bin("JosefinSans-SemiBold.ttf") } fn should_destruct_on_fail_without_leaking() { #[test]; #[should_fail]; - #[ignore]; - let _font = create_test_font(); + let lib = FontLibrary(); + let _font = lib.get_test_font(); fail; } fn should_get_glyph_indexes() { #[test]; - #[ignore(reason = "random failures")]; - let font = create_test_font(); + let lib = FontLibrary(); + let font = lib.get_test_font(); let glyph_idx = font.glyph_index('w'); assert glyph_idx == some(40u); } fn should_get_glyph_advance() { #[test]; - #[ignore(reason = "random failures")]; - let font = create_test_font(); + let lib = FontLibrary(); + let font = lib.get_test_font(); let x = font.glyph_h_advance(40u); assert x == 15; } fn should_be_able_to_create_instances_in_multiple_threads() { #[test]; - #[ignore]; - for iter::repeat(10u) {do task::spawn {create_test_font();}} + for iter::repeat(10u) { + do task::spawn { + let lib = FontLibrary(); + let font = lib.get_test_font(); + } + } } diff --git a/servo/src/servo/text/shaper.rs b/servo/src/servo/text/shaper.rs index 29aac68e9704..be566cdfdf93 100644 --- a/servo/src/servo/text/shaper.rs +++ b/servo/src/servo/text/shaper.rs @@ -9,6 +9,7 @@ import glyph::{Glyph, GlyphPos}; import ptr::{null, addr_of, offset}; import gfx::geometry::{au, px_to_au}; import geom::point::Point2D; +import font_library::FontLibrary; import unsafe::reinterpret_cast; import harfbuzz::{HB_MEMORY_MODE_READONLY, @@ -143,9 +144,10 @@ fn hb_glyph_pos_to_servo_glyph_pos(hb_pos: &hb_glyph_position_t) -> GlyphPos { fn should_get_glyph_indexes() { #[test]; - #[ignore(reason = "random failures")]; + #[ignore]; - let font = font::create_test_font(); + let lib = FontLibrary(); + let font = lib.get_test_font(); let glyphs = shape_text(font, ~"firecracker"); let idxs = glyphs.map(|glyph| glyph.index); assert idxs == ~[32u, 8u, 13u, 14u, 10u, 13u, 201u, 10u, 37u, 14u, 13u]; @@ -153,9 +155,10 @@ fn should_get_glyph_indexes() { fn should_get_glyph_h_advance() { #[test]; - #[ignore(reason = "random failures")]; + #[ignore]; - let font = font::create_test_font(); + let lib = FontLibrary(); + let font = lib.get_test_font(); let glyphs = shape_text(font, ~"firecracker"); let actual = glyphs.map(|g| g.pos.advance.x); let expected = (~[6, 4, 7, 9, 8, 7, 10, 8, 9, 9, 7]).map(|a| px_to_au(a));