Reenable some text tests

This commit is contained in:
Brian Anderson 2012-08-09 19:14:56 -07:00
parent 7512cfad4c
commit fb5a2cc238
2 changed files with 20 additions and 19 deletions

View file

@ -5,6 +5,7 @@ import vec_to_ptr = vec::unsafe::to_ptr;
import libc::{ c_int, c_double, c_ulong }; import libc::{ c_int, c_double, c_ulong };
import ptr::{ null, addr_of }; import ptr::{ null, addr_of };
import native_font::NativeFont; import native_font::NativeFont;
import font_library::FontLibrary;
// FIXME (rust 2708): convert this to a class // 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 test_font_bin() -> ~[u8] { #include_bin("JosefinSans-SemiBold.ttf") }
fn should_destruct_on_fail_without_leaking() { fn should_destruct_on_fail_without_leaking() {
#[test]; #[test];
#[should_fail]; #[should_fail];
#[ignore];
let _font = create_test_font(); let lib = FontLibrary();
let _font = lib.get_test_font();
fail; fail;
} }
fn should_get_glyph_indexes() { fn should_get_glyph_indexes() {
#[test]; #[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'); let glyph_idx = font.glyph_index('w');
assert glyph_idx == some(40u); assert glyph_idx == some(40u);
} }
fn should_get_glyph_advance() { fn should_get_glyph_advance() {
#[test]; #[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); let x = font.glyph_h_advance(40u);
assert x == 15; assert x == 15;
} }
fn should_be_able_to_create_instances_in_multiple_threads() { fn should_be_able_to_create_instances_in_multiple_threads() {
#[test]; #[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();
}
}
} }

View file

@ -9,6 +9,7 @@ import glyph::{Glyph, GlyphPos};
import ptr::{null, addr_of, offset}; import ptr::{null, addr_of, offset};
import gfx::geometry::{au, px_to_au}; import gfx::geometry::{au, px_to_au};
import geom::point::Point2D; import geom::point::Point2D;
import font_library::FontLibrary;
import unsafe::reinterpret_cast; import unsafe::reinterpret_cast;
import harfbuzz::{HB_MEMORY_MODE_READONLY, 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() { fn should_get_glyph_indexes() {
#[test]; #[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 glyphs = shape_text(font, ~"firecracker");
let idxs = glyphs.map(|glyph| glyph.index); let idxs = glyphs.map(|glyph| glyph.index);
assert idxs == ~[32u, 8u, 13u, 14u, 10u, 13u, 201u, 10u, 37u, 14u, 13u]; 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() { fn should_get_glyph_h_advance() {
#[test]; #[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 glyphs = shape_text(font, ~"firecracker");
let actual = glyphs.map(|g| g.pos.advance.x); 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)); let expected = (~[6, 4, 7, 9, 8, 7, 10, 8, 9, 9, 7]).map(|a| px_to_au(a));