def test_ISize(width, height, is_empty, is_zero, area): assert isinstance(skia.ISize(), skia.ISize) assert isinstance(skia.ISize(width, height), skia.ISize) assert isinstance(skia.ISize.Make(width, height), skia.ISize) size = skia.ISize.MakeEmpty() assert isinstance(size, skia.ISize) size.set(width, height) assert size.isEmpty() == is_empty assert size.isZero() == is_zero assert size.area() == area assert size.width() == width assert size.height() == height assert size.fWidth == width assert size.fHeight == height assert size.equals(width, height) assert not size.equals(width, height + 1) size.setEmpty() assert size.isEmpty()
def test_Size(width, height, is_empty, is_zero): assert isinstance(skia.Size(), skia.Size) assert isinstance(skia.Size(width, height), skia.Size) assert isinstance(skia.Size(skia.ISize()), skia.Size) assert isinstance(skia.Size.Make(width, height), skia.Size) assert isinstance(skia.Size.Make(skia.ISize.Make(int(width), int(height))), skia.Size) size = skia.Size.MakeEmpty() assert isinstance(size, skia.Size) size.set(width, height) assert size.isEmpty() == is_empty assert size.isZero() == is_zero assert size.width() == width assert size.height() == height assert size.equals(width, height) assert not size.equals(width, height + 1.) assert isinstance(size.toRound(), skia.ISize) assert isinstance(size.toCeil(), skia.ISize) assert isinstance(size.toFloor(), skia.ISize) assert size.fWidth == width assert size.fHeight == height size.setEmpty() assert size.isEmpty()
def test_ImageInfo_makeDimensions(imageinfo): check_imageinfo(imageinfo.makeDimensions(skia.ISize(100, 100)))
def test_ImageInfo_validRowBytes(imageinfo): assert imageinfo.validRowBytes(1280) def test_ImageInfo_reset(): imageinfo = skia.ImageInfo() imageinfo.reset() @pytest.mark.parametrize('args', [ (100, 100, skia.ColorType.kRGBA_8888_ColorType, skia.AlphaType.kPremul_AlphaType), (100, 100, skia.ColorType.kRGBA_8888_ColorType, skia.AlphaType.kPremul_AlphaType, skia.ColorSpace.MakeSRGBLinear()), (skia.ISize(100, 100), skia.ColorType.kRGBA_8888_ColorType, skia.AlphaType.kPremul_AlphaType), (skia.ISize(100, 100), skia.ColorInfo()), ]) def test_ImageInfo_Make(args): check_imageinfo(skia.ImageInfo.Make(*args)) @pytest.mark.parametrize('args', [ (100, 100, skia.AlphaType.kPremul_AlphaType), ]) def test_ImageInfo_MakeN32(args): check_imageinfo(skia.ImageInfo.MakeN32(*args)) def test_ImageInfo_MakeS32():
def isize(): return skia.ISize(100, 100)
def test_ISize_init(args): assert isinstance(skia.ISize(*args), skia.ISize)
def test_ISize_len(isize): assert len(isize) == 2 def test_ISize_repr(isize): assert repr(isize) == 'ISize(100, 100)' @pytest.mark.parametrize('args', [ tuple(), ( 1, 1, ), (skia.ISize(1, 0), ), (( 1, 1, ), ), ]) def test_Size_init(args): assert isinstance(skia.Size(*args), skia.Size) @pytest.mark.parametrize('args', [ (skia.ISize(1, 1), ), (1, 1), ]) def test_Size_Make(args): assert isinstance(skia.Size.Make(*args), skia.Size)
def test_IRect_MakeSize(): assert isinstance(skia.IRect.MakeSize(skia.ISize()), skia.IRect)
def test_IRect_ne(irect): assert irect != skia.IRect() @pytest.fixture() def rect(): return skia.Rect(0, 0, 240, 120) @pytest.mark.parametrize('args', [ tuple(), (240, 120), (0, 0, 240, 120), (skia.IRect(), ), (skia.ISize(), ), (tuple(), ), ((240, 120), ), ((0, 0, 240, 120), ), ]) def test_Rect_init(args): assert isinstance(skia.Rect(*args), skia.Rect) def test_Rect_iter(rect): assert tuple(rect) == (0, 0, 240, 120) def test_Rect_len(rect): assert len(rect) == 4
def test_ImageFilters_MatrixConvolution(): assert isinstance(skia.ImageFilters.MatrixConvolution( skia.ISize(5, 5), [1. for i in range(25)], 1. / 25., 0, skia.IPoint(2, 2), skia.TileMode.kClamp, False), skia.ImageFilter)