Adds parsing test for linear-gradient

This commit is contained in:
Martin Naumann 2016-10-21 21:32:47 +02:00 committed by Keith Yeung
parent 6d29bf3f80
commit ba96603b86

View file

@ -9,6 +9,36 @@ use style::stylesheets::Origin;
use style::values::specified::image::*;
use url::Url;
#[test]
fn test_linear_gradient() {
// Parsing from the right
assert_roundtrip_with_context!(Image::parse, "linear-gradient(to left, red, green)",
"linear-gradient(4.712389rad, red, green)");
// Parsing from the left
assert_roundtrip_with_context!(Image::parse, "linear-gradient(to right, red, green)",
"linear-gradient(1.5707964rad, red, green)");
// Parsing with two values for <side-or-corner>
assert_roundtrip_with_context!(Image::parse, "linear-gradient(to right top, red, green)");
// Parsing with <angle>
assert_roundtrip_with_context!(Image::parse, "linear-gradient(45deg, red, green)",
"linear-gradient(0.7853982rad, red, green)");
// Parsing with more than two entries in <color-stop-list>
assert_roundtrip_with_context!(Image::parse, "linear-gradient(red, yellow, green)",
"linear-gradient(3.1415927rad, red, yellow, green)");
// Parsing with percentage in the <color-stop-list>
assert_roundtrip_with_context!(Image::parse, "linear-gradient(red, green, yellow 50%)",
"linear-gradient(3.1415927rad, red, green, yellow 50%)");
// Parsing without <angle> and <side-or-corner>
assert_roundtrip_with_context!(Image::parse, "linear-gradient(red, green)",
"linear-gradient(3.1415927rad, red, green)");
}
#[test]
fn test_radial_gradient() {
// Parsing with all values