|
@@ -49,14 +49,10 @@ func (s *ProcessingTestSuite) openFile(name string) imagedata.ImageData {
|
|
|
return imagedata
|
|
|
}
|
|
|
|
|
|
-func (s *ProcessingTestSuite) checkSize(imgdata imagedata.ImageData, width, height int) {
|
|
|
- img := new(vips.Image)
|
|
|
- err := img.Load(imgdata, 1, 1, 1)
|
|
|
- s.Require().NoError(err)
|
|
|
- defer img.Clear()
|
|
|
-
|
|
|
- s.Require().Equal(width, img.Width(), "Width mismatch")
|
|
|
- s.Require().Equal(height, img.Height(), "Height mismatch")
|
|
|
+func (s *ProcessingTestSuite) checkSize(r *Result, width, height int) {
|
|
|
+ s.Require().NotNil(r)
|
|
|
+ s.Require().Equal(width, r.ResultWidth, "Width mismatch")
|
|
|
+ s.Require().Equal(height, r.ResultHeight, "Height mismatch")
|
|
|
}
|
|
|
|
|
|
func (s *ProcessingTestSuite) TestResizeToFit() {
|
|
@@ -88,11 +84,11 @@ func (s *ProcessingTestSuite) TestResizeToFit() {
|
|
|
po.Width = tc.width
|
|
|
po.Height = tc.height
|
|
|
|
|
|
- outImgdata, err := ProcessImage(context.Background(), imgdata, po)
|
|
|
+ result, err := ProcessImage(context.Background(), imgdata, po)
|
|
|
s.Require().NoError(err)
|
|
|
- s.Require().NotNil(outImgdata)
|
|
|
+ s.Require().NotNil(result)
|
|
|
|
|
|
- s.checkSize(outImgdata, tc.outWidth, tc.outHeight)
|
|
|
+ s.checkSize(result, tc.outWidth, tc.outHeight)
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -127,11 +123,11 @@ func (s *ProcessingTestSuite) TestResizeToFitEnlarge() {
|
|
|
po.Width = tc.width
|
|
|
po.Height = tc.height
|
|
|
|
|
|
- outImgdata, err := ProcessImage(context.Background(), imgdata, po)
|
|
|
+ result, err := ProcessImage(context.Background(), imgdata, po)
|
|
|
s.Require().NoError(err)
|
|
|
- s.Require().NotNil(outImgdata)
|
|
|
+ s.Require().NotNil(result)
|
|
|
|
|
|
- s.checkSize(outImgdata, tc.outWidth, tc.outHeight)
|
|
|
+ s.checkSize(result, tc.outWidth, tc.outHeight)
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -171,11 +167,11 @@ func (s *ProcessingTestSuite) TestResizeToFitExtend() {
|
|
|
po.Width = tc.width
|
|
|
po.Height = tc.height
|
|
|
|
|
|
- outImgdata, err := ProcessImage(context.Background(), imgdata, po)
|
|
|
+ result, err := ProcessImage(context.Background(), imgdata, po)
|
|
|
s.Require().NoError(err)
|
|
|
- s.Require().NotNil(outImgdata)
|
|
|
+ s.Require().NotNil(result)
|
|
|
|
|
|
- s.checkSize(outImgdata, tc.outWidth, tc.outHeight)
|
|
|
+ s.checkSize(result, tc.outWidth, tc.outHeight)
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -215,11 +211,11 @@ func (s *ProcessingTestSuite) TestResizeToFitExtendAR() {
|
|
|
po.Width = tc.width
|
|
|
po.Height = tc.height
|
|
|
|
|
|
- outImgdata, err := ProcessImage(context.Background(), imgdata, po)
|
|
|
+ result, err := ProcessImage(context.Background(), imgdata, po)
|
|
|
s.Require().NoError(err)
|
|
|
- s.Require().NotNil(outImgdata)
|
|
|
+ s.Require().NotNil(result)
|
|
|
|
|
|
- s.checkSize(outImgdata, tc.outWidth, tc.outHeight)
|
|
|
+ s.checkSize(result, tc.outWidth, tc.outHeight)
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -253,11 +249,11 @@ func (s *ProcessingTestSuite) TestResizeToFill() {
|
|
|
po.Width = tc.width
|
|
|
po.Height = tc.height
|
|
|
|
|
|
- outImgdata, err := ProcessImage(context.Background(), imgdata, po)
|
|
|
+ result, err := ProcessImage(context.Background(), imgdata, po)
|
|
|
s.Require().NoError(err)
|
|
|
- s.Require().NotNil(outImgdata)
|
|
|
+ s.Require().NotNil(result)
|
|
|
|
|
|
- s.checkSize(outImgdata, tc.outWidth, tc.outHeight)
|
|
|
+ s.checkSize(result, tc.outWidth, tc.outHeight)
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -292,11 +288,11 @@ func (s *ProcessingTestSuite) TestResizeToFillEnlarge() {
|
|
|
po.Width = tc.width
|
|
|
po.Height = tc.height
|
|
|
|
|
|
- outImgdata, err := ProcessImage(context.Background(), imgdata, po)
|
|
|
+ result, err := ProcessImage(context.Background(), imgdata, po)
|
|
|
s.Require().NoError(err)
|
|
|
- s.Require().NotNil(outImgdata)
|
|
|
+ s.Require().NotNil(result)
|
|
|
|
|
|
- s.checkSize(outImgdata, tc.outWidth, tc.outHeight)
|
|
|
+ s.checkSize(result, tc.outWidth, tc.outHeight)
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -338,11 +334,11 @@ func (s *ProcessingTestSuite) TestResizeToFillExtend() {
|
|
|
po.Width = tc.width
|
|
|
po.Height = tc.height
|
|
|
|
|
|
- outImgdata, err := ProcessImage(context.Background(), imgdata, po)
|
|
|
+ result, err := ProcessImage(context.Background(), imgdata, po)
|
|
|
s.Require().NoError(err)
|
|
|
- s.Require().NotNil(outImgdata)
|
|
|
+ s.Require().NotNil(result)
|
|
|
|
|
|
- s.checkSize(outImgdata, tc.outWidth, tc.outHeight)
|
|
|
+ s.checkSize(result, tc.outWidth, tc.outHeight)
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -384,11 +380,11 @@ func (s *ProcessingTestSuite) TestResizeToFillExtendAR() {
|
|
|
po.Width = tc.width
|
|
|
po.Height = tc.height
|
|
|
|
|
|
- outImgdata, err := ProcessImage(context.Background(), imgdata, po)
|
|
|
+ result, err := ProcessImage(context.Background(), imgdata, po)
|
|
|
s.Require().NoError(err)
|
|
|
- s.Require().NotNil(outImgdata)
|
|
|
+ s.Require().NotNil(result)
|
|
|
|
|
|
- s.checkSize(outImgdata, tc.outWidth, tc.outHeight)
|
|
|
+ s.checkSize(result, tc.outWidth, tc.outHeight)
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -422,11 +418,11 @@ func (s *ProcessingTestSuite) TestResizeToFillDown() {
|
|
|
po.Width = tc.width
|
|
|
po.Height = tc.height
|
|
|
|
|
|
- outImgdata, err := ProcessImage(context.Background(), imgdata, po)
|
|
|
+ result, err := ProcessImage(context.Background(), imgdata, po)
|
|
|
s.Require().NoError(err)
|
|
|
- s.Require().NotNil(outImgdata)
|
|
|
+ s.Require().NotNil(result)
|
|
|
|
|
|
- s.checkSize(outImgdata, tc.outWidth, tc.outHeight)
|
|
|
+ s.checkSize(result, tc.outWidth, tc.outHeight)
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -461,11 +457,11 @@ func (s *ProcessingTestSuite) TestResizeToFillDownEnlarge() {
|
|
|
po.Width = tc.width
|
|
|
po.Height = tc.height
|
|
|
|
|
|
- outImgdata, err := ProcessImage(context.Background(), imgdata, po)
|
|
|
+ result, err := ProcessImage(context.Background(), imgdata, po)
|
|
|
s.Require().NoError(err)
|
|
|
- s.Require().NotNil(outImgdata)
|
|
|
+ s.Require().NotNil(result)
|
|
|
|
|
|
- s.checkSize(outImgdata, tc.outWidth, tc.outHeight)
|
|
|
+ s.checkSize(result, tc.outWidth, tc.outHeight)
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -507,11 +503,11 @@ func (s *ProcessingTestSuite) TestResizeToFillDownExtend() {
|
|
|
po.Width = tc.width
|
|
|
po.Height = tc.height
|
|
|
|
|
|
- outImgdata, err := ProcessImage(context.Background(), imgdata, po)
|
|
|
+ result, err := ProcessImage(context.Background(), imgdata, po)
|
|
|
s.Require().NoError(err)
|
|
|
- s.Require().NotNil(outImgdata)
|
|
|
+ s.Require().NotNil(result)
|
|
|
|
|
|
- s.checkSize(outImgdata, tc.outWidth, tc.outHeight)
|
|
|
+ s.checkSize(result, tc.outWidth, tc.outHeight)
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -551,11 +547,11 @@ func (s *ProcessingTestSuite) TestResizeToFillDownExtendAR() {
|
|
|
po.Width = tc.width
|
|
|
po.Height = tc.height
|
|
|
|
|
|
- outImgdata, err := ProcessImage(context.Background(), imgdata, po)
|
|
|
+ result, err := ProcessImage(context.Background(), imgdata, po)
|
|
|
s.Require().NoError(err)
|
|
|
- s.Require().NotNil(outImgdata)
|
|
|
+ s.Require().NotNil(result)
|
|
|
|
|
|
- s.checkSize(outImgdata, tc.outWidth, tc.outHeight)
|
|
|
+ s.checkSize(result, tc.outWidth, tc.outHeight)
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -980,11 +976,12 @@ func (s *ProcessingTestSuite) TestResultSizeLimit() {
|
|
|
po.Rotate = tc.rotate
|
|
|
po.Padding = tc.padding
|
|
|
|
|
|
- outImgdata, err := ProcessImage(context.Background(), imgdata, po)
|
|
|
+ result, err := ProcessImage(context.Background(), imgdata, po)
|
|
|
+
|
|
|
s.Require().NoError(err)
|
|
|
- s.Require().NotNil(outImgdata)
|
|
|
+ s.Require().NotNil(result)
|
|
|
|
|
|
- s.checkSize(outImgdata, tc.outWidth, tc.outHeight)
|
|
|
+ s.checkSize(result, tc.outWidth, tc.outHeight)
|
|
|
})
|
|
|
}
|
|
|
}
|