1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 
5 use parsing::parse;
6 use servo_atoms::Atom;
7 use style::parser::Parse;
8 use style::properties::longhands::animation_name;
9 use style::values::{KeyframesName, CustomIdent};
10 use style::values::specified::AnimationIterationCount;
11 use style_traits::ToCss;
12 
13 #[test]
test_animation_name()14 fn test_animation_name() {
15     use self::animation_name::single_value::SpecifiedValue as SingleValue;
16     let other_name = Atom::from("other-name");
17     assert_eq!(parse_longhand!(animation_name, "none"),
18                animation_name::SpecifiedValue(vec![SingleValue(None)]));
19     assert_eq!(parse_longhand!(animation_name, "other-name, none, 'other-name', \"other-name\""),
20                animation_name::SpecifiedValue(
21                    vec![SingleValue(Some(KeyframesName::Ident(CustomIdent(other_name.clone())))),
22                         SingleValue(None),
23                         SingleValue(Some(KeyframesName::QuotedString(other_name.clone()))),
24                         SingleValue(Some(KeyframesName::QuotedString(other_name.clone())))]));
25 }
26 
27 #[test]
test_animation_iteration()28 fn test_animation_iteration() {
29     assert_roundtrip_with_context!(AnimationIterationCount::parse, "0", "0");
30     assert_roundtrip_with_context!(AnimationIterationCount::parse, "0.1", "0.1");
31     assert_roundtrip_with_context!(AnimationIterationCount::parse, "infinite", "infinite");
32 
33     // Negative numbers are invalid
34     assert!(parse(AnimationIterationCount::parse, "-1").is_err());
35 }
36