Bug 1502754 - Synchronize style system unit tests.

These are not part of the Gecko build, just prevent that they end up out of
sync.
This commit is contained in:
Emilio Cobos Álvarez 2018-10-28 23:59:10 +01:00
Родитель 585bf5454b
Коммит d6266e508a
5 изменённых файлов: 11 добавлений и 106 удалений

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

@ -11,11 +11,11 @@ doctest = false
[dependencies]
byteorder = "1.0"
app_units = "0.6"
app_units = "0.7"
cssparser = "0.24.0"
euclid = "0.18"
euclid = "0.19"
html5ever = "0.22"
parking_lot = "0.5"
parking_lot = "0.6"
rayon = "1"
serde_json = "1.0"
selectors = {path = "../../../components/selectors"}
@ -26,3 +26,4 @@ servo_url = {path = "../../../components/url"}
size_of_test = {path = "../../../components/size_of_test"}
style = {path = "../../../components/style"}
style_traits = {path = "../../../components/style_traits"}
std_test_override = { path = "../../../components/std_test_override" }

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

@ -5,7 +5,7 @@
use cssparser::{Parser, ParserInput};
use servo_arc::Arc;
use style::custom_properties::{Name, SpecifiedValue, CustomPropertiesMap, CustomPropertiesBuilder};
use style::properties::DeclaredValue;
use style::properties::CustomDeclarationValue;
use test::{self, Bencher};
fn cascade(
@ -21,7 +21,7 @@ fn cascade(
let mut builder = CustomPropertiesBuilder::new(inherited);
for &(ref name, ref val) in &values {
builder.cascade(name, DeclaredValue::Value(val));
builder.cascade(name, &CustomDeclarationValue::Value(val.clone()));
}
builder.build()

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

@ -35,19 +35,3 @@ fn test_steps() {
assert!(parse(transition_timing_function::parse, "steps(-1)").is_err());
assert!(parse(transition_timing_function::parse, "steps(1, middle)").is_err());
}
#[test]
fn test_frames() {
assert_roundtrip_with_context!(transition_timing_function::parse, "frames( 2 )", "frames(2)");
assert_roundtrip_with_context!(transition_timing_function::parse, "frames(10000)");
// Frames number must be an integer greater than 1
assert!(parse(transition_timing_function::parse, "frames(1)").is_err());
assert!(parse(transition_timing_function::parse, "frames(-2)").is_err());
assert!(parse(transition_timing_function::parse, "frames()").is_err());
assert!(parse(transition_timing_function::parse, "frames(,)").is_err());
assert!(parse(transition_timing_function::parse, "frames(a)").is_err());
assert!(parse(transition_timing_function::parse, "frames(2.0)").is_err());
assert!(parse(transition_timing_function::parse, "frames(2.5)").is_err());
assert!(parse(transition_timing_function::parse, "frames(2 3)").is_err());
}

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

@ -707,86 +707,6 @@ mod shorthand_serialization {
}
}
mod transition {
pub use super::*;
#[test]
fn transition_should_serialize_all_available_properties() {
let block_text = "transition-property: margin-left; \
transition-duration: 3s; \
transition-delay: 4s; \
transition-timing-function: cubic-bezier(0.2, 5, 0.5, 2);";
let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();
let serialization = block.to_css_string();
assert_eq!(serialization, "transition: margin-left 3s cubic-bezier(0.2, 5, 0.5, 2) 4s;");
}
#[test]
fn serialize_multiple_transitions() {
let block_text = "transition-property: margin-left, width; \
transition-duration: 3s, 2s; \
transition-delay: 4s, 5s; \
transition-timing-function: cubic-bezier(0.2, 5, 0.5, 2), ease;";
let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();
let serialization = block.to_css_string();
assert_eq!(serialization, "transition: \
margin-left 3s cubic-bezier(0.2, 5, 0.5, 2) 4s, \
width 2s ease 5s;");
}
#[test]
fn serialize_multiple_transitions_unequal_property_lists() {
// When the lengths of property values are different, the shorthand serialization
// should not be used. Previously the implementation cycled values if the lists were
// uneven. This is incorrect, in that we should serialize to a shorthand only when the
// lists have the same length (this affects background, transition and animation).
// https://github.com/servo/servo/issues/15398 )
// The duration below has 1 extra value.
let block_text = "transition-property: margin-left, width; \
transition-duration: 3s, 2s, 4s; \
transition-delay: 4s, 5s; \
transition-timing-function: cubic-bezier(0.2, 5, 0.5, 2), ease;";
let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();
let serialization = block.to_css_string();
assert_eq!(serialization, block_text);
}
#[test]
fn transition_should_serialize_acceptable_step_timing_function() {
let block_text = "transition-property: margin-left; \
transition-duration: 3s; \
transition-delay: 4s; \
transition-timing-function: steps(2, start);";
let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();
let serialization = block.to_css_string();
assert_eq!(serialization, "transition: margin-left 3s steps(2, start) 4s;");
}
#[test]
fn transition_should_serialize_acceptable_frames_timing_function() {
let block_text = "transition-property: margin-left; \
transition-duration: 3s; \
transition-delay: 4s; \
transition-timing-function: frames(2);";
let block = parse(|c, i| Ok(parse_property_declaration_list(c, i)), block_text).unwrap();
let serialization = block.to_css_string();
assert_eq!(serialization, "transition: margin-left 3s frames(2) 4s;");
}
}
mod keywords {
pub use super::*;
#[test]

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

@ -17,8 +17,8 @@ use std::sync::atomic::AtomicBool;
use style::context::QuirksMode;
use style::error_reporting::{ParseErrorReporter, ContextualParseError};
use style::media_queries::MediaList;
use style::properties::{CSSWideKeyword, CustomDeclaration, DeclarationPushMode};
use style::properties::{DeclaredValueOwned, Importance};
use style::properties::{CSSWideKeyword, CustomDeclaration};
use style::properties::{CustomDeclarationValue, Importance};
use style::properties::{PropertyDeclaration, PropertyDeclarationBlock};
use style::properties::longhands::{self, animation_timing_function};
use style::shared_lock::SharedRwLock;
@ -28,13 +28,13 @@ use style::stylesheets::keyframes_rule::{Keyframe, KeyframeSelector, KeyframePer
use style::values::{KeyframesName, CustomIdent};
use style::values::computed::Percentage;
use style::values::specified::{LengthOrPercentageOrAuto, PositionComponent};
use style::values::specified::transform::TimingFunction;
use style::values::specified::TimingFunction;
pub fn block_from<I>(iterable: I) -> PropertyDeclarationBlock
where I: IntoIterator<Item=(PropertyDeclaration, Importance)> {
let mut block = PropertyDeclarationBlock::new();
for (d, i) in iterable {
block.push(d, i, DeclarationPushMode::Append);
block.push(d, i);
}
block
}
@ -113,7 +113,7 @@ fn test_parse_stylesheet() {
(
PropertyDeclaration::Custom(CustomDeclaration {
name: Atom::from("a"),
value: DeclaredValueOwned::CSSWideKeyword(CSSWideKeyword::Inherit),
value: CustomDeclarationValue::CSSWideKeyword(CSSWideKeyword::Inherit),
}),
Importance::Important,
),