test: replace fake and duplicate tests with real assertions
Fake tests rewritten to assert real behavior: - audio_smoke: conversion tests now actually Convert() samples and verify output; waveform length/summary assertions tightened to exact values - plugin_format_conversion: RowBytes/U8ToU16/LoadImageFile now call real production code (VideoParams::GetBytesPerPixel, sws scaler, OIIO decode of tests/img.png with known pixel values) - core_color: HSV round trip now verifies fromHsv(toHsv(c)) == c instead of comparing toHsv against its own accessors - core_bezier/node_inputimmediate: expected values replaced with independently derived constants instead of re-running the code under test - common_commandlineparser/common_debug/common_jobtime: capture stdout/stderr/qDebug and assert actual output content - proxy_manager: ProxyFinished test now drives a real proxy job instead of emitting the signal itself; proxy_dialog/panel/proxy/preferences/timeruler tests assert real widget state - viewer_smoke/preview_autocacher/render_misc: zero-assertion tests given observable-state assertions or removed where nothing is observable Duplicates removed: - plugin_smoke_test.cpp: 18 tests duplicated from plugin_paraminstance / plugin_support_* / plugin_renderer_readback (751 -> 180 lines) - module_smoke HumanStrings tests covered precisely by ui_humanstrings_test - render_misc duplicate kDefaultInterpolation constant check Removed by policy (skip allowed, never disabled): - all DISABLED_ prefixes: re-enabled as real offscreen tests or deleted - ffmpeg_decoder_hw: hardcoded personal path replaced with OAK_TEST_HW_DECODE_FILE env var, GTEST_SKIP when unset Also: - config_test: restore Config defaults after run (cross-test pollution) - render_worker_footage: drop /tmp debug-output scaffolding - previewaudiodevice construction test asserts the real bugfix
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QSignalSpy>
|
||||
|
||||
#include "codec/conformmanager.h"
|
||||
#include "node/generator/solid/solid.h"
|
||||
#include "node/output/viewer/viewer.h"
|
||||
#include "node/project.h"
|
||||
#include "render/diskmanager.h"
|
||||
#include "render/previewautocacher.h"
|
||||
#include "render/rendermanager.h"
|
||||
#include "render/videoparams.h"
|
||||
|
||||
using namespace olive;
|
||||
|
||||
@@ -36,6 +39,22 @@ protected:
|
||||
DiskManager::DestroyInstance();
|
||||
}
|
||||
|
||||
ViewerOutput *CreateViewer()
|
||||
{
|
||||
auto *viewer = new ViewerOutput();
|
||||
viewer->setParent(project_.get());
|
||||
return viewer;
|
||||
}
|
||||
|
||||
ViewerOutput *CreateViewerWithValidParams()
|
||||
{
|
||||
ViewerOutput *viewer = CreateViewer();
|
||||
viewer->SetVideoParams(
|
||||
VideoParams(64, 64, rational(1, 25), PixelFormat::U8,
|
||||
VideoParams::kRGBAChannelCount));
|
||||
return viewer;
|
||||
}
|
||||
|
||||
std::unique_ptr<Project> project_;
|
||||
};
|
||||
|
||||
@@ -45,45 +64,119 @@ TEST_F(PreviewAutoCacherTest, ConstructionInitializesDefaultState)
|
||||
EXPECT_FALSE(cacher.IsRenderingCustomRange());
|
||||
}
|
||||
|
||||
TEST_F(PreviewAutoCacherTest, SetProjectToNullDoesNotCrash)
|
||||
// With a project set, a single-frame request is dispatched to the render
|
||||
// pipeline, so the next request must not cancel it. After SetProject(nullptr)
|
||||
// the copied graph is gone, so requests can only stay queued and each new
|
||||
// request cancels the previously queued one.
|
||||
TEST_F(PreviewAutoCacherTest, SetProjectToNullStopsSingleFrameDispatch)
|
||||
{
|
||||
ViewerOutput *viewer = CreateViewerWithValidParams();
|
||||
|
||||
// The single-frame path renders the node connected to the viewer's
|
||||
// texture input, so connect something the copier can duplicate.
|
||||
auto *solid = new SolidGenerator();
|
||||
solid->setParent(project_.get());
|
||||
Node::ConnectEdge(solid, NodeInput(viewer, ViewerOutput::kTextureInput));
|
||||
|
||||
PreviewAutoCacher cacher;
|
||||
cacher.SetProject(project_.get());
|
||||
|
||||
RenderTicketPtr dispatched = cacher.GetSingleFrame(viewer, rational(0));
|
||||
ASSERT_NE(dispatched, nullptr);
|
||||
|
||||
// A dispatched ticket is owned by the render pipeline; the next request
|
||||
// must leave it alone
|
||||
RenderTicketPtr next = cacher.GetSingleFrame(viewer, rational(1));
|
||||
ASSERT_NE(next, nullptr);
|
||||
EXPECT_EQ(dispatched->GetFinishCount(), 0);
|
||||
EXPECT_TRUE(dispatched->IsRunning());
|
||||
|
||||
cacher.SetProject(nullptr);
|
||||
|
||||
// Without a copied graph there is nothing to dispatch to: the request
|
||||
// stays queued and the next request cancels it
|
||||
RenderTicketPtr queued = cacher.GetSingleFrame(viewer, rational(2));
|
||||
ASSERT_NE(queued, nullptr);
|
||||
RenderTicketPtr cancelling = cacher.GetSingleFrame(viewer, rational(3));
|
||||
ASSERT_NE(cancelling, nullptr);
|
||||
EXPECT_EQ(queued->GetFinishCount(), 1);
|
||||
EXPECT_FALSE(queued->HasResult());
|
||||
|
||||
cacher.SetProject(nullptr);
|
||||
EXPECT_FALSE(cacher.IsRenderingCustomRange());
|
||||
}
|
||||
|
||||
TEST_F(PreviewAutoCacherTest, SetRendersPausedTogglesState)
|
||||
// While renders are paused, forced cache ranges must stay queued; unpausing
|
||||
// must dispatch them.
|
||||
TEST_F(PreviewAutoCacherTest, SetRendersPausedBlocksAndResumesCacheJobs)
|
||||
{
|
||||
ViewerOutput *viewer = CreateViewerWithValidParams();
|
||||
|
||||
PreviewAutoCacher cacher;
|
||||
cacher.SetProject(project_.get());
|
||||
|
||||
QSignalSpy stop_spy(&cacher, &PreviewAutoCacher::StopCacheProxyTasks);
|
||||
|
||||
cacher.SetRendersPaused(true);
|
||||
cacher.ForceCacheRange(viewer, TimeRange(rational(0), rational(1, 25)));
|
||||
EXPECT_TRUE(cacher.IsRenderingCustomRange());
|
||||
EXPECT_EQ(stop_spy.count(), 0);
|
||||
|
||||
// The dummy backend finishes each ticket without a result, exhausting the
|
||||
// range as soon as it is dispatched
|
||||
cacher.SetRendersPaused(false);
|
||||
EXPECT_FALSE(cacher.IsRenderingCustomRange());
|
||||
EXPECT_GE(stop_spy.count(), 1);
|
||||
|
||||
// Deliver the queued RenderTicketWatcher::Finished emissions so the
|
||||
// completed watchers are reaped before teardown.
|
||||
QCoreApplication::processEvents();
|
||||
|
||||
cacher.SetProject(nullptr);
|
||||
}
|
||||
|
||||
TEST_F(PreviewAutoCacherTest, SetThumbnailsPausedTogglesState)
|
||||
// pause_thumbnails_ gates the same pending-video-job dispatch loop, so it is
|
||||
// observable the same way as pause_renders_.
|
||||
TEST_F(PreviewAutoCacherTest, SetThumbnailsPausedBlocksAndResumesCacheJobs)
|
||||
{
|
||||
ViewerOutput *viewer = CreateViewerWithValidParams();
|
||||
|
||||
PreviewAutoCacher cacher;
|
||||
cacher.SetProject(project_.get());
|
||||
|
||||
QSignalSpy stop_spy(&cacher, &PreviewAutoCacher::StopCacheProxyTasks);
|
||||
|
||||
cacher.SetThumbnailsPaused(true);
|
||||
cacher.ForceCacheRange(viewer, TimeRange(rational(0), rational(1, 25)));
|
||||
EXPECT_TRUE(cacher.IsRenderingCustomRange());
|
||||
EXPECT_EQ(stop_spy.count(), 0);
|
||||
|
||||
cacher.SetThumbnailsPaused(false);
|
||||
EXPECT_FALSE(cacher.IsRenderingCustomRange());
|
||||
EXPECT_GE(stop_spy.count(), 1);
|
||||
|
||||
// Deliver the queued RenderTicketWatcher::Finished emissions so the
|
||||
// completed watchers are reaped before teardown.
|
||||
QCoreApplication::processEvents();
|
||||
|
||||
cacher.SetProject(nullptr);
|
||||
}
|
||||
|
||||
TEST_F(PreviewAutoCacherTest, SetPlayheadStoresPlayhead)
|
||||
// ClearSingleFrameRenders only cancels already-dispatched passthrough renders;
|
||||
// a single-frame ticket that is still queued must be left untouched.
|
||||
TEST_F(PreviewAutoCacherTest, ClearSingleFrameRendersLeavesQueuedTicketPending)
|
||||
{
|
||||
PreviewAutoCacher cacher;
|
||||
cacher.SetPlayhead(rational(42));
|
||||
}
|
||||
ViewerOutput *viewer = CreateViewer();
|
||||
|
||||
TEST_F(PreviewAutoCacherTest, ClearSingleFrameRendersDoesNotCrashWhenEmpty)
|
||||
{
|
||||
PreviewAutoCacher cacher;
|
||||
RenderTicketPtr ticket = cacher.GetSingleFrame(viewer, rational(0));
|
||||
ASSERT_NE(ticket, nullptr);
|
||||
|
||||
cacher.ClearSingleFrameRenders();
|
||||
}
|
||||
|
||||
TEST_F(PreviewAutoCacherTest,
|
||||
ClearSingleFrameRendersThatArentRunningDoesNotCrashWhenEmpty)
|
||||
{
|
||||
PreviewAutoCacher cacher;
|
||||
cacher.ClearSingleFrameRendersThatArentRunning();
|
||||
|
||||
EXPECT_TRUE(ticket->IsRunning());
|
||||
EXPECT_EQ(ticket->GetFinishCount(), 0);
|
||||
EXPECT_FALSE(ticket->HasResult());
|
||||
}
|
||||
|
||||
TEST_F(PreviewAutoCacherTest, GetSingleFrameWithoutProjectReturnsTicket)
|
||||
@@ -95,27 +188,3 @@ TEST_F(PreviewAutoCacherTest, GetSingleFrameWithoutProjectReturnsTicket)
|
||||
RenderTicketPtr ticket = cacher.GetSingleFrame(viewer, rational(0));
|
||||
EXPECT_NE(ticket, nullptr);
|
||||
}
|
||||
|
||||
TEST_F(PreviewAutoCacherTest, ForceCacheRangeDoesNotCrash)
|
||||
{
|
||||
auto *viewer = new ViewerOutput();
|
||||
viewer->setParent(project_.get());
|
||||
|
||||
PreviewAutoCacher cacher;
|
||||
cacher.ForceCacheRange(viewer, TimeRange(rational(0), rational(1)));
|
||||
cacher.SetProject(nullptr);
|
||||
}
|
||||
|
||||
TEST_F(PreviewAutoCacherTest, CancelVideoTasksDoesNotCrashWhenIdle)
|
||||
{
|
||||
PreviewAutoCacher cacher;
|
||||
cacher.CancelVideoTasks(false);
|
||||
cacher.CancelVideoTasks(true);
|
||||
}
|
||||
|
||||
TEST_F(PreviewAutoCacherTest, CancelAudioTasksDoesNotCrashWhenIdle)
|
||||
{
|
||||
PreviewAutoCacher cacher;
|
||||
cacher.CancelAudioTasks(false);
|
||||
cacher.CancelAudioTasks(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user