修正测试

This commit is contained in:
2026-01-05 03:11:34 +08:00
parent 1f679551f2
commit 8263ccf814
14 changed files with 61 additions and 12 deletions
+3
View File
@@ -178,6 +178,9 @@ list(APPEND OLIVE_LIBRARIES
KDAB::kddockwidgets
)
# Link OFX HostSupport wherever libolive-editor objects are used.
list(APPEND OLIVE_LIBRARIES OfxHost)
# Link FFmpeg
find_package(FFMPEG REQUIRED
COMPONENTS
+4
View File
@@ -252,6 +252,10 @@ bool NodeKeyframe::load(QXmlStreamReader *reader, NodeValue::Type data_type)
this->set_value(
NodeValue::StringToValue(data_type, reader->readElementText(), true));
if (!key_input.isEmpty()) {
this->set_input(key_input);
}
this->set_bezier_control_in(key_in_handle);
this->set_bezier_control_out(key_out_handle);
+4
View File
@@ -71,11 +71,15 @@ VideoParams::VideoParams()
: width_(0)
, height_(0)
, depth_(0)
, time_base_(0)
, format_(PixelFormat::INVALID)
, channel_count_(0)
, pixel_aspect_ratio_(1)
, interlacing_(Interlacing::kInterlaceNone)
, divider_(1)
{
calculate_effective_size();
validate_pixel_aspect_ratio();
set_defaults_for_footage();
}
+2
View File
@@ -45,6 +45,8 @@ function(olive_add_test GROUP NAME SOURCE)
PRIVATE
${CMAKE_SOURCE_DIR}/app
${CMAKE_SOURCE_DIR}/tests
${CMAKE_SOURCE_DIR}/third_party/openfx/include
${CMAKE_SOURCE_DIR}/third_party/openfx/HostSupport/include
${OLIVE_INCLUDE_DIRS}
)
target_link_libraries(
+2
View File
@@ -24,6 +24,8 @@ target_include_directories(
PRIVATE
${CMAKE_SOURCE_DIR}/app
${CMAKE_SOURCE_DIR}/tests
${CMAKE_SOURCE_DIR}/third_party/openfx/include
${CMAKE_SOURCE_DIR}/third_party/openfx/HostSupport/include
${OLIVE_INCLUDE_DIRS}
)
+1 -1
View File
@@ -7,5 +7,5 @@ TEST(CodecFrame, DefaultState)
olive::Frame frame;
EXPECT_EQ(frame.width(), 0);
EXPECT_EQ(frame.height(), 0);
EXPECT_EQ(frame.pixel_format(), olive::core::PixelFormat::Format::kFormatNone);
EXPECT_EQ(frame.format(), olive::core::PixelFormat::INVALID);
}
+1 -1
View File
@@ -2,7 +2,7 @@
#include "common/Current.h"
#include "render/videoparams.h"
#include "render/audioparams.h"
#include "olive/core/render/audioparams.h"
TEST(CommonCurrent, SetAndGetVideoParams)
{
+2 -2
View File
@@ -13,8 +13,8 @@ TEST(CommonXmlUtils, ReadNextStartElement)
buffer.open(QIODevice::ReadOnly);
QXmlStreamReader reader(&buffer);
EXPECT_TRUE(XMLReadNextStartElement(&reader));
EXPECT_TRUE(olive::XMLReadNextStartElement(&reader));
EXPECT_EQ(reader.name().toString(), QStringLiteral("root"));
EXPECT_TRUE(XMLReadNextStartElement(&reader));
EXPECT_TRUE(olive::XMLReadNextStartElement(&reader));
EXPECT_EQ(reader.name().toString(), QStringLiteral("child"));
}
+2 -2
View File
@@ -1,9 +1,9 @@
#include <QCoreApplication>
#include <QApplication>
#include <gtest/gtest.h>
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
QApplication app(argc, argv);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
+16 -2
View File
@@ -6,7 +6,9 @@
#include "node/node.h"
#include "node/serializeddata.h"
#include "node/splitvalue.h"
#include "node/value.h"
#include "render/diskmanager.h"
namespace {
class TestNode final : public olive::Node {
@@ -14,7 +16,9 @@ public:
TestNode()
{
AddInput(QStringLiteral("Value"), olive::NodeValue::kFloat);
SetSplitStandardValue(QStringLiteral("Value"), 3.5, -1);
olive::SplitValue value;
value.append(3.5);
SetSplitStandardValue(QStringLiteral("Value"), value, -1);
}
TestNode *copy() const override
@@ -42,7 +46,8 @@ public:
return QStringLiteral("Test node for serialization");
}
void Value(const NodeValueRow &, const NodeGlobals &, NodeValueTable *) const override
void Value(const olive::NodeValueRow &, const olive::NodeGlobals &,
olive::NodeValueTable *) const override
{
}
};
@@ -50,6 +55,11 @@ public:
TEST(NodeSerialization, SaveAndLoadInput)
{
const bool created_disk_manager = (olive::DiskManager::instance() == nullptr);
if (created_disk_manager) {
olive::DiskManager::CreateInstance();
}
TestNode node;
node.SetLabel(QStringLiteral("MyNode"));
node.SetOverrideColor(2);
@@ -78,4 +88,8 @@ TEST(NodeSerialization, SaveAndLoadInput)
EXPECT_EQ(loaded.GetOverrideColor(), 2);
EXPECT_DOUBLE_EQ(loaded.GetSplitStandardValue(QStringLiteral("Value"), -1)
.first().toDouble(), 3.5);
if (created_disk_manager) {
olive::DiskManager::DestroyInstance();
}
}
+17 -2
View File
@@ -8,10 +8,19 @@
#include "node/project.h"
#include "node/input/time/timeinput.h"
#include "node/project/serializer/serializer.h"
#include "node/color/colormanager/colormanager.h"
#include "render/diskmanager.h"
TEST(ProjectSerializer, SaveLoadProjectRoundTrip)
{
const bool created_disk_manager = (olive::DiskManager::instance() == nullptr);
if (created_disk_manager) {
olive::DiskManager::CreateInstance();
}
olive::ColorManager::SetUpDefaultConfig();
olive::NodeFactory::Initialize();
olive::ProjectSerializer::Initialize();
olive::Project project;
project.Initialize();
@@ -27,8 +36,9 @@ TEST(ProjectSerializer, SaveLoadProjectRoundTrip)
QBuffer buffer(&xml);
buffer.open(QIODevice::WriteOnly);
QXmlStreamWriter writer(&buffer);
EXPECT_EQ(olive::ProjectSerializer::Save(&writer, save_data),
olive::ProjectSerializer::kSuccess);
olive::ProjectSerializer::Result save_result =
olive::ProjectSerializer::Save(&writer, save_data);
EXPECT_EQ(save_result.code(), olive::ProjectSerializer::kSuccess);
buffer.close();
olive::Project loaded_project;
@@ -40,4 +50,9 @@ TEST(ProjectSerializer, SaveLoadProjectRoundTrip)
olive::ProjectSerializer::kProject);
EXPECT_EQ(result.code(), olive::ProjectSerializer::kSuccess);
EXPECT_FALSE(loaded_project.nodes().isEmpty());
olive::ProjectSerializer::Destroy();
if (created_disk_manager) {
olive::DiskManager::DestroyInstance();
}
}
+1 -1
View File
@@ -5,7 +5,7 @@
#include <QXmlStreamWriter>
#include "node/project/serializer/typeserializer.h"
#include "render/audioparams.h"
#include "olive/core/render/audioparams.h"
TEST(RenderAudioParams, SaveLoadRoundTrip)
{
+1 -1
View File
@@ -32,7 +32,7 @@ TEST(TimelineMarker, SaveLoadRoundTrip)
EXPECT_EQ(reader.name().toString(), QStringLiteral("marker"));
loaded.load(&reader);
EXPECT_EQ(loaded.time(), olive::core::rational(10, 1));
EXPECT_EQ(loaded.time().in(), olive::core::rational(10, 1));
EXPECT_EQ(loaded.name(), QStringLiteral("Marker"));
EXPECT_EQ(loaded.color(), 5);
}
+5
View File
@@ -11,6 +11,11 @@ public:
{
}
olive::Project *GetRelevantProject() const override
{
return nullptr;
}
protected:
void redo() override
{