2013-09-12 23:41:49 -05:00
|
|
|
/**
|
|
|
|
|
* @file
|
|
|
|
|
* @brief Unit tests for openshot::Timeline
|
|
|
|
|
* @author Jonathan Thomas <jonathan@openshot.org>
|
|
|
|
|
*
|
|
|
|
|
* @section LICENSE
|
|
|
|
|
*
|
2014-03-29 18:49:22 -05:00
|
|
|
* 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/>.
|
2013-09-12 23:41:49 -05:00
|
|
|
*
|
2014-03-29 18:49:22 -05:00
|
|
|
* OpenShot Library (libopenshot) is free software: you can redistribute it
|
2014-07-11 16:52:14 -05:00
|
|
|
* and/or modify it under the terms of the GNU Lesser General Public License
|
2014-03-29 18:49:22 -05:00
|
|
|
* as published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
* License, or (at your option) any later version.
|
2013-09-12 23:41:49 -05:00
|
|
|
*
|
2014-03-29 18:49:22 -05:00
|
|
|
* 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
|
2014-07-11 16:52:14 -05:00
|
|
|
* GNU Lesser General Public License for more details.
|
2013-09-12 23:41:49 -05:00
|
|
|
*
|
2014-07-11 16:52:14 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
2014-03-29 18:49:22 -05:00
|
|
|
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
|
2013-09-12 23:41:49 -05:00
|
|
|
*/
|
|
|
|
|
|
2012-10-05 01:58:27 -05:00
|
|
|
#include "UnitTest++.h"
|
|
|
|
|
#include "../include/OpenShot.h"
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
using namespace openshot;
|
|
|
|
|
|
|
|
|
|
TEST(Timeline_Constructor)
|
|
|
|
|
{
|
|
|
|
|
// Create a default fraction (should be 1/1)
|
2014-01-05 22:37:11 -06:00
|
|
|
Fraction fps(30000,1000);
|
2012-11-07 17:45:13 -06:00
|
|
|
Timeline t1(640, 480, fps, 44100, 2);
|
2012-10-05 01:58:27 -05:00
|
|
|
|
|
|
|
|
// Check values
|
2014-01-05 22:37:11 -06:00
|
|
|
CHECK_EQUAL(640, t1.info.width);
|
|
|
|
|
CHECK_EQUAL(480, t1.info.height);
|
2012-10-05 01:58:27 -05:00
|
|
|
|
|
|
|
|
// Create a default fraction (should be 1/1)
|
2012-11-07 17:45:13 -06:00
|
|
|
Timeline t2(300, 240, fps, 44100, 2);
|
2012-10-05 01:58:27 -05:00
|
|
|
|
|
|
|
|
// Check values
|
2014-01-05 22:37:11 -06:00
|
|
|
CHECK_EQUAL(300, t2.info.width);
|
|
|
|
|
CHECK_EQUAL(240, t2.info.height);
|
2012-10-05 01:58:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(Timeline_Width_and_Height_Functions)
|
|
|
|
|
{
|
|
|
|
|
// Create a default fraction (should be 1/1)
|
2014-01-05 22:37:11 -06:00
|
|
|
Fraction fps(30000,1000);
|
2012-11-07 17:45:13 -06:00
|
|
|
Timeline t1(640, 480, fps, 44100, 2);
|
2012-10-05 01:58:27 -05:00
|
|
|
|
|
|
|
|
// Check values
|
2014-01-05 22:37:11 -06:00
|
|
|
CHECK_EQUAL(640, t1.info.width);
|
|
|
|
|
CHECK_EQUAL(480, t1.info.height);
|
2012-10-05 01:58:27 -05:00
|
|
|
|
|
|
|
|
// Set width
|
2014-01-05 22:37:11 -06:00
|
|
|
t1.info.width = 600;
|
2012-10-05 01:58:27 -05:00
|
|
|
|
|
|
|
|
// Check values
|
2014-01-05 22:37:11 -06:00
|
|
|
CHECK_EQUAL(600, t1.info.width);
|
|
|
|
|
CHECK_EQUAL(480, t1.info.height);
|
2012-10-05 01:58:27 -05:00
|
|
|
|
|
|
|
|
// Set height
|
2014-01-05 22:37:11 -06:00
|
|
|
t1.info.height = 400;
|
2012-10-05 01:58:27 -05:00
|
|
|
|
|
|
|
|
// Check values
|
2014-01-05 22:37:11 -06:00
|
|
|
CHECK_EQUAL(600, t1.info.width);
|
|
|
|
|
CHECK_EQUAL(400, t1.info.height);
|
2012-10-05 01:58:27 -05:00
|
|
|
}
|
2012-10-10 01:07:47 -05:00
|
|
|
|
|
|
|
|
TEST(Timeline_Framerate)
|
|
|
|
|
{
|
|
|
|
|
// Create a default fraction (should be 1/1)
|
2014-01-05 22:37:11 -06:00
|
|
|
Fraction fps(24,1);
|
2012-11-07 17:45:13 -06:00
|
|
|
Timeline t1(640, 480, fps, 44100, 2);
|
2012-10-10 01:07:47 -05:00
|
|
|
|
|
|
|
|
// Check values
|
2014-01-05 22:37:11 -06:00
|
|
|
CHECK_CLOSE(24.0f, t1.info.fps.ToFloat(), 0.00001);
|
2012-10-10 01:07:47 -05:00
|
|
|
}
|
2014-04-03 22:47:21 -05:00
|
|
|
|
|
|
|
|
TEST(Timeline_Check_Two_Track_Video)
|
|
|
|
|
{
|
|
|
|
|
// Create a reader
|
|
|
|
|
Clip clip_video("../../src/examples/test.mp4");
|
|
|
|
|
clip_video.Layer(0);
|
|
|
|
|
|
|
|
|
|
Clip clip_overlay("../../src/examples/front3.png");
|
|
|
|
|
clip_overlay.Layer(1);
|
|
|
|
|
|
|
|
|
|
// Create a timeline
|
|
|
|
|
Timeline t(640, 480, Fraction(30, 1), 44100, 2);
|
|
|
|
|
|
|
|
|
|
// Add clips
|
|
|
|
|
t.AddClip(&clip_video);
|
|
|
|
|
t.AddClip(&clip_overlay);
|
|
|
|
|
|
|
|
|
|
// Open Timeline
|
|
|
|
|
t.Open();
|
|
|
|
|
|
|
|
|
|
// Get frame 1
|
|
|
|
|
tr1::shared_ptr<Frame> f = t.GetFrame(1);
|
|
|
|
|
|
|
|
|
|
// Get the image data
|
|
|
|
|
const Magick::PixelPacket* pixels = f->GetPixels(200);
|
|
|
|
|
|
|
|
|
|
// Check image properties on scanline 10, pixel 112
|
|
|
|
|
CHECK_EQUAL(34256, pixels[400].red);
|
|
|
|
|
CHECK_EQUAL(0, pixels[400].blue);
|
|
|
|
|
CHECK_EQUAL(57460, pixels[400].green);
|
|
|
|
|
CHECK_EQUAL(0, pixels[400].opacity);
|
|
|
|
|
|
|
|
|
|
// Get frame 1
|
|
|
|
|
f = t.GetFrame(2);
|
|
|
|
|
|
|
|
|
|
// Get the next frame
|
|
|
|
|
pixels = f->GetPixels(200);
|
|
|
|
|
|
|
|
|
|
// Check image properties on scanline 10, pixel 112
|
|
|
|
|
CHECK_EQUAL(63861, pixels[400].red);
|
|
|
|
|
CHECK_EQUAL(31871, pixels[400].blue);
|
|
|
|
|
CHECK_EQUAL(65151, pixels[400].green);
|
|
|
|
|
CHECK_EQUAL(0, pixels[400].opacity);
|
|
|
|
|
|
|
|
|
|
// Close reader
|
|
|
|
|
t.Close();
|
|
|
|
|
}
|