You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Added many new unit tests, including Color tests and ImageWriter tests.
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief Unit tests for openshot::Color
|
||||
* @author Jonathan Thomas <jonathan@openshot.org>
|
||||
*
|
||||
* @section LICENSE
|
||||
*
|
||||
* Copyright (c) 2008-2014 OpenShot Studios, LLC
|
||||
* <http://www.openshotstudios.com/>. This file is part of
|
||||
* OpenShot Library (libopenshot), an open-source project dedicated to
|
||||
* delivering high quality video editing and animation solutions to the
|
||||
* world. For more information visit <http://www.openshot.org/>.
|
||||
*
|
||||
* OpenShot Library (libopenshot) is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* OpenShot Library (libopenshot) is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "UnitTest++.h"
|
||||
#include "../include/OpenShot.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace openshot;
|
||||
|
||||
TEST(Color_Default_Constructor)
|
||||
{
|
||||
// Create an empty color
|
||||
Color c1;
|
||||
|
||||
CHECK_CLOSE(0.0f, c1.red.GetValue(0), 0.00001);
|
||||
CHECK_CLOSE(0.0f, c1.green.GetValue(0), 0.00001);
|
||||
CHECK_CLOSE(0.0f, c1.blue.GetValue(0), 0.00001);
|
||||
}
|
||||
|
||||
TEST(Color_Animate_Colors)
|
||||
{
|
||||
// Create an empty color
|
||||
Color c1;
|
||||
|
||||
// Set starting color (on frame 0)
|
||||
c1.red.AddPoint(0, 12000);
|
||||
c1.green.AddPoint(0, 5000);
|
||||
c1.blue.AddPoint(0, 1000);
|
||||
|
||||
// Set ending color (on frame 1000)
|
||||
c1.red.AddPoint(1000, 32000);
|
||||
c1.green.AddPoint(1000, 12000);
|
||||
c1.blue.AddPoint(1000, 5000);
|
||||
|
||||
// Check the color at frame 500
|
||||
CHECK_CLOSE(22011, c1.red.GetInt(500), 0.01);
|
||||
CHECK_CLOSE(8504, c1.green.GetInt(500), 0.01);
|
||||
CHECK_CLOSE(3002, c1.blue.GetInt(500), 0.01);
|
||||
}
|
||||
@@ -41,20 +41,15 @@ TEST(FFmpegWriter_Test_Webm)
|
||||
FFmpegWriter w("output1.webm");
|
||||
|
||||
// Set options
|
||||
w.SetAudioOptions(true, "libvorbis", 44100, 2, 188000);
|
||||
w.SetAudioOptions(true, "libvorbis", 44100, 2, LAYOUT_STEREO, 188000);
|
||||
w.SetVideoOptions(true, "libvpx", Fraction(24,1), 1280, 720, Fraction(1,1), false, false, 30000000);
|
||||
|
||||
// Prepare Streams
|
||||
w.PrepareStreams();
|
||||
|
||||
// Write header
|
||||
w.WriteHeader();
|
||||
// Open writer
|
||||
w.Open();
|
||||
|
||||
// Write some frames
|
||||
w.WriteFrame(&r, 24, 50);
|
||||
|
||||
// Write Footer
|
||||
w.WriteTrailer();
|
||||
|
||||
// Close writer & reader
|
||||
w.Close();
|
||||
r.Close();
|
||||
@@ -67,10 +62,10 @@ TEST(FFmpegWriter_Test_Webm)
|
||||
CHECK_EQUAL(24, r1.info.fps.num);
|
||||
CHECK_EQUAL(1, r1.info.fps.den);
|
||||
|
||||
// Check frame 20
|
||||
// Get a specific frame
|
||||
tr1::shared_ptr<Frame> f = r1.GetFrame(8);
|
||||
|
||||
// Get the image data for row 50
|
||||
// Get the image data for row 500
|
||||
const Magick::PixelPacket* pixels = f->GetPixels(500);
|
||||
|
||||
// Check pixel values on scanline 500, pixel 600
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief Unit tests for openshot::ImageWriter
|
||||
* @author Jonathan Thomas <jonathan@openshot.org>
|
||||
*
|
||||
* @section LICENSE
|
||||
*
|
||||
* Copyright (c) 2008-2014 OpenShot Studios, LLC
|
||||
* <http://www.openshotstudios.com/>. This file is part of
|
||||
* OpenShot Library (libopenshot), an open-source project dedicated to
|
||||
* delivering high quality video editing and animation solutions to the
|
||||
* world. For more information visit <http://www.openshot.org/>.
|
||||
*
|
||||
* OpenShot Library (libopenshot) is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* OpenShot Library (libopenshot) is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "UnitTest++.h"
|
||||
#include "../include/OpenShot.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace openshot;
|
||||
|
||||
TEST(ImageWriter_Test_Webm)
|
||||
{
|
||||
// Reader
|
||||
FFmpegReader r("../../src/examples/sintel_trailer-720p.mp4");
|
||||
r.Open();
|
||||
|
||||
/* WRITER ---------------- */
|
||||
ImageWriter w("output1.gif");
|
||||
|
||||
// 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);
|
||||
|
||||
// Open writer
|
||||
w.Open();
|
||||
|
||||
// Write some frames (start on frame 500 and go to frame 510)
|
||||
w.WriteFrame(&r, 500, 510);
|
||||
|
||||
// Close writer & reader
|
||||
w.Close();
|
||||
r.Close();
|
||||
|
||||
// Open up the 5th frame from the newly created GIF
|
||||
ImageReader r1("output1.gif[5]");
|
||||
r1.Open();
|
||||
|
||||
// Verify various settings
|
||||
CHECK_EQUAL(r.info.width, r1.info.width);
|
||||
CHECK_EQUAL(r.info.height, r1.info.height);
|
||||
|
||||
// Get a specific frame
|
||||
tr1::shared_ptr<Frame> f = r1.GetFrame(8);
|
||||
|
||||
// Get the image data for row 500
|
||||
const Magick::PixelPacket* pixels = f->GetPixels(500);
|
||||
|
||||
// Check pixel values on scanline 500, pixel 600
|
||||
CHECK_EQUAL(4883, pixels[600].red);
|
||||
CHECK_EQUAL(2570, pixels[600].blue);
|
||||
CHECK_EQUAL(3341, pixels[600].green);
|
||||
CHECK_EQUAL(0, pixels[600].opacity);
|
||||
}
|
||||
@@ -39,7 +39,7 @@ TEST(ReaderBase_Derived_Class)
|
||||
class TestReader : public ReaderBase
|
||||
{
|
||||
public:
|
||||
TestReader() { InitFileInfo(); };
|
||||
TestReader() { };
|
||||
tr1::shared_ptr<Frame> GetFrame(int number) { tr1::shared_ptr<Frame> f(new Frame()); return f; }
|
||||
void Close() { };
|
||||
void Open() { };
|
||||
|
||||
Reference in New Issue
Block a user