MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / TEST_F

Function TEST_F

test/ModelExport.cpp:21–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19using ModelExportTest = RadiantTest;
20
21TEST_F(ModelExportTest, ExportPatchMesh)
22{
23 // Load a map with a cylinder patch
24 loadMap("modelexport_patch.map");
25
26 auto patchNode = algorithm::findFirstPatchWithMaterial(GlobalMapModule().findOrInsertWorldspawn(),
27 "textures/darkmod/wood/boards/ship_hull_medium");
28 EXPECT_TRUE(patchNode);
29
30 Node_setSelected(patchNode, true);
31
32 // Choose a file in our temp data folder
33 std::string modRelativePath = "models/temp/temp_patch.lwo";
34
35 fs::path outputFilename = _context.getTestProjectPath();
36 outputFilename /= modRelativePath;
37 os::makeDirectory(outputFilename.parent_path().string());
38
39 auto exporter = GlobalModelFormatManager().getExporter("lwo");
40
41 cmd::ArgumentList argList;
42
43 // ExportSelectedAsModel <Path> <ExportFormat> [<ExportOrigin>] [<OriginEntityName>] [<CustomOrigin>][<SkipCaulk>][<ReplaceSelectionWithModel>][<ExportLightsAsObjects>]
44 argList.push_back(outputFilename.string());
45 argList.push_back(std::string("lwo"));
46 argList.push_back(model::getExportOriginString(model::ModelExportOrigin::SelectionCenter)); // centerObjects
47 argList.push_back(std::string()); // OriginEntityName
48 argList.push_back(Vector3()); // CustomOrigin
49 argList.push_back(true); // skipCaulk
50 argList.push_back(false); // replaceSelectionWithModel
51 argList.push_back(false); // exportLightsAsObjects
52
53 GlobalCommandSystem().executeCommand("ExportSelectedAsModel", argList);
54
55 auto model = GlobalModelCache().getModel(modRelativePath);
56
57 EXPECT_TRUE(model);
58
59 // We expect exactly the same amount of vertices as in the patch mesh
60 // This ensures that no vertices have been duplicated or faces separated
61 auto patch = std::dynamic_pointer_cast<IPatchNode>(patchNode);
62 EXPECT_EQ(model->getVertexCount(), patch->getPatch().getTesselatedPatchMesh().vertices.size());
63
64 // Clean up the file
65 fs::remove(outputFilename);
66}
67
68// #5658: Model exporter failed to write the file if the folder doesn't exist
69TEST_F(ModelExportTest, ExportFolderNotExisting)

Callers

nothing calls this directly

Calls 15

Node_setSelectedFunction · 0.85
makeDirectoryFunction · 0.85
getExportOriginStringFunction · 0.85
TexCoord2fClass · 0.85
runConverterCodeFunction · 0.85
to_upper_copyFunction · 0.85
getExtensionFunction · 0.85
createCubicBrushFunction · 0.85
addNodeToContainerFunction · 0.85
Node_getEntityFunction · 0.85

Tested by

no test coverage detected