mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Remove testing feature from style crate
This commit is contained in:
parent
a6369149dc
commit
2ebce54d75
33 changed files with 63 additions and 1181 deletions
|
@ -2,7 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use parsing::{assert_computed_serialization, parse, parse_entirely};
|
||||
use parsing::{parse, parse_entirely};
|
||||
use style::parser::Parse;
|
||||
use style::values::specified::position::*;
|
||||
use style_traits::ToCss;
|
||||
|
@ -144,105 +144,3 @@ fn test_vertical_position() {
|
|||
assert!(parse(VerticalPosition::parse, "y-end").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_grid_auto_flow() {
|
||||
use style::properties::longhands::grid_auto_flow;
|
||||
|
||||
assert_roundtrip_with_context!(grid_auto_flow::parse, "row dense", "row dense");
|
||||
assert_roundtrip_with_context!(grid_auto_flow::parse, "dense row", "row dense");
|
||||
assert_roundtrip_with_context!(grid_auto_flow::parse, "column dense", "column dense");
|
||||
assert_roundtrip_with_context!(grid_auto_flow::parse, "dense column", "column dense");
|
||||
assert_roundtrip_with_context!(grid_auto_flow::parse, "dense", "row dense");
|
||||
assert_roundtrip_with_context!(grid_auto_flow::parse, "row", "row");
|
||||
assert_roundtrip_with_context!(grid_auto_flow::parse, "column", "column");
|
||||
|
||||
// Neither row, column or dense can be repeated
|
||||
assert!(parse(grid_auto_flow::parse, "dense dense").is_err());
|
||||
assert!(parse(grid_auto_flow::parse, "row row").is_err());
|
||||
assert!(parse(grid_auto_flow::parse, "column column").is_err());
|
||||
assert!(parse(grid_auto_flow::parse, "row dense dense").is_err());
|
||||
assert!(parse(grid_auto_flow::parse, "column dense dense").is_err());
|
||||
|
||||
// Only row, column, dense idents are allowed
|
||||
assert!(parse(grid_auto_flow::parse, "dense 1").is_err());
|
||||
assert!(parse(grid_auto_flow::parse, "column 'dense'").is_err());
|
||||
assert!(parse(grid_auto_flow::parse, "column 2px dense").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_grid_auto_rows_columns() {
|
||||
use style::properties::longhands::grid_auto_rows;
|
||||
|
||||
// the grammar is <track-size>+ but gecko supports only a single value, so we've clamped ourselves
|
||||
assert_roundtrip_with_context!(grid_auto_rows::parse, "55%");
|
||||
assert_roundtrip_with_context!(grid_auto_rows::parse, "0.5fr");
|
||||
assert_roundtrip_with_context!(grid_auto_rows::parse, "fit-content(11%)");
|
||||
// only <inflexible-breadth> is allowed in first arg of minmax
|
||||
assert!(parse(grid_auto_rows::parse, "minmax(1fr, max-content)").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_grid_template_rows_columns() {
|
||||
use style::properties::longhands::grid_template_rows;
|
||||
|
||||
assert_roundtrip_with_context!(grid_template_rows::parse, "none"); // none keyword
|
||||
// <track-size>{2} with `<track-breadth> minmax(<inflexible-breadth>, <track-breadth>)`
|
||||
assert_roundtrip_with_context!(grid_template_rows::parse, "1fr minmax(min-content, 1fr)");
|
||||
// <track-size> with <track-breadth> as <length-percentage>
|
||||
assert_roundtrip_with_context!(grid_template_rows::parse, "calc(4em + 5px)");
|
||||
// <track-size> with <length> followed by <track-repeat> with `<track-size>{3}` (<flex>, auto, minmax)
|
||||
assert_roundtrip_with_context!(grid_template_rows::parse,
|
||||
"10px repeat(2, 1fr auto minmax(200px, 1fr))",
|
||||
"10px 1fr auto minmax(200px, 1fr) 1fr auto minmax(200px, 1fr)");
|
||||
// <track-repeat> with `<track-size> <line-names>` followed by <track-size>
|
||||
assert_roundtrip_with_context!(grid_template_rows::parse,
|
||||
"repeat(2, 10px [col-start] 250px [col-end]) 10px",
|
||||
"10px [col-start] 250px [col-end] 10px [col-start] 250px [col-end] 10px");
|
||||
// mixture of <track-size>, <track-repeat> and <line-names>
|
||||
assert_roundtrip_with_context!(grid_template_rows::parse,
|
||||
"[a] auto [b] minmax(min-content, 1fr) [b c d] repeat(2, 40px [e] 30px) [i]",
|
||||
"[a] auto [b] minmax(min-content, 1fr) [b c d] 40px [e] 30px 40px [e] 30px [i]");
|
||||
assert!(parse(grid_template_rows::parse, "subgrid").is_ok());
|
||||
|
||||
// no span allowed in <line-names>
|
||||
assert!(parse(grid_template_rows::parse, "[a span] 10px").is_err());
|
||||
// <track-list> needs at least one <track-size> | <track-repeat>
|
||||
assert!(parse(grid_template_rows::parse, "[a b c]").is_err());
|
||||
// at least one argument of <fixed-size> should be a <fixed-breadth> (i.e., <length-percentage>)
|
||||
assert!(parse(grid_template_rows::parse, "[a b] repeat(auto-fill, 50px) minmax(auto, 1fr)").is_err());
|
||||
// fit-content is not a <fixed-size>
|
||||
assert!(parse(grid_template_rows::parse, "[a b] repeat(auto-fill, fit-content(20%))").is_err());
|
||||
// <auto-track-list> only allows <fixed-size> | <fixed-repeat>
|
||||
assert!(parse(grid_template_rows::parse, "[a] repeat(2, auto) repeat(auto-fill, 10px)").is_err());
|
||||
// only <inflexible-breadth> allowed in <auto-track-repeat>
|
||||
assert!(parse(grid_template_rows::parse, "[a] repeat(auto-fill, 1fr)").is_err());
|
||||
// <auto-track-repeat> is allowed only once
|
||||
assert!(parse(grid_template_rows::parse, "[a] repeat(auto-fit, [b] 8px) [c] repeat(auto-fill, [c] 8px)").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_computed_grid_template_rows_colums() {
|
||||
use style::properties::longhands::grid_template_rows;
|
||||
|
||||
assert_computed_serialization(grid_template_rows::parse,
|
||||
"[a] repeat(calc(1 + 1), [b] auto)", "[a b] auto [b] auto");
|
||||
|
||||
assert_computed_serialization(grid_template_rows::parse,
|
||||
"[a] repeat(2, [b c] auto [e] auto [d])",
|
||||
"[a b c] auto [e] auto [d b c] auto [e] auto [d]");
|
||||
|
||||
assert_computed_serialization(grid_template_rows::parse,
|
||||
"[a] 50px [b] 10% [b c d] repeat(2, [e] 40px [f]) [g] repeat(auto-fill, [h i] 20px [j]) [k] 10px [l]",
|
||||
"[a] 50px [b] 10% [b c d e] 40px [f e] 40px [f g] repeat(auto-fill, [h i] 20px [j]) [k] 10px [l]");
|
||||
|
||||
assert_computed_serialization(grid_template_rows::parse,
|
||||
"10px repeat(2, 1fr auto minmax(200px, 1fr))",
|
||||
"10px 1fr auto minmax(200px, 1fr) 1fr auto minmax(200px, 1fr)");
|
||||
|
||||
assert_computed_serialization(grid_template_rows::parse,
|
||||
"subgrid [a] [] repeat(auto-fill, [])", "subgrid [a] [] repeat(auto-fill, [])");
|
||||
|
||||
assert_computed_serialization(grid_template_rows::parse,
|
||||
"subgrid [a] [b] repeat(2, [c d] [] [e]) [] repeat(auto-fill, [])",
|
||||
"subgrid [a] [b] [c d] [] [e] [c d] [] [e] [] repeat(auto-fill, [])");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue