Skip to content

Commit

Permalink
Remove gecko-only unit tests that rely on style/testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Aug 6, 2017
1 parent aa91cdd commit ddf8292
Show file tree
Hide file tree
Showing 12 changed files with 1 addition and 939 deletions.
108 changes: 0 additions & 108 deletions tests/unit/style/parsing/basic_shape.rs

This file was deleted.

18 changes: 0 additions & 18 deletions tests/unit/style/parsing/box_.rs
Expand Up @@ -5,24 +5,6 @@
use parsing::parse;
use style_traits::ToCss;

#[test]
fn test_will_change() {
use style::properties::longhands::will_change;

assert_roundtrip_with_context!(will_change::parse, "auto");
assert_roundtrip_with_context!(will_change::parse, "scroll-position");
assert_roundtrip_with_context!(will_change::parse, "contents");
assert_roundtrip_with_context!(will_change::parse, "transition");
assert_roundtrip_with_context!(will_change::parse, "opacity, transform");

assert!(parse(will_change::parse, "will-change").is_err());
assert!(parse(will_change::parse, "all").is_err());
assert!(parse(will_change::parse, "none").is_err());
assert!(parse(will_change::parse, "contents, auto").is_err());
assert!(parse(will_change::parse, "contents, inherit, initial").is_err());
assert!(parse(will_change::parse, "transform scroll-position").is_err());
}

#[test]
fn test_transform_translate() {
use style::properties::longhands::transform;
Expand Down
27 changes: 0 additions & 27 deletions tests/unit/style/parsing/containment.rs

This file was deleted.

96 changes: 1 addition & 95 deletions tests/unit/style/parsing/font.rs
Expand Up @@ -3,96 +3,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use parsing::parse;
use style::properties::longhands::{font_feature_settings, font_weight};
use style::properties::longhands::font_feature_settings::SpecifiedValue;
use style::properties::longhands::font_weight;
use style::values::generics::{FontSettings, FontSettingTag, FontSettingTagInt};
use style_traits::ToCss;

#[test]
fn font_feature_settings_should_parse_properly() {
use byteorder::{ReadBytesExt, BigEndian};
use std::io::Cursor;

let normal = parse_longhand!(font_feature_settings, "normal");
let normal_computed = SpecifiedValue::Value(FontSettings::Normal);
assert_eq!(normal, normal_computed);

let mut a_d_bytes = Cursor::new(b"abcd");
let mut e_h_bytes = Cursor::new(b"efgh");

let abcd = a_d_bytes.read_u32::<BigEndian>().unwrap();
let efgh = e_h_bytes.read_u32::<BigEndian>().unwrap();

let on = parse_longhand!(font_feature_settings, "\"abcd\" on");
let on_computed = SpecifiedValue::Value(FontSettings::Tag(vec![
FontSettingTag { tag: abcd, value: FontSettingTagInt(1) }
]));
assert_eq!(on, on_computed);

let off = parse_longhand!(font_feature_settings, "\"abcd\" off");
let off_computed = SpecifiedValue::Value(FontSettings::Tag(vec![
FontSettingTag { tag: abcd, value: FontSettingTagInt(0) }
]));
assert_eq!(off, off_computed);

let no_value = parse_longhand!(font_feature_settings, "\"abcd\"");
let no_value_computed = SpecifiedValue::Value(FontSettings::Tag(vec![
FontSettingTag { tag: abcd, value: FontSettingTagInt(1) }
]));
assert_eq!(no_value, no_value_computed);

let pos_integer = parse_longhand!(font_feature_settings, "\"abcd\" 100");
let pos_integer_computed = SpecifiedValue::Value(FontSettings::Tag(vec![
FontSettingTag { tag: abcd, value: FontSettingTagInt(100) }
]));
assert_eq!(pos_integer, pos_integer_computed);

let multiple = parse_longhand!(font_feature_settings, "\"abcd\" off, \"efgh\"");
let multiple_computed = SpecifiedValue::Value(FontSettings::Tag(vec![
FontSettingTag { tag: abcd, value: FontSettingTagInt(0) },
FontSettingTag { tag: efgh, value: FontSettingTagInt(1) }
]));
assert_eq!(multiple, multiple_computed);
}

#[test]
fn font_feature_settings_should_throw_on_bad_input() {
assert!(parse(font_feature_settings::parse, "").is_err());
assert!(parse(font_feature_settings::parse, "\"abcd\" -1").is_err());
assert!(parse(font_feature_settings::parse, "\"abc\"").is_err());
assert!(parse(font_feature_settings::parse, "\"abcó\"").is_err());
}

#[test]
fn font_feature_settings_to_css() {
assert_roundtrip_with_context!(font_feature_settings::parse, "normal");
assert_roundtrip_with_context!(font_feature_settings::parse, "\"abcd\"");
assert_roundtrip_with_context!(font_feature_settings::parse, "\"abcd\" on", "\"abcd\"");
assert_roundtrip_with_context!(font_feature_settings::parse, "\"abcd\" off");
assert_roundtrip_with_context!(font_feature_settings::parse, "\"abcd\" 4");
assert_roundtrip_with_context!(font_feature_settings::parse, "\"abcd\", \"efgh\"");
}

#[test]
fn font_language_override_should_parse_properly() {
use style::properties::longhands::font_language_override::{self, SpecifiedValue};

let normal = parse_longhand!(font_language_override, "normal");
assert_eq!(normal, SpecifiedValue::Normal);

let empty_str = parse_longhand!(font_language_override, "\"\"");
assert_eq!(empty_str, SpecifiedValue::Override("".to_string()));

let normal_str = parse_longhand!(font_language_override, "\"normal\"");
assert_eq!(normal_str, SpecifiedValue::Override("normal".to_string()));

let turkic = parse_longhand!(font_language_override, "\"TRK\"");
assert_eq!(turkic, SpecifiedValue::Override("TRK".to_string()));

let danish = parse_longhand!(font_language_override, "\"DAN\"");
assert_eq!(danish, SpecifiedValue::Override("DAN".to_string()));
}

#[test]
fn font_weight_keyword_should_preserve_keyword() {
use style::properties::longhands::font_weight::SpecifiedValue;
Expand All @@ -103,11 +17,3 @@ fn font_weight_keyword_should_preserve_keyword() {
let result = parse(font_weight::parse, "bold").unwrap();
assert_eq!(result, SpecifiedValue::Bold);
}

#[test]
#[should_panic]
fn font_language_override_should_fail_on_empty_str() {
use style::properties::longhands::font_language_override;

parse_longhand!(font_language_override, "");
}
27 changes: 0 additions & 27 deletions tests/unit/style/parsing/inherited_box.rs

This file was deleted.

88 changes: 0 additions & 88 deletions tests/unit/style/parsing/inherited_text.rs
Expand Up @@ -27,94 +27,6 @@ fn negative_word_spacing_should_parse_properly() {
assert_eq!(negative_value, expected);
}

#[test]
fn text_emphasis_style_longhand_should_parse_properly() {
use style::properties::longhands::text_emphasis_style;
use style::properties::longhands::text_emphasis_style::{ShapeKeyword, SpecifiedValue, KeywordValue};

let none = parse_longhand!(text_emphasis_style, "none");
assert_eq!(none, SpecifiedValue::None);

let fill = parse_longhand!(text_emphasis_style, "open");
let fill_struct = SpecifiedValue::Keyword(KeywordValue::Fill(false));
assert_eq!(fill, fill_struct);

let shape = parse_longhand!(text_emphasis_style, "triangle");
let shape_struct = SpecifiedValue::Keyword(KeywordValue::Shape(ShapeKeyword::Triangle));
assert_eq!(shape, shape_struct);

let fill_shape = parse_longhand!(text_emphasis_style, "filled dot");
let fill_shape_struct = SpecifiedValue::Keyword(KeywordValue::FillAndShape(true, ShapeKeyword::Dot));
assert_eq!(fill_shape, fill_shape_struct);

let shape_fill = parse_longhand!(text_emphasis_style, "dot filled");
let shape_fill_struct = SpecifiedValue::Keyword(KeywordValue::FillAndShape(true, ShapeKeyword::Dot));
assert_eq!(shape_fill, shape_fill_struct);

let a_string = parse_longhand!(text_emphasis_style, "\"a\"");
let a_string_struct = SpecifiedValue::String("a".to_string());
assert_eq!(a_string, a_string_struct);

let chinese_string = parse_longhand!(text_emphasis_style, "\"\"");
let chinese_string_struct = SpecifiedValue::String("点".to_string());
assert_eq!(chinese_string, chinese_string_struct);

let unicode_string = parse_longhand!(text_emphasis_style, "\"\\25B2\"");
let unicode_string_struct = SpecifiedValue::String("▲".to_string());
assert_eq!(unicode_string, unicode_string_struct);

let devanagari_string = parse_longhand!(text_emphasis_style, "\"षि\"");
let devanagari_string_struct = SpecifiedValue::String("षि".to_string());
assert_eq!(devanagari_string, devanagari_string_struct);
}

#[test]
fn test_text_emphasis_position() {
use style::properties::longhands::text_emphasis_position;
use style::properties::longhands::text_emphasis_position::{HorizontalWritingModeValue, VerticalWritingModeValue};
use style::properties::longhands::text_emphasis_position::SpecifiedValue;

let over_right = parse_longhand!(text_emphasis_position, "over right");
assert_eq!(over_right, SpecifiedValue(HorizontalWritingModeValue::Over, VerticalWritingModeValue::Right));

let over_left = parse_longhand!(text_emphasis_position, "over left");
assert_eq!(over_left, SpecifiedValue(HorizontalWritingModeValue::Over, VerticalWritingModeValue::Left));

let under_right = parse_longhand!(text_emphasis_position, "under right");
assert_eq!(under_right, SpecifiedValue(HorizontalWritingModeValue::Under, VerticalWritingModeValue::Right));

let under_left = parse_longhand!(text_emphasis_position, "under left");
assert_eq!(under_left, SpecifiedValue(HorizontalWritingModeValue::Under, VerticalWritingModeValue::Left));

let right_over = parse_longhand!(text_emphasis_position, "right over");
assert_eq!(right_over, SpecifiedValue(HorizontalWritingModeValue::Over, VerticalWritingModeValue::Right));

let left_over = parse_longhand!(text_emphasis_position, "left over");
assert_eq!(left_over, SpecifiedValue(HorizontalWritingModeValue::Over, VerticalWritingModeValue::Left));

let right_under = parse_longhand!(text_emphasis_position, "right under");
assert_eq!(right_under, SpecifiedValue(HorizontalWritingModeValue::Under, VerticalWritingModeValue::Right));

let left_under = parse_longhand!(text_emphasis_position, "left under");
assert_eq!(left_under, SpecifiedValue(HorizontalWritingModeValue::Under, VerticalWritingModeValue::Left));
}

#[test]
fn webkit_text_stroke_shorthand_should_parse_properly() {
use style::properties::longhands::_webkit_text_stroke_color;
use style::properties::longhands::_webkit_text_stroke_width;
use style::properties::shorthands::_webkit_text_stroke;

let result = parse(_webkit_text_stroke::parse_value, "thin red").unwrap();
assert_eq!(result._webkit_text_stroke_color, parse_longhand!(_webkit_text_stroke_color, "red"));
assert_eq!(result._webkit_text_stroke_width, parse_longhand!(_webkit_text_stroke_width, "thin"));

// ensure its no longer sensitive to order
let result = parse(_webkit_text_stroke::parse_value, "red thin").unwrap();
assert_eq!(result._webkit_text_stroke_color, parse_longhand!(_webkit_text_stroke_color, "red"));
assert_eq!(result._webkit_text_stroke_width, parse_longhand!(_webkit_text_stroke_width, "thin"));
}

#[test]
fn line_height_should_return_number_on_plain_zero() {
use style::properties::longhands::line_height;
Expand Down

0 comments on commit ddf8292

Please sign in to comment.