in Ambit/Source/Ambit/Mode/GltfExport.spec.cpp [31:127]
void GltfExportSpec::Define()
{
Describe("Test glTF export process failure", [this]()
{
BeforeEach([this]()
{
World = FAutomationEditorCommonUtils::CreateNewMap();
Exporter = NewObject<UMockableGltfExport>();
});
Describe("Test GLTFExporter plugin failure", [this]()
{
BeforeEach([this]()
{
auto MockFunction = [](UGLTFLevelExporter* LevelExporter, UWorld* World, FBufferArchive& Buffer) -> bool
{
return false;
};
Exporter->SetExportBinary(MockFunction);
});
It("Should return error if ExportBinary() fails", [this]()
{
const UGltfExport::GltfExportReturnCode ReturnCode = Exporter->Export(World, Filename);
TestEqual("Export should fail", ReturnCode, UGltfExport::Failed);
});
});
Describe("Test write to file", [this]()
{
BeforeEach([this]()
{
auto MockBinaryFunction = [](UGLTFLevelExporter* LevelExporter, UWorld* World,
FBufferArchive& Buffer) -> bool
{
return true;
};
Exporter->SetExportBinary(MockBinaryFunction);
auto MockWriteFunction = [](FBufferArchive& Buffer, const FString& Filename) -> bool
{
return false;
};
Exporter->SetWriteToFile(MockWriteFunction);
});
It("Should fail if file name is empty", [this]()
{
const UGltfExport::GltfExportReturnCode ReturnCode = Exporter->Export(World, Filename);
TestEqual("Write to file should fail", ReturnCode, UGltfExport::WriteToFileError);
});
});
AfterEach([this]()
{
Exporter = nullptr;
});
});
Describe("Test glTF export process success", [this]()
{
BeforeEach([this]()
{
World = FAutomationEditorCommonUtils::CreateNewMap();
Exporter = NewObject<UMockableGltfExport>();
auto MockBinaryFunction = [](UGLTFLevelExporter* LevelExporter, UWorld* World,
FBufferArchive& Buffer) -> bool
{
return true;
};
Exporter->SetExportBinary(MockBinaryFunction);
auto MockWriteFunction = [](FBufferArchive& Buffer, const FString& Filename) -> bool
{
return true;
};
Exporter->SetWriteToFile(MockWriteFunction);
});
It("Should return success code on completion", [this]()
{
const UGltfExport::GltfExportReturnCode ReturnCode = Exporter->Export(World, Filename);
TestEqual("Export should complete successfully", ReturnCode, UGltfExport::Success);
});
AfterEach([this]()
{
Exporter = nullptr;
});
});
}