Add full parsing/serialization for mask-repeat and background-repeat

This commit is contained in:
James Bendig 2017-03-24 15:31:16 -05:00
parent 9eb6bb78b0
commit 67282f9bee
8 changed files with 237 additions and 68 deletions

View file

@ -121,3 +121,70 @@ fn mask_shorthand_should_parse_mode_everywhere() {
let mut parser = Parser::new("alpha");
assert!(mask::parse_value(&context, &mut parser).is_ok());
}
#[test]
fn mask_repeat_should_parse_shorthand_correctly() {
use style::properties::longhands::mask_repeat::single_value::{RepeatKeyword, SpecifiedValue};
let repeat_x = parse_longhand!(mask_repeat, "repeat-x");
assert_eq!(repeat_x, mask_repeat::SpecifiedValue(vec![SpecifiedValue::RepeatX]));
let repeat_y = parse_longhand!(mask_repeat, "repeat-y");
assert_eq!(repeat_y, mask_repeat::SpecifiedValue(vec![SpecifiedValue::RepeatY]));
let repeat = parse_longhand!(mask_repeat, "repeat");
assert_eq!(repeat,
mask_repeat::SpecifiedValue(vec![SpecifiedValue::Other(RepeatKeyword::Repeat, None)]));
let space = parse_longhand!(mask_repeat, "space");
assert_eq!(space,
mask_repeat::SpecifiedValue(vec![SpecifiedValue::Other(RepeatKeyword::Space, None)]));
let round = parse_longhand!(mask_repeat, "round");
assert_eq!(round,
mask_repeat::SpecifiedValue(vec![SpecifiedValue::Other(RepeatKeyword::Round, None)]));
let no_repeat = parse_longhand!(mask_repeat, "no-repeat");
assert_eq!(no_repeat,
mask_repeat::SpecifiedValue(vec![SpecifiedValue::Other(RepeatKeyword::NoRepeat, None)]));
}
#[test]
fn mask_repeat_should_parse_longhand_correctly() {
use style::properties::longhands::mask_repeat::single_value::{RepeatKeyword, SpecifiedValue};
let url = ServoUrl::parse("http://localhost").unwrap();
let reporter = CSSErrorReporterTest;
let context = ParserContext::new(Origin::Author, &url, &reporter);
// repeat-x is not available in longhand form.
let mut parser = Parser::new("repeat-x no-repeat");
assert!(mask_repeat::parse(&context, &mut parser).is_err());
let mut parser = Parser::new("no-repeat repeat-x");
assert!(mask_repeat::parse(&context, &mut parser).is_err());
// repeat-y is not available in longhand form.
let mut parser = Parser::new("repeat-y no-repeat");
assert!(mask_repeat::parse(&context, &mut parser).is_err());
let mut parser = Parser::new("no-repeat repeat-y");
assert!(mask_repeat::parse(&context, &mut parser).is_err());
// Longhand form supports two directions.
let no_repeat_and_round = parse_longhand!(mask_repeat, "no-repeat round");
assert_eq!(no_repeat_and_round,
mask_repeat::SpecifiedValue(vec![SpecifiedValue::Other(RepeatKeyword::NoRepeat,
Some(RepeatKeyword::Round))]));
// Not three directions.
let mut parser = Parser::new("repeat no-repeat round");
assert!(mask_repeat::parse(&context, &mut parser).is_err());
// Multiple values with mixed shortform and longform should parse.
let multiple = parse_longhand!(mask_repeat, "repeat, no-repeat round");
assert_eq!(multiple,
mask_repeat::SpecifiedValue(vec![SpecifiedValue::Other(RepeatKeyword::Repeat, None),
SpecifiedValue::Other(RepeatKeyword::NoRepeat,
Some(RepeatKeyword::Round))]));
}

View file

@ -827,7 +827,7 @@ mod shorthand_serialization {
)
);
let repeat = single_vec_keyword_value!(repeat, repeat_x);
let repeat = single_vec_keyword_value!(repeat, RepeatX);
let origin = single_vec_keyword_value!(origin, padding_box);
let clip = single_vec_keyword_value!(clip, border_box);
let composite = single_vec_keyword_value!(composite, subtract);
@ -883,7 +883,7 @@ mod shorthand_serialization {
)
);
let repeat = single_vec_keyword_value!(repeat, repeat_x);
let repeat = single_vec_keyword_value!(repeat, RepeatX);
let origin = single_vec_keyword_value!(origin, padding_box);
let clip = single_vec_keyword_value!(clip, padding_box);
let composite = single_vec_keyword_value!(composite, subtract);

View file

@ -1,3 +0,0 @@
[background-size-027.htm]
type: reftest
expected: FAIL

View file

@ -1,3 +0,0 @@
[background-size-031.htm]
type: reftest
expected: FAIL