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:
2026-07-19 13:58:31 +08:00
parent b0aa683499
commit cb1718a103
37 changed files with 1560 additions and 1038 deletions
+100 -22
View File
@@ -16,6 +16,7 @@
#include <QXmlStreamWriter>
#include "audio/audiomanager.h"
#include "config/config.h"
#include "node/block/clip/clip.h"
#include "node/color/colormanager/colormanager.h"
#include "node/generator/solid/solid.h"
@@ -51,10 +52,28 @@ TEST_F(AudioManagerTest, InstanceLifecycle)
olive::AudioManager::CreateInstance();
EXPECT_EQ(olive::AudioManager::instance(), first);
// Whatever PortAudio reports, the stored indices are either a valid
// device index or paNoDevice
EXPECT_GE(olive::AudioManager::instance()->GetOutputDevice(), paNoDevice);
EXPECT_GE(olive::AudioManager::instance()->GetInputDevice(), paNoDevice);
// The stored indices are either paNoDevice or a valid device index with
// channels in the appropriate direction
const PaDeviceIndex output =
olive::AudioManager::instance()->GetOutputDevice();
const PaDeviceIndex input = olive::AudioManager::instance()->GetInputDevice();
if (Pa_GetDeviceCount() == 0) {
// No devices exist, so nothing could have been selected
EXPECT_EQ(output, paNoDevice);
EXPECT_EQ(input, paNoDevice);
} else {
if (output != paNoDevice) {
ASSERT_GE(output, 0);
ASSERT_LT(output, Pa_GetDeviceCount());
EXPECT_GT(Pa_GetDeviceInfo(output)->maxOutputChannels, 0);
}
if (input != paNoDevice) {
ASSERT_GE(input, 0);
ASSERT_LT(input, Pa_GetDeviceCount());
EXPECT_GT(Pa_GetDeviceInfo(input)->maxInputChannels, 0);
}
}
}
TEST_F(AudioManagerTest, SetAndGetNoDevice)
@@ -101,13 +120,16 @@ TEST_F(AudioManagerTest, StartRecordingWithoutInputDeviceFails)
TEST_F(AudioManagerTest, OutputControlsWithoutStreamAreNoOps)
{
olive::AudioManager::instance()->SetOutputDevice(paNoDevice);
// No output stream is open; all of these must be harmless no-ops
olive::AudioManager::instance()->StopOutput();
olive::AudioManager::instance()->ClearBufferedOutput();
olive::AudioManager::instance()->SetOutputNotifyInterval(64);
olive::AudioManager::instance()->SetOutputNotifyInterval(0);
SUCCEED();
// ...and they must not disturb the device bookkeeping
EXPECT_EQ(olive::AudioManager::instance()->GetOutputDevice(), paNoDevice);
}
TEST_F(AudioManagerTest, HardResetKeepsManagerUsable)
@@ -119,36 +141,92 @@ TEST_F(AudioManagerTest, HardResetKeepsManagerUsable)
EXPECT_EQ(olive::AudioManager::instance()->GetOutputDevice(), paNoDevice);
}
TEST_F(AudioManagerTest, FindDeviceByNameReturnsValidIndexOrNoDevice)
TEST_F(AudioManagerTest, FindDeviceByNameFallsBackForUnknownName)
{
// A name that matches nothing must never produce a garbage index. When no
// devices exist there is nothing to fall back to and the result must be
// exactly paNoDevice; otherwise the fallback is a preferred/default
// device, i.e. a valid index or paNoDevice.
const PaDeviceIndex bogus_output = olive::AudioManager::FindDeviceByName(
QStringLiteral("OakNoSuchAudioDevice12345"), true);
EXPECT_TRUE(bogus_output == paNoDevice ||
(bogus_output >= 0 && bogus_output < Pa_GetDeviceCount()));
const PaDeviceIndex bogus_input = olive::AudioManager::FindDeviceByName(
QStringLiteral("OakNoSuchAudioDevice12345"), false);
EXPECT_TRUE(bogus_input == paNoDevice ||
(bogus_input >= 0 && bogus_input < Pa_GetDeviceCount()));
// An empty name falls back to the default/preferred device
const PaDeviceIndex fallback =
olive::AudioManager::FindDeviceByName(QString(), true);
EXPECT_TRUE(fallback == paNoDevice ||
(fallback >= 0 && fallback < Pa_GetDeviceCount()));
if (Pa_GetDeviceCount() == 0) {
EXPECT_EQ(bogus_output, paNoDevice);
EXPECT_EQ(bogus_input, paNoDevice);
} else {
EXPECT_TRUE(bogus_output == paNoDevice ||
(bogus_output >= 0 && bogus_output < Pa_GetDeviceCount()));
EXPECT_TRUE(bogus_input == paNoDevice ||
(bogus_input >= 0 && bogus_input < Pa_GetDeviceCount()));
}
}
TEST_F(AudioManagerTest, FindConfigDeviceByNameReturnsValidIndexOrNoDevice)
TEST_F(AudioManagerTest, FindDeviceByNameFindsExactMatch)
{
if (Pa_GetDeviceCount() == 0) {
GTEST_SKIP() << "No PortAudio devices available on this system";
}
// Searching the exact name of a device must return that device's index.
// On Linux a match on a non-preferred backend (e.g. ALSA) may legitimately
// be upgraded to a preferred device, so only a device that already sits on
// a preferred host API (PipeWire/JACK/PulseAudio) gives an exact contract.
for (PaDeviceIndex i = 0, end = Pa_GetDeviceCount(); i < end; i++) {
const PaDeviceInfo *info = Pa_GetDeviceInfo(i);
if (!info || !info->maxOutputChannels) {
continue;
}
#ifdef Q_OS_LINUX
const PaHostApiInfo *api = Pa_GetHostApiInfo(info->hostApi);
if (!api) {
continue;
}
const QString api_name = QString::fromLatin1(api->name);
if (!api_name.contains(QStringLiteral("PipeWire"),
Qt::CaseInsensitive) &&
!api_name.contains(QStringLiteral("JACK"), Qt::CaseInsensitive) &&
!api_name.contains(QStringLiteral("PulseAudio"),
Qt::CaseInsensitive)) {
continue;
}
#endif
EXPECT_EQ(olive::AudioManager::FindDeviceByName(
QString::fromLatin1(info->name), true),
i);
return;
}
GTEST_SKIP() << "No output device on a preferred host API on this system";
}
TEST_F(AudioManagerTest, FindConfigDeviceByNameMatchesConfiguredLookup)
{
// The config-driven lookup must be exactly FindDeviceByName applied to the
// configured name, and must never return a garbage index
const PaDeviceIndex output =
olive::AudioManager::FindConfigDeviceByName(true);
EXPECT_TRUE(output == paNoDevice ||
(output >= 0 && output < Pa_GetDeviceCount()));
const PaDeviceIndex input =
olive::AudioManager::FindConfigDeviceByName(false);
EXPECT_TRUE(input == paNoDevice ||
(input >= 0 && input < Pa_GetDeviceCount()));
EXPECT_EQ(output,
olive::AudioManager::FindDeviceByName(
olive::Config::Current()[QStringLiteral("AudioOutput")]
.toString(),
true));
EXPECT_EQ(input,
olive::AudioManager::FindDeviceByName(
olive::Config::Current()[QStringLiteral("AudioInput")]
.toString(),
false));
if (Pa_GetDeviceCount() == 0) {
EXPECT_EQ(output, paNoDevice);
EXPECT_EQ(input, paNoDevice);
}
}
TEST_F(AudioManagerTest, PortAudioParamsReflectAudioParams)