mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
style: Fix unit tests.
This commit is contained in:
parent
0c01325c05
commit
8020faed9b
2 changed files with 8 additions and 58 deletions
|
@ -92,53 +92,3 @@ fn test_transform_interpolation_on_scale() {
|
||||||
Transform(vec![TransformOperation::Scale3D(1.5, 3.0, 1.5)])
|
Transform(vec![TransformOperation::Scale3D(1.5, 3.0, 1.5)])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_transform_interpolation_on_rotate() {
|
|
||||||
use style::values::computed::Angle;
|
|
||||||
|
|
||||||
let from = Transform(vec![TransformOperation::Rotate3D(
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
1.0,
|
|
||||||
Angle::from_radians(0.0),
|
|
||||||
)]);
|
|
||||||
let to = Transform(vec![TransformOperation::Rotate3D(
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
1.0,
|
|
||||||
Angle::from_radians(100.0),
|
|
||||||
)]);
|
|
||||||
assert_eq!(
|
|
||||||
from.animate(&to, Procedure::Interpolate { progress: 0.5 })
|
|
||||||
.unwrap(),
|
|
||||||
Transform(vec![TransformOperation::Rotate3D(
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
1.0,
|
|
||||||
Angle::from_radians(50.0)
|
|
||||||
)])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_transform_interpolation_on_skew() {
|
|
||||||
use style::values::computed::Angle;
|
|
||||||
|
|
||||||
let from = Transform(vec![TransformOperation::Skew(
|
|
||||||
Angle::from_radians(0.0),
|
|
||||||
Some(Angle::from_radians(100.0)),
|
|
||||||
)]);
|
|
||||||
let to = Transform(vec![TransformOperation::Skew(
|
|
||||||
Angle::from_radians(100.0),
|
|
||||||
Some(Angle::from_radians(0.0)),
|
|
||||||
)]);
|
|
||||||
assert_eq!(
|
|
||||||
from.animate(&to, Procedure::Interpolate { progress: 0.5 })
|
|
||||||
.unwrap(),
|
|
||||||
Transform(vec![TransformOperation::Skew(
|
|
||||||
Angle::from_radians(50.0),
|
|
||||||
Some(Angle::from_radians(50.0)),
|
|
||||||
)])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
|
@ -7,30 +7,30 @@ use servo_arc::Arc;
|
||||||
use style::custom_properties::{
|
use style::custom_properties::{
|
||||||
CssEnvironment, CustomPropertiesBuilder, CustomPropertiesMap, Name, SpecifiedValue,
|
CssEnvironment, CustomPropertiesBuilder, CustomPropertiesMap, Name, SpecifiedValue,
|
||||||
};
|
};
|
||||||
use style::properties::CustomDeclarationValue;
|
use style::properties::{CustomDeclaration, CustomDeclarationValue};
|
||||||
|
use style::stylesheets::Origin;
|
||||||
use test::{self, Bencher};
|
use test::{self, Bencher};
|
||||||
|
|
||||||
fn cascade(
|
fn cascade(
|
||||||
name_and_value: &[(&str, &str)],
|
name_and_value: &[(&str, &str)],
|
||||||
inherited: Option<&Arc<CustomPropertiesMap>>,
|
inherited: Option<&Arc<CustomPropertiesMap>>,
|
||||||
) -> Option<Arc<CustomPropertiesMap>> {
|
) -> Option<Arc<CustomPropertiesMap>> {
|
||||||
let values = name_and_value
|
let declarations = name_and_value
|
||||||
.iter()
|
.iter()
|
||||||
.map(|&(name, value)| {
|
.map(|&(name, value)| {
|
||||||
let mut input = ParserInput::new(value);
|
let mut input = ParserInput::new(value);
|
||||||
let mut parser = Parser::new(&mut input);
|
let mut parser = Parser::new(&mut input);
|
||||||
(
|
let name = Name::from(name);
|
||||||
Name::from(name),
|
let value = CustomDeclarationValue::Value(SpecifiedValue::parse(&mut parser).unwrap());
|
||||||
SpecifiedValue::parse(&mut parser).unwrap(),
|
CustomDeclaration { name, value }
|
||||||
)
|
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let env = CssEnvironment;
|
let env = CssEnvironment;
|
||||||
let mut builder = CustomPropertiesBuilder::new(inherited, &env);
|
let mut builder = CustomPropertiesBuilder::new(inherited, &env);
|
||||||
|
|
||||||
for &(ref name, ref val) in &values {
|
for declaration in &declarations {
|
||||||
builder.cascade(name, &CustomDeclarationValue::Value(val.clone()));
|
builder.cascade(declaration, Origin::Author);
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.build()
|
builder.build()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue