From 767b2bd5e41a997ba709172ae0dca138945a61f8 Mon Sep 17 00:00:00 2001 From: CalligaroV Date: Tue, 23 Apr 2024 10:22:12 +0200 Subject: [PATCH] App/Toponaming: import SubObjectT dependencies for SubShapeBinder * Fixed a mistake made in getSubObjectListFlatten() * Applied modifications according to review comments Signed-off-by: CalligaroV --- src/App/DocumentObject.cpp | 12 +- src/App/DocumentObject.h | 2 +- src/App/DocumentObserver.cpp | 8 +- src/App/DocumentObserver.h | 3 + tests/src/App/DocumentObject.cpp | 13 +- tests/src/App/DocumentObserver.cpp | 194 +++++++++++++++++++++++------ 6 files changed, 179 insertions(+), 53 deletions(-) diff --git a/src/App/DocumentObject.cpp b/src/App/DocumentObject.cpp index a427ac2ed0..a7f1f93efe 100644 --- a/src/App/DocumentObject.cpp +++ b/src/App/DocumentObject.cpp @@ -899,10 +899,10 @@ getSubObjectListFlatten(const std::vector& resNotFlatten, { auto res {resNotFlatten}; auto linked = sobj->getLinkedObject(); - if (container) { + if (*container) { auto grp = App::GeoFeatureGroupExtension::getGroupOfObject(linked); if (grp != *container) { - container = nullptr; + *container = nullptr; } else { if (lastChild && !res.empty()) { @@ -920,12 +920,12 @@ getSubObjectListFlatten(const std::vector& resNotFlatten, } else if (linked != sobj || sobj->hasChildElement()) { // Check for Link or LinkGroup - container = nullptr; + *container = nullptr; } else if (auto ext = sobj->getExtensionByType(true)) { // check for Link array if (ext->getElementCountValue() != 0) { - container = nullptr; + *container = nullptr; } } return res; @@ -941,7 +941,7 @@ std::vector DocumentObject::getSubObjectList(const char* subnam if (subsizes) { subsizes->push_back(0); } - if (!subname || (subname[0] == 0)) { + if (!subname || (subname[0] == '\0')) { return res; } auto element = Data::findElementName(subname); @@ -961,7 +961,7 @@ std::vector DocumentObject::getSubObjectList(const char* subnam } for (auto pos = sub.find('.'); pos != std::string::npos; pos = sub.find('.', pos + 1)) { char subTail = sub[pos + 1]; - sub[pos + 1] = 0; + sub[pos + 1] = '\0'; auto sobj = getSubObject(sub.c_str()); if (!sobj || !sobj->isAttachedToDocument()) { continue; diff --git a/src/App/DocumentObject.h b/src/App/DocumentObject.h index 03e8182722..af4867a5bd 100644 --- a/src/App/DocumentObject.h +++ b/src/App/DocumentObject.h @@ -384,7 +384,7 @@ public: * @param flatten: whether to flatten the object hierarchies that belong to * the same geo feature group, e.g. (Part.Fusion.Box -> Part.Box) * - * @return Return a list of object along the path. + * @return Return a list of objects along the path. */ std::vector getSubObjectList(const char* subname, std::vector* subsizes = nullptr, diff --git a/src/App/DocumentObserver.cpp b/src/App/DocumentObserver.cpp index 461c80fa4b..411cada33f 100644 --- a/src/App/DocumentObserver.cpp +++ b/src/App/DocumentObserver.cpp @@ -348,7 +348,7 @@ bool normalizeConvertIndex(const std::vector& objs, const { if (auto ext = objs[idx - 1]->getExtensionByType(true)) { if ((ext->getElementCountValue() != 0) && !ext->getShowElementValue()) { - // if the parent is a collapsed link array element, then we + // If the parent is a collapsed link array element, then we // have to keep the index no matter what, because there is // no sub-object corresponding to an array element. return true; @@ -376,7 +376,7 @@ bool SubObjectT::normalize(NormalizeOptions options) return false; } for (unsigned i = 1; i < objs.size(); ++i) { - // Keep digit only subname, as it maybe an index to an array, which does + // Keep digit-only subname, as it maybe an index to an array, which does // not expand its elements as objects. const char* end = subname.c_str() + subs[i]; const char* sub = end - 2; @@ -391,7 +391,7 @@ bool SubObjectT::normalize(NormalizeOptions options) } } bool _keepSub {}; - if (std::isdigit(sub[0]) == 0) { + if (!std::isdigit(sub[0])) { _keepSub = keepSub; } else if (!convertIndex) { @@ -454,7 +454,7 @@ bool SubObjectT::hasSubObject() const bool SubObjectT::hasSubElement() const { auto element = getElementName(); - return (element != nullptr) && (element[0] != 0); + return element && (element[0] != '\0'); } std::string SubObjectT::getNewElementName() const { diff --git a/src/App/DocumentObserver.h b/src/App/DocumentObserver.h index 33b6ccbb17..e9ce51692c 100644 --- a/src/App/DocumentObserver.h +++ b/src/App/DocumentObserver.h @@ -256,12 +256,14 @@ public: { /// Do not include sub-element reference in the output path NoElement = 0x01, + /** Do not flatten the output path. If not specified, the output path * will be flatten to exclude intermediate objects that belong to the * same geo feature group before resolving. For example, * Part.Fusion.Box. -> Part.Box. */ NoFlatten = 0x02, + /** Do not change the sub-object component inside the path. Each * component of the subname object path can be either the object * internal name, the label of the object if starts with '$', or an @@ -269,6 +271,7 @@ public: * be converted to object internal name, except for integer index. */ KeepSubName = 0x04, + /** Convert integer index in the path to sub-object internal name */ ConvertIndex = 0x08, }; diff --git a/tests/src/App/DocumentObject.cpp b/tests/src/App/DocumentObject.cpp index b584aa21b8..cd73bd01b0 100644 --- a/tests/src/App/DocumentObject.cpp +++ b/tests/src/App/DocumentObject.cpp @@ -62,7 +62,7 @@ TEST_F(DocumentObjectTest, getSubObjectList) // A vector of int used as argument for the call of DocumentObject::getSubObjectList() with // argument flatten set to true auto sizesFlatten {std::vector()}; - // An helper string used to compose the argument of some calls of + // A helper string used to compose the argument of some calls of // Base::Interpreter().runString() auto cmd {std::string()}; @@ -133,17 +133,18 @@ TEST_F(DocumentObjectTest, getSubObjectList) // If DocumentObject::getSubObjectList() is called with the subsizes argument it returns the // same vector of the previous case and the subsizes argument stores the positions in the - // subname string corresponding to start of the sub objects names + // subname string corresponding to start of the sub objects names. + // The position takes into account also the '.' in the subname EXPECT_EQ(docSubObjsWithSubSizes.size(), 3); EXPECT_EQ(docSubObjsWithSubSizes[0]->getID(), _doc->getObject(partName)->getID()); EXPECT_EQ(docSubObjsWithSubSizes[1]->getID(), _doc->getObject(fuseName)->getID()); EXPECT_EQ(docSubObjsWithSubSizes[2]->getID(), _doc->getObject(boxName)->getID()); EXPECT_EQ(sizesNoFlatten.size(), 3); EXPECT_EQ(sizesNoFlatten[0], 0); - EXPECT_EQ(sizesNoFlatten[1], 7); - EXPECT_EQ(sizesNoFlatten[2], 17); + EXPECT_EQ(sizesNoFlatten[1], strlen(fuseName) + 1); + EXPECT_EQ(sizesNoFlatten[2], strlen(fuseName) + strlen(boxName) + 2); - // If DocumentObject::getSubObjectList() is called with the flatten argument set to true it + // If DocumentObject::getSubObjectList() is called with the flattened argument set to true, it // returns a vector with all the sub objects in the subname that don't belong to the same // App::GeoFeatureGroupExtension object, plus one entry with the object that called the method EXPECT_EQ(docSubObjsFlatten.size(), 2); @@ -151,7 +152,7 @@ TEST_F(DocumentObjectTest, getSubObjectList) EXPECT_EQ(docSubObjsFlatten[1]->getID(), _doc->getObject(boxName)->getID()); EXPECT_EQ(sizesFlatten.size(), 2); EXPECT_EQ(sizesFlatten[0], 0); - EXPECT_EQ(sizesFlatten[1], 17); + EXPECT_EQ(sizesFlatten[1], strlen(fuseName) + strlen(boxName) + 2); } // NOLINTEND(readability-magic-numbers, cppcoreguidelines-avoid-magic-numbers) diff --git a/tests/src/App/DocumentObserver.cpp b/tests/src/App/DocumentObserver.cpp index 6fdb18b970..5f85866977 100644 --- a/tests/src/App/DocumentObserver.cpp +++ b/tests/src/App/DocumentObserver.cpp @@ -135,6 +135,12 @@ TEST_F(DocumentObserverTest, normalize) auto box {_doc->addObject("Part::Box")}; // The name of the Part::Box added to the document auto boxName {box->getNameInDocument()}; + // Changing the label of the Part::Box to test the differences between calling + // SubObjectT::normalized() with the options argument set to + // SubObjectT::NormalizeOption::KeepSubName or set to other values + box->Label.setValue("Cube"); + // The label of the Part::Box added to the document + auto boxLabel {box->Label.getValue()}; // The name of a Part::Cylinder added to the document auto cylName {_doc->addObject("Part::Cylinder")->getNameInDocument()}; // An App::Part added to the document @@ -148,7 +154,7 @@ TEST_F(DocumentObserverTest, normalize) // The name of the object used as argument for various calls of the constructors of // App::SubObjectT objects auto subName {std::string()}; - // An helper string used to compose the argument of some calls of + // A helper string used to compose the argument of some calls of // Base::Interpreter().runString() auto cmd {std::string()}; @@ -210,10 +216,21 @@ TEST_F(DocumentObserverTest, normalize) auto subObjTNoFlatten {SubObjectT(lGrp, subName.c_str())}; // An App::SubObjectT object used to test SubObjectT::normalize() with the option argument set // to SubObjectT::NormalizeOption::KeepSubName - auto subObjTKeepSubName {SubObjectT(lGrp, subName.replace(0, strlen(partName), "0").c_str())}; + // The subName is modified replacing "Part__Box" with "$Cube" to test the effect of using + // SubObjectT::NormalizeOption::KeepSubName, that is leaving the "$Cube" instead of replacing it + // with the name of the DocumentObject with that label ("Part__Box") + auto subObjTKeepSubName {SubObjectT(lGrp, + subName + .replace(strlen(partName) + strlen(fuseName) + 2, + strlen(boxName), + std::string("$").append(boxLabel).c_str()) + .c_str())}; // An App::SubObjectT object used to test SubObjectT::normalize() with the option argument set // to SubObjectT::NormalizeOption::ConvertIndex - auto subObjTConvertIndex {SubObjectT(lGrp, subName.c_str())}; + // The subName is modified replacing "App_Part" with "0" to test the effect of using + // SubObjectT::NormalizeOption::ConvertIndex, that is replacing the "0" with the name of the + // DocumentObject at position 0 of lGrp + auto subObjTConvertIndex {SubObjectT(lGrp, subName.replace(0, strlen(partName), "0").c_str())}; // A bool variable used to store the result of subObjTEmpty.normalize() auto normalizeEmpty {false}; @@ -251,25 +268,42 @@ TEST_F(DocumentObserverTest, normalize) // hasn't any sub objects EXPECT_FALSE(normalizeWithoutSubObj); - // In this case calling SubObjectT::normalize() changes subObjTWithSubObj subname removing the - // "Fusion." part of the of the original subname + // In this case calling SubObjectT::normalize() changes subObjTWithSubObj subname in this way: + // The "Fusion." part of the of the original subname is removed because the + // SubObjectT::NormalizeOption::NoFlatten flag isn't set; + // The "Edge1" part of the of the original subname is kept because the + // SubObjectT::NormalizeOption::NoElement flag isn't set; EXPECT_TRUE(normalizeWithSubObj); - // In this case calling SubObjectT::normalize() changes subObjTWithoutEl subname removing the - // "Fusion." and "Edge1" parts of the of the original subname + // In this case calling SubObjectT::normalize() changes subObjTWithoutEl subname in this way: + // The "Fusion." part of the of the original subname is removed because the + // SubObjectT::NormalizeOption::NoFlatten flag isn't set; + // The "Edge1" part of the of the original subname is removed because the + // SubObjectT::NormalizeOption::NoElement flag is set; EXPECT_TRUE(normalizeWithoutEl); // In this case calling SubObjectT::normalize() doesn't have effect as neither the // DocumentObject referenced nor the subname of subObjTNoFlatten are changed EXPECT_FALSE(normalizeNoFlatten); - // In this case calling SubObjectT::normalize() changes subObjTKeepSubName subname removing the - // "Fusion." part of the of the original subname + // In this case calling SubObjectT::normalize() changes subObjTKeepSubName subname in this way: + // The "Fusion." part of the of the original subname is removed because the + // SubObjectT::NormalizeOption::NoFlatten flag isn't set; + // The "$Cube." part of the of the original subname is kept because the + // SubObjectT::NormalizeOption::KeepSubName flag is set; + // The "Edge1" part of the of the original subname is kept because the + // SubObjectT::NormalizeOption::NoElement flag isn't set; EXPECT_TRUE(normalizeKeepSubName); - // In this case calling SubObjectT::normalize() changes subObjTConvertIndex subname replacing - // the "0" part of the of the original subname with "App__Part" as lGrp object at position 0 is - // the DocumentObject with name "App__Part" and removing the "Fusion" part + // In this case calling SubObjectT::normalize() changes subObjTConvertIndex subname in this way: + // The "0." part of the of the original subname is replaced with "App__Part" because the + // SubObjectT::NormalizeOption::ConvertIndex flag is set; + // The "Fusion." part of the of the original subname is removed because the + // SubObjectT::NormalizeOption::NoFlatten flag isn't set; + // The "$Cube." part of the of the original subname is replaced with "Part__Box." because the + // SubObjectT::NormalizeOption::KeepSubName flag isn't set; + // The "Edge1" part of the of the original subname is kept because the + // SubObjectT::NormalizeOption::NoElement flag isn't set; EXPECT_TRUE(normalizeConvertIndex); } @@ -281,6 +315,12 @@ TEST_F(DocumentObserverTest, normalized) auto box {_doc->addObject("Part::Box")}; // The name of the Part::Box added to the document auto boxName {box->getNameInDocument()}; + // Changing the label of the Part::Box to test the differences between calling + // SubObjectT::normalized() with the options argument set to + // SubObjectT::NormalizeOption::KeepSubName or set to other values + box->Label.setValue("Cube"); + // The label of the Part::Box added to the document + auto boxLabel {box->Label.getValue()}; // The name of a Part::Cylinder added to the document auto cylName {_doc->addObject("Part::Cylinder")->getNameInDocument()}; // An App::Part added to the document @@ -291,10 +331,11 @@ TEST_F(DocumentObserverTest, normalized) auto lGrp {_doc->addObject("App::LinkGroup")}; // The name of the App::LinkGroup added to the document auto lGrpName {lGrp->getNameInDocument()}; + // The name of the object used as argument for various calls of the constructors of // App::SubObjectT objects auto subName {std::string()}; - // An helper string used to compose the argument of some calls of + // A helper string used to compose the argument of some calls of // Base::Interpreter().runString() auto cmd {std::string()}; @@ -323,24 +364,43 @@ TEST_F(DocumentObserverTest, normalized) Base::Interpreter().runString(cmd.c_str()); Base::Interpreter().runString("App.ActiveDocument.recompute()"); - // Adding the fusion to the App::LinkGroup object to test SubObjectT::normalized() with the - // options argument set to SubObjectT::NormalizeOption::ConvertIndex + // Creating a Link Array with the App::Part object added to the document to test + // SubObjectT::normalized() with the options argument set to + // SubObjectT::NormalizeOption::ConvertIndex or set to other values + Base::Interpreter().runString("import Draft"); + cmd = "_obj = Draft.make_ortho_array(App.ActiveDocument."; + cmd += partName; + cmd += ", v_x=FreeCAD.Vector(100.0, 0.0, 0.0), v_y=FreeCAD.Vector(0.0, 100.0, 0.0), " + "v_z=FreeCAD.Vector(0.0, 0.0, 100.0), n_x=2, n_y=2, n_z=1, use_link=True)"; + Base::Interpreter().runString(cmd.c_str()); + cmd = "_obj.Fuse = False"; + Base::Interpreter().runString(cmd.c_str()); + cmd = "Draft.autogroup(_obj)"; + Base::Interpreter().runString(cmd.c_str()); + Base::Interpreter().runString("App.ActiveDocument.recompute()"); + auto lArr {_doc->getObject("Array")}; + auto lArrName {lArr->getNameInDocument()}; + + // Adding the Link Array to the App::LinkGroup object to test SubObjectT::normalized() with the + // options argument set to SubObjectT::NormalizeOption::ConvertIndex or set to other values cmd = "App.ActiveDocument.getObject(\""; cmd += lGrpName; cmd += "\").setLink(App.ActiveDocument.getObject(\""; - cmd += partName; + cmd += lArrName; cmd += "\"))"; Base::Interpreter().runString(cmd.c_str()); Base::Interpreter().runString("App.ActiveDocument.recompute()"); // Defining the name of the object that will be used as argument for various calls of the // constructors of App::SubObjectT objects - subName = partName; - subName += "."; + subName = "0."; + subName += "3."; subName += fuseName; subName += "."; - subName += boxName; - subName += ".Edge1"; + subName += "$"; + subName += boxLabel; + subName += "."; + subName += "Edge1"; // An empty App::SubObjectT object auto subObjTEmpty {SubObjectT()}; @@ -356,7 +416,7 @@ TEST_F(DocumentObserverTest, normalized) auto subObjTNoFlatten {SubObjectT(lGrp, subName.c_str())}; // An App::SubObjectT object used to test SubObjectT::normalized() with the option argument set // to SubObjectT::NormalizeOption::KeepSubName - auto subObjTKeepSubName {SubObjectT(lGrp, subName.replace(0, strlen(partName), "0").c_str())}; + auto subObjTKeepSubName {SubObjectT(lGrp, subName.c_str())}; // An App::SubObjectT object used to test SubObjectT::normalized() with the option argument set // to SubObjectT::NormalizeOption::ConvertIndex auto subObjTConvertIndex {SubObjectT(lGrp, subName.c_str())}; @@ -398,29 +458,91 @@ TEST_F(DocumentObserverTest, normalized) // In this case calling SubObjectT::normalized() doesn't have effect as subObjTWithoutSubObj // hasn't any sub objects - EXPECT_EQ(subObjTWithoutSubObj.getSubName(), subObjTWithoutSubObj.getSubName()); + EXPECT_EQ(subObjTWithoutSubObj.getSubName(), subObjTWithoutSubObjNormalized.getSubName()); - // In this case calling SubObjectT::normalized() changes subObjTWithSubObj subname removing the - // "Fusion." part of the of the original subname + // In this case calling SubObjectT::normalized() changes subObjTWithSubObj subname in this way: + // The "0." part of the of the original subname is kept because the + // SubObjectT::NormalizeOption::ConvertIndex flag isn't set; + // The "3." part of the of the original subname is kept because the + // SubObjectT::NormalizeOption::ConvertIndex flag isn't set; + // The "Fusion." part of the of the original subname is removed because the + // SubObjectT::NormalizeOption::NoFlatten flag isn't set; + // The "$Cube." part of the of the original subname is replaced with "Part__Box." because the + // SubObjectT::NormalizeOption::KeepSubName flag isn't set; + // The "Edge1" part of the of the original subname is kept because the + // SubObjectT::NormalizeOption::NoElement flag isn't set; + EXPECT_NE(subObjTWithSubObjNormalized.getSubName().find("0."), std::string::npos); EXPECT_EQ(subObjTWithSubObjNormalized.getSubName().find(fuseName), std::string::npos); + EXPECT_EQ(subObjTWithSubObjNormalized.getSubName().find(boxLabel), std::string::npos); + EXPECT_NE(subObjTWithSubObjNormalized.getSubName().find(boxName), std::string::npos); + EXPECT_NE(subObjTWithSubObjNormalized.getSubName().find("Edge1"), std::string::npos); - // In this case calling SubObjectT::normalized() changes subObjTWithoutEl subname removing the - // "Fusion." and "Edge1" parts of the of the original subname + // In this case calling SubObjectT::normalized() changes subObjTWithoutEl subname in this way: + // The "0." part of the of the original subname is kept because the + // SubObjectT::NormalizeOption::ConvertIndex flag isn't set; + // The "3." part of the of the original subname is kept because the + // SubObjectT::NormalizeOption::ConvertIndex flag isn't set; + // The "Fusion." part of the of the original subname is removed because the + // SubObjectT::NormalizeOption::NoFlatten flag isn't set; + // The "$Cube." part of the of the original subname is replaced with "Part__Box." because the + // SubObjectT::NormalizeOption::KeepSubName flag isn't set; + // The "Edge1" part of the of the original subname is removed because the + // SubObjectT::NormalizeOption::NoElement flag is set; + EXPECT_NE(subObjTWithoutElNormalized.getSubName().find("0."), std::string::npos); EXPECT_EQ(subObjTWithoutElNormalized.getSubName().find(fuseName), std::string::npos); + EXPECT_EQ(subObjTWithoutElNormalized.getSubName().find(boxLabel), std::string::npos); + EXPECT_NE(subObjTWithoutElNormalized.getSubName().find(boxName), std::string::npos); EXPECT_EQ(subObjTWithoutElNormalized.getSubName().find("Edge1"), std::string::npos); - // In this case calling SubObjectT::normalized() doesn't have effect as neither the - // DocumentObject referenced nor the subname of subObjTNoFlatten are changed - EXPECT_EQ(subObjTNoFlatten.getSubName(), subObjTNoFlattenNormalized.getSubName()); + // In this case calling SubObjectT::normalized() changes subObjTNoFlatten subname in this way: + // The "0." part of the of the original subname is kept because the + // SubObjectT::NormalizeOption::ConvertIndex flag isn't set; + // The "3." part of the of the original subname is kept because the + // SubObjectT::NormalizeOption::ConvertIndex flag isn't set; + // The "Fusion." part of the of the original subname is kept because the + // SubObjectT::NormalizeOption::NoFlatten flag is set; + // The "$Cube." part of the of the original subname is replaced with "Part__Box." because the + // SubObjectT::NormalizeOption::KeepSubName flag isn't set; + // The "Edge1" part of the of the original subname is kept because the + // SubObjectT::NormalizeOption::NoElement flag isn't set; + EXPECT_NE(subObjTNoFlattenNormalized.getSubName().find("0."), std::string::npos); + EXPECT_NE(subObjTNoFlattenNormalized.getSubName().find(fuseName), std::string::npos); + EXPECT_EQ(subObjTNoFlattenNormalized.getSubName().find(boxLabel), std::string::npos); + EXPECT_NE(subObjTNoFlattenNormalized.getSubName().find(boxName), std::string::npos); + EXPECT_NE(subObjTNoFlattenNormalized.getSubName().find("Edge1"), std::string::npos); - // In this case calling SubObjectT::normalized() changes subObjTKeepSubName subname removing the - // "Fusion." part of the of the original subname + // In this case calling SubObjectT::normalized() changes subObjTKeepSubName subname in this way: + // The "0." part of the of the original subname is kept because the + // SubObjectT::NormalizeOption::ConvertIndex flag isn't set; + // The "3." part of the of the original subname is kept because the + // SubObjectT::NormalizeOption::ConvertIndex flag isn't set; + // The "Fusion." part of the of the original subname is removed because the + // SubObjectT::NormalizeOption::NoFlatten flag isn't set; + // The "$Cube." part of the of the original subname is kept because the + // SubObjectT::NormalizeOption::KeepSubName flag is set; + // The "Edge1" part of the of the original subname is kept because the + // SubObjectT::NormalizeOption::NoElement flag isn't set; + EXPECT_NE(subObjTKeepSubNameNormalized.getSubName().find("0."), std::string::npos); EXPECT_EQ(subObjTKeepSubNameNormalized.getSubName().find(fuseName), std::string::npos); + EXPECT_NE(subObjTKeepSubNameNormalized.getSubName().find(boxLabel), std::string::npos); + EXPECT_NE(subObjTKeepSubNameNormalized.getSubName().find("Edge1"), std::string::npos); - // In this case calling SubObjectT::normalized() changes subObjTConvertIndex subname replacing - // the "0" part of the of the original subname with "App__Part" as lGrp object at position 0 is - // the DocumentObject with name "App__Part" and removing the "Fusion" part - EXPECT_EQ(subObjTConvertIndexNormalized.getSubName().find("0"), std::string::npos); + // In this case calling SubObjectT::normalized() changes subObjTConvertIndex in this way: + // The "0." part of the of the original subname is replaced with "Array." because the + // SubObjectT::NormalizeOption::ConvertIndex flag is set; + // The "3." part of the of the original subname is kept even if the + // SubObjectT::NormalizeOption::ConvertIndex flag is set because it refers to a specific + // DocumentObject of the "Array." DocumentObject; + // The "Fusion." part of the of the original subname is removed because the + // SubObjectT::NormalizeOption::NoFlatten flag isn't set; + // The "$Cube." part of the of the original subname is replaced with "Part__Box." because the + // SubObjectT::NormalizeOption::KeepSubName flag isn't set; + // The "Edge1" part of the of the original subname is kept because the + // SubObjectT::NormalizeOption::NoElement flag isn't set; + EXPECT_EQ(subObjTConvertIndexNormalized.getSubName().find("0."), std::string::npos); + EXPECT_NE(subObjTConvertIndexNormalized.getSubName().find(lArrName), std::string::npos); EXPECT_EQ(subObjTConvertIndexNormalized.getSubName().find(fuseName), std::string::npos); - EXPECT_NE(subObjTConvertIndexNormalized.getSubName().find(partName), std::string::npos); + EXPECT_EQ(subObjTConvertIndexNormalized.getSubName().find(boxLabel), std::string::npos); + EXPECT_NE(subObjTConvertIndexNormalized.getSubName().find(boxName), std::string::npos); + EXPECT_NE(subObjTConvertIndexNormalized.getSubName().find("Edge1"), std::string::npos); }