tests/ImageWriter: Increase coverage

This commit is contained in:
FeRD (Frank Dana)
2021-11-03 06:57:14 -04:00
parent 1c5e9dbe38
commit cff2109316

View File

@@ -25,6 +25,26 @@
using namespace openshot;
TEST_CASE( "conversions", "[libopenshot][imagewriter]" )
{
auto magick1 = openshot::QImage2Magick(nullptr);
CHECK_FALSE(magick1);
auto qimage1 = openshot::Magick2QImage(nullptr);
CHECK_FALSE(qimage1);
std::stringstream path_overlay;
path_overlay << TEST_MEDIA_PATH << "front3.png";
openshot::Clip overlay(path_overlay.str());
overlay.Open();
auto frame = overlay.Reader()->GetFrame(1);
auto qimage = frame->GetImage();
auto magick = openshot::QImage2Magick(qimage);
auto qimage_out = openshot::Magick2QImage(magick);
CHECK(qimage->pixelColor(100, 100) == qimage_out->pixelColor(100, 100));
}
TEST_CASE( "Gif", "[libopenshot][imagewriter]" )
{
// Reader ---------------
@@ -49,16 +69,18 @@ TEST_CASE( "Gif", "[libopenshot][imagewriter]" )
CHECK_FALSE(w.IsOpen());
// Check for exception on write-before-open
CHECK_THROWS_AS(w.WriteFrame(&r, 500, 504), WriterClosed);
CHECK_THROWS_AS(w.WriteFrame(&r, 500, 509), WriterClosed);
// Set the image output settings (format, fps, width, height, quality, loops, combine)
w.SetVideoOptions("GIF", r.info.fps, r.info.width, r.info.height, 70, 1, true);
// Set the image output settings
// (format, fps, width, height, quality, loops, combine)
// loops=0 == infinite looping
w.SetVideoOptions("GIF", r.info.fps, r.info.width, r.info.height, 70, 0, true);
// Open writer
w.Open();
// Write some frames (start on frame 500 and go to frame 510)
w.WriteFrame(&r, 500, 504);
// Write some frames
w.WriteFrame(&r, 500, 509);
// Close writer & reader
w.Close();