Commit 185ae52b authored by Nicolas Carion's avatar Nicolas Carion

[Timeline2][Model][Testing] Added basic testing capability

parent bdca5621
......@@ -119,6 +119,7 @@ endif()
ecm_optional_add_subdirectory(po)
add_subdirectory(renderer)
add_subdirectory(src)
add_subdirectory(tests)
add_subdirectory(thumbnailer)
#add_subdirectory(testingArea)
......
......@@ -33,11 +33,19 @@ TimelineModel::TimelineModel() :
}
int TimelineModel::getTrackNumber()
{
int count = m_tractor.count();
Q_ASSERT(count >= 0);
Q_ASSERT(count == static_cast<int>(m_allTracks.size()));
return count;
}
void TimelineModel::registerTrack(std::unique_ptr<TrackModel>&& track, int pos)
{
int id = track->getId();
if (pos == -1) {
pos = m_allTracks.size();
pos = static_cast<int>(m_allTracks.size());
}
//effective insertion (MLT operation)
int error = m_tractor.insert_track(*track ,pos);
......@@ -57,7 +65,7 @@ void TimelineModel::deregisterTrack(int id)
{
auto it = m_iteratorTable[id]; //iterator to the element
m_iteratorTable.erase(id);
int index = std::distance(m_allTracks.begin(), it);
m_tractor.remove_track(index);
auto index = std::distance(m_allTracks.begin(), it);
m_tractor.remove_track(static_cast<int>(index));
m_allTracks.erase(it);
}
......@@ -31,9 +31,13 @@ class TrackModel;
*/
class TimelineModel
{
public:
TimelineModel();
friend class TrackModel;
/* @brief returns the number of tracks */
int getTrackNumber();
protected:
/* @brief Register a new track. This is a call-back meant to be called from TrackModel
@param pos indicates the number of the track we are adding. If this is -1, then we add at the end.
......
############################
# Tests
############################
set(QT_MIN_VERSION 5.5.0)
find_package(Qt5Core)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -fexceptions")
SET(Tests_SRCS
TestMain.cpp
trackmodeltest.cpp
../src/timeline2/model/trackmodel.cpp
../src/timeline2/model/timelinemodel.cpp
)
INCLUDE_DIRECTORIES(../src/)
include_directories(
${CMAKE_BINARY_DIR}
${MLT_INCLUDE_DIR}
${MLTPP_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/lib/external
${CMAKE_CURRENT_SOURCE_DIR}/lib
)
ADD_EXECUTABLE(runTests ${Tests_SRCS})
target_link_libraries(runTests Qt5::Core)
target_link_libraries(runTests
${MLT_LIBRARIES}
${MLTPP_LIBRARIES}
${CMAKE_DL_LIBS}
${CMAKE_THREAD_LIBS_INIT}
)
ADD_TEST(runTests runTests -d yes)
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
/* This file is intended to remain empty.
Write your tests in a file with a name corresponding to what you're testing */
This diff is collapsed.
#include "catch.hpp"
#include <memory>
#define private public
#include "timeline2/model/trackmodel.hpp"
#include "timeline2/model/timelinemodel.hpp"
#include "timeline2/model/clipmodel.hpp"
TEST_CASE("Basic creation of a track", "[TrackModel]")
{
std::shared_ptr<TimelineModel> timeline = std::make_shared<TimelineModel>();
TrackModel::construct(timeline);
REQUIRE(timeline->getTrackNumber() == 1);
TrackModel::construct(timeline);
REQUIRE(timeline->getTrackNumber() == 2);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment