@@ -261,6 +261,35 @@ public void GradientTwoPositionColorStopLegal(string snippet, string expected)
261261 Assert . Equal ( expected , backgroundImage . Value ) ;
262262 }
263263
264+ [ Theory ]
265+ // conic-gradient()/repeating-conic-gradient() (CSS Images 4 3.4): an optional
266+ // "[ from <angle> ]? [ at <position> ]?" prelude, then an <angular-color-stop> list whose stops are
267+ // positioned by <angle-percentage>.
268+ [ InlineData ( "background-image: conic-gradient(red, blue)" ,
269+ "conic-gradient(rgb(255, 0, 0), rgb(0, 0, 255))" ) ]
270+ [ InlineData ( "background-image: conic-gradient(from 90deg, red, blue)" ,
271+ "conic-gradient(from 90deg, rgb(255, 0, 0), rgb(0, 0, 255))" ) ]
272+ [ InlineData ( "background-image: conic-gradient(at center, red, blue)" ,
273+ "conic-gradient(at center, rgb(255, 0, 0), rgb(0, 0, 255))" ) ]
274+ [ InlineData ( "background-image: conic-gradient(from 45deg at 30% 70%, red, blue)" ,
275+ "conic-gradient(from 45deg at 30% 70%, rgb(255, 0, 0), rgb(0, 0, 255))" ) ]
276+ [ InlineData ( "background-image: conic-gradient(red 0deg, blue 90deg, lime 180deg)" ,
277+ "conic-gradient(rgb(255, 0, 0) 0deg, rgb(0, 0, 255) 90deg, rgb(0, 255, 0) 180deg)" ) ]
278+ [ InlineData ( "background-image: conic-gradient(red 25%, blue 50%)" ,
279+ "conic-gradient(rgb(255, 0, 0) 25%, rgb(0, 0, 255) 50%)" ) ]
280+ [ InlineData ( "background-image: conic-gradient(from 1turn, red, blue)" ,
281+ "conic-gradient(from 1turn, rgb(255, 0, 0), rgb(0, 0, 255))" ) ]
282+ [ InlineData ( "background-image: repeating-conic-gradient(red, blue 30deg)" ,
283+ "repeating-conic-gradient(rgb(255, 0, 0), rgb(0, 0, 255) 30deg)" ) ]
284+ public void ConicGradientLegal ( string source , string expected )
285+ {
286+ var property = ParseDeclaration ( source ) ;
287+ Assert . IsType < BackgroundImageProperty > ( property ) ;
288+ var backgroundImage = ( BackgroundImageProperty ) property ;
289+ Assert . True ( backgroundImage . HasValue ) ;
290+ Assert . Equal ( expected , backgroundImage . Value ) ;
291+ }
292+
264293 [ Theory ]
265294 // Single-position and no-position stops, plus a bare-position colour hint, must be unaffected.
266295 [ InlineData ( "background-image: linear-gradient(red, blue)" ) ]
@@ -282,5 +311,24 @@ public void GradientMalformedColorStopIllegal(string snippet)
282311 var property = ParseDeclaration ( snippet ) ;
283312 Assert . False ( ( ( BackgroundImageProperty ) property ) . HasValue ) ;
284313 }
314+
315+ [ Theory ]
316+ [ InlineData ( "background-image: conic-gradient(from red, blue, green)" ) ] // from needs an <angle>
317+ [ InlineData ( "background-image: conic-gradient(at, red, blue)" ) ] // at needs a <position>
318+ [ InlineData ( "background-image: conic-gradient(red 0px, blue 90px)" ) ] // conic stops use angles
319+ public void ConicGradientIllegal ( string source )
320+ {
321+ var property = ParseDeclaration ( source ) ;
322+ Assert . False ( ( ( BackgroundImageProperty ) property ) . HasValue ) ;
323+ }
324+
325+ [ Fact ]
326+ public void ConicGradientDoesNotDisturbLinearOrRadial ( )
327+ {
328+ Assert . True ( ( ( BackgroundImageProperty ) ParseDeclaration (
329+ "background-image: linear-gradient(90deg, red, blue 50%)" ) ) . HasValue ) ;
330+ Assert . True ( ( ( BackgroundImageProperty ) ParseDeclaration (
331+ "background-image: radial-gradient(circle at center, red, blue)" ) ) . HasValue ) ;
332+ }
285333 }
286334}
0 commit comments