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.
This commit is contained in:
2026-07-13 15:34:11 +08:00
parent 6a696bc234
commit f03b6b58ff
61 changed files with 2873 additions and 2740 deletions
+2 -1
View File
@@ -11,7 +11,8 @@ extern "C" {
#include <libavutil/channel_layout.h>
}
namespace {
namespace
{
olive::core::AudioParams MakeStereoParams()
{
+14 -7
View File
@@ -33,9 +33,12 @@ extern "C" {
using namespace olive;
using namespace olive::core;
namespace olive {
namespace audio {
namespace test {
namespace olive
{
namespace audio
{
namespace test
{
// ============================================================================
// Helper Functions
@@ -109,7 +112,8 @@ TEST(AudioSmokeParams, TimeConversions)
EXPECT_EQ(params.time_to_samples(2.0), 96000);
// Samples to bytes
EXPECT_EQ(params.samples_to_bytes(48000), 48000 * 2 * 4); // samples * channels * bytes_per_sample
EXPECT_EQ(params.samples_to_bytes(48000),
48000 * 2 * 4); // samples * channels * bytes_per_sample
// Time to bytes
EXPECT_EQ(params.time_to_bytes(1.0), 48000 * 2 * 4);
@@ -636,7 +640,8 @@ TEST(AudioSmokePreviewDevice, Construction)
{
PreviewAudioDevice device;
EXPECT_TRUE(device.isSequential());
EXPECT_EQ(device.bytes_per_frame(), 0); // BUG: Should be initialized properly
EXPECT_EQ(device.bytes_per_frame(),
0); // BUG: Should be initialized properly
}
TEST(AudioSmokePreviewDevice, BytesPerFrame)
@@ -807,12 +812,14 @@ TEST(AudioSmokeThread, ConcurrentSampleBufferOperations)
break;
case 2: {
auto ripped = buffer.rip_channel(0);
if (ripped.channel_count() == 1) success_count++;
if (ripped.channel_count() == 1)
success_count++;
break;
}
case 3: {
auto ptrs = buffer.to_raw_ptrs();
if (!ptrs.empty()) success_count++;
if (!ptrs.empty())
success_count++;
break;
}
}
+6 -6
View File
@@ -13,8 +13,8 @@ TEST(AudioSynchronizer, PlacesCandidateBySourceStartTime)
candidate.has_source_start_time = true;
const olive::AudioSynchronizer::Placement placement =
olive::AudioSynchronizer::PlaceBySourceTime(
reference, candidate, olive::core::rational(10));
olive::AudioSynchronizer::PlaceBySourceTime(reference, candidate,
olive::core::rational(10));
ASSERT_TRUE(placement.valid);
EXPECT_EQ(placement.timeline_in, olive::core::rational(22));
@@ -33,8 +33,8 @@ TEST(AudioSynchronizer, AccountsForMediaInWhenPlacingBySourceTime)
candidate.has_source_start_time = true;
const olive::AudioSynchronizer::Placement placement =
olive::AudioSynchronizer::PlaceBySourceTime(
reference, candidate, olive::core::rational(20));
olive::AudioSynchronizer::PlaceBySourceTime(reference, candidate,
olive::core::rational(20));
ASSERT_TRUE(placement.valid);
EXPECT_EQ(placement.timeline_in, olive::core::rational(23));
@@ -49,8 +49,8 @@ TEST(AudioSynchronizer, RejectsMissingSourceStartTime)
olive::AudioSynchronizer::SourceClip candidate;
const olive::AudioSynchronizer::Placement placement =
olive::AudioSynchronizer::PlaceBySourceTime(
reference, candidate, olive::core::rational(10));
olive::AudioSynchronizer::PlaceBySourceTime(reference, candidate,
olive::core::rational(10));
EXPECT_FALSE(placement.valid);
}
+12 -15
View File
@@ -9,7 +9,8 @@ extern "C" {
#include <libavutil/channel_layout.h>
}
namespace {
namespace
{
olive::core::AudioParams MakeMonoParams()
{
@@ -46,13 +47,11 @@ TEST(AudioWaveformSync, ExtractsRmsEnvelope)
TEST(AudioWaveformSync, EstimatesCandidateLag)
{
const QVector<float> reference_values = {
0.0f, 0.0f, 0.8f, 0.8f, 0.1f, 0.1f, 0.6f, 0.6f, 0.0f, 0.0f
};
const QVector<float> candidate_values = {
0.0f, 0.0f, 0.0f, 0.0f, 0.8f, 0.8f, 0.1f,
0.1f, 0.6f, 0.6f, 0.0f, 0.0f
};
const QVector<float> reference_values = { 0.0f, 0.0f, 0.8f, 0.8f, 0.1f,
0.1f, 0.6f, 0.6f, 0.0f, 0.0f };
const QVector<float> candidate_values = { 0.0f, 0.0f, 0.0f, 0.0f,
0.8f, 0.8f, 0.1f, 0.1f,
0.6f, 0.6f, 0.0f, 0.0f };
const olive::AudioWaveformSync::OffsetResult result =
olive::AudioWaveformSync::EstimateOffset(
@@ -65,13 +64,11 @@ TEST(AudioWaveformSync, EstimatesCandidateLag)
TEST(AudioWaveformSync, EstimatesCandidateLead)
{
const QVector<float> reference_values = {
0.0f, 0.0f, 0.0f, 0.0f, 0.9f, 0.9f, 0.3f,
0.3f, 0.7f, 0.7f, 0.0f, 0.0f
};
const QVector<float> candidate_values = {
0.9f, 0.9f, 0.3f, 0.3f, 0.7f, 0.7f, 0.0f, 0.0f
};
const QVector<float> reference_values = { 0.0f, 0.0f, 0.0f, 0.0f,
0.9f, 0.9f, 0.3f, 0.3f,
0.7f, 0.7f, 0.0f, 0.0f };
const QVector<float> candidate_values = { 0.9f, 0.9f, 0.3f, 0.3f,
0.7f, 0.7f, 0.0f, 0.0f };
const olive::AudioWaveformSync::OffsetResult result =
olive::AudioWaveformSync::EstimateOffset(
+2 -1
View File
@@ -11,7 +11,8 @@ TEST(CodecDecoder, RetrieveVideoFrameFromDemoMp4)
.filePath(QStringLiteral("tests/demo.mp4"));
ASSERT_TRUE(QFileInfo::exists(path));
olive::DecoderPtr decoder = olive::Decoder::CreateFromID(QStringLiteral("ffmpeg"));
olive::DecoderPtr decoder =
olive::Decoder::CreateFromID(QStringLiteral("ffmpeg"));
ASSERT_TRUE(decoder);
ASSERT_TRUE(decoder->Open(olive::Decoder::CodecStream(path, 0, nullptr)));
+10 -12
View File
@@ -2,7 +2,8 @@
#include "codec/encoder.h"
namespace {
namespace
{
class TestEncoder final : public olive::Encoder {
public:
explicit TestEncoder(const olive::EncodingParams &params)
@@ -57,8 +58,8 @@ TEST(CodecEncoder, ImageSequenceFilenames)
QStringLiteral("frame_[####].png")),
QStringLiteral("frame.png"));
const QString filename = encoder.GetFilenameForFrame(
olive::core::rational(1, 24));
const QString filename =
encoder.GetFilenameForFrame(olive::core::rational(1, 24));
EXPECT_EQ(filename, QStringLiteral("frame_0001.png"));
}
@@ -66,21 +67,18 @@ TEST(CodecEncoder, MatrixGeneration)
{
using Method = olive::EncodingParams::VideoScalingMethod;
QMatrix4x4 stretch =
olive::EncodingParams::GenerateMatrix(Method::kStretch, 1920, 1080,
1280, 720);
QMatrix4x4 stretch = olive::EncodingParams::GenerateMatrix(
Method::kStretch, 1920, 1080, 1280, 720);
EXPECT_TRUE(qFuzzyCompare(stretch(0, 0), 1.0f));
EXPECT_TRUE(qFuzzyCompare(stretch(1, 1), 1.0f));
QMatrix4x4 fit =
olive::EncodingParams::GenerateMatrix(Method::kFit, 1920, 1080,
1024, 1024);
QMatrix4x4 fit = olive::EncodingParams::GenerateMatrix(Method::kFit, 1920,
1080, 1024, 1024);
EXPECT_TRUE(qFuzzyCompare(fit(0, 0), 1.0f));
EXPECT_FALSE(qFuzzyCompare(fit(1, 1), 1.0f));
QMatrix4x4 crop =
olive::EncodingParams::GenerateMatrix(Method::kCrop, 1920, 1080,
1024, 1024);
QMatrix4x4 crop = olive::EncodingParams::GenerateMatrix(Method::kCrop, 1920,
1080, 1024, 1024);
EXPECT_FALSE(qFuzzyCompare(crop(0, 0), 1.0f));
EXPECT_TRUE(qFuzzyCompare(crop(1, 1), 1.0f));
}
+2 -1
View File
@@ -12,7 +12,8 @@ TEST(CodecExportFormat, NamesAndExtensions)
QStringLiteral("mxf"));
EXPECT_EQ(ExportFormat::GetName(ExportFormat::kFormatCount),
QStringLiteral("Unknown"));
EXPECT_TRUE(ExportFormat::GetExtension(ExportFormat::kFormatCount).isEmpty());
EXPECT_TRUE(
ExportFormat::GetExtension(ExportFormat::kFormatCount).isEmpty());
}
TEST(CodecExportFormat, AllFormatsHaveNames)
+9 -9
View File
@@ -44,8 +44,8 @@ TEST(CodecFrame, AllocateMatchesLineSize)
TEST(CodecFrame, DestroyDeallocatesData)
{
olive::FramePtr frame = olive::Frame::Create();
frame->set_video_params(olive::VideoParams(
8, 8, olive::core::PixelFormat::U8,
frame->set_video_params(
olive::VideoParams(8, 8, olive::core::PixelFormat::U8,
olive::VideoParams::kRGBAChannelCount));
frame->allocate();
EXPECT_TRUE(frame->is_allocated());
@@ -55,7 +55,6 @@ TEST(CodecFrame, DestroyDeallocatesData)
EXPECT_EQ(frame->data(), nullptr);
}
TEST(CodecFrame, AllocateInvalidParamsFails)
{
olive::Frame frame;
@@ -157,13 +156,15 @@ TEST(CodecFrame, InterlaceFrames)
TEST(CodecFrame, InterlaceIncompatibleReturnsNull)
{
olive::FramePtr top = olive::Frame::Create();
top->set_video_params(olive::VideoParams(
4, 4, olive::core::PixelFormat::U8, olive::VideoParams::kRGBAChannelCount));
top->set_video_params(
olive::VideoParams(4, 4, olive::core::PixelFormat::U8,
olive::VideoParams::kRGBAChannelCount));
top->allocate();
olive::FramePtr bottom = olive::Frame::Create();
bottom->set_video_params(olive::VideoParams(
8, 8, olive::core::PixelFormat::U8, olive::VideoParams::kRGBAChannelCount));
bottom->set_video_params(
olive::VideoParams(8, 8, olive::core::PixelFormat::U8,
olive::VideoParams::kRGBAChannelCount));
bottom->allocate();
EXPECT_EQ(olive::Frame::Interlace(top, bottom), nullptr);
@@ -177,8 +178,7 @@ TEST(CodecFrame, ConvertU8ToU16)
frame->set_video_params(params);
frame->allocate();
olive::FramePtr converted =
frame->convert(olive::core::PixelFormat::U16);
olive::FramePtr converted = frame->convert(olive::core::PixelFormat::U16);
ASSERT_NE(converted, nullptr);
EXPECT_EQ(converted->format(), olive::core::PixelFormat::U16);
EXPECT_EQ(converted->width(), 4);
+30 -40
View File
@@ -18,7 +18,8 @@
namespace OCIO = OCIO_NAMESPACE;
namespace {
namespace
{
bool IsOakSupportedLutExtension(QString suffix)
{
@@ -31,14 +32,14 @@ bool IsOakSupportedLutExtension(QString suffix)
QString WriteTestCube(QTemporaryDir *dir)
{
const QString path = QDir(dir->path()).filePath(QStringLiteral("invert.cube"));
const QString path =
QDir(dir->path()).filePath(QStringLiteral("invert.cube"));
QFile file(path);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
return QString();
}
const QByteArray data =
"TITLE \"Oak test invert\"\n"
const QByteArray data = "TITLE \"Oak test invert\"\n"
"LUT_1D_SIZE 2\n"
"DOMAIN_MIN 0.0 0.0 0.0\n"
"DOMAIN_MAX 1.0 1.0 1.0\n"
@@ -87,7 +88,8 @@ protected:
}
}
virtual void ProcessColorTransform(olive::TexturePtr destination,
virtual void
ProcessColorTransform(olive::TexturePtr destination,
const olive::Node *node,
const olive::ColorTransformJob *job) override
{
@@ -110,11 +112,12 @@ protected:
}
};
QString WriteTestCubeLut(QTemporaryDir *dir, const char *title,
float low, float high)
QString WriteTestCubeLut(QTemporaryDir *dir, const char *title, float low,
float high)
{
const QString path = QDir(dir->path()).filePath(
QStringLiteral("%1.cube").arg(QString::fromUtf8(title)));
const QString path =
QDir(dir->path())
.filePath(QStringLiteral("%1.cube").arg(QString::fromUtf8(title)));
QFile file(path);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
return QString();
@@ -147,8 +150,7 @@ QString WriteAsymmetricCube(QTemporaryDir *dir)
return QString();
}
const QByteArray data =
"TITLE \"Oak test asymmetric\"\n"
const QByteArray data = "TITLE \"Oak test asymmetric\"\n"
"LUT_1D_SIZE 3\n"
"DOMAIN_MIN 0.0 0.0 0.0\n"
"DOMAIN_MAX 1.0 1.0 1.0\n"
@@ -231,7 +233,8 @@ TEST(ColorLut, CubeFileTransformConvertsColor)
olive::ColorProcessor::Create(config->getProcessor(transform));
ASSERT_TRUE(processor);
const olive::Color out = processor->ConvertColor(olive::Color(0.25f, 0.50f, 0.75f, 1.0f));
const olive::Color out =
processor->ConvertColor(olive::Color(0.25f, 0.50f, 0.75f, 1.0f));
EXPECT_NEAR(out.red(), 0.75f, 0.02f);
EXPECT_NEAR(out.green(), 0.50f, 0.02f);
EXPECT_NEAR(out.blue(), 0.25f, 0.02f);
@@ -240,8 +243,7 @@ TEST(ColorLut, CubeFileTransformConvertsColor)
TEST(ColorV04, FactoryCreatesColorNodes)
{
std::unique_ptr<olive::Node> lut(
olive::NodeFactory::CreateFromFactoryIndex(
std::unique_ptr<olive::Node> lut(olive::NodeFactory::CreateFromFactoryIndex(
olive::NodeFactory::kOCIOLut));
ASSERT_NE(lut, nullptr);
EXPECT_EQ(lut->id(), QStringLiteral("org.olivevideoeditor.Olive.ociolut"));
@@ -260,8 +262,8 @@ TEST(ColorV04, FactoryCreatesColorNodes)
olive::ThreeWayColorNode::kHighlightsColorInput));
const olive::Color neutral =
three_way->GetStandardValue(
olive::ThreeWayColorNode::kMidtonesColorInput)
three_way
->GetStandardValue(olive::ThreeWayColorNode::kMidtonesColorInput)
.value<olive::Color>();
EXPECT_FLOAT_EQ(neutral.red(), 0.5f);
EXPECT_FLOAT_EQ(neutral.green(), 0.5f);
@@ -306,8 +308,7 @@ TEST(ColorLutNode, ForwardDirectionInvertsPixels)
olive::Node::ConnectEdge(
solid, olive::NodeInput(lut, olive::OCIOLutNode::kTextureInput));
const olive::VideoParams params(
16, 16, olive::core::PixelFormat::F32,
const olive::VideoParams params(16, 16, olive::core::PixelFormat::F32,
olive::VideoParams::kRGBAChannelCount);
PixelColorTransformTraverser traverser;
@@ -354,8 +355,7 @@ TEST(ColorLutNode, InverseDirectionReversesForwardTransform)
olive::Node::ConnectEdge(
solid, olive::NodeInput(lut, olive::OCIOLutNode::kTextureInput));
const olive::VideoParams params(
16, 16, olive::core::PixelFormat::F32,
const olive::VideoParams params(16, 16, olive::core::PixelFormat::F32,
olive::VideoParams::kRGBAChannelCount);
PixelColorTransformTraverser traverser;
@@ -402,8 +402,7 @@ TEST(ColorLutNode, SwitchingDirectionUpdatesProcessorAndPixels)
olive::Node::ConnectEdge(
solid, olive::NodeInput(lut, olive::OCIOLutNode::kTextureInput));
const olive::VideoParams params(
16, 16, olive::core::PixelFormat::F32,
const olive::VideoParams params(16, 16, olive::core::PixelFormat::F32,
olive::VideoParams::kRGBAChannelCount);
// First render: forward direction.
@@ -471,8 +470,7 @@ TEST(ColorLutNode, EmptyFilePathLeavesProcessorNull)
olive::Node::ConnectEdge(
solid, olive::NodeInput(lut, olive::OCIOLutNode::kTextureInput));
const olive::VideoParams params(
16, 16, olive::core::PixelFormat::F32,
const olive::VideoParams params(16, 16, olive::core::PixelFormat::F32,
olive::VideoParams::kRGBAChannelCount);
PixelColorTransformTraverser traverser;
@@ -508,8 +506,7 @@ TEST(ColorLutNode, MissingFilePathLeavesProcessorNull)
olive::Node::ConnectEdge(
solid, olive::NodeInput(lut, olive::OCIOLutNode::kTextureInput));
const olive::VideoParams params(
16, 16, olive::core::PixelFormat::F32,
const olive::VideoParams params(16, 16, olive::core::PixelFormat::F32,
olive::VideoParams::kRGBAChannelCount);
PixelColorTransformTraverser traverser;
@@ -543,8 +540,7 @@ TEST(ColorLutNode, UnsupportedExtensionLeavesProcessorNull)
olive::Node::ConnectEdge(
solid, olive::NodeInput(lut, olive::OCIOLutNode::kTextureInput));
const olive::VideoParams params(
16, 16, olive::core::PixelFormat::F32,
const olive::VideoParams params(16, 16, olive::core::PixelFormat::F32,
olive::VideoParams::kRGBAChannelCount);
PixelColorTransformTraverser traverser;
@@ -584,8 +580,7 @@ TEST(ColorLutNode, DirectionStringValuesAreAccepted)
olive::Node::ConnectEdge(
solid, olive::NodeInput(lut, olive::OCIOLutNode::kTextureInput));
const olive::VideoParams params(
16, 16, olive::core::PixelFormat::F32,
const olive::VideoParams params(16, 16, olive::core::PixelFormat::F32,
olive::VideoParams::kRGBAChannelCount);
PixelColorTransformTraverser traverser;
@@ -631,8 +626,7 @@ TEST(ColorLutNode, DirectionStringInverseIsAccepted)
olive::Node::ConnectEdge(
solid, olive::NodeInput(lut, olive::OCIOLutNode::kTextureInput));
const olive::VideoParams params(
16, 16, olive::core::PixelFormat::F32,
const olive::VideoParams params(16, 16, olive::core::PixelFormat::F32,
olive::VideoParams::kRGBAChannelCount);
PixelColorTransformTraverser traverser;
@@ -676,8 +670,7 @@ TEST(ColorLutNode, ReusingSameFileDoesNotCrash)
olive::Node::ConnectEdge(
solid, olive::NodeInput(lut, olive::OCIOLutNode::kTextureInput));
const olive::VideoParams params(
16, 16, olive::core::PixelFormat::F32,
const olive::VideoParams params(16, 16, olive::core::PixelFormat::F32,
olive::VideoParams::kRGBAChannelCount);
// Render twice; the second render should reuse the cached processor.
@@ -708,10 +701,8 @@ TEST(ColorLutNode, SwitchingBackToOriginalFileRestoresOriginalPixels)
QTemporaryDir dir;
ASSERT_TRUE(dir.isValid());
const QString invert_path = WriteTestCubeLut(
&dir, "invert", 0.0f, 1.0f);
const QString boost_path = WriteTestCubeLut(
&dir, "boost", 0.5f, 1.0f);
const QString invert_path = WriteTestCubeLut(&dir, "invert", 0.0f, 1.0f);
const QString boost_path = WriteTestCubeLut(&dir, "boost", 0.5f, 1.0f);
ASSERT_FALSE(invert_path.isEmpty());
ASSERT_FALSE(boost_path.isEmpty());
@@ -728,8 +719,7 @@ TEST(ColorLutNode, SwitchingBackToOriginalFileRestoresOriginalPixels)
olive::Node::ConnectEdge(
solid, olive::NodeInput(lut, olive::OCIOLutNode::kTextureInput));
const olive::VideoParams params(
16, 16, olive::core::PixelFormat::F32,
const olive::VideoParams params(16, 16, olive::core::PixelFormat::F32,
olive::VideoParams::kRGBAChannelCount);
auto render = [&]() {
@@ -5,8 +5,8 @@
TEST(CommonCommandLineParser, OptionWithoutArgument)
{
CommandLineParser parser;
const CommandLineParser::Option *opt = parser.AddOption(
{QStringLiteral("help"), QStringLiteral("h")},
const CommandLineParser::Option *opt =
parser.AddOption({ QStringLiteral("help"), QStringLiteral("h") },
QStringLiteral("Show help"), false);
parser.Process({ QStringLiteral("app"), QStringLiteral("-help") });
@@ -17,8 +17,8 @@ TEST(CommonCommandLineParser, OptionWithoutArgument)
TEST(CommonCommandLineParser, ShortOption)
{
CommandLineParser parser;
const CommandLineParser::Option *opt = parser.AddOption(
{QStringLiteral("help"), QStringLiteral("h")},
const CommandLineParser::Option *opt =
parser.AddOption({ QStringLiteral("help"), QStringLiteral("h") },
QStringLiteral("Show help"), false);
parser.Process({ QStringLiteral("app"), QStringLiteral("-h") });
+4 -2
View File
@@ -11,7 +11,8 @@ TEST(CommonCurrent, SetAndGetVideoParams)
params.set_height(1080);
Current::getInstance().setCurrentVideoParams(params);
const olive::VideoParams &stored = Current::getInstance().currentVideoParams();
const olive::VideoParams &stored =
Current::getInstance().currentVideoParams();
EXPECT_EQ(stored.width(), 1920);
EXPECT_EQ(stored.height(), 1080);
}
@@ -22,6 +23,7 @@ TEST(CommonCurrent, SetAndGetAudioParams)
params.set_sample_rate(48000);
Current::getInstance().setCurrentAudioParams(params);
const olive::AudioParams &stored = Current::getInstance().currentAudioParams();
const olive::AudioParams &stored =
Current::getInstance().currentAudioParams();
EXPECT_EQ(stored.sample_rate(), 48000);
}
+10 -5
View File
@@ -72,13 +72,17 @@ TEST(CommonFFmpegUtils, GetSwsColorspaceFromAVColorSpace)
SWS_CS_FCC);
EXPECT_EQ(FFmpegUtils::GetSwsColorspaceFromAVColorSpace(AVCOL_SPC_BT470BG),
SWS_CS_ITU624);
EXPECT_EQ(FFmpegUtils::GetSwsColorspaceFromAVColorSpace(AVCOL_SPC_SMPTE170M),
EXPECT_EQ(
FFmpegUtils::GetSwsColorspaceFromAVColorSpace(AVCOL_SPC_SMPTE170M),
SWS_CS_SMPTE170M);
EXPECT_EQ(FFmpegUtils::GetSwsColorspaceFromAVColorSpace(AVCOL_SPC_SMPTE240M),
EXPECT_EQ(
FFmpegUtils::GetSwsColorspaceFromAVColorSpace(AVCOL_SPC_SMPTE240M),
SWS_CS_SMPTE240M);
EXPECT_EQ(FFmpegUtils::GetSwsColorspaceFromAVColorSpace(AVCOL_SPC_BT2020_NCL),
EXPECT_EQ(
FFmpegUtils::GetSwsColorspaceFromAVColorSpace(AVCOL_SPC_BT2020_NCL),
SWS_CS_BT2020);
EXPECT_EQ(FFmpegUtils::GetSwsColorspaceFromAVColorSpace(AVCOL_SPC_UNSPECIFIED),
EXPECT_EQ(
FFmpegUtils::GetSwsColorspaceFromAVColorSpace(AVCOL_SPC_UNSPECIFIED),
SWS_CS_DEFAULT);
}
@@ -140,7 +144,8 @@ TEST(CommonFFmpegUtils, GetFFmpegPixelFormat)
TEST(CommonFFmpegUtils, GetCompatiblePixelFormatAV)
{
AVPixelFormat fmt = FFmpegUtils::GetCompatiblePixelFormat(AV_PIX_FMT_YUV420P);
AVPixelFormat fmt =
FFmpegUtils::GetCompatiblePixelFormat(AV_PIX_FMT_YUV420P);
EXPECT_NE(fmt, AV_PIX_FMT_NONE);
fmt = FFmpegUtils::GetCompatiblePixelFormat(AV_PIX_FMT_YUV420P,
+11 -6
View File
@@ -16,7 +16,9 @@ TEST(CommonFileFunctions, EnsureFilenameExtension)
EXPECT_EQ(olive::FileFunctions::EnsureFilenameExtension(
QStringLiteral("PROJECT"), QStringLiteral("ove")),
QStringLiteral("PROJECT.ove"));
EXPECT_TRUE(olive::FileFunctions::EnsureFilenameExtension(QString(), QStringLiteral("ove")).isEmpty());
EXPECT_TRUE(olive::FileFunctions::EnsureFilenameExtension(
QString(), QStringLiteral("ove"))
.isEmpty());
EXPECT_EQ(olive::FileFunctions::EnsureFilenameExtension(
QStringLiteral("project"), QString()),
QStringLiteral("project"));
@@ -46,7 +48,8 @@ TEST(CommonFileFunctions, DirectoryIsValid)
QTemporaryDir dir;
ASSERT_TRUE(dir.isValid());
EXPECT_TRUE(olive::FileFunctions::DirectoryIsValid(QDir(dir.path()), false));
EXPECT_TRUE(
olive::FileFunctions::DirectoryIsValid(QDir(dir.path()), false));
QDir nonexistent(dir.filePath(QStringLiteral("subdir/nested")));
EXPECT_TRUE(olive::FileFunctions::DirectoryIsValid(nonexistent, true));
@@ -133,7 +136,8 @@ TEST(CommonFileFunctions, ReadFileAsString)
EXPECT_EQ(olive::FileFunctions::ReadFileAsString(f.fileName()),
QStringLiteral("hello world"));
EXPECT_TRUE(olive::FileFunctions::ReadFileAsString(
QStringLiteral("/nonexistent/path")).isEmpty());
QStringLiteral("/nonexistent/path"))
.isEmpty());
}
TEST(CommonFileFunctions, GetUniqueFileIdentifier)
@@ -148,10 +152,10 @@ TEST(CommonFileFunctions, GetUniqueFileIdentifier)
EXPECT_EQ(id1, id2);
EXPECT_TRUE(olive::FileFunctions::GetUniqueFileIdentifier(
QStringLiteral("/nonexistent")).isEmpty());
QStringLiteral("/nonexistent"))
.isEmpty());
}
TEST(CommonFileFunctions, GetConfigurationLocation)
{
QString loc = olive::FileFunctions::GetConfigurationLocation();
@@ -176,7 +180,8 @@ TEST(CommonFileFunctions, DirectoryIsValidExisting)
{
QTemporaryDir dir;
ASSERT_TRUE(dir.isValid());
EXPECT_TRUE(olive::FileFunctions::DirectoryIsValid(QDir(dir.path()), false));
EXPECT_TRUE(
olive::FileFunctions::DirectoryIsValid(QDir(dir.path()), false));
}
TEST(CommonFileFunctions, CopyDirectoryWithOverwrite)
+4 -4
View File
@@ -30,7 +30,8 @@ TEST(CommonQtUtils, FlipControlAndShiftModifiers)
// (Qt::ControlModifier & Qt::ShiftModifier is always zero), so the function
// always swaps Control and Shift. This test documents current behavior.
Qt::KeyboardModifiers both = Qt::ControlModifier | Qt::ShiftModifier;
Qt::KeyboardModifiers flipped = olive::QtUtils::FlipControlAndShiftModifiers(both);
Qt::KeyboardModifiers flipped =
olive::QtUtils::FlipControlAndShiftModifiers(both);
EXPECT_TRUE(flipped & Qt::ControlModifier);
EXPECT_FALSE(flipped & Qt::ShiftModifier);
@@ -112,7 +113,6 @@ TEST(CommonQtUtils, ToQColor)
EXPECT_NEAR(qc.alphaF(), 0.4, 0.001);
}
TEST(CommonQtUtils, GetFormattedDateTime)
{
QDateTime dt = QDateTime::fromString(QStringLiteral("2025-01-15T10:30:00"),
@@ -132,8 +132,8 @@ TEST(CommonQtUtils, WordWrapString)
EXPECT_GE(wrapped.size(), 1u);
// Should preserve manual newlines
wrapped = olive::QtUtils::WordWrapString(
QStringLiteral("line1\nline2"), fm, 1000);
wrapped = olive::QtUtils::WordWrapString(QStringLiteral("line1\nline2"), fm,
1000);
EXPECT_EQ(wrapped.size(), 2);
}
-1
View File
@@ -59,7 +59,6 @@ TEST(CommonXmlUtils, ReadNextStartElementSkipsUnknown)
EXPECT_EQ(reader.name().toString(), QStringLiteral("known"));
}
TEST(CommonXmlUtils, ReadNextStartElementWithCancel)
{
QByteArray xml = "<root><child/></root>";
+8 -8
View File
@@ -46,17 +46,17 @@ TEST(Config, GraphicsBackendStringConversion)
olive::RenderManager::kVulkan);
EXPECT_EQ(olive::RenderManager::BackendFromString(QStringLiteral("dummy")),
olive::RenderManager::kDummy);
EXPECT_EQ(olive::RenderManager::BackendFromString(
QStringLiteral("multiprocess")),
EXPECT_EQ(
olive::RenderManager::BackendFromString(QStringLiteral("multiprocess")),
olive::RenderManager::kMultiProcess);
EXPECT_EQ(olive::RenderManager::BackendToString(
olive::RenderManager::kOpenGL),
EXPECT_EQ(
olive::RenderManager::BackendToString(olive::RenderManager::kOpenGL),
QStringLiteral("opengl"));
EXPECT_EQ(olive::RenderManager::BackendToString(
olive::RenderManager::kVulkan),
EXPECT_EQ(
olive::RenderManager::BackendToString(olive::RenderManager::kVulkan),
QStringLiteral("vulkan"));
EXPECT_EQ(olive::RenderManager::BackendToString(
olive::RenderManager::kDummy),
EXPECT_EQ(
olive::RenderManager::BackendToString(olive::RenderManager::kDummy),
QStringLiteral("dummy"));
EXPECT_EQ(olive::RenderManager::BackendToString(
olive::RenderManager::kMultiProcess),
+2 -1
View File
@@ -17,7 +17,8 @@ TEST(CoreStringUtils, Split)
TEST(CoreStringUtils, SplitRegex)
{
auto result = StringUtils::split_regex("one:two;three", std::regex("(:)|(;)| "));
auto result =
StringUtils::split_regex("one:two;three", std::regex("(:)|(;)| "));
ASSERT_EQ(result.size(), 3u);
EXPECT_EQ(result[0], "one");
EXPECT_EQ(result[1], "two");
+8 -7
View File
@@ -8,7 +8,8 @@ TEST(CoreTimecode, TimeToTimecodeSeconds)
{
rational time(5, 1);
rational tb(1, 25);
std::string tc = Timecode::time_to_timecode(time, tb, Timecode::kTimecodeSeconds);
std::string tc =
Timecode::time_to_timecode(time, tb, Timecode::kTimecodeSeconds);
EXPECT_EQ(tc, "00:00:05.000");
}
@@ -25,8 +26,8 @@ TEST(CoreTimecode, TimeToTimecodePlusSign)
{
rational time(1, 1);
rational tb(1, 25);
std::string tc = Timecode::time_to_timecode(time, tb,
Timecode::kTimecodeSeconds, true);
std::string tc =
Timecode::time_to_timecode(time, tb, Timecode::kTimecodeSeconds, true);
EXPECT_EQ(tc.substr(0, 1), "+");
}
@@ -51,8 +52,8 @@ TEST(CoreTimecode, TimecodeToTimeNonDropFrame)
{
rational tb(1, 25);
bool ok = false;
rational t = Timecode::timecode_to_time("00:00:02:03", tb,
Timecode::kTimecodeNonDropFrame, &ok);
rational t = Timecode::timecode_to_time(
"00:00:02:03", tb, Timecode::kTimecodeNonDropFrame, &ok);
EXPECT_TRUE(ok);
EXPECT_EQ(t, rational(53, 25));
}
@@ -61,8 +62,8 @@ TEST(CoreTimecode, TimecodeToTimeInvalid)
{
rational tb(1, 25);
bool ok = true;
Timecode::timecode_to_time("not a timecode", tb,
Timecode::kTimecodeSeconds, &ok);
Timecode::timecode_to_time("not a timecode", tb, Timecode::kTimecodeSeconds,
&ok);
EXPECT_FALSE(ok);
}
+2 -1
View File
@@ -147,7 +147,8 @@ TEST(CoreTimeRangeList, Intersects)
list.insert(TimeRange(rational(0), rational(10)));
list.insert(TimeRange(rational(20), rational(30)));
TimeRangeList result = list.Intersects(TimeRange(rational(5), rational(25)));
TimeRangeList result =
list.Intersects(TimeRange(rational(5), rational(25)));
EXPECT_EQ(result.size(), 2);
EXPECT_EQ(result.first().in(), rational(5));
EXPECT_EQ(result.first().out(), rational(10));
+40 -27
View File
@@ -21,7 +21,8 @@ TEST(DynamicRenderBackend, LoadsExperimentalOpenGLBackend)
#else
olive::DynamicRenderer renderer(QStringLiteral("opengl"));
if (!renderer.Load()) {
GTEST_SKIP() << "opengl backend library could not be loaded in this environment";
GTEST_SKIP()
<< "opengl backend library could not be loaded in this environment";
}
EXPECT_EQ(renderer.OpenGLContext(), nullptr);
@@ -48,11 +49,13 @@ TEST(DynamicRenderBackend, OpenGLBackendFollowsAdapterToRenderThread)
#else
olive::DynamicRenderer renderer(QStringLiteral("opengl"));
if (!renderer.Load()) {
GTEST_SKIP() << "opengl backend library could not be loaded in this environment";
GTEST_SKIP()
<< "opengl backend library could not be loaded in this environment";
}
if (!renderer.Init()) {
GTEST_SKIP() << "OpenGL backend could not be initialized on this system";
GTEST_SKIP()
<< "OpenGL backend could not be initialized on this system";
}
QThread render_thread;
@@ -71,8 +74,8 @@ TEST(DynamicRenderBackend, OpenGLBackendFollowsAdapterToRenderThread)
&renderer,
[&]() {
renderer.PostInit();
texture = renderer.CreateTexture(olive::VideoParams(
64, 64, olive::PixelFormat::U8,
texture = renderer.CreateTexture(
olive::VideoParams(64, 64, olive::PixelFormat::U8,
olive::VideoParams::kRGBAChannelCount));
},
Qt::BlockingQueuedConnection);
@@ -94,7 +97,8 @@ TEST(DynamicRenderBackend, LoadsExperimentalVulkanBackendWhenAvailable)
#else
olive::DynamicRenderer renderer(QStringLiteral("vulkan"));
if (!renderer.Load()) {
GTEST_SKIP() << "vulkan backend library could not be loaded in this environment";
GTEST_SKIP()
<< "vulkan backend library could not be loaded in this environment";
}
OakRenderBackendInfo info = {};
@@ -121,13 +125,15 @@ TEST(DynamicRenderBackend, FallsBackWhenExperimentalVulkanUnavailable)
#else
olive::DynamicRenderer renderer(QStringLiteral("vulkan"));
if (!renderer.Load()) {
GTEST_SKIP() << "vulkan backend library could not be loaded in this environment";
GTEST_SKIP()
<< "vulkan backend library could not be loaded in this environment";
}
OakRenderBackendInfo info = {};
ASSERT_TRUE(renderer.GetBackendInfo(&info));
if (info.kind == OAK_RENDER_BACKEND_VULKAN) {
GTEST_SKIP() << "Vulkan backend is available on this system; skip fallback test";
GTEST_SKIP()
<< "Vulkan backend is available on this system; skip fallback test";
}
EXPECT_EQ(renderer.backend_name(), QStringLiteral("opengl"));
EXPECT_EQ(renderer.OpenGLContext(), nullptr);
@@ -145,7 +151,8 @@ TEST(DynamicRenderBackend, VulkanUploadBlitDownload)
#else
olive::DynamicRenderer renderer(QStringLiteral("vulkan"));
if (!renderer.Load()) {
GTEST_SKIP() << "vulkan backend library could not be loaded in this environment";
GTEST_SKIP()
<< "vulkan backend library could not be loaded in this environment";
}
OakRenderBackendInfo info = {};
@@ -178,8 +185,8 @@ TEST(DynamicRenderBackend, VulkanUploadBlitDownload)
ASSERT_NE(dst, nullptr);
ASSERT_FALSE(dst->IsDummy());
const QString vert = QStringLiteral(
"uniform mat4 ove_mvpmat;\n"
const QString vert =
QStringLiteral("uniform mat4 ove_mvpmat;\n"
"in vec4 a_position;\n"
"in vec2 a_texcoord;\n"
"out vec2 ove_texcoord;\n"
@@ -187,14 +194,15 @@ TEST(DynamicRenderBackend, VulkanUploadBlitDownload)
" gl_Position = ove_mvpmat * a_position;\n"
" ove_texcoord = a_texcoord;\n"
"}\n");
const QString frag = QStringLiteral(
"uniform sampler2D ove_maintex;\n"
const QString frag =
QStringLiteral("uniform sampler2D ove_maintex;\n"
"in vec2 ove_texcoord;\n"
"out vec4 frag_color;\n"
"void main() {\n"
" frag_color = texture(ove_maintex, ove_texcoord);\n"
"}\n");
QVariant shader = renderer.CreateNativeShader(olive::ShaderCode(frag, vert));
QVariant shader =
renderer.CreateNativeShader(olive::ShaderCode(frag, vert));
ASSERT_FALSE(shader.isNull());
olive::ShaderJob job;
@@ -226,7 +234,8 @@ TEST(DynamicRenderBackend, VulkanNullDestinationBlitDoesNotCrash)
#else
olive::DynamicRenderer renderer(QStringLiteral("vulkan"));
if (!renderer.Load()) {
GTEST_SKIP() << "vulkan backend library could not be loaded in this environment";
GTEST_SKIP()
<< "vulkan backend library could not be loaded in this environment";
}
OakRenderBackendInfo info = {};
@@ -253,8 +262,8 @@ TEST(DynamicRenderBackend, VulkanNullDestinationBlitDoesNotCrash)
}
src->Upload(src_data.data(), kSize);
const QString vert = QStringLiteral(
"uniform mat4 ove_mvpmat;\n"
const QString vert =
QStringLiteral("uniform mat4 ove_mvpmat;\n"
"in vec4 a_position;\n"
"in vec2 a_texcoord;\n"
"out vec2 ove_texcoord;\n"
@@ -262,14 +271,15 @@ TEST(DynamicRenderBackend, VulkanNullDestinationBlitDoesNotCrash)
" gl_Position = ove_mvpmat * a_position;\n"
" ove_texcoord = a_texcoord;\n"
"}\n");
const QString frag = QStringLiteral(
"uniform sampler2D ove_maintex;\n"
const QString frag =
QStringLiteral("uniform sampler2D ove_maintex;\n"
"in vec2 ove_texcoord;\n"
"out vec4 frag_color;\n"
"void main() {\n"
" frag_color = texture(ove_maintex, ove_texcoord);\n"
"}\n");
QVariant shader = renderer.CreateNativeShader(olive::ShaderCode(frag, vert));
QVariant shader =
renderer.CreateNativeShader(olive::ShaderCode(frag, vert));
ASSERT_FALSE(shader.isNull());
olive::ShaderJob job;
@@ -294,7 +304,8 @@ TEST(DynamicRenderBackend, VulkanIterativeBlitPingPong)
#else
olive::DynamicRenderer renderer(QStringLiteral("vulkan"));
if (!renderer.Load()) {
GTEST_SKIP() << "vulkan backend library could not be loaded in this environment";
GTEST_SKIP()
<< "vulkan backend library could not be loaded in this environment";
}
OakRenderBackendInfo info = {};
@@ -327,8 +338,8 @@ TEST(DynamicRenderBackend, VulkanIterativeBlitPingPong)
ASSERT_FALSE(dst->IsDummy());
// Shader that samples the iterative input and scales RGB by 0.5 each pass.
const QString vert = QStringLiteral(
"uniform mat4 ove_mvpmat;\n"
const QString vert =
QStringLiteral("uniform mat4 ove_mvpmat;\n"
"in vec4 a_position;\n"
"in vec2 a_texcoord;\n"
"out vec2 ove_texcoord;\n"
@@ -336,15 +347,16 @@ TEST(DynamicRenderBackend, VulkanIterativeBlitPingPong)
" gl_Position = ove_mvpmat * a_position;\n"
" ove_texcoord = a_texcoord;\n"
"}\n");
const QString frag = QStringLiteral(
"uniform sampler2D ove_maintex;\n"
const QString frag =
QStringLiteral("uniform sampler2D ove_maintex;\n"
"in vec2 ove_texcoord;\n"
"out vec4 frag_color;\n"
"void main() {\n"
" vec4 c = texture(ove_maintex, ove_texcoord);\n"
" frag_color = vec4(c.rgb * 0.5, c.a);\n"
"}\n");
QVariant shader = renderer.CreateNativeShader(olive::ShaderCode(frag, vert));
QVariant shader =
renderer.CreateNativeShader(olive::ShaderCode(frag, vert));
ASSERT_FALSE(shader.isNull());
olive::ShaderJob job;
@@ -378,7 +390,8 @@ TEST(DynamicRenderBackend, VulkanUploadDownloadThreeChannel)
#else
olive::DynamicRenderer renderer(QStringLiteral("vulkan"));
if (!renderer.Load()) {
GTEST_SKIP() << "vulkan backend library could not be loaded in this environment";
GTEST_SKIP()
<< "vulkan backend library could not be loaded in this environment";
}
OakRenderBackendInfo info = {};
+2 -1
View File
@@ -12,7 +12,8 @@ using namespace olive;
TEST(FFmpegDecoderHW, H264_422_10bit_CPUFrame_IsNotBlack)
{
const QString path = QStringLiteral("/home/mikesolar/Videos/dual_system_video.MOV");
const QString path =
QStringLiteral("/home/mikesolar/Videos/dual_system_video.MOV");
if (!QFileInfo::exists(path)) {
GTEST_SKIP() << "Test footage not available: " << path.toStdString();
+2 -2
View File
@@ -10,8 +10,8 @@ int main(int argc, char **argv)
{
Q_INIT_RESOURCE(ocioconf);
if (qEnvironmentVariableIsEmpty("OCIO")) {
qputenv("OCIO", QFile::encodeName(
QDir(QStringLiteral(OAK_TEST_SOURCE_DIR))
qputenv("OCIO",
QFile::encodeName(QDir(QStringLiteral(OAK_TEST_SOURCE_DIR))
.filePath(QStringLiteral(
"app/render/ocioconf/config.ocio"))));
}
+37 -18
View File
@@ -5,24 +5,39 @@
TEST(ModuleSmoke, ToolAddableObjectNames)
{
EXPECT_FALSE(olive::Tool::GetAddableObjectName(olive::Tool::kAddableEmpty).isEmpty());
EXPECT_FALSE(olive::Tool::GetAddableObjectName(olive::Tool::kAddableBars).isEmpty());
EXPECT_FALSE(olive::Tool::GetAddableObjectName(olive::Tool::kAddableShape).isEmpty());
EXPECT_FALSE(olive::Tool::GetAddableObjectName(olive::Tool::kAddableSolid).isEmpty());
EXPECT_FALSE(olive::Tool::GetAddableObjectName(olive::Tool::kAddableTitle).isEmpty());
EXPECT_FALSE(olive::Tool::GetAddableObjectName(olive::Tool::kAddableTone).isEmpty());
EXPECT_FALSE(olive::Tool::GetAddableObjectName(olive::Tool::kAddableSubtitle).isEmpty());
EXPECT_FALSE(
olive::Tool::GetAddableObjectName(olive::Tool::kAddableEmpty).isEmpty());
EXPECT_FALSE(
olive::Tool::GetAddableObjectName(olive::Tool::kAddableBars).isEmpty());
EXPECT_FALSE(
olive::Tool::GetAddableObjectName(olive::Tool::kAddableShape).isEmpty());
EXPECT_FALSE(
olive::Tool::GetAddableObjectName(olive::Tool::kAddableSolid).isEmpty());
EXPECT_FALSE(
olive::Tool::GetAddableObjectName(olive::Tool::kAddableTitle).isEmpty());
EXPECT_FALSE(
olive::Tool::GetAddableObjectName(olive::Tool::kAddableTone).isEmpty());
EXPECT_FALSE(
olive::Tool::GetAddableObjectName(olive::Tool::kAddableSubtitle)
.isEmpty());
}
TEST(ModuleSmoke, ToolAddableObjectIds)
{
EXPECT_EQ(olive::Tool::GetAddableObjectID(olive::Tool::kAddableEmpty), QStringLiteral("empty"));
EXPECT_EQ(olive::Tool::GetAddableObjectID(olive::Tool::kAddableBars), QStringLiteral("bars"));
EXPECT_EQ(olive::Tool::GetAddableObjectID(olive::Tool::kAddableShape), QStringLiteral("shape"));
EXPECT_EQ(olive::Tool::GetAddableObjectID(olive::Tool::kAddableSolid), QStringLiteral("solid"));
EXPECT_EQ(olive::Tool::GetAddableObjectID(olive::Tool::kAddableTitle), QStringLiteral("title"));
EXPECT_EQ(olive::Tool::GetAddableObjectID(olive::Tool::kAddableTone), QStringLiteral("tone"));
EXPECT_EQ(olive::Tool::GetAddableObjectID(olive::Tool::kAddableSubtitle), QStringLiteral("subtitle"));
EXPECT_EQ(olive::Tool::GetAddableObjectID(olive::Tool::kAddableEmpty),
QStringLiteral("empty"));
EXPECT_EQ(olive::Tool::GetAddableObjectID(olive::Tool::kAddableBars),
QStringLiteral("bars"));
EXPECT_EQ(olive::Tool::GetAddableObjectID(olive::Tool::kAddableShape),
QStringLiteral("shape"));
EXPECT_EQ(olive::Tool::GetAddableObjectID(olive::Tool::kAddableSolid),
QStringLiteral("solid"));
EXPECT_EQ(olive::Tool::GetAddableObjectID(olive::Tool::kAddableTitle),
QStringLiteral("title"));
EXPECT_EQ(olive::Tool::GetAddableObjectID(olive::Tool::kAddableTone),
QStringLiteral("tone"));
EXPECT_EQ(olive::Tool::GetAddableObjectID(olive::Tool::kAddableSubtitle),
QStringLiteral("subtitle"));
}
TEST(ModuleSmoke, HumanStringsSampleRate)
@@ -33,12 +48,16 @@ TEST(ModuleSmoke, HumanStringsSampleRate)
TEST(ModuleSmoke, HumanStringsChannelLayout)
{
EXPECT_FALSE(olive::HumanStrings::ChannelLayoutToString(AV_CH_LAYOUT_MONO).isEmpty());
EXPECT_FALSE(olive::HumanStrings::ChannelLayoutToString(AV_CH_LAYOUT_STEREO).isEmpty());
EXPECT_FALSE(
olive::HumanStrings::ChannelLayoutToString(AV_CH_LAYOUT_MONO).isEmpty());
EXPECT_FALSE(olive::HumanStrings::ChannelLayoutToString(AV_CH_LAYOUT_STEREO)
.isEmpty());
}
TEST(ModuleSmoke, HumanStringsFormat)
{
EXPECT_FALSE(olive::HumanStrings::FormatToString(olive::SampleFormat::U8).isEmpty());
EXPECT_FALSE(olive::HumanStrings::FormatToString(olive::SampleFormat::F32).isEmpty());
EXPECT_FALSE(
olive::HumanStrings::FormatToString(olive::SampleFormat::U8).isEmpty());
EXPECT_FALSE(
olive::HumanStrings::FormatToString(olive::SampleFormat::F32).isEmpty());
}
+4 -2
View File
@@ -19,8 +19,10 @@ TEST(NodeGlobals, ConstructedWithParams)
audio_params.set_sample_rate(48000);
audio_params.set_channel_layout(AV_CH_LAYOUT_STEREO);
olive::TimeRange time(olive::core::rational(1, 24), olive::core::rational(2, 24));
olive::NodeGlobals globals(video_params, audio_params, time, olive::LoopMode::kLoopModeLoop);
olive::TimeRange time(olive::core::rational(1, 24),
olive::core::rational(2, 24));
olive::NodeGlobals globals(video_params, audio_params, time,
olive::LoopMode::kLoopModeLoop);
EXPECT_EQ(globals.vparams().width(), 1920);
EXPECT_EQ(globals.vparams().height(), 1080);
+4 -2
View File
@@ -47,7 +47,8 @@ TEST(NodeProject, SettingsRoundTrip)
{
olive::Project project;
project.SetSetting(olive::Project::kCacheLocationSettingKey,
project.SetSetting(
olive::Project::kCacheLocationSettingKey,
QString::number(olive::Project::kCacheStoreAlongsideProject));
EXPECT_EQ(project.GetCacheLocationSetting(),
olive::Project::kCacheStoreAlongsideProject);
@@ -62,7 +63,8 @@ TEST(NodeProject, SettingsRoundTrip)
EXPECT_EQ(project.GetDefaultInputColorSpace(), QStringLiteral("ACEScg"));
project.SetColorReferenceSpace(QStringLiteral("ACES - ACEScg"));
EXPECT_EQ(project.GetColorReferenceSpace(), QStringLiteral("ACES - ACEScg"));
EXPECT_EQ(project.GetColorReferenceSpace(),
QStringLiteral("ACES - ACEScg"));
}
TEST(NodeProject, InitializeCreatesRoot)
+7 -3
View File
@@ -10,7 +10,8 @@
#include "node/value.h"
#include "render/diskmanager.h"
namespace {
namespace
{
class TestNode final : public olive::Node {
public:
TestNode()
@@ -55,7 +56,8 @@ public:
TEST(NodeSerialization, SaveAndLoadInput)
{
const bool created_disk_manager = (olive::DiskManager::instance() == nullptr);
const bool created_disk_manager =
(olive::DiskManager::instance() == nullptr);
if (created_disk_manager) {
olive::DiskManager::CreateInstance();
}
@@ -87,7 +89,9 @@ TEST(NodeSerialization, SaveAndLoadInput)
EXPECT_EQ(loaded.GetLabel(), QStringLiteral("MyNode"));
EXPECT_EQ(loaded.GetOverrideColor(), 2);
EXPECT_DOUBLE_EQ(loaded.GetSplitStandardValue(QStringLiteral("Value"), -1)
.first().toDouble(), 3.5);
.first()
.toDouble(),
3.5);
if (created_disk_manager) {
olive::DiskManager::DestroyInstance();
+26 -19
View File
@@ -11,27 +11,27 @@ TEST(NodeValue, VectorRoundTrip)
QVector2D v2(1.5f, -2.0f);
QString encoded = olive::NodeValue::ValueToString(
olive::NodeValue::kVec2, QVariant::fromValue(v2), false);
QVariant decoded = olive::NodeValue::StringToValue(
olive::NodeValue::kVec2, encoded, false);
QVariant decoded = olive::NodeValue::StringToValue(olive::NodeValue::kVec2,
encoded, false);
QVector2D v2_out = decoded.value<QVector2D>();
EXPECT_FLOAT_EQ(v2_out.x(), v2.x());
EXPECT_FLOAT_EQ(v2_out.y(), v2.y());
QVector3D v3(1.0f, 2.0f, 3.0f);
encoded = olive::NodeValue::ValueToString(
olive::NodeValue::kVec3, QVariant::fromValue(v3), false);
decoded = olive::NodeValue::StringToValue(
olive::NodeValue::kVec3, encoded, false);
encoded = olive::NodeValue::ValueToString(olive::NodeValue::kVec3,
QVariant::fromValue(v3), false);
decoded = olive::NodeValue::StringToValue(olive::NodeValue::kVec3, encoded,
false);
QVector3D v3_out = decoded.value<QVector3D>();
EXPECT_FLOAT_EQ(v3_out.x(), v3.x());
EXPECT_FLOAT_EQ(v3_out.y(), v3.y());
EXPECT_FLOAT_EQ(v3_out.z(), v3.z());
QVector4D v4(1.0f, 2.0f, 3.0f, 4.0f);
encoded = olive::NodeValue::ValueToString(
olive::NodeValue::kVec4, QVariant::fromValue(v4), false);
decoded = olive::NodeValue::StringToValue(
olive::NodeValue::kVec4, encoded, false);
encoded = olive::NodeValue::ValueToString(olive::NodeValue::kVec4,
QVariant::fromValue(v4), false);
decoded = olive::NodeValue::StringToValue(olive::NodeValue::kVec4, encoded,
false);
QVector4D v4_out = decoded.value<QVector4D>();
EXPECT_FLOAT_EQ(v4_out.x(), v4.x());
EXPECT_FLOAT_EQ(v4_out.y(), v4.y());
@@ -42,8 +42,8 @@ TEST(NodeValue, VectorRoundTrip)
TEST(NodeValue, BinaryRoundTrip)
{
QByteArray data("OliveTest");
QString encoded = olive::NodeValue::ValueToString(
olive::NodeValue::kBinary, data, false);
QString encoded =
olive::NodeValue::ValueToString(olive::NodeValue::kBinary, data, false);
QVariant decoded = olive::NodeValue::StringToValue(
olive::NodeValue::kBinary, encoded, false);
EXPECT_EQ(decoded.toByteArray(), data);
@@ -51,9 +51,12 @@ TEST(NodeValue, BinaryRoundTrip)
TEST(NodeValue, TypeClassification)
{
EXPECT_TRUE(olive::NodeValue::type_can_be_interpolated(olive::NodeValue::kFloat));
EXPECT_TRUE(olive::NodeValue::type_can_be_interpolated(olive::NodeValue::kColor));
EXPECT_FALSE(olive::NodeValue::type_can_be_interpolated(olive::NodeValue::kInt));
EXPECT_TRUE(
olive::NodeValue::type_can_be_interpolated(olive::NodeValue::kFloat));
EXPECT_TRUE(
olive::NodeValue::type_can_be_interpolated(olive::NodeValue::kColor));
EXPECT_FALSE(
olive::NodeValue::type_can_be_interpolated(olive::NodeValue::kInt));
EXPECT_TRUE(olive::NodeValue::type_is_numeric(olive::NodeValue::kInt));
EXPECT_TRUE(olive::NodeValue::type_is_numeric(olive::NodeValue::kFloat));
@@ -70,7 +73,8 @@ TEST(NodeValue, TypeClassification)
TEST(NodeValue, DataTypeNameRoundTrip)
{
for (int i = olive::NodeValue::kNone; i < olive::NodeValue::kDataTypeCount; ++i) {
for (int i = olive::NodeValue::kNone; i < olive::NodeValue::kDataTypeCount;
++i) {
auto type = static_cast<olive::NodeValue::Type>(i);
QString name = olive::NodeValue::GetDataTypeName(type);
if (name.isEmpty()) {
@@ -109,8 +113,10 @@ TEST(NodeValueTable, PushAndGet)
TEST(NodeValueTable, TakeRemovesValue)
{
olive::NodeValueTable table;
table.Push(olive::NodeValue(olive::NodeValue::kInt, static_cast<int64_t>(1)));
table.Push(olive::NodeValue(olive::NodeValue::kInt, static_cast<int64_t>(2)));
table.Push(
olive::NodeValue(olive::NodeValue::kInt, static_cast<int64_t>(1)));
table.Push(
olive::NodeValue(olive::NodeValue::kInt, static_cast<int64_t>(2)));
olive::NodeValue taken = table.Take(olive::NodeValue::kInt);
EXPECT_EQ(taken.toInt(), 2);
@@ -120,7 +126,8 @@ TEST(NodeValueTable, TakeRemovesValue)
TEST(NodeValueTable, ClearEmptiesTable)
{
olive::NodeValueTable table;
table.Push(olive::NodeValue(olive::NodeValue::kText, QStringLiteral("hello")));
table.Push(
olive::NodeValue(olive::NodeValue::kText, QStringLiteral("hello")));
table.Clear();
EXPECT_TRUE(table.isEmpty());
EXPECT_EQ(table.Count(), 0);
+4 -3
View File
@@ -14,7 +14,8 @@ TEST(OpenGLRenderer, DownloadFromTextureWithoutCurrentContext)
QOpenGLContext context;
if (!context.create()) {
GTEST_SKIP() << "Skipping OpenGL test because no context can be created";
GTEST_SKIP()
<< "Skipping OpenGL test because no context can be created";
}
ASSERT_EQ(QOpenGLContext::currentContext(), nullptr);
@@ -26,8 +27,8 @@ TEST(OpenGLRenderer, DownloadFromTextureWithoutCurrentContext)
olive::VideoParams::kInterlaceNone, 1);
unsigned char buffer[4 * 4 * 4] = {};
renderer.DownloadFromTexture(QVariant::fromValue<GLuint>(0), params,
buffer, 4 * 4);
renderer.DownloadFromTexture(QVariant::fromValue<GLuint>(0), params, buffer,
4 * 4);
EXPECT_EQ(QOpenGLContext::currentContext(), nullptr);
}
+36 -19
View File
@@ -20,7 +20,9 @@ using namespace olive;
using namespace olive::core;
// Test helper to create AVFrame with specific format
static AVFramePtr CreateTestFrame(int width, int height, AVPixelFormat fmt, uint32_t fill_color = 0xFF804020) {
static AVFramePtr CreateTestFrame(int width, int height, AVPixelFormat fmt,
uint32_t fill_color = 0xFF804020)
{
AVFramePtr frame = CreateAVFramePtr();
frame->width = width;
frame->height = height;
@@ -56,7 +58,8 @@ static AVFramePtr CreateTestFrame(int width, int height, AVPixelFormat fmt, uint
uint16_t b16 = (b << 8) | b;
uint16_t a16 = (a << 8) | a;
for (int y = 0; y < height; ++y) {
uint16_t *row = reinterpret_cast<uint16_t*>(frame->data[0] + y * frame->linesize[0]);
uint16_t *row = reinterpret_cast<uint16_t *>(
frame->data[0] + y * frame->linesize[0]);
for (int x = 0; x < width; ++x) {
row[x * 4 + 0] = r16;
row[x * 4 + 1] = g16;
@@ -70,13 +73,15 @@ static AVFramePtr CreateTestFrame(int width, int height, AVPixelFormat fmt, uint
}
// Test U8 to U16 conversion
TEST(FormatConversion, U8ToU16) {
TEST(FormatConversion, U8ToU16)
{
const int width = 10;
const int height = 10;
const uint32_t test_color = 0xFF804020; // ARGB: A=255, R=128, G=64, B=32
// Create U8 frame
AVFramePtr u8_frame = CreateTestFrame(width, height, AV_PIX_FMT_RGBA, test_color);
AVFramePtr u8_frame =
CreateTestFrame(width, height, AV_PIX_FMT_RGBA, test_color);
ASSERT_NE(u8_frame, nullptr);
// Verify U8 values
@@ -87,11 +92,13 @@ TEST(FormatConversion, U8ToU16) {
EXPECT_EQ(first_pixel_u8[3], 0x20); // A
// Create U16 frame
AVFramePtr u16_frame = CreateTestFrame(width, height, AV_PIX_FMT_RGBA64, test_color);
AVFramePtr u16_frame =
CreateTestFrame(width, height, AV_PIX_FMT_RGBA64, test_color);
ASSERT_NE(u16_frame, nullptr);
// Verify U16 values (should be U8 value repeated: 0xFF -> 0xFFFF, 0x80 -> 0x8080)
uint16_t *first_pixel_u16 = reinterpret_cast<uint16_t*>(u16_frame->data[0]);
uint16_t *first_pixel_u16 =
reinterpret_cast<uint16_t *>(u16_frame->data[0]);
EXPECT_EQ(first_pixel_u16[0], 0xFFFF); // R
EXPECT_EQ(first_pixel_u16[1], 0x8080); // G
EXPECT_EQ(first_pixel_u16[2], 0x4040); // B
@@ -99,13 +106,15 @@ TEST(FormatConversion, U8ToU16) {
}
// Test FFmpeg sws_scale for U16 to U8 conversion
TEST(FormatConversion, FFmpegU16ToU8) {
TEST(FormatConversion, FFmpegU16ToU8)
{
const int width = 10;
const int height = 10;
const uint32_t test_color = 0xFF804020;
// Create U16 frame
AVFramePtr u16_frame = CreateTestFrame(width, height, AV_PIX_FMT_RGBA64, test_color);
AVFramePtr u16_frame =
CreateTestFrame(width, height, AV_PIX_FMT_RGBA64, test_color);
ASSERT_NE(u16_frame, nullptr);
// Create destination U8 frame
@@ -113,8 +122,7 @@ TEST(FormatConversion, FFmpegU16ToU8) {
ASSERT_NE(u8_frame, nullptr);
// Use sws_scale to convert
SwsContext *sws_ctx = sws_getContext(
width, height, AV_PIX_FMT_RGBA64,
SwsContext *sws_ctx = sws_getContext(width, height, AV_PIX_FMT_RGBA64,
width, height, AV_PIX_FMT_RGBA,
SWS_POINT, nullptr, nullptr, nullptr);
ASSERT_NE(sws_ctx, nullptr);
@@ -133,30 +141,36 @@ TEST(FormatConversion, FFmpegU16ToU8) {
}
// Test VideoParams to AVPixelFormat mapping
TEST(FormatConversion, VideoParamsToAVFormat) {
TEST(FormatConversion, VideoParamsToAVFormat)
{
// U8 RGBA
VideoParams u8_rgba(320, 240, PixelFormat::U8, 4);
AVPixelFormat fmt_u8_rgba = FFmpegUtils::GetFFmpegPixelFormat(u8_rgba.format(), u8_rgba.channel_count());
AVPixelFormat fmt_u8_rgba = FFmpegUtils::GetFFmpegPixelFormat(
u8_rgba.format(), u8_rgba.channel_count());
EXPECT_EQ(fmt_u8_rgba, AV_PIX_FMT_RGBA);
// U16 RGBA
VideoParams u16_rgba(320, 240, PixelFormat::U16, 4);
AVPixelFormat fmt_u16_rgba = FFmpegUtils::GetFFmpegPixelFormat(u16_rgba.format(), u16_rgba.channel_count());
AVPixelFormat fmt_u16_rgba = FFmpegUtils::GetFFmpegPixelFormat(
u16_rgba.format(), u16_rgba.channel_count());
EXPECT_EQ(fmt_u16_rgba, AV_PIX_FMT_RGBA64);
// U8 RGB
VideoParams u8_rgb(320, 240, PixelFormat::U8, 3);
AVPixelFormat fmt_u8_rgb = FFmpegUtils::GetFFmpegPixelFormat(u8_rgb.format(), u8_rgb.channel_count());
AVPixelFormat fmt_u8_rgb = FFmpegUtils::GetFFmpegPixelFormat(
u8_rgb.format(), u8_rgb.channel_count());
EXPECT_EQ(fmt_u8_rgb, AV_PIX_FMT_RGB24);
// U16 RGB
VideoParams u16_rgb(320, 240, PixelFormat::U16, 3);
AVPixelFormat fmt_u16_rgb = FFmpegUtils::GetFFmpegPixelFormat(u16_rgb.format(), u16_rgb.channel_count());
AVPixelFormat fmt_u16_rgb = FFmpegUtils::GetFFmpegPixelFormat(
u16_rgb.format(), u16_rgb.channel_count());
EXPECT_EQ(fmt_u16_rgb, AV_PIX_FMT_RGB48);
}
// Test row bytes calculation
TEST(FormatConversion, RowBytes) {
TEST(FormatConversion, RowBytes)
{
const int width = 320;
// U8 RGBA: 4 bytes per pixel
@@ -173,7 +187,8 @@ TEST(FormatConversion, RowBytes) {
}
// Test that linesize may differ from width * bpp due to alignment
TEST(FormatConversion, LinesizeAlignment) {
TEST(FormatConversion, LinesizeAlignment)
{
const int width = 10;
const int height = 10;
@@ -193,9 +208,11 @@ TEST(FormatConversion, LinesizeAlignment) {
}
// Test loading actual image file
TEST(FormatConversion, LoadImageFile) {
TEST(FormatConversion, LoadImageFile)
{
// Load the test image
QString img_path = QStringLiteral("%1/../tests/img.png").arg(QDir::currentPath());
QString img_path =
QStringLiteral("%1/../tests/img.png").arg(QDir::currentPath());
AVFramePtr frame = CreateAVFramePtr();
// Just create a simple test frame instead of loading an image
+2 -1
View File
@@ -15,7 +15,8 @@ extern "C" {
#include "render/texture.h"
#include "render/videoparams.h"
namespace {
namespace
{
olive::TexturePtr CreateSolidTexture(const olive::VideoParams &params)
{
+56 -36
View File
@@ -27,11 +27,15 @@ extern "C" {
#include "render/texture.h"
#include "render/videoparams.h"
namespace olive {
namespace plugin {
namespace test {
namespace olive
{
namespace plugin
{
namespace test
{
namespace {
namespace
{
// Helper to create a test texture with solid color
// For U8: fill_value is 0-255
@@ -41,8 +45,8 @@ template<typename T>
TexturePtr CreateSolidTextureT(const VideoParams &params, T fill_value)
{
AVFramePtr frame = CreateAVFramePtr();
frame->format = FFmpegUtils::GetFFmpegPixelFormat(
params.format(), params.channel_count());
frame->format = FFmpegUtils::GetFFmpegPixelFormat(params.format(),
params.channel_count());
frame->width = params.width();
frame->height = params.height();
if (frame->format == AV_PIX_FMT_NONE) {
@@ -68,17 +72,21 @@ TexturePtr CreateSolidTextureT(const VideoParams &params, T fill_value)
return texture;
}
TexturePtr CreateSolidTexture(const VideoParams &params, uint32_t fill_value = 0x7f)
TexturePtr CreateSolidTexture(const VideoParams &params,
uint32_t fill_value = 0x7f)
{
// Choose type based on pixel format
switch (params.format()) {
case core::PixelFormat::U8:
return CreateSolidTextureT<uint8_t>(params, static_cast<uint8_t>(fill_value));
return CreateSolidTextureT<uint8_t>(params,
static_cast<uint8_t>(fill_value));
case core::PixelFormat::U16:
return CreateSolidTextureT<uint16_t>(params, static_cast<uint16_t>(fill_value));
return CreateSolidTextureT<uint16_t>(params,
static_cast<uint16_t>(fill_value));
case core::PixelFormat::F16:
case core::PixelFormat::F32:
return CreateSolidTextureT<float>(params, static_cast<float>(fill_value) / 255.0f);
return CreateSolidTextureT<float>(
params, static_cast<float>(fill_value) / 255.0f);
default:
return nullptr;
}
@@ -91,8 +99,8 @@ template<typename T>
TexturePtr CreateGradientTextureT(const VideoParams &params, float scale)
{
AVFramePtr frame = CreateAVFramePtr();
frame->format = FFmpegUtils::GetFFmpegPixelFormat(
params.format(), params.channel_count());
frame->format = FFmpegUtils::GetFFmpegPixelFormat(params.format(),
params.channel_count());
frame->width = params.width();
frame->height = params.height();
if (frame->format == AV_PIX_FMT_NONE) {
@@ -135,14 +143,13 @@ TexturePtr CreateGradientTexture(const VideoParams &params)
}
// Helper function to find and render a plugin
bool RenderPlugin(const std::string &plugin_id,
const VideoParams &params,
const NodeValueRow &inputs,
bool verbose = false)
bool RenderPlugin(const std::string &plugin_id, const VideoParams &params,
const NodeValueRow &inputs, bool verbose = false)
{
auto *cache = OFX::Host::PluginCache::getPluginCache();
if (!cache) {
if (verbose) std::cerr << "Plugin cache not available" << std::endl;
if (verbose)
std::cerr << "Plugin cache not available" << std::endl;
return false;
}
@@ -155,13 +162,16 @@ bool RenderPlugin(const std::string &plugin_id,
}
if (!found) {
if (verbose) std::cerr << "Plugin not found: " << plugin_id << std::endl;
if (verbose)
std::cerr << "Plugin not found: " << plugin_id << std::endl;
return false;
}
auto *image_effect = dynamic_cast<OFX::Host::ImageEffect::ImageEffectPlugin *>(found);
auto *image_effect =
dynamic_cast<OFX::Host::ImageEffect::ImageEffectPlugin *>(found);
if (!image_effect) {
if (verbose) std::cerr << "Not an image effect plugin" << std::endl;
if (verbose)
std::cerr << "Not an image effect plugin" << std::endl;
return false;
}
@@ -175,13 +185,15 @@ bool RenderPlugin(const std::string &plugin_id,
OFX::Host::ImageEffect::Instance *instance =
image_effect->createInstance(context, nullptr);
if (!instance) {
if (verbose) std::cerr << "Failed to create instance" << std::endl;
if (verbose)
std::cerr << "Failed to create instance" << std::endl;
return false;
}
auto *olive_instance = dynamic_cast<OlivePluginInstance *>(instance);
if (!olive_instance) {
if (verbose) std::cerr << "Not an OlivePluginInstance" << std::endl;
if (verbose)
std::cerr << "Not an OlivePluginInstance" << std::endl;
return false;
}
@@ -202,7 +214,8 @@ bool RenderPlugin(const std::string &plugin_id,
}
// Skip check function
bool ShouldSkipTest() {
bool ShouldSkipTest()
{
const char *itest = std::getenv("OAK_OFX_ITEST");
if (!itest || std::string(itest) != "1") {
return true;
@@ -270,7 +283,8 @@ TEST(PluginMisc, TransformTranslate)
row.insert(QString::fromStdString(kOfxImageEffectSimpleSourceClipName),
NodeValue(NodeValue::kTexture, input));
bool result = RenderPlugin("net.sf.openfx.TransformPlugin", params, row, true);
bool result =
RenderPlugin("net.sf.openfx.TransformPlugin", params, row, true);
EXPECT_TRUE(result) << "Transform plugin should produce output";
}
@@ -292,7 +306,8 @@ TEST(PluginMisc, ColorCorrect)
row.insert(QString::fromStdString(kOfxImageEffectSimpleSourceClipName),
NodeValue(NodeValue::kTexture, input));
bool result = RenderPlugin("net.sf.openfx.ColorCorrectPlugin", params, row, true);
bool result =
RenderPlugin("net.sf.openfx.ColorCorrectPlugin", params, row, true);
EXPECT_TRUE(result) << "ColorCorrect plugin should produce output";
}
@@ -310,7 +325,8 @@ TEST(PluginMisc, Saturation)
row.insert(QString::fromStdString(kOfxImageEffectSimpleSourceClipName),
NodeValue(NodeValue::kTexture, input));
bool result = RenderPlugin("net.sf.openfx.SaturationPlugin", params, row, true);
bool result =
RenderPlugin("net.sf.openfx.SaturationPlugin", params, row, true);
EXPECT_TRUE(result) << "Saturation plugin should produce output";
}
@@ -395,7 +411,8 @@ TEST(PluginMisc, NonExistentPlugin)
row.insert(QString::fromStdString(kOfxImageEffectSimpleSourceClipName),
NodeValue(NodeValue::kTexture, input));
bool result = RenderPlugin("net.sf.openfx.NonExistentPlugin", params, row, true);
bool result =
RenderPlugin("net.sf.openfx.NonExistentPlugin", params, row, true);
EXPECT_FALSE(result) << "Non-existent plugin should fail gracefully";
}
@@ -474,8 +491,7 @@ TEST(PluginMisc, MergeOver)
NodeValueRow row;
row.insert(QString::fromStdString(kOfxImageEffectSimpleSourceClipName),
NodeValue(NodeValue::kTexture, input));
row.insert(QStringLiteral("Bg"),
NodeValue(NodeValue::kTexture, input));
row.insert(QStringLiteral("Bg"), NodeValue(NodeValue::kTexture, input));
bool result = RenderPlugin("net.sf.openfx.MergePlugin", params, row, true);
EXPECT_TRUE(result) << "Merge plugin should produce output";
@@ -521,7 +537,8 @@ TEST(PluginMisc, CornerPin)
row.insert(QString::fromStdString(kOfxImageEffectSimpleSourceClipName),
NodeValue(NodeValue::kTexture, input));
bool result = RenderPlugin("net.sf.openfx.CornerPinPlugin", params, row, true);
bool result =
RenderPlugin("net.sf.openfx.CornerPinPlugin", params, row, true);
EXPECT_TRUE(result) << "CornerPin plugin should produce output";
}
@@ -539,7 +556,8 @@ TEST(PluginMisc, LensDistortion)
row.insert(QString::fromStdString(kOfxImageEffectSimpleSourceClipName),
NodeValue(NodeValue::kTexture, input));
bool result = RenderPlugin("net.sf.openfx.LensDistortion", params, row, true);
bool result =
RenderPlugin("net.sf.openfx.LensDistortion", params, row, true);
EXPECT_TRUE(result) << "LensDistortion plugin should produce output";
}
@@ -611,7 +629,8 @@ TEST(PluginMisc, ListAvailablePlugins)
TEST(PluginMisc, CImgBilateralGuided_MultiInput)
{
if (ShouldSkipTest()) GTEST_SKIP() << "OFX integration test not enabled";
if (ShouldSkipTest())
GTEST_SKIP() << "OFX integration test not enabled";
// CImgBilateralGuided is a multi-input plugin (Source + Guide).
// This test verifies that connecting both inputs does not trigger
// the frame-rate mismatch exception in setupClipPreferencesArgs.
@@ -624,10 +643,11 @@ TEST(PluginMisc, CImgBilateralGuided_MultiInput)
NodeValueRow row;
row.insert(QString::fromStdString(kOfxImageEffectSimpleSourceClipName),
NodeValue(NodeValue::kTexture, source));
row.insert(QStringLiteral("Guide"),
NodeValue(NodeValue::kTexture, guide));
bool result = RenderPlugin("net.sf.cimg.CImgBilateralGuided", params, row, true);
EXPECT_TRUE(result) << "CImgBilateralGuided plugin should produce output with both Source and Guide connected";
row.insert(QStringLiteral("Guide"), NodeValue(NodeValue::kTexture, guide));
bool result =
RenderPlugin("net.sf.cimg.CImgBilateralGuided", params, row, true);
EXPECT_TRUE(result)
<< "CImgBilateralGuided plugin should produce output with both Source and Guide connected";
}
} // namespace test
+2 -1
View File
@@ -6,7 +6,8 @@
#include "render/texture.h"
#include "render/videoparams.h"
namespace {
namespace
{
class PluginJobTraverser : public olive::NodeTraverser {
public:
@@ -8,9 +8,8 @@ TEST(PluginRendererReadback, BytesToPixels)
olive::core::rational(1, 1),
olive::VideoParams::kInterlaceNone, 1);
const int bytes_per_pixel =
olive::VideoParams::GetBytesPerPixel(params.format(),
params.channel_count());
const int bytes_per_pixel = olive::VideoParams::GetBytesPerPixel(
params.format(), params.channel_count());
ASSERT_EQ(bytes_per_pixel, 4);
EXPECT_EQ(olive::plugin::detail::BytesToPixels(64, params), 16);
+75 -51
View File
@@ -47,17 +47,19 @@ extern "C" {
#include <libavutil/frame.h>
}
namespace olive {
namespace plugin {
namespace test {
namespace olive
{
namespace plugin
{
namespace test
{
// ============================================================================
// Helper Functions
// ============================================================================
static VideoParams MakeVideoParams(int width, int height,
core::PixelFormat format,
int channels,
core::PixelFormat format, int channels,
bool premultiplied = false)
{
VideoParams params;
@@ -71,11 +73,12 @@ static VideoParams MakeVideoParams(int width, int height,
return params;
}
static TexturePtr CreateTestTexture(const VideoParams &params, uint8_t fill_value = 0x7f)
static TexturePtr CreateTestTexture(const VideoParams &params,
uint8_t fill_value = 0x7f)
{
AVFramePtr frame = CreateAVFramePtr();
frame->format = FFmpegUtils::GetFFmpegPixelFormat(
params.format(), params.channel_count());
frame->format = FFmpegUtils::GetFFmpegPixelFormat(params.format(),
params.channel_count());
frame->width = params.width();
frame->height = params.height();
if (frame->format == AV_PIX_FMT_NONE) {
@@ -112,17 +115,14 @@ TEST(PluginSmoke, HostSingletonExists)
TEST(PluginSmoke, LoadPluginsEmptyPathNoCrash)
{
// Loading plugins from empty path should not crash
EXPECT_NO_THROW({
loadPlugins(QString());
});
EXPECT_NO_THROW({ loadPlugins(QString()); });
}
TEST(PluginSmoke, LoadPluginsNonExistentPathNoCrash)
{
// Loading plugins from non-existent path should not crash
EXPECT_NO_THROW({
loadPlugins(QStringLiteral("/nonexistent/path/to/plugins"));
});
EXPECT_NO_THROW(
{ loadPlugins(QStringLiteral("/nonexistent/path/to/plugins")); });
}
// ============================================================================
@@ -132,7 +132,8 @@ TEST(PluginSmoke, LoadPluginsNonExistentPathNoCrash)
TEST(PluginSmokeClip, OutputClipProperties)
{
OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName);
VideoParams params = MakeVideoParams(1920, 1080, core::PixelFormat::U8, 4, true);
VideoParams params =
MakeVideoParams(1920, 1080, core::PixelFormat::U8, 4, true);
params.set_pixel_aspect_ratio(core::rational(16, 9));
params.set_frame_rate(core::rational(24, 1));
params.set_start_time(0);
@@ -166,8 +167,10 @@ TEST(PluginSmokeClip, ClipDifferentPixelFormats)
{
// Test U16 format
{
OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName);
VideoParams params = MakeVideoParams(640, 480, core::PixelFormat::U16, 3, false);
OFX::Host::ImageEffect::ClipDescriptor desc(
kOfxImageEffectOutputClipName);
VideoParams params =
MakeVideoParams(640, 480, core::PixelFormat::U16, 3, false);
OliveClipInstance clip(nullptr, desc, params);
EXPECT_EQ(clip.getUnmappedBitDepth(), kOfxBitDepthShort);
EXPECT_EQ(clip.getUnmappedComponents(), kOfxImageComponentRGB);
@@ -176,8 +179,10 @@ TEST(PluginSmokeClip, ClipDifferentPixelFormats)
// Test F16 format
{
OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName);
VideoParams params = MakeVideoParams(640, 480, core::PixelFormat::F16, 4, true);
OFX::Host::ImageEffect::ClipDescriptor desc(
kOfxImageEffectOutputClipName);
VideoParams params =
MakeVideoParams(640, 480, core::PixelFormat::F16, 4, true);
OliveClipInstance clip(nullptr, desc, params);
EXPECT_EQ(clip.getUnmappedBitDepth(), kOfxBitDepthHalf);
EXPECT_EQ(clip.getUnmappedComponents(), kOfxImageComponentRGBA);
@@ -186,8 +191,10 @@ TEST(PluginSmokeClip, ClipDifferentPixelFormats)
// Test F32 format
{
OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName);
VideoParams params = MakeVideoParams(640, 480, core::PixelFormat::F32, 4, false);
OFX::Host::ImageEffect::ClipDescriptor desc(
kOfxImageEffectOutputClipName);
VideoParams params =
MakeVideoParams(640, 480, core::PixelFormat::F32, 4, false);
OliveClipInstance clip(nullptr, desc, params);
EXPECT_EQ(clip.getUnmappedBitDepth(), kOfxBitDepthFloat);
EXPECT_EQ(clip.getUnmappedComponents(), kOfxImageComponentRGBA);
@@ -198,7 +205,8 @@ TEST(PluginSmokeClip, ClipDifferentPixelFormats)
TEST(PluginSmokeClip, SourceClipNotConnected)
{
OFX::Host::ImageEffect::ClipDescriptor desc("Source");
VideoParams params = MakeVideoParams(320, 240, core::PixelFormat::U8, 4, false);
VideoParams params =
MakeVideoParams(320, 240, core::PixelFormat::U8, 4, false);
OliveClipInstance clip(nullptr, desc, params);
// Source clips should not be connected (no input provided in test)
@@ -213,7 +221,8 @@ TEST(PluginSmokeClip, SourceClipNotConnected)
TEST(PluginSmokeImage, BasicAllocation)
{
OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName);
VideoParams params = MakeVideoParams(64, 64, core::PixelFormat::U8, 4, true);
VideoParams params =
MakeVideoParams(64, 64, core::PixelFormat::U8, 4, true);
OliveClipInstance clip(nullptr, desc, params);
Image image(clip);
@@ -232,7 +241,8 @@ TEST(PluginSmokeImage, BasicAllocation)
TEST(PluginSmokeImage, ClearOnAllocate)
{
OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName);
VideoParams params = MakeVideoParams(16, 16, core::PixelFormat::U8, 4, false);
VideoParams params =
MakeVideoParams(16, 16, core::PixelFormat::U8, 4, false);
OliveClipInstance clip(nullptr, desc, params);
Image image(clip);
@@ -265,7 +275,8 @@ TEST(PluginSmokeImage, ClearOnAllocate)
TEST(PluginSmokeImage, ResizeOnAllocate)
{
OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName);
VideoParams params = MakeVideoParams(32, 32, core::PixelFormat::U8, 4, false);
VideoParams params =
MakeVideoParams(32, 32, core::PixelFormat::U8, 4, false);
OliveClipInstance clip(nullptr, desc, params);
Image image(clip);
@@ -504,8 +515,7 @@ TEST(PluginSmokeParam, CustomNullNode)
TEST(PluginSmokeRenderer, BytesToPixelsConversion)
{
VideoParams params(100, 100, core::PixelFormat::U8, 4,
core::rational(1, 1),
VideoParams params(100, 100, core::PixelFormat::U8, 4, core::rational(1, 1),
VideoParams::kInterlaceNone, 1);
// 4 channels * 1 byte = 4 bytes per pixel
@@ -514,15 +524,14 @@ TEST(PluginSmokeRenderer, BytesToPixelsConversion)
// Test with RGB (3 channels)
VideoParams params_rgb(100, 100, core::PixelFormat::U8, 3,
core::rational(1, 1),
VideoParams::kInterlaceNone, 1);
core::rational(1, 1), VideoParams::kInterlaceNone,
1);
EXPECT_EQ(detail::BytesToPixels(300, params_rgb), 100);
}
TEST(PluginSmokeRenderer, BytesToPixelsInvalidInput)
{
VideoParams params(100, 100, core::PixelFormat::U8, 4,
core::rational(1, 1),
VideoParams params(100, 100, core::PixelFormat::U8, 4, core::rational(1, 1),
VideoParams::kInterlaceNone, 1);
// Negative input should return 0
@@ -590,32 +599,40 @@ TEST(PluginSmokeIntegration, VideoParamsToOfxMapping)
{
// Test U8 -> Byte mapping
{
VideoParams params = MakeVideoParams(100, 100, core::PixelFormat::U8, 4, false);
OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName);
VideoParams params =
MakeVideoParams(100, 100, core::PixelFormat::U8, 4, false);
OFX::Host::ImageEffect::ClipDescriptor desc(
kOfxImageEffectOutputClipName);
OliveClipInstance clip(nullptr, desc, params);
EXPECT_EQ(clip.getUnmappedBitDepth(), kOfxBitDepthByte);
}
// Test U16 -> Short mapping
{
VideoParams params = MakeVideoParams(100, 100, core::PixelFormat::U16, 4, false);
OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName);
VideoParams params =
MakeVideoParams(100, 100, core::PixelFormat::U16, 4, false);
OFX::Host::ImageEffect::ClipDescriptor desc(
kOfxImageEffectOutputClipName);
OliveClipInstance clip(nullptr, desc, params);
EXPECT_EQ(clip.getUnmappedBitDepth(), kOfxBitDepthShort);
}
// Test F16 -> Half mapping
{
VideoParams params = MakeVideoParams(100, 100, core::PixelFormat::F16, 4, false);
OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName);
VideoParams params =
MakeVideoParams(100, 100, core::PixelFormat::F16, 4, false);
OFX::Host::ImageEffect::ClipDescriptor desc(
kOfxImageEffectOutputClipName);
OliveClipInstance clip(nullptr, desc, params);
EXPECT_EQ(clip.getUnmappedBitDepth(), kOfxBitDepthHalf);
}
// Test F32 -> Float mapping
{
VideoParams params = MakeVideoParams(100, 100, core::PixelFormat::F32, 4, false);
OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName);
VideoParams params =
MakeVideoParams(100, 100, core::PixelFormat::F32, 4, false);
OFX::Host::ImageEffect::ClipDescriptor desc(
kOfxImageEffectOutputClipName);
OliveClipInstance clip(nullptr, desc, params);
EXPECT_EQ(clip.getUnmappedBitDepth(), kOfxBitDepthFloat);
}
@@ -625,24 +642,30 @@ TEST(PluginSmokeIntegration, ComponentCountMapping)
{
// Test RGB (3 channels)
{
VideoParams params = MakeVideoParams(100, 100, core::PixelFormat::U8, 3, false);
OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName);
VideoParams params =
MakeVideoParams(100, 100, core::PixelFormat::U8, 3, false);
OFX::Host::ImageEffect::ClipDescriptor desc(
kOfxImageEffectOutputClipName);
OliveClipInstance clip(nullptr, desc, params);
EXPECT_EQ(clip.getUnmappedComponents(), kOfxImageComponentRGB);
}
// Test RGBA (4 channels)
{
VideoParams params = MakeVideoParams(100, 100, core::PixelFormat::U8, 4, false);
OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName);
VideoParams params =
MakeVideoParams(100, 100, core::PixelFormat::U8, 4, false);
OFX::Host::ImageEffect::ClipDescriptor desc(
kOfxImageEffectOutputClipName);
OliveClipInstance clip(nullptr, desc, params);
EXPECT_EQ(clip.getUnmappedComponents(), kOfxImageComponentRGBA);
}
// Test Alpha (1 channel)
{
VideoParams params = MakeVideoParams(100, 100, core::PixelFormat::U8, 1, false);
OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName);
VideoParams params =
MakeVideoParams(100, 100, core::PixelFormat::U8, 1, false);
OFX::Host::ImageEffect::ClipDescriptor desc(
kOfxImageEffectOutputClipName);
OliveClipInstance clip(nullptr, desc, params);
EXPECT_EQ(clip.getUnmappedComponents(), kOfxImageComponentAlpha);
}
@@ -663,9 +686,10 @@ TEST(PluginSmokeThread, ConcurrentImageAllocation)
for (int t = 0; t < num_threads; ++t) {
threads.emplace_back([&success_count, num_allocs_per_thread, t]() {
for (int i = 0; i < num_allocs_per_thread; ++i) {
OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName);
VideoParams params = MakeVideoParams(32 + t, 32 + i,
core::PixelFormat::U8, 4, false);
OFX::Host::ImageEffect::ClipDescriptor desc(
kOfxImageEffectOutputClipName);
VideoParams params = MakeVideoParams(
32 + t, 32 + i, core::PixelFormat::U8, 4, false);
OliveClipInstance clip(nullptr, desc, params);
Image image(clip);
@@ -673,8 +697,7 @@ TEST(PluginSmokeThread, ConcurrentImageAllocation)
OfxRectI rod = bounds;
image.AllocateFromParams(params, bounds, rod, true);
if (image.data() != nullptr &&
image.width() == 32 + t &&
if (image.data() != nullptr && image.width() == 32 + t &&
image.height() == 32 + i) {
success_count++;
}
@@ -702,7 +725,8 @@ TEST(PluginSmokeThread, ConcurrentParamAccess)
std::vector<std::thread> threads;
for (int t = 0; t < num_threads; ++t) {
threads.emplace_back([&instance, &success_count, &access_mutex, t, num_ops_per_thread]() {
threads.emplace_back([&instance, &success_count, &access_mutex, t,
num_ops_per_thread]() {
for (int i = 0; i < num_ops_per_thread; ++i) {
int value = t * 1000 + i;
std::lock_guard<std::mutex> lock(access_mutex);
+5 -7
View File
@@ -4,10 +4,10 @@
#include "ofxhClip.h"
#include "pluginSupport/OliveClip.h"
namespace {
namespace
{
olive::VideoParams MakeParams(int width, int height,
olive::core::PixelFormat format,
int channels,
olive::core::PixelFormat format, int channels,
bool premultiplied)
{
olive::VideoParams params;
@@ -64,16 +64,14 @@ TEST(PluginSupportClip, GetImageClampsBoundsAndCachesOutput)
olive::plugin::OliveClipInstance clip(nullptr, desc, params);
OfxRectD optional_bounds = { -10.0, -10.0, 200.0, 200.0 };
OFX::Host::ImageEffect::Image *image =
clip.getImage(0.0, &optional_bounds);
OFX::Host::ImageEffect::Image *image = clip.getImage(0.0, &optional_bounds);
ASSERT_NE(image, nullptr);
auto *olive_image = static_cast<olive::plugin::Image *>(image);
EXPECT_EQ(olive_image->width(), 100);
EXPECT_EQ(olive_image->height(), 80);
OFX::Host::ImageEffect::Image *image_again =
clip.getImage(0.0, nullptr);
OFX::Host::ImageEffect::Image *image_again = clip.getImage(0.0, nullptr);
EXPECT_EQ(image, image_again);
}
+3 -3
View File
@@ -5,10 +5,10 @@
#include "pluginSupport/OliveClip.h"
#include "pluginSupport/image.h"
namespace {
namespace
{
olive::VideoParams MakeParams(int width, int height,
olive::core::PixelFormat format,
int channels,
olive::core::PixelFormat format, int channels,
bool premultiplied)
{
olive::VideoParams params;
+1 -3
View File
@@ -4,7 +4,5 @@
TEST(PluginSupport, LoadPluginsEmptyPath)
{
EXPECT_NO_THROW({
olive::plugin::loadPlugins(QString());
});
EXPECT_NO_THROW({ olive::plugin::loadPlugins(QString()); });
}
@@ -53,8 +53,8 @@ TEST(PreferencesBehaviorTab, BehaviorPrefTrProvidesTranslations)
foreach (const QString &key, keys) {
EXPECT_FALSE(
PreferencesBehaviorTab::BehaviorPrefTr(
key.toUtf8().constData()).isEmpty())
PreferencesBehaviorTab::BehaviorPrefTr(key.toUtf8().constData())
.isEmpty())
<< key.toStdString();
}
}
@@ -76,8 +76,8 @@ TEST(PreferencesGeneralTab, ContainsHoverFocusOption)
bool found = false;
foreach (QCheckBox *box, boxes) {
if (box->text() == PreferencesBehaviorTab::BehaviorPrefTr(
"Enable hover focus")) {
if (box->text() ==
PreferencesBehaviorTab::BehaviorPrefTr("Enable hover focus")) {
found = true;
break;
}
+2 -1
View File
@@ -79,7 +79,8 @@ TEST_F(PreviewAutoCacherTest, ClearSingleFrameRendersDoesNotCrashWhenEmpty)
cacher.ClearSingleFrameRenders();
}
TEST_F(PreviewAutoCacherTest, ClearSingleFrameRendersThatArentRunningDoesNotCrashWhenEmpty)
TEST_F(PreviewAutoCacherTest,
ClearSingleFrameRendersThatArentRunningDoesNotCrashWhenEmpty)
{
PreviewAutoCacher cacher;
cacher.ClearSingleFrameRendersThatArentRunning();
+7 -6
View File
@@ -13,7 +13,8 @@
TEST(ProjectSerializer, SaveLoadProjectRoundTrip)
{
const bool created_disk_manager = (olive::DiskManager::instance() == nullptr);
const bool created_disk_manager =
(olive::DiskManager::instance() == nullptr);
if (created_disk_manager) {
olive::DiskManager::CreateInstance();
}
@@ -45,15 +46,15 @@ TEST(ProjectSerializer, SaveLoadProjectRoundTrip)
QBuffer read_buffer(&xml);
read_buffer.open(QIODevice::ReadOnly);
QXmlStreamReader reader(&read_buffer);
olive::ProjectSerializer::Result result =
olive::ProjectSerializer::Load(&loaded_project, &reader,
olive::ProjectSerializer::kProject);
olive::ProjectSerializer::Result result = olive::ProjectSerializer::Load(
&loaded_project, &reader, olive::ProjectSerializer::kProject);
EXPECT_EQ(result.code(), olive::ProjectSerializer::kSuccess);
EXPECT_FALSE(loaded_project.nodes().isEmpty());
ASSERT_TRUE(result.GetLoadData().node_ptrs.contains(
reinterpret_cast<quintptr>(node)));
EXPECT_TRUE(loaded_project.nodes().contains(
result.GetLoadData().node_ptrs.value(reinterpret_cast<quintptr>(node))));
EXPECT_TRUE(
loaded_project.nodes().contains(result.GetLoadData().node_ptrs.value(
reinterpret_cast<quintptr>(node))));
olive::ProjectSerializer::Destroy();
if (created_disk_manager) {
+24 -26
View File
@@ -18,14 +18,14 @@ TEST(ProxyManager, BuildsStableProxyFilename)
params.version = 1;
const QString first = olive::ProxyManager::GetProxyFilename(
QStringLiteral("/tmp/oak-cache"),
QStringLiteral("/media/source.mov"), 0, params);
QStringLiteral("/tmp/oak-cache"), QStringLiteral("/media/source.mov"),
0, params);
const QString second = olive::ProxyManager::GetProxyFilename(
QStringLiteral("/tmp/oak-cache"),
QStringLiteral("/media/source.mov"), 0, params);
QStringLiteral("/tmp/oak-cache"), QStringLiteral("/media/source.mov"),
0, params);
const QString other_stream = olive::ProxyManager::GetProxyFilename(
QStringLiteral("/tmp/oak-cache"),
QStringLiteral("/media/source.mov"), 1, params);
QStringLiteral("/tmp/oak-cache"), QStringLiteral("/media/source.mov"),
1, params);
EXPECT_EQ(first, second);
EXPECT_NE(first, other_stream);
@@ -48,11 +48,11 @@ TEST(ProxyManager, ProxyFilenameIncludesPresetParameters)
mov_540p.extension = QStringLiteral("mov");
const QString first = olive::ProxyManager::GetProxyFilename(
QStringLiteral("/tmp/oak-cache"),
QStringLiteral("/media/source.mov"), 0, mp4_720p);
QStringLiteral("/tmp/oak-cache"), QStringLiteral("/media/source.mov"),
0, mp4_720p);
const QString second = olive::ProxyManager::GetProxyFilename(
QStringLiteral("/tmp/oak-cache"),
QStringLiteral("/media/source.mov"), 0, mov_540p);
QStringLiteral("/tmp/oak-cache"), QStringLiteral("/media/source.mov"),
0, mov_540p);
EXPECT_NE(first, second);
EXPECT_TRUE(first.contains(QStringLiteral(".1280x720.v1.")));
@@ -117,20 +117,20 @@ TEST(ProxyManager, ConvertsProxyStateToAndFromStrings)
olive::ProxyManager::kProxyFailed),
QStringLiteral("failed"));
EXPECT_EQ(olive::ProxyManager::ProxyStateFromString(
QStringLiteral("missing")),
EXPECT_EQ(
olive::ProxyManager::ProxyStateFromString(QStringLiteral("missing")),
olive::ProxyManager::kProxyMissing);
EXPECT_EQ(olive::ProxyManager::ProxyStateFromString(
QStringLiteral("generating")),
EXPECT_EQ(
olive::ProxyManager::ProxyStateFromString(QStringLiteral("generating")),
olive::ProxyManager::kProxyGenerating);
EXPECT_EQ(olive::ProxyManager::ProxyStateFromString(
QStringLiteral("ready")),
EXPECT_EQ(
olive::ProxyManager::ProxyStateFromString(QStringLiteral("ready")),
olive::ProxyManager::kProxyReady);
EXPECT_EQ(olive::ProxyManager::ProxyStateFromString(
QStringLiteral("failed")),
EXPECT_EQ(
olive::ProxyManager::ProxyStateFromString(QStringLiteral("failed")),
olive::ProxyManager::kProxyFailed);
EXPECT_EQ(olive::ProxyManager::ProxyStateFromString(
QStringLiteral("unknown")),
EXPECT_EQ(
olive::ProxyManager::ProxyStateFromString(QStringLiteral("unknown")),
olive::ProxyManager::kProxyMissing);
}
@@ -225,8 +225,8 @@ TEST(ProxyManager, EmitsProxyFinishedState)
received_state = state;
});
emit olive::ProxyManager::instance()->ProxyFinished(
QStringLiteral("/media/source.mov"), 0,
emit olive::ProxyManager::instance()
-> ProxyFinished(QStringLiteral("/media/source.mov"), 0,
QStringLiteral("/cache/proxy/example.mp4"),
olive::ProxyManager::kProxyFailed);
@@ -241,10 +241,8 @@ TEST(ProxyManager, EmitsProxyFinishedState)
TEST(ProxyManager, WorkingProxyFilenamePrependsExtension)
{
const QString proxy =
QStringLiteral("/cache/proxy/example.mp4");
const QString working =
olive::ProxyManager::GetWorkingProxyFilename(proxy);
const QString proxy = QStringLiteral("/cache/proxy/example.mp4");
const QString working = olive::ProxyManager::GetWorkingProxyFilename(proxy);
EXPECT_EQ(working, QStringLiteral("/cache/proxy/example.mp4.working.mp4"));
}
+20 -20
View File
@@ -7,12 +7,12 @@ TEST(RenderAudioParams, ValidityAndEquality)
olive::core::AudioParams invalid;
EXPECT_FALSE(invalid.is_valid());
olive::core::AudioParams params(
48000, AV_CH_LAYOUT_STEREO, olive::core::SampleFormat::S16);
olive::core::AudioParams params(48000, AV_CH_LAYOUT_STEREO,
olive::core::SampleFormat::S16);
EXPECT_TRUE(params.is_valid());
olive::core::AudioParams other(
48000, AV_CH_LAYOUT_STEREO, olive::core::SampleFormat::S16);
olive::core::AudioParams other(48000, AV_CH_LAYOUT_STEREO,
olive::core::SampleFormat::S16);
EXPECT_TRUE(params == other);
other.set_sample_rate(44100);
@@ -21,8 +21,8 @@ TEST(RenderAudioParams, ValidityAndEquality)
TEST(RenderAudioParams, TimeAndSampleConversions)
{
olive::core::AudioParams params(
48000, AV_CH_LAYOUT_STEREO, olive::core::SampleFormat::S16);
olive::core::AudioParams params(48000, AV_CH_LAYOUT_STEREO,
olive::core::SampleFormat::S16);
EXPECT_EQ(params.channel_count(), 2);
EXPECT_EQ(params.bytes_per_sample_per_channel(), 2);
@@ -43,34 +43,34 @@ TEST(RenderAudioParams, TimeAndSampleConversions)
TEST(RenderAudioParams, ChannelLayoutCount)
{
olive::core::AudioParams mono(
48000, AV_CH_LAYOUT_MONO, olive::core::SampleFormat::F32);
olive::core::AudioParams mono(48000, AV_CH_LAYOUT_MONO,
olive::core::SampleFormat::F32);
EXPECT_EQ(mono.channel_count(), 1);
olive::core::AudioParams surround(
48000, AV_CH_LAYOUT_5POINT1, olive::core::SampleFormat::F32);
olive::core::AudioParams surround(48000, AV_CH_LAYOUT_5POINT1,
olive::core::SampleFormat::F32);
EXPECT_EQ(surround.channel_count(), 6);
}
TEST(RenderAudioParams, SampleFormatSizes)
{
olive::core::AudioParams u8(
48000, AV_CH_LAYOUT_MONO, olive::core::SampleFormat::U8);
olive::core::AudioParams u8(48000, AV_CH_LAYOUT_MONO,
olive::core::SampleFormat::U8);
EXPECT_EQ(u8.bytes_per_sample_per_channel(), 1);
olive::core::AudioParams f32(
48000, AV_CH_LAYOUT_MONO, olive::core::SampleFormat::F32);
olive::core::AudioParams f32(48000, AV_CH_LAYOUT_MONO,
olive::core::SampleFormat::F32);
EXPECT_EQ(f32.bytes_per_sample_per_channel(), 4);
olive::core::AudioParams f64(
48000, AV_CH_LAYOUT_MONO, olive::core::SampleFormat::F64);
olive::core::AudioParams f64(48000, AV_CH_LAYOUT_MONO,
olive::core::SampleFormat::F64);
EXPECT_EQ(f64.bytes_per_sample_per_channel(), 8);
}
TEST(RenderAudioParams, CopyAndAssignment)
{
olive::core::AudioParams params(
96000, AV_CH_LAYOUT_STEREO, olive::core::SampleFormat::F32);
olive::core::AudioParams params(96000, AV_CH_LAYOUT_STEREO,
olive::core::SampleFormat::F32);
olive::core::AudioParams copy(params);
EXPECT_EQ(copy.sample_rate(), 96000);
@@ -85,8 +85,8 @@ TEST(RenderAudioParams, CopyAndAssignment)
TEST(RenderAudioParams, SettersModifyState)
{
olive::core::AudioParams params(
44100, AV_CH_LAYOUT_MONO, olive::core::SampleFormat::S16);
olive::core::AudioParams params(44100, AV_CH_LAYOUT_MONO,
olive::core::SampleFormat::S16);
EXPECT_TRUE(params.is_valid());
params.set_sample_rate(48000);
+10 -5
View File
@@ -75,7 +75,8 @@ TEST(SpscRingBuffer, WrapAround)
TEST(SpscRingBuffer, ConcurrentProducerConsumer)
{
constexpr uint32_t kCapacity = 1024;
constexpr uint32_t kCount = 2'000'000; // values 0..kCount-1 streamed through the ring
constexpr uint32_t kCount =
2'000'000; // values 0..kCount-1 streamed through the ring
std::vector<uint8_t> mem(SpscRingBuffer::BytesNeeded(kCapacity));
SpscRingBuffer *ring = SpscRingBuffer::Create(mem.data(), kCapacity);
@@ -124,7 +125,8 @@ TEST(FrameSlotPool, SingleThreadedHandoff)
constexpr size_t kSlotBytes = 256;
std::vector<uint8_t> mem(FrameSlotPool::BytesNeeded(kSlots, kSlotBytes));
FrameSlotPool filler = FrameSlotPool::Create(mem.data(), kSlots, kSlotBytes);
FrameSlotPool filler =
FrameSlotPool::Create(mem.data(), kSlots, kSlotBytes);
FrameSlotPool drainer = FrameSlotPool::Attach(mem.data());
ASSERT_TRUE(filler.IsValid());
@@ -156,7 +158,8 @@ TEST(FrameSlotPool, SingleThreadedHandoff)
EXPECT_EQ(got_meta->id, 4242);
EXPECT_EQ(got_meta->width, 16);
const auto *got_data = static_cast<const uint8_t *>(drainer.SlotData(got_idx));
const auto *got_data =
static_cast<const uint8_t *>(drainer.SlotData(got_idx));
for (size_t i = 0; i < kSlotBytes; i++) {
ASSERT_EQ(got_data[i], uint8_t(i & 0xFF));
}
@@ -202,7 +205,8 @@ TEST(FrameSlotPool, ConcurrentFillDrainIntegrity)
constexpr int64_t kFrames = 200'000;
std::vector<uint8_t> mem(FrameSlotPool::BytesNeeded(kSlots, kSlotBytes));
FrameSlotPool filler = FrameSlotPool::Create(mem.data(), kSlots, kSlotBytes);
FrameSlotPool filler =
FrameSlotPool::Create(mem.data(), kSlots, kSlotBytes);
FrameSlotPool drainer = FrameSlotPool::Attach(mem.data());
std::atomic<bool> integrity_ok{ true };
@@ -349,7 +353,8 @@ TEST(IpcMessage, PartialFrameByteByByte)
CancelMsg c;
c.ticket_id = 7;
const QByteArray full =
QByteArray(QJsonDocument(c.ToJson()).toJson(QJsonDocument::Compact)) + '\n';
QByteArray(QJsonDocument(c.ToJson()).toJson(QJsonDocument::Compact)) +
'\n';
// Feed the bytes one at a time; ReadMessage must return false until the terminating '\n'.
QByteArray reader;
+17 -20
View File
@@ -15,29 +15,27 @@ TEST(RenderVideoParams, BytesPerChannelAndPixel)
EXPECT_EQ(olive::VideoParams::GetBytesPerChannel(
olive::core::PixelFormat::INVALID),
0);
EXPECT_EQ(olive::VideoParams::GetBytesPerChannel(
olive::core::PixelFormat::U8),
EXPECT_EQ(
olive::VideoParams::GetBytesPerChannel(olive::core::PixelFormat::U8),
1);
EXPECT_EQ(olive::VideoParams::GetBytesPerChannel(
olive::core::PixelFormat::U16),
EXPECT_EQ(
olive::VideoParams::GetBytesPerChannel(olive::core::PixelFormat::U16),
2);
EXPECT_EQ(olive::VideoParams::GetBytesPerChannel(
olive::core::PixelFormat::F16),
EXPECT_EQ(
olive::VideoParams::GetBytesPerChannel(olive::core::PixelFormat::F16),
2);
EXPECT_EQ(olive::VideoParams::GetBytesPerChannel(
olive::core::PixelFormat::F32),
EXPECT_EQ(
olive::VideoParams::GetBytesPerChannel(olive::core::PixelFormat::F32),
4);
EXPECT_EQ(olive::VideoParams::GetBytesPerPixel(
olive::core::PixelFormat::U8, 4),
EXPECT_EQ(olive::VideoParams::GetBytesPerPixel(olive::core::PixelFormat::U8,
4),
4);
}
TEST(RenderVideoParams, DividerAndFormatNames)
{
EXPECT_EQ(olive::VideoParams::GetNameForDivider(1),
QStringLiteral("Full"));
EXPECT_EQ(olive::VideoParams::GetNameForDivider(3),
QStringLiteral("1/3"));
EXPECT_EQ(olive::VideoParams::GetNameForDivider(1), QStringLiteral("Full"));
EXPECT_EQ(olive::VideoParams::GetNameForDivider(3), QStringLiteral("1/3"));
const QString unknown =
olive::VideoParams::GetFormatName(olive::core::PixelFormat::INVALID);
@@ -47,11 +45,11 @@ TEST(RenderVideoParams, DividerAndFormatNames)
TEST(RenderVideoParams, ScalingAndDividerForTarget)
{
EXPECT_EQ(olive::VideoParams::GetScaledDimension(100, 3), 33);
EXPECT_EQ(olive::VideoParams::GetDividerForTargetResolution(
1920, 1080, 960, 540),
EXPECT_EQ(olive::VideoParams::GetDividerForTargetResolution(1920, 1080, 960,
540),
2);
EXPECT_EQ(olive::VideoParams::GetDividerForTargetResolution(
1920, 1080, 480, 270),
EXPECT_EQ(olive::VideoParams::GetDividerForTargetResolution(1920, 1080, 480,
270),
4);
}
@@ -191,8 +189,7 @@ TEST(RenderVideoParams, SaveLoadRoundTripExtended)
EXPECT_FLOAT_EQ(loaded.x(), 1.5f);
EXPECT_FLOAT_EQ(loaded.y(), -2.25f);
EXPECT_EQ(loaded.stream_index(), 7);
EXPECT_EQ(loaded.video_type(),
olive::VideoParams::kVideoTypeImageSequence);
EXPECT_EQ(loaded.video_type(), olive::VideoParams::kVideoTypeImageSequence);
EXPECT_EQ(loaded.frame_rate(), olive::core::rational(30000, 1001));
EXPECT_EQ(loaded.start_time(), 123);
EXPECT_EQ(loaded.duration(), 456);
+42 -29
View File
@@ -49,7 +49,8 @@
using namespace olive;
using namespace olive::core;
namespace {
namespace
{
#ifdef OAK_ENABLE_DYNAMIC_RENDER_BACKEND
bool IsRenderBackendAvailable(const QString &backend)
@@ -140,8 +141,10 @@ void SaveFrameAsPng(const void *data, int width, int height,
for (int x = 0; x < width; ++x) {
for (int c = 0; c < 4; ++c) {
float v = src[(y * width + x) * 4 + c];
if (v < 0.0f) v = 0.0f;
if (v > 1.0f) v = 1.0f;
if (v < 0.0f)
v = 0.0f;
if (v > 1.0f)
v = 1.0f;
dst[(x * 4) + c] = static_cast<uchar>(v * 255.0f);
}
}
@@ -210,8 +213,8 @@ protected:
temp_dir_.filePath(QStringLiteral("worker_graph.ove")));
ProjectSerializer::Result r = ProjectSerializer::Save(
ProjectSerializer::SaveData(ProjectSerializer::kProject, project_.get(),
project_file_),
ProjectSerializer::SaveData(ProjectSerializer::kProject,
project_.get(), project_file_),
false);
ASSERT_EQ(r.code(), ProjectSerializer::kSuccess)
<< "Failed to save project file: " << r.GetDetails().toStdString();
@@ -222,7 +225,8 @@ protected:
{
// ---- decode a frame so we know the dimensions and slot sizes ----
DecoderPtr decoder = Decoder::CreateFromID(QStringLiteral("ffmpeg"));
if (!decoder || !decoder->Open(Decoder::CodecStream(demo_path_, 0, nullptr))) {
if (!decoder ||
!decoder->Open(Decoder::CodecStream(demo_path_, 0, nullptr))) {
return false;
}
Decoder::RetrieveVideoParams retrieve;
@@ -251,10 +255,10 @@ protected:
output_shm_key_ = ipc::SharedMemoryRegion::MakeKey(owner_pid, 0);
input_shm_key_ = ipc::SharedMemoryRegion::MakeKey(owner_pid, 1);
const size_t output_bytes = ipc::FrameSlotPool::BytesNeeded(
kOutputSlots, output_data_bytes_);
const size_t input_bytes = ipc::FrameSlotPool::BytesNeeded(
kInputSlots, input_data_bytes_);
const size_t output_bytes =
ipc::FrameSlotPool::BytesNeeded(kOutputSlots, output_data_bytes_);
const size_t input_bytes =
ipc::FrameSlotPool::BytesNeeded(kInputSlots, input_data_bytes_);
if (!output_region_.Open(output_shm_key_, output_bytes,
ipc::SharedMemoryRegion::kCreate)) {
@@ -278,7 +282,8 @@ protected:
// ---- spawn worker ----
worker_.setProcessChannelMode(QProcess::SeparateChannels);
worker_.start(worker_path_, QStringList{QStringLiteral("--backend"), backend});
worker_.start(worker_path_,
QStringList{ QStringLiteral("--backend"), backend });
if (!worker_.waitForStarted(kTimeoutMs)) {
return false;
}
@@ -333,8 +338,8 @@ protected:
if (!input_pool_->Acquire(&input_slot)) {
return false;
}
std::memcpy(input_pool_->SlotData(input_slot), decoded_frame_->const_data(),
input_data_bytes_);
std::memcpy(input_pool_->SlotData(input_slot),
decoded_frame_->const_data(), input_data_bytes_);
ipc::FrameSlotMeta *meta = input_pool_->Meta(input_slot);
meta->id = 0;
meta->time_num = 0;
@@ -345,7 +350,8 @@ protected:
meta->channel_count = decoded_frame_->channel_count();
meta->linesize = input_stride_;
meta->data_size = int32_t(input_data_bytes_);
std::strncpy(meta->colorspace,
std::strncpy(
meta->colorspace,
decoded_frame_->video_params().colorspace().toUtf8().constData(),
sizeof(meta->colorspace) - 1);
meta->colorspace[sizeof(meta->colorspace) - 1] = '\0';
@@ -363,7 +369,8 @@ protected:
req.mode = int(RenderMode::kOnline);
req.input_slot = 0;
if (!ipc::WriteMessage(&worker_, req.ToJson())) {
std::cerr << "RenderFrameAndWait: failed to write request" << std::endl;
std::cerr << "RenderFrameAndWait: failed to write request"
<< std::endl;
return false;
}
@@ -378,7 +385,8 @@ protected:
std::cerr << "RenderFrameAndWait: unexpected message type "
<< ready[QStringLiteral("type")].toString().toStdString()
<< " body="
<< QJsonDocument(ready).toJson(QJsonDocument::Compact)
<< QJsonDocument(ready)
.toJson(QJsonDocument::Compact)
.toStdString()
<< std::endl;
return false;
@@ -407,8 +415,9 @@ protected:
if (worker_.state() == QProcess::NotRunning) {
std::cerr << "WaitForMessage: worker exited with code "
<< worker_.exitCode() << std::endl;
std::cerr << "Worker stdout buffer: "
<< read_buffer_.toStdString() << std::endl;
std::cerr
<< "Worker stdout buffer: " << read_buffer_.toStdString()
<< std::endl;
QByteArray err = worker_.readAllStandardError();
if (!err.isEmpty()) {
std::cerr << "Worker stderr:\n"
@@ -417,8 +426,9 @@ protected:
return false;
}
}
std::cerr << "WaitForMessage: timeout, buffer="
<< read_buffer_.toStdString() << std::endl;
std::cerr
<< "WaitForMessage: timeout, buffer=" << read_buffer_.toStdString()
<< std::endl;
return false;
}
@@ -473,19 +483,21 @@ TEST_F(RenderWorkerFootageTest, VulkanFootageIsNotBlack)
ASSERT_EQ(int(consumed_slot), output_slot);
const void *output_data = output_pool_->SlotData(consumed_slot);
const double brightness = SampleBrightnessF32(
output_data, output_width_, output_height_,
const double brightness =
SampleBrightnessF32(output_data, output_width_, output_height_,
output_width_ * 4 * int(sizeof(float)));
EXPECT_GT(brightness, 0.01)
<< "Worker output frame is black (brightness=" << brightness << ")";
SaveFrameAsPng(output_data, output_width_, output_height_,
SaveFrameAsPng(
output_data, output_width_, output_height_,
temp_dir_.filePath(QStringLiteral("worker_output_vulkan.png")));
QFile::remove(QStringLiteral("/tmp/worker_output_vulkan.png"));
QFile::copy(temp_dir_.filePath(QStringLiteral("worker_output_vulkan.png")),
QStringLiteral("/tmp/worker_output_vulkan.png"));
std::cerr << "Vulkan output copied to /tmp/worker_output_vulkan.png" << std::endl;
std::cerr << "Vulkan output copied to /tmp/worker_output_vulkan.png"
<< std::endl;
output_pool_->Release(consumed_slot);
}
@@ -507,19 +519,20 @@ TEST_F(RenderWorkerFootageTest, OpenGLFootageIsNotBlack)
ASSERT_EQ(int(consumed_slot), output_slot);
const void *output_data = output_pool_->SlotData(consumed_slot);
const double brightness = SampleBrightnessF32(
output_data, output_width_, output_height_,
const double brightness =
SampleBrightnessF32(output_data, output_width_, output_height_,
output_width_ * 4 * int(sizeof(float)));
EXPECT_GT(brightness, 0.01)
<< "Worker output frame is black (brightness=" << brightness << ")";
SaveFrameAsPng(output_data, output_width_, output_height_,
SaveFrameAsPng(
output_data, output_width_, output_height_,
temp_dir_.filePath(QStringLiteral("worker_output_opengl.png")));
QFile::remove(QStringLiteral("/tmp/worker_output_opengl.png"));
QFile::copy(temp_dir_.filePath(QStringLiteral("worker_output_opengl.png")),
QStringLiteral("/tmp/worker_output_opengl.png"));
std::cerr << "OpenGL output copied to /tmp/worker_output_opengl.png" << std::endl;
std::cerr << "OpenGL output copied to /tmp/worker_output_opengl.png"
<< std::endl;
output_pool_->Release(consumed_slot);
}
+2 -2
View File
@@ -51,8 +51,8 @@ TEST(Shaders, ResourcesAvailable)
for (const QString &path : shader_paths) {
QFile file(path);
ASSERT_TRUE(file.exists()) << "Missing shader resource: "
<< path.toStdString();
ASSERT_TRUE(file.exists())
<< "Missing shader resource: " << path.toStdString();
ASSERT_TRUE(file.open(QIODevice::ReadOnly))
<< "Failed to open shader resource: " << path.toStdString();
const QByteArray contents = file.readAll();
+4 -4
View File
@@ -5,7 +5,8 @@
#include "task/taskmanager.h"
namespace {
namespace
{
class DummyTask final : public olive::Task {
public:
explicit DummyTask(bool *ran)
@@ -74,9 +75,8 @@ TEST(TaskManager, AddAndRunTask)
DummyTask *task = new DummyTask(&ran);
QEventLoop loop;
QObject::connect(task, &olive::Task::Finished, &loop, [&loop](olive::Task *, bool) {
loop.quit();
});
QObject::connect(task, &olive::Task::Finished, &loop,
[&loop](olive::Task *, bool) { loop.quit(); });
mgr->AddTask(task);
+10 -11
View File
@@ -36,8 +36,8 @@ TEST(TimecodeMetadata, ParsesDropFrameTimecode)
TEST(TimecodeMetadata, ParsesBwfTimeReference)
{
const olive::TimecodeMetadata::SourceTime parsed =
olive::TimecodeMetadata::FromBwfTimeReference(
QStringLiteral("96000"), 48000);
olive::TimecodeMetadata::FromBwfTimeReference(QStringLiteral("96000"),
48000);
ASSERT_TRUE(parsed.valid);
EXPECT_EQ(parsed.source, QStringLiteral("bwf_time_reference"));
@@ -63,19 +63,19 @@ TEST(TimecodeMetadata, RejectsInvalidMetadata)
EXPECT_FALSE(olive::TimecodeMetadata::FromBwfTimeReference(
QStringLiteral("not-a-number"), 48000)
.valid);
EXPECT_FALSE(olive::TimecodeMetadata::FromBwfTimeReference(
QStringLiteral("123"), 0)
EXPECT_FALSE(
olive::TimecodeMetadata::FromBwfTimeReference(QStringLiteral("123"), 0)
.valid);
EXPECT_FALSE(olive::TimecodeMetadata::FromTimecodeString(
QStringLiteral("not-a-timecode"),
olive::core::rational(1, 24))
EXPECT_FALSE(
olive::TimecodeMetadata::FromTimecodeString(
QStringLiteral("not-a-timecode"), olive::core::rational(1, 24))
.valid);
}
TEST(TimecodeMetadata, FromBwfTimeReferenceZeroSampleRateIsInvalid)
{
EXPECT_FALSE(olive::TimecodeMetadata::FromBwfTimeReference(
QStringLiteral("0"), 0)
EXPECT_FALSE(
olive::TimecodeMetadata::FromBwfTimeReference(QStringLiteral("0"), 0)
.valid);
}
@@ -113,8 +113,7 @@ TEST(TimecodeMetadata, FootagePersistsSourceStartTime)
writer.writeStartElement(QStringLiteral("custom"));
writer.writeTextElement(QStringLiteral("timestamp"), QStringLiteral("0"));
writer.writeStartElement(QStringLiteral("sourcestarttime"));
writer.writeAttribute(QStringLiteral("source"),
QStringLiteral("timecode"));
writer.writeAttribute(QStringLiteral("source"), QStringLiteral("timecode"));
writer.writeCharacters(QStringLiteral("3600/1"));
writer.writeEndElement();
writer.writeEndElement();
+8 -4
View File
@@ -52,13 +52,17 @@ TEST(TimelineCoordinate, CopyAndAssignment)
TEST(TimelineCoordinate, Equality)
{
olive::TimelineCoordinate a(olive::core::rational(5, 1),
olive::Track::Reference(olive::Track::kVideo, 1));
olive::Track::Reference(olive::Track::kVideo,
1));
olive::TimelineCoordinate b(olive::core::rational(5, 1),
olive::Track::Reference(olive::Track::kVideo, 1));
olive::Track::Reference(olive::Track::kVideo,
1));
olive::TimelineCoordinate c(olive::core::rational(6, 1),
olive::Track::Reference(olive::Track::kVideo, 1));
olive::Track::Reference(olive::Track::kVideo,
1));
olive::TimelineCoordinate d(olive::core::rational(5, 1),
olive::Track::Reference(olive::Track::kAudio, 1));
olive::Track::Reference(olive::Track::kAudio,
1));
EXPECT_EQ(a.GetFrame(), b.GetFrame());
EXPECT_EQ(a.GetTrack(), b.GetTrack());
+10 -17
View File
@@ -51,20 +51,17 @@ TEST(TimelineMarkerList, OrderAndLookup)
1,
olive::core::TimeRange(olive::core::rational(10, 1),
olive::core::rational(10, 1)),
QStringLiteral("A"),
&list);
QStringLiteral("A"), &list);
olive::TimelineMarker marker_b(
2,
olive::core::TimeRange(olive::core::rational(5, 1),
olive::core::rational(5, 1)),
QStringLiteral("B"),
&list);
QStringLiteral("B"), &list);
olive::TimelineMarker marker_c(
3,
olive::core::TimeRange(olive::core::rational(20, 1),
olive::core::rational(20, 1)),
QStringLiteral("C"),
&list);
QStringLiteral("C"), &list);
ASSERT_EQ(list.size(), 3);
auto it = list.cbegin();
@@ -85,7 +82,8 @@ TEST(TimelineMarkerList, GetMarkerAtTimeReturnsNullWhenEmpty)
{
olive::TimelineMarkerList list;
EXPECT_EQ(list.GetMarkerAtTime(olive::core::rational(10, 1)), nullptr);
EXPECT_EQ(list.GetClosestMarkerToTime(olive::core::rational(10, 1)), nullptr);
EXPECT_EQ(list.GetClosestMarkerToTime(olive::core::rational(10, 1)),
nullptr);
}
TEST(TimelineMarkerList, SaveLoadWithUnknownElements)
@@ -95,8 +93,7 @@ TEST(TimelineMarkerList, SaveLoadWithUnknownElements)
4,
olive::core::TimeRange(olive::core::rational(12, 1),
olive::core::rational(15, 1)),
QStringLiteral("Span"),
&list);
QStringLiteral("Span"), &list);
QByteArray xml;
QBuffer buffer(&xml);
@@ -130,8 +127,7 @@ TEST(TimelineMarkerCommands, AddRemoveAndChange)
&list,
olive::core::TimeRange(olive::core::rational(1, 1),
olive::core::rational(2, 1)),
QStringLiteral("One"),
1);
QStringLiteral("One"), 1);
add.redo_now();
ASSERT_EQ(list.size(), 1);
auto *marker = list.front();
@@ -159,13 +155,11 @@ TEST(TimelineMarkerCommands, AddRemoveAndChange)
2,
olive::core::TimeRange(olive::core::rational(5, 1),
olive::core::rational(5, 1)),
QStringLiteral("Two"),
&list);
QStringLiteral("Two"), &list);
EXPECT_EQ(list.front()->time().in(), olive::core::rational(1, 1));
olive::MarkerChangeTimeCommand move(
marker,
olive::core::TimeRange(olive::core::rational(0, 1),
marker, olive::core::TimeRange(olive::core::rational(0, 1),
olive::core::rational(0, 1)));
move.redo_now();
EXPECT_EQ(list.front(), marker);
@@ -180,8 +174,7 @@ TEST(TimelineMarkerCommands, AddCommandUndo)
&list,
olive::core::TimeRange(olive::core::rational(5, 1),
olive::core::rational(5, 1)),
QStringLiteral("UndoMe"),
2);
QStringLiteral("UndoMe"), 2);
add.redo_now();
EXPECT_EQ(list.size(), 1);
add.undo_now();
+6 -7
View File
@@ -24,7 +24,8 @@ extern "C" {
using namespace olive;
using namespace olive::core;
namespace {
namespace
{
AudioParams MakeMonoParams(int sample_rate)
{
@@ -55,8 +56,7 @@ void WritePartialWaveform(AudioWaveformCache *cache, int sample_rate)
waveform.OverwriteSamples(buf, sample_rate, rational(1));
// Tell the cache that only the middle second is valid in a 3-second clip.
cache->WriteWaveform(TimeRange(1, 2),
TimeRangeList({ TimeRange(1, 2) }),
cache->WriteWaveform(TimeRange(1, 2), TimeRangeList({ TimeRange(1, 2) }),
&waveform);
}
@@ -76,8 +76,8 @@ TEST(TimelineWaveformSync, ExtractEnvelopeUsesOnlyValidatedRanges)
clip.sample_rate = kSampleRate;
const QVector<double> envelope =
TimelineWaveformSync::ExtractWaveformCacheEnvelope(
clip, kSampleRate, kWindowSamples);
TimelineWaveformSync::ExtractWaveformCacheEnvelope(clip, kSampleRate,
kWindowSamples);
// 3 seconds at 20 windows per second == 60 windows.
EXPECT_EQ(envelope.size(), 60);
@@ -134,8 +134,7 @@ TEST(TimelineWaveformSync, EmptyCacheIsNotReady)
clip.set_length_and_media_out(rational(3));
clip.set_media_in(rational(0));
Node::ConnectEdge(
&footage, NodeInput(&clip, ClipBlock::kBufferIn));
Node::ConnectEdge(&footage, NodeInput(&clip, ClipBlock::kBufferIn));
WaveformSyncClip out;
EXPECT_FALSE(TimelineWaveformSync::GetWaveformSyncClip(&clip, &out));
+2 -1
View File
@@ -5,7 +5,8 @@
#include "undo/undostack.h"
#include "undo/undocommand.h"
namespace {
namespace
{
class TestCommand final : public olive::UndoCommand {
public:
explicit TestCommand(int *value)
+11 -5
View File
@@ -25,9 +25,12 @@
using namespace olive;
using namespace olive::core;
namespace olive {
namespace viewer {
namespace test {
namespace olive
{
namespace viewer
{
namespace test
{
// ============================================================================
// Smoke Test: ViewerPlaybackTimer
@@ -492,9 +495,12 @@ TEST(ViewerSmokeThread, ConcurrentQueueAccess)
std::atomic<int> append_count{ 0 };
for (int t = 0; t < num_threads; ++t) {
threads.emplace_back([&queue, &append_count, t, num_frames_per_thread]() {
threads.emplace_back(
[&queue, &append_count, t, num_frames_per_thread]() {
for (int i = 0; i < num_frames_per_thread; ++i) {
ViewerPlaybackFrame frame{rational(t * num_frames_per_thread + i, 24), QVariant()};
ViewerPlaybackFrame frame{
rational(t * num_frames_per_thread + i, 24), QVariant()
};
queue.AppendTimewise(frame, 1);
append_count++;
}