Files
oak-editor/tests/gtest/timeline_coordinate_test.cpp
T
Mike-Solar f03b6b58ff style: reformat C/C++ sources and headers with clang-format
Run clang-format over all project C/C++ source and header files
(.c, .cpp, .cc, .h, .hpp, .hh, .m, .mm) under app/ and tests/.
Non-source files (svg, qm, qrc, etc.) were not touched.
2026-07-13 15:34:11 +08:00

72 lines
2.1 KiB
C++

#include <gtest/gtest.h>
#include "timeline/timelinecoordinate.h"
TEST(TimelineCoordinate, DefaultAndSetters)
{
olive::TimelineCoordinate coord;
EXPECT_EQ(coord.GetTrack().type(), olive::Track::kNone);
EXPECT_EQ(coord.GetTrack().index(), 0);
const olive::core::rational frame(10, 1);
olive::Track::Reference ref(olive::Track::kVideo, 2);
coord.SetFrame(frame);
coord.SetTrack(ref);
EXPECT_EQ(coord.GetFrame(), frame);
EXPECT_EQ(coord.GetTrack(), ref);
}
TEST(TimelineCoordinate, Constructors)
{
const olive::core::rational frame(5, 1);
olive::Track::Reference ref(olive::Track::kAudio, 1);
olive::TimelineCoordinate with_ref(frame, ref);
EXPECT_EQ(with_ref.GetFrame(), frame);
EXPECT_EQ(with_ref.GetTrack(), ref);
olive::TimelineCoordinate with_type(frame, olive::Track::kSubtitle, 3);
EXPECT_EQ(with_type.GetFrame(), frame);
EXPECT_EQ(with_type.GetTrack().type(), olive::Track::kSubtitle);
EXPECT_EQ(with_type.GetTrack().index(), 3);
}
TEST(TimelineCoordinate, CopyAndAssignment)
{
const olive::core::rational frame(7, 1);
olive::Track::Reference ref(olive::Track::kVideo, 4);
olive::TimelineCoordinate original(frame, ref);
olive::TimelineCoordinate copy(original);
EXPECT_EQ(copy.GetFrame(), frame);
EXPECT_EQ(copy.GetTrack(), ref);
olive::TimelineCoordinate assigned;
assigned = original;
EXPECT_EQ(assigned.GetFrame(), frame);
EXPECT_EQ(assigned.GetTrack(), ref);
}
TEST(TimelineCoordinate, Equality)
{
olive::TimelineCoordinate a(olive::core::rational(5, 1),
olive::Track::Reference(olive::Track::kVideo,
1));
olive::TimelineCoordinate b(olive::core::rational(5, 1),
olive::Track::Reference(olive::Track::kVideo,
1));
olive::TimelineCoordinate c(olive::core::rational(6, 1),
olive::Track::Reference(olive::Track::kVideo,
1));
olive::TimelineCoordinate d(olive::core::rational(5, 1),
olive::Track::Reference(olive::Track::kAudio,
1));
EXPECT_EQ(a.GetFrame(), b.GetFrame());
EXPECT_EQ(a.GetTrack(), b.GetTrack());
EXPECT_NE(a.GetFrame(), c.GetFrame());
EXPECT_NE(a.GetTrack(), d.GetTrack());
}