style: unify identifier naming per updated conventions
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.
This commit is contained in:
@@ -23,13 +23,13 @@ namespace
|
||||
{
|
||||
|
||||
// PlaybackControls and playhead seeking talk to the Core singleton
|
||||
void EnsureAppSingletons()
|
||||
void ensure_app_singletons()
|
||||
{
|
||||
if (!olive::Core::instance()) {
|
||||
new olive::Core(olive::Core::CoreParams()); // intentionally leaked
|
||||
}
|
||||
if (!olive::DiskManager::instance()) {
|
||||
olive::DiskManager::CreateInstance();
|
||||
olive::DiskManager::create_instance();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,12 +37,12 @@ void EnsureAppSingletons()
|
||||
|
||||
TEST(TimeRuler, ConstructionWithAndWithoutDecorations)
|
||||
{
|
||||
EnsureAppSingletons();
|
||||
ensure_app_singletons();
|
||||
|
||||
// Text shown, cache status hidden
|
||||
TimeRuler plain;
|
||||
EXPECT_EQ(plain.GetMarkers(), nullptr);
|
||||
EXPECT_EQ(plain.GetWorkArea(), nullptr);
|
||||
EXPECT_EQ(plain.get_markers(), nullptr);
|
||||
EXPECT_EQ(plain.get_work_area(), nullptr);
|
||||
|
||||
// Text hidden, cache status shown
|
||||
TimeRuler decorated(false, true);
|
||||
@@ -51,19 +51,19 @@ TEST(TimeRuler, ConstructionWithAndWithoutDecorations)
|
||||
// text height plus marker height always, another text height when text
|
||||
// is visible, and the cache indicator height when cache status is shown
|
||||
const QFontMetrics fm = plain.fontMetrics();
|
||||
const int marker_h = TimelineMarker::GetMarkerHeight(fm);
|
||||
const int marker_h = TimelineMarker::get_marker_height(fm);
|
||||
|
||||
EXPECT_EQ(plain.minimumHeight(), 2 * fm.height() + marker_h);
|
||||
EXPECT_EQ(plain.maximumHeight(), plain.minimumHeight());
|
||||
|
||||
EXPECT_EQ(decorated.minimumHeight(),
|
||||
fm.height() + PlaybackCache::GetCacheIndicatorHeight() + marker_h);
|
||||
fm.height() + PlaybackCache::get_cache_indicator_height() + marker_h);
|
||||
EXPECT_EQ(decorated.maximumHeight(), decorated.minimumHeight());
|
||||
|
||||
// Centered text only affects painting, not geometry
|
||||
decorated.SetCenteredText(true);
|
||||
decorated.set_centered_text(true);
|
||||
EXPECT_EQ(decorated.minimumHeight(),
|
||||
fm.height() + PlaybackCache::GetCacheIndicatorHeight() + marker_h);
|
||||
fm.height() + PlaybackCache::get_cache_indicator_height() + marker_h);
|
||||
}
|
||||
|
||||
TEST(TimeRuler, TimebaseAndScaleDriveTimePixelConversion)
|
||||
@@ -71,67 +71,67 @@ TEST(TimeRuler, TimebaseAndScaleDriveTimePixelConversion)
|
||||
TimeRuler ruler;
|
||||
|
||||
// Without a timebase everything collapses to zero
|
||||
EXPECT_DOUBLE_EQ(ruler.TimeToScene(rational(1)), 0.0);
|
||||
EXPECT_DOUBLE_EQ(ruler.time_to_scene(Rational(1)), 0.0);
|
||||
|
||||
ruler.SetTimebase(rational(1, 30));
|
||||
ruler.SetScale(100.0);
|
||||
ruler.set_timebase(Rational(1, 30));
|
||||
ruler.set_scale(100.0);
|
||||
|
||||
// One second at scale 100 lands at scene x=100, half a second at 50
|
||||
EXPECT_DOUBLE_EQ(ruler.TimeToScene(rational(1)), 100.0);
|
||||
EXPECT_DOUBLE_EQ(ruler.TimeToScene(rational(1, 2)), 50.0);
|
||||
EXPECT_DOUBLE_EQ(ruler.time_to_scene(Rational(1)), 100.0);
|
||||
EXPECT_DOUBLE_EQ(ruler.time_to_scene(Rational(1, 2)), 50.0);
|
||||
|
||||
// Inverse conversion returns whole frames in the ruler's timebase
|
||||
EXPECT_EQ(ruler.SceneToTime(100.0), rational(1));
|
||||
EXPECT_EQ(ruler.SceneToTime(50.0), rational(1, 2));
|
||||
EXPECT_EQ(ruler.scene_to_time(100.0), Rational(1));
|
||||
EXPECT_EQ(ruler.scene_to_time(50.0), Rational(1, 2));
|
||||
|
||||
// Fractional positions floor to the frame below (or ceil when negative)
|
||||
EXPECT_EQ(ruler.SceneToTime(51.0), rational(1, 2));
|
||||
EXPECT_EQ(ruler.SceneToTime(-51.0), rational(-1, 2));
|
||||
EXPECT_EQ(ruler.scene_to_time(51.0), Rational(1, 2));
|
||||
EXPECT_EQ(ruler.scene_to_time(-51.0), Rational(-1, 2));
|
||||
|
||||
// Rounding mode snaps to the nearest frame instead
|
||||
EXPECT_EQ(ruler.SceneToTime(51.0, true), rational(1, 2));
|
||||
EXPECT_EQ(ruler.SceneToTime(80.0, true), rational(4, 5));
|
||||
EXPECT_EQ(ruler.scene_to_time(51.0, true), Rational(1, 2));
|
||||
EXPECT_EQ(ruler.scene_to_time(80.0, true), Rational(4, 5));
|
||||
}
|
||||
|
||||
TEST(TimeRuler, SeekToScenePointSeeksConnectedViewer)
|
||||
{
|
||||
EnsureAppSingletons();
|
||||
ensure_app_singletons();
|
||||
|
||||
TimeRuler ruler;
|
||||
ruler.SetTimebase(rational(1, 30));
|
||||
ruler.SetScale(100.0);
|
||||
ruler.set_timebase(Rational(1, 30));
|
||||
ruler.set_scale(100.0);
|
||||
|
||||
ViewerOutput viewer;
|
||||
ruler.SetViewerNode(&viewer);
|
||||
ruler.set_viewer_node(&viewer);
|
||||
|
||||
ruler.SeekToScenePoint(150.0);
|
||||
EXPECT_EQ(viewer.GetPlayhead(), rational(3, 2));
|
||||
ruler.seek_to_scene_point(150.0);
|
||||
EXPECT_EQ(viewer.get_playhead(), Rational(3, 2));
|
||||
|
||||
// Positions before zero clamp to zero
|
||||
viewer.SetPlayhead(rational(5));
|
||||
ruler.SeekToScenePoint(-50.0);
|
||||
EXPECT_EQ(viewer.GetPlayhead(), rational(0));
|
||||
viewer.set_playhead(Rational(5));
|
||||
ruler.seek_to_scene_point(-50.0);
|
||||
EXPECT_EQ(viewer.get_playhead(), Rational(0));
|
||||
}
|
||||
|
||||
TEST(TimeRuler, SeekToScenePointWithoutTimebaseIsNoOp)
|
||||
{
|
||||
// No timebase and no viewer: must return before touching either
|
||||
TimeRuler ruler;
|
||||
ruler.SeekToScenePoint(150.0);
|
||||
ruler.seek_to_scene_point(150.0);
|
||||
SUCCEED();
|
||||
}
|
||||
|
||||
TEST(TimeRuler, SeekToScenePointWithoutViewerIsNoOp)
|
||||
{
|
||||
EnsureAppSingletons();
|
||||
ensure_app_singletons();
|
||||
|
||||
// Timebase set but no viewer connected: previously dereferenced a null
|
||||
// GetViewerNode() and crashed.
|
||||
TimeRuler ruler;
|
||||
ruler.SetTimebase(rational(1, 30));
|
||||
ruler.SetScale(100.0);
|
||||
ruler.set_timebase(Rational(1, 30));
|
||||
ruler.set_scale(100.0);
|
||||
|
||||
ruler.SeekToScenePoint(150.0);
|
||||
ruler.seek_to_scene_point(150.0);
|
||||
SUCCEED();
|
||||
}
|
||||
|
||||
@@ -139,12 +139,12 @@ class PlaybackControlsTest : public ::testing::Test {
|
||||
protected:
|
||||
void SetUp() override
|
||||
{
|
||||
EnsureAppSingletons();
|
||||
ensure_app_singletons();
|
||||
}
|
||||
|
||||
// The play/pause stacked widget (SliderBase is also a QStackedWidget
|
||||
// and must be filtered out)
|
||||
static QStackedWidget *PlayPauseStack(PlaybackControls *controls)
|
||||
static QStackedWidget *play_pause_stack(PlaybackControls *controls)
|
||||
{
|
||||
foreach (QStackedWidget *s, controls->findChildren<QStackedWidget *>()) {
|
||||
if (!qobject_cast<SliderBase *>(s)) {
|
||||
@@ -155,21 +155,21 @@ protected:
|
||||
}
|
||||
|
||||
// The play/pause buttons live inside the play/pause stacked widget
|
||||
static void PlayPauseButtons(PlaybackControls *controls,
|
||||
static void play_pause_buttons(PlaybackControls *controls,
|
||||
QPushButton **play_btn, QPushButton **pause_btn)
|
||||
{
|
||||
QStackedWidget *stack = PlayPauseStack(controls);
|
||||
QStackedWidget *stack = play_pause_stack(controls);
|
||||
*play_btn = qobject_cast<QPushButton *>(stack->widget(0));
|
||||
*pause_btn = qobject_cast<QPushButton *>(stack->widget(1));
|
||||
}
|
||||
|
||||
// The remaining buttons in creation order: go-to-start, previous frame,
|
||||
// next frame, go-to-end, video drag, audio drag
|
||||
static QList<QPushButton *> NavigationButtons(PlaybackControls *controls)
|
||||
static QList<QPushButton *> navigation_buttons(PlaybackControls *controls)
|
||||
{
|
||||
QPushButton *play_btn;
|
||||
QPushButton *pause_btn;
|
||||
PlayPauseButtons(controls, &play_btn, &pause_btn);
|
||||
play_pause_buttons(controls, &play_btn, &pause_btn);
|
||||
|
||||
QList<QPushButton *> buttons;
|
||||
foreach (QPushButton *b, controls->findChildren<QPushButton *>()) {
|
||||
@@ -186,35 +186,35 @@ TEST_F(PlaybackControlsTest, NullTimebaseDisablesWidget)
|
||||
PlaybackControls controls;
|
||||
EXPECT_FALSE(controls.isEnabled());
|
||||
|
||||
controls.SetTimebase(rational(1, 30));
|
||||
controls.set_timebase(Rational(1, 30));
|
||||
EXPECT_TRUE(controls.isEnabled());
|
||||
|
||||
controls.SetTimebase(rational());
|
||||
controls.set_timebase(Rational());
|
||||
EXPECT_FALSE(controls.isEnabled());
|
||||
}
|
||||
|
||||
TEST_F(PlaybackControlsTest, ButtonsEmitCorrespondingSignals)
|
||||
{
|
||||
PlaybackControls controls;
|
||||
controls.SetTimebase(rational(1, 30));
|
||||
controls.set_timebase(Rational(1, 30));
|
||||
|
||||
QPushButton *play_btn;
|
||||
QPushButton *pause_btn;
|
||||
PlayPauseButtons(&controls, &play_btn, &pause_btn);
|
||||
play_pause_buttons(&controls, &play_btn, &pause_btn);
|
||||
ASSERT_NE(play_btn, nullptr);
|
||||
ASSERT_NE(pause_btn, nullptr);
|
||||
|
||||
const QList<QPushButton *> buttons = NavigationButtons(&controls);
|
||||
const QList<QPushButton *> buttons = navigation_buttons(&controls);
|
||||
ASSERT_EQ(buttons.size(), 6);
|
||||
|
||||
QSignalSpy begin_spy(&controls, &PlaybackControls::BeginClicked);
|
||||
QSignalSpy prev_spy(&controls, &PlaybackControls::PrevFrameClicked);
|
||||
QSignalSpy play_spy(&controls, &PlaybackControls::PlayClicked);
|
||||
QSignalSpy pause_spy(&controls, &PlaybackControls::PauseClicked);
|
||||
QSignalSpy next_spy(&controls, &PlaybackControls::NextFrameClicked);
|
||||
QSignalSpy end_spy(&controls, &PlaybackControls::EndClicked);
|
||||
QSignalSpy video_spy(&controls, &PlaybackControls::VideoClicked);
|
||||
QSignalSpy audio_spy(&controls, &PlaybackControls::AudioClicked);
|
||||
QSignalSpy begin_spy(&controls, &PlaybackControls::begin_clicked);
|
||||
QSignalSpy prev_spy(&controls, &PlaybackControls::prev_frame_clicked);
|
||||
QSignalSpy play_spy(&controls, &PlaybackControls::play_clicked);
|
||||
QSignalSpy pause_spy(&controls, &PlaybackControls::pause_clicked);
|
||||
QSignalSpy next_spy(&controls, &PlaybackControls::next_frame_clicked);
|
||||
QSignalSpy end_spy(&controls, &PlaybackControls::end_clicked);
|
||||
QSignalSpy video_spy(&controls, &PlaybackControls::video_clicked);
|
||||
QSignalSpy audio_spy(&controls, &PlaybackControls::audio_clicked);
|
||||
|
||||
buttons.at(0)->click();
|
||||
EXPECT_EQ(begin_spy.count(), 1);
|
||||
@@ -244,15 +244,15 @@ TEST_F(PlaybackControlsTest, ButtonsEmitCorrespondingSignals)
|
||||
TEST_F(PlaybackControlsTest, SetTimeUpdatesCurrentTimecodeWithoutEmitting)
|
||||
{
|
||||
PlaybackControls controls;
|
||||
controls.SetTimebase(rational(1, 30));
|
||||
controls.set_timebase(Rational(1, 30));
|
||||
|
||||
auto *slider = controls.findChild<RationalSlider *>();
|
||||
ASSERT_NE(slider, nullptr);
|
||||
|
||||
QSignalSpy time_spy(&controls, &PlaybackControls::TimeChanged);
|
||||
QSignalSpy time_spy(&controls, &PlaybackControls::time_changed);
|
||||
|
||||
controls.SetTime(rational(3, 2));
|
||||
EXPECT_EQ(slider->GetValue(), rational(3, 2));
|
||||
controls.set_time(Rational(3, 2));
|
||||
EXPECT_EQ(slider->get_value(), Rational(3, 2));
|
||||
|
||||
// Programmatic updates must not feed back into TimeChanged
|
||||
EXPECT_EQ(time_spy.count(), 0);
|
||||
@@ -261,7 +261,7 @@ TEST_F(PlaybackControlsTest, SetTimeUpdatesCurrentTimecodeWithoutEmitting)
|
||||
TEST_F(PlaybackControlsTest, SetEndTimeFormatsEndTimecodeLabel)
|
||||
{
|
||||
PlaybackControls controls;
|
||||
controls.SetTimebase(rational(1, 30));
|
||||
controls.set_timebase(Rational(1, 30));
|
||||
|
||||
// The only plain QLabel is the end timecode; the current-time slider
|
||||
// uses a SliderLabel (a QLabel subclass) internally
|
||||
@@ -277,54 +277,54 @@ TEST_F(PlaybackControlsTest, SetEndTimeFormatsEndTimecodeLabel)
|
||||
// Pin the display mode so the expected strings don't depend on whatever
|
||||
// the config happens to hold
|
||||
const core::Timecode::Display saved_display =
|
||||
Core::instance()->GetTimecodeDisplay();
|
||||
Core::instance()->SetTimecodeDisplay(core::Timecode::kTimecodeNonDropFrame);
|
||||
Core::instance()->get_timecode_display();
|
||||
Core::instance()->set_timecode_display(core::Timecode::k_timecode_non_drop_frame);
|
||||
|
||||
// 30 seconds at 30 fps is frame 900 = 30 seconds + 0 frames
|
||||
controls.SetEndTime(rational(30));
|
||||
controls.set_end_time(Rational(30));
|
||||
EXPECT_EQ(end_label->text(), QStringLiteral("00:00:30:00"));
|
||||
|
||||
// 1.5 seconds at 30 fps is frame 45 = 1 second + 15 frames
|
||||
controls.SetEndTime(rational(3, 2));
|
||||
controls.set_end_time(Rational(3, 2));
|
||||
EXPECT_EQ(end_label->text(), QStringLiteral("00:00:01:15"));
|
||||
|
||||
Core::instance()->SetTimecodeDisplay(saved_display);
|
||||
Core::instance()->set_timecode_display(saved_display);
|
||||
}
|
||||
|
||||
TEST_F(PlaybackControlsTest, PlayPauseStackSwitchesVisibleButton)
|
||||
{
|
||||
PlaybackControls controls;
|
||||
|
||||
QStackedWidget *stack = PlayPauseStack(&controls);
|
||||
QStackedWidget *stack = play_pause_stack(&controls);
|
||||
ASSERT_NE(stack, nullptr);
|
||||
|
||||
QPushButton *play_btn;
|
||||
QPushButton *pause_btn;
|
||||
PlayPauseButtons(&controls, &play_btn, &pause_btn);
|
||||
play_pause_buttons(&controls, &play_btn, &pause_btn);
|
||||
ASSERT_NE(play_btn, nullptr);
|
||||
ASSERT_NE(pause_btn, nullptr);
|
||||
|
||||
// The play button is the default page
|
||||
EXPECT_EQ(stack->currentWidget(), play_btn);
|
||||
|
||||
controls.ShowPauseButton();
|
||||
controls.show_pause_button();
|
||||
EXPECT_EQ(stack->currentWidget(), pause_btn);
|
||||
|
||||
controls.ShowPlayButton();
|
||||
controls.show_play_button();
|
||||
EXPECT_EQ(stack->currentWidget(), play_btn);
|
||||
}
|
||||
|
||||
TEST_F(PlaybackControlsTest, AudioVideoDragButtonsToggleVisibility)
|
||||
{
|
||||
PlaybackControls controls;
|
||||
const QList<QPushButton *> buttons = NavigationButtons(&controls);
|
||||
const QList<QPushButton *> buttons = navigation_buttons(&controls);
|
||||
ASSERT_EQ(buttons.size(), 6);
|
||||
|
||||
// Hidden by default (constructor passes false)
|
||||
EXPECT_TRUE(buttons.at(4)->isHidden());
|
||||
EXPECT_TRUE(buttons.at(5)->isHidden());
|
||||
|
||||
controls.SetAudioVideoDragButtonsVisible(true);
|
||||
controls.set_audio_video_drag_buttons_visible(true);
|
||||
EXPECT_FALSE(buttons.at(4)->isHidden());
|
||||
EXPECT_FALSE(buttons.at(5)->isHidden());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user