style: Remove useless unit tests, and fix not-so-useless ones.

This commit is contained in:
Emilio Cobos Álvarez 2019-05-25 03:48:56 +02:00
parent 4671ef5243
commit ac01c76e5e
4 changed files with 8 additions and 64 deletions

View file

@ -4,7 +4,6 @@
use cssparser::RGBA;
use style::values::animated::{Animate, Procedure, ToAnimatedValue};
use style::values::generics::transform::{Transform, TransformOperation};
fn interpolate_rgba(from: RGBA, to: RGBA, progress: f64) -> RGBA {
let from = from.to_animated_value();
@ -81,14 +80,3 @@ fn test_rgba_color_interepolation_out_of_range_clamped_2() {
RGBA::from_floats(0.0, 0.0, 0.0, 0.0)
);
}
#[test]
fn test_transform_interpolation_on_scale() {
let from = Transform(vec![TransformOperation::Scale3D(1.0, 2.0, 1.0)]);
let to = Transform(vec![TransformOperation::Scale3D(2.0, 4.0, 2.0)]);
assert_eq!(
from.animate(&to, Procedure::Interpolate { progress: 0.5 })
.unwrap(),
Transform(vec![TransformOperation::Scale3D(1.5, 3.0, 1.5)])
);
}

View file

@ -1,43 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::parsing::parse;
use servo_atoms::Atom;
use style::parser::Parse;
use style::properties::longhands::animation_name;
use style::values::specified::AnimationIterationCount;
use style::values::{CustomIdent, KeyframesName};
use style_traits::ToCss;
#[test]
fn test_animation_name() {
use self::animation_name::single_value::SpecifiedValue as SingleValue;
let other_name = Atom::from("other-name");
assert_eq!(
parse_longhand!(animation_name, "none"),
animation_name::SpecifiedValue(vec![SingleValue(None)])
);
assert_eq!(
parse_longhand!(
animation_name,
"other-name, none, 'other-name', \"other-name\""
),
animation_name::SpecifiedValue(vec![
SingleValue(Some(KeyframesName::Ident(CustomIdent(other_name.clone())))),
SingleValue(None),
SingleValue(Some(KeyframesName::QuotedString(other_name.clone()))),
SingleValue(Some(KeyframesName::QuotedString(other_name.clone())))
])
);
}
#[test]
fn test_animation_iteration() {
assert_roundtrip_with_context!(AnimationIterationCount::parse, "0", "0");
assert_roundtrip_with_context!(AnimationIterationCount::parse, "0.1", "0.1");
assert_roundtrip_with_context!(AnimationIterationCount::parse, "infinite", "infinite");
// Negative numbers are invalid
assert!(parse(AnimationIterationCount::parse, "-1").is_err());
}

View file

@ -133,7 +133,6 @@ macro_rules! parse_longhand {
};
}
mod animation;
mod background;
mod border;
mod box_;

View file

@ -194,7 +194,7 @@ fn test_parse_stylesheet() {
PropertyDeclaration::BackgroundPositionX(
longhands::background_position_x::SpecifiedValue(vec![
PositionComponent::zero(),
]),
].into()),
),
Importance::Normal,
),
@ -202,7 +202,7 @@ fn test_parse_stylesheet() {
PropertyDeclaration::BackgroundPositionY(
longhands::background_position_y::SpecifiedValue(vec![
PositionComponent::zero(),
]),
].into()),
),
Importance::Normal,
),
@ -210,7 +210,7 @@ fn test_parse_stylesheet() {
PropertyDeclaration::BackgroundRepeat(
longhands::background_repeat::SpecifiedValue(
vec![longhands::background_repeat::single_value
::get_initial_specified_value()],
::get_initial_specified_value()].into(),
),
),
Importance::Normal,
@ -219,7 +219,7 @@ fn test_parse_stylesheet() {
PropertyDeclaration::BackgroundAttachment(
longhands::background_attachment::SpecifiedValue(
vec![longhands::background_attachment::single_value
::get_initial_specified_value()],
::get_initial_specified_value()].into(),
),
),
Importance::Normal,
@ -228,7 +228,7 @@ fn test_parse_stylesheet() {
PropertyDeclaration::BackgroundImage(
longhands::background_image::SpecifiedValue(
vec![longhands::background_image::single_value
::get_initial_specified_value()],
::get_initial_specified_value()].into(),
),
),
Importance::Normal,
@ -237,7 +237,7 @@ fn test_parse_stylesheet() {
PropertyDeclaration::BackgroundSize(
longhands::background_size::SpecifiedValue(
vec![longhands::background_size::single_value
::get_initial_specified_value()],
::get_initial_specified_value()].into(),
),
),
Importance::Normal,
@ -246,7 +246,7 @@ fn test_parse_stylesheet() {
PropertyDeclaration::BackgroundOrigin(
longhands::background_origin::SpecifiedValue(
vec![longhands::background_origin::single_value
::get_initial_specified_value()],
::get_initial_specified_value()].into(),
),
),
Importance::Normal,
@ -255,7 +255,7 @@ fn test_parse_stylesheet() {
PropertyDeclaration::BackgroundClip(
longhands::background_clip::SpecifiedValue(
vec![longhands::background_clip::single_value
::get_initial_specified_value()],
::get_initial_specified_value()].into(),
),
),
Importance::Normal,