Automated with clang-tidy readability-identifier-naming (config added to .clang-tidy) plus scripted passes, per the updated rules now documented in CONTRIBUTING.md: - types (class/struct/enum/alias/template params): PascalCase - functions, variables, members: snake_case (incl. rational -> Rational) - private/protected members: trailing underscore; static member variables likewise (instance_, available_themes_) - constants and enum values: snake_case (kLinear -> k_linear, F32P -> f32p); ALL_CAPS reserved for macros - macros: OAK_ prefix (OLIVE_ADD_TEST/OLIVE_ASSERT/OLIVE_CONFIG -> OAK_ADD_TEST/OAK_ASSERT/OAK_CONFIG, GL_PREAMBLE -> OAK_GL_PREAMBLE, include guards -> OAK_*) - file names: all lowercase (Current/Plugin/OliveHost/OliveClip/ OlivePluginInstance -> current/plugin/olivehost/oliveclip/ oliveplugininstance) - getters share the member name sans underscore, setters set_foo() - Qt and third-party (OpenFX) virtual overrides and framework callbacks keep their original names (exempt in .clang-tidy) Manual follow-ups required where automation could not reach: - string-based QMetaObject/SIGNAL/SLOT references updated to renamed methods (AddTask, CreatedFile, DeleteSpecificFile, moveSelectionUp, ...) - macro bodies referencing renamed methods (OLIVE_CONFIG, NODE_DEFAULT_DESTRUCTOR, MANAGEDDISPLAYWIDGET_*) - self-shadowing locals renamed where signals/methods became same-named (size_changed, worker_count, selected_items, import param, filters) - third_party OFX member/namespace usages restored (OFX::Host::*, _created, _clipPrefsDirty, createInstance, clearPersistentMessage) - STL protocol aliases restored (const_iterator) with .clang-tidy ignore rules; qHash overloads restored Full build and test suite pass: ctest 4/4, ~1960 gtest cases green.
100 lines
3.2 KiB
C++
100 lines
3.2 KiB
C++
#include <gtest/gtest.h>
|
|
|
|
#include "ofxImageEffect.h"
|
|
#include "ofxhClip.h"
|
|
#include "pluginSupport/oliveclip.h"
|
|
|
|
namespace
|
|
{
|
|
olive::VideoParams make_params(int width, int height,
|
|
olive::core::PixelFormat format, int channels,
|
|
bool premultiplied)
|
|
{
|
|
olive::VideoParams params;
|
|
params.set_width(width);
|
|
params.set_height(height);
|
|
params.set_format(format);
|
|
params.set_channel_count(channels);
|
|
params.set_premultiplied_alpha(premultiplied);
|
|
return params;
|
|
}
|
|
}
|
|
|
|
TEST(PluginSupportClip, PropertyGetters)
|
|
{
|
|
OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName);
|
|
olive::VideoParams params =
|
|
make_params(1920, 1080, olive::core::PixelFormat::u16, 3, false);
|
|
params.set_pixel_aspect_ratio(olive::core::Rational(2, 1));
|
|
params.set_frame_rate(olive::core::Rational(30, 1));
|
|
params.set_start_time(2);
|
|
params.set_duration(4);
|
|
params.set_interlacing(olive::VideoParams::k_interlaced_top_first);
|
|
|
|
olive::plugin::OliveClipInstance clip(nullptr, desc, params);
|
|
|
|
EXPECT_EQ(clip.getUnmappedBitDepth(), kOfxBitDepthShort);
|
|
EXPECT_EQ(clip.getUnmappedComponents(), kOfxImageComponentRGB);
|
|
EXPECT_EQ(clip.getPremult(), kOfxImageUnPreMultiplied);
|
|
EXPECT_DOUBLE_EQ(clip.getAspectRatio(), 2.0);
|
|
EXPECT_DOUBLE_EQ(clip.getFrameRate(), 30.0);
|
|
|
|
double start_frame = 0.0;
|
|
double end_frame = 0.0;
|
|
clip.getFrameRange(start_frame, end_frame);
|
|
EXPECT_DOUBLE_EQ(start_frame, 60.0);
|
|
EXPECT_DOUBLE_EQ(end_frame, 180.0);
|
|
|
|
EXPECT_EQ(clip.getFieldOrder(), kOfxImageFieldUpper);
|
|
EXPECT_DOUBLE_EQ(clip.getUnmappedFrameRate(), 30.0);
|
|
|
|
clip.getUnmappedFrameRange(start_frame, end_frame);
|
|
EXPECT_DOUBLE_EQ(start_frame, 60.0);
|
|
EXPECT_DOUBLE_EQ(end_frame, 180.0);
|
|
|
|
EXPECT_FALSE(clip.getContinuousSamples());
|
|
EXPECT_FALSE(clip.getConnected());
|
|
}
|
|
|
|
TEST(PluginSupportClip, GetImageClampsBoundsAndCachesOutput)
|
|
{
|
|
OFX::Host::ImageEffect::ClipDescriptor desc(kOfxImageEffectOutputClipName);
|
|
olive::VideoParams params =
|
|
make_params(100, 80, olive::core::PixelFormat::u8, 4, true);
|
|
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);
|
|
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);
|
|
EXPECT_EQ(image, image_again);
|
|
}
|
|
|
|
TEST(PluginSupportClip, GetImageCachesImageForNonOutput)
|
|
{
|
|
OFX::Host::ImageEffect::ClipDescriptor desc("Source");
|
|
olive::VideoParams params =
|
|
make_params(64, 64, olive::core::PixelFormat::u8, 4, false);
|
|
olive::plugin::OliveClipInstance clip(nullptr, desc, params);
|
|
|
|
EXPECT_FALSE(clip.getConnected());
|
|
|
|
OFX::Host::ImageEffect::Image *first = clip.getImage(0.0, nullptr);
|
|
OFX::Host::ImageEffect::Image *second = clip.getImage(0.0, nullptr);
|
|
|
|
EXPECT_NE(first, nullptr);
|
|
EXPECT_NE(second, nullptr);
|
|
// On-demand images are cached per time, so both fetches return the
|
|
// same image and the clip now reports as connected.
|
|
EXPECT_EQ(first, second);
|
|
EXPECT_TRUE(clip.getConnected());
|
|
|
|
first->releaseReference();
|
|
second->releaseReference();
|
|
}
|