Files
libopenshot/tests/Timeline_Tests.cpp

86 lines
2.2 KiB
C++

/**
* @file
* @brief Unit tests for openshot::Timeline
* @author Jonathan Thomas <jonathan@openshot.org>
*
* @section LICENSE
*
* Copyright (c) 2008-2013 OpenShot Studios, LLC
* (http://www.openshotstudios.com). This file is part of
* OpenShot Library (http://www.openshot.org), an open-source project
* dedicated to delivering high quality video editing and animation solutions
* to the world.
*
* OpenShot Library is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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 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 General Public License for more details.
*
* You should have received a copy of the GNU 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(Timeline_Constructor)
{
// Create a default fraction (should be 1/1)
Fraction fps(30000,1000);
Timeline t1(640, 480, fps, 44100, 2);
// Check values
CHECK_EQUAL(640, t1.info.width);
CHECK_EQUAL(480, t1.info.height);
// Create a default fraction (should be 1/1)
Timeline t2(300, 240, fps, 44100, 2);
// Check values
CHECK_EQUAL(300, t2.info.width);
CHECK_EQUAL(240, t2.info.height);
}
TEST(Timeline_Width_and_Height_Functions)
{
// Create a default fraction (should be 1/1)
Fraction fps(30000,1000);
Timeline t1(640, 480, fps, 44100, 2);
// Check values
CHECK_EQUAL(640, t1.info.width);
CHECK_EQUAL(480, t1.info.height);
// Set width
t1.info.width = 600;
// Check values
CHECK_EQUAL(600, t1.info.width);
CHECK_EQUAL(480, t1.info.height);
// Set height
t1.info.height = 400;
// Check values
CHECK_EQUAL(600, t1.info.width);
CHECK_EQUAL(400, t1.info.height);
}
TEST(Timeline_Framerate)
{
// Create a default fraction (should be 1/1)
Fraction fps(24,1);
Timeline t1(640, 480, fps, 44100, 2);
// Check values
CHECK_CLOSE(24.0f, t1.info.fps.ToFloat(), 0.00001);
}