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.
108 lines
2.7 KiB
C++
108 lines
2.7 KiB
C++
#include <gtest/gtest.h>
|
|
|
|
#include <QDir>
|
|
#include <QFile>
|
|
#include <QSignalSpy>
|
|
#include <QTemporaryDir>
|
|
|
|
#include "config/config.h"
|
|
#include "render/lutlibrary.h"
|
|
#include "widget/filefield/lutfilefield.h"
|
|
|
|
namespace
|
|
{
|
|
|
|
class LutLibraryConfigGuard {
|
|
public:
|
|
LutLibraryConfigGuard()
|
|
: previous_(olive::Config::current()[QStringLiteral("LUTLibraryPaths")]
|
|
.toString())
|
|
{
|
|
}
|
|
|
|
~LutLibraryConfigGuard()
|
|
{
|
|
olive::Config::current()[QStringLiteral("LUTLibraryPaths")] = previous_;
|
|
}
|
|
|
|
private:
|
|
QString previous_;
|
|
};
|
|
|
|
QString write_file(const QString &path)
|
|
{
|
|
QFile file(path);
|
|
if (!file.open(QIODevice::WriteOnly)) {
|
|
return QString();
|
|
}
|
|
file.close();
|
|
return path;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
TEST(LutFileField, PopulatesComboFromLibrary)
|
|
{
|
|
LutLibraryConfigGuard guard;
|
|
|
|
QTemporaryDir dir;
|
|
ASSERT_TRUE(dir.isValid());
|
|
|
|
const QString cube =
|
|
write_file(QDir(dir.path()).filePath(QStringLiteral("a.cube")));
|
|
const QString three_dl =
|
|
write_file(QDir(dir.path()).filePath(QStringLiteral("b.3dl")));
|
|
const QString other =
|
|
write_file(QDir(dir.path()).filePath(QStringLiteral("c.txt")));
|
|
ASSERT_FALSE(cube.isEmpty());
|
|
ASSERT_FALSE(three_dl.isEmpty());
|
|
ASSERT_FALSE(other.isEmpty());
|
|
|
|
olive::LUTLibrary::set_directories({ dir.path() });
|
|
|
|
olive::LutFileField field;
|
|
|
|
// One "Other" entry plus one entry per supported LUT
|
|
ASSERT_EQ(field.library_combo()->count(), 3);
|
|
EXPECT_TRUE(field.library_combo()->itemData(0).toString().isEmpty());
|
|
EXPECT_GE(field.library_combo()->findData(cube), 1);
|
|
EXPECT_GE(field.library_combo()->findData(three_dl), 1);
|
|
EXPECT_EQ(field.library_combo()->findData(other), -1);
|
|
}
|
|
|
|
TEST(LutFileField, SelectionFollowsFilenameAndEmitsOnPick)
|
|
{
|
|
LutLibraryConfigGuard guard;
|
|
|
|
QTemporaryDir dir;
|
|
ASSERT_TRUE(dir.isValid());
|
|
|
|
const QString cube =
|
|
write_file(QDir(dir.path()).filePath(QStringLiteral("a.cube")));
|
|
ASSERT_FALSE(cube.isEmpty());
|
|
|
|
olive::LUTLibrary::set_directories({ dir.path() });
|
|
|
|
olive::LutFileField field;
|
|
|
|
// A path that is not in the library shows the "Other" entry
|
|
field.set_filename(QStringLiteral("/custom/elsewhere.cube"));
|
|
EXPECT_EQ(field.library_combo()->currentIndex(), 0);
|
|
|
|
// A library path selects its entry
|
|
field.set_filename(cube);
|
|
EXPECT_GT(field.library_combo()->currentIndex(), 0);
|
|
|
|
// Picking a library entry updates the filename and emits the change
|
|
// signal so the parameter bridge applies it like any other edit
|
|
field.set_filename(QString());
|
|
QSignalSpy spy(&field, &olive::FileField::filename_changed);
|
|
const int index = field.library_combo()->findData(cube);
|
|
ASSERT_GE(index, 1);
|
|
emit field.library_combo()->activated(index);
|
|
|
|
EXPECT_EQ(field.get_filename(), cube);
|
|
ASSERT_EQ(spy.count(), 1);
|
|
EXPECT_EQ(spy.first().first().toString(), cube);
|
|
}
|