colors_svg_test.dart 1.6 KB

123456789101112131415161718192021222324252627282930313233
  1. import 'dart:ui' show Color;
  2. import 'package:flutter_svg/src/svg/colors.dart';
  3. import 'package:test/test.dart';
  4. void main() {
  5. const Color white = Color(0xFFFFFFFF);
  6. const Color black = Color(0xFF000000);
  7. test('Color Tests', () {
  8. expect(parseColor('#FFFFFF'), white);
  9. expect(parseColor('white'), white);
  10. expect(parseColor('rgb(255, 255, 255)'), white);
  11. expect(parseColor('rgb(100%, 100%, 100%)'), white);
  12. expect(parseColor('RGB( 100% , 100.0% , 99.9999% )'), white);
  13. expect(parseColor('rGb( .0%,0.0%,.0000001% )'), black);
  14. expect(parseColor('rgba(255,255, 255, 0.0)'), const Color(0x00FFFFFF));
  15. expect(parseColor('rgba(0,0, 0, 1.0)'), const Color(0xFF000000));
  16. expect(parseColor('#DDFFFFFF'), const Color(0xDDFFFFFF));
  17. expect(parseColor(''), null);
  18. expect(parseColor('transparent'), const Color(0x00FFFFFF));
  19. expect(parseColor('none'), null);
  20. expect(parseColor('hsl(0,0%,0%)'), const Color(0xFF000000));
  21. expect(parseColor('hsl(0,0%,100%)'), const Color(0xFFFFFFFF));
  22. expect(parseColor('hsl(136,47%,79%)'), const Color(0xFFB0E3BE));
  23. expect(parseColor('hsl(136,80%,9%)'), const Color(0xFF05290E));
  24. expect(parseColor('hsl(17,55%,29%)'), const Color(0xFF733821));
  25. expect(parseColor('hsl(78,55%,29%)'), const Color(0xFF5A7321));
  26. expect(parseColor('hsl(192,55%,29%)'), const Color(0xFF216273));
  27. expect(parseColor('hsl(297,55%,29%)'), const Color(0xFF6F2173));
  28. expect(parseColor('hsla(0,0%,100%, 0.0)'), const Color(0x00FFFFFF));
  29. expect(() => parseColor('invalid name'), throwsStateError);
  30. });
  31. }