servo: Reenable some text tests

Source-Repo: https://github.com/servo/servo
Source-Revision: fb5a2cc2384d5536858c3e364e13f93a84c44f88
This commit is contained in:
Brian Anderson 2012-08-09 19:14:56 -07:00
Родитель 612e99c54c
Коммит ce80240ee2
2 изменённых файлов: 20 добавлений и 19 удалений

Просмотреть файл

@ -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();
}
}
}

Просмотреть файл

@ -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));