MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / TEST_F

Function TEST_F

tests/src/App/DocumentObject.cpp:44–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42
43
44TEST_F(DocumentObjectTest, getSubObjectList)
45{
46 // Arrange
47
48 // The name of a Part::Box added to the document
49 auto boxName {_doc->addObject("Part::Box")->getNameInDocument()};
50 // The name of a Part::Cylinder added to the document
51 auto cylName {_doc->addObject("Part::Cylinder")->getNameInDocument()};
52 // An App::Part object added to the document
53 auto part {_doc->addObject("App::Part")};
54 // The name of the App::Part added to the document
55 auto partName {part->getNameInDocument()};
56 // The name of the object used as argument for the calls of DocumentObject::getSubObjectList()
57 auto subName {std::string()};
58
59 // A vector of int used as argument for the call of DocumentObject::getSubObjectList() with
60 // argument flatten not set (or set to false)
61 auto sizesNoFlatten {std::vector<int>()};
62 // A vector of int used as argument for the call of DocumentObject::getSubObjectList() with
63 // argument flatten set to true
64 auto sizesFlatten {std::vector<int>()};
65 // A helper string used to compose the argument of some calls of
66 // Base::Interpreter().runString()
67 auto cmd {std::string()};
68
69 // Performing a fusion to create an object that will be searched with the calls of
70 // DocumentObject::getSubObjectList()
71 Base::Interpreter().runString("from BOPTools import BOPFeatures");
72 Base::Interpreter().runString("bp = BOPFeatures.BOPFeatures(App.activeDocument())");
73 cmd = "bp.make_multi_fuse([\"";
74 cmd += boxName;
75 cmd += "\", \"";
76 cmd += cylName;
77 cmd += "\", ])";
78 Base::Interpreter().runString(cmd.c_str());
79 Base::Interpreter().runString("App.ActiveDocument.recompute()");
80 // The name of the fusion object
81 auto fuseName {_doc->getObject("Fusion")->getNameInDocument()};
82
83 // Defining the name of the object that will be searched with the calls of
84 // DocumentObject::getSubObjectList()
85 subName = fuseName;
86 subName += ".";
87 subName += boxName;
88 subName += ".Edge1";
89
90 // Adding the fusion to the App::Part object to test the differences between calling
91 // DocumentObject::getSubObjectList() with the flatten argument set to false or set to true
92 cmd = "App.ActiveDocument.getObject(\"";
93 cmd += partName;
94 cmd += "\").addObject(App.ActiveDocument.getObject(\"";
95 cmd += fuseName;
96 cmd += "\"))";
97 Base::Interpreter().runString(cmd.c_str());
98 Base::Interpreter().runString("App.ActiveDocument.recompute()");
99
100 // A vector of DocumentObjects used to store the result of the call to
101 // DocumentObject::getSubObjectList() without the subname parameter

Callers

nothing calls this directly

Calls 8

runStringMethod · 0.80
getNameInDocumentMethod · 0.45
addObjectMethod · 0.45
c_strMethod · 0.45
getObjectMethod · 0.45
getSubObjectListMethod · 0.45
sizeMethod · 0.45
getIDMethod · 0.45

Tested by

no test coverage detected