From ac82798d166665fb8f3271483d32b37fde4a0851 Mon Sep 17 00:00:00 2001 From: Ivan Vlasov Date: Thu, 29 Feb 2024 11:49:29 -0500 Subject: [PATCH 1/4] Fixing double-rendering of USD prims + autotest --- .../test/adskHydraSceneBrowserTestFixture.cpp | 55 +++++++++++++++++++ .../test/adskHydraSceneBrowserTestFixture.h | 2 + .../test/adskHydraSceneBrowserTesting.cpp | 10 ++++ .../test/adskHydraSceneBrowserTesting.h | 3 + ...pWireframeSelectionHighlightSceneIndex.cpp | 18 ++---- .../mayaHydraSceneBrowserTestCmd.cpp | 20 +++++-- 6 files changed, 91 insertions(+), 17 deletions(-) diff --git a/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTestFixture.cpp b/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTestFixture.cpp index 0e9e93c24f..6c48fb1caf 100644 --- a/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTestFixture.cpp +++ b/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTestFixture.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include @@ -90,6 +91,60 @@ void AdskHydraSceneBrowserTestFixture::SetReferenceSceneIndex( sceneIndex = referenceSceneIndex; } +void AdskHydraSceneBrowserTestFixture::VerifySceneCorrectness() +{ + // Traverse prim hierarchy + QTreeWidgetItemIterator itPrimsTreeWidget = GetIteratorForTree(_primHierarchyWidget); + for (; *itPrimsTreeWidget; itPrimsTreeWidget++) { + QTreeWidgetItem* primQtItem = *itPrimsTreeWidget; + _primHierarchyWidget->setCurrentItem(primQtItem); + + // Traverse data source hierarchy + QTreeWidgetItemIterator itDataSourceTreeWidget = GetIteratorForTree(_dataSourceHierarchyWidget); + for (; *itDataSourceTreeWidget; itDataSourceTreeWidget++) { + QTreeWidgetItem* dataSourceQtItem = *itDataSourceTreeWidget; + + // Verify representation selector's correctness + if (dataSourceQtItem->text(0) == "reprSelector") { + _dataSourceHierarchyWidget->setCurrentItem(dataSourceQtItem); + + int numPointReprs = 0; + int numWireReprs = 0; + int numSurfReprs = 0; + + // Count representations in use + _dataSourceValueView->expandAll(); + QAbstractItemModel* dataSourceItemModel = _dataSourceValueView->model(); + for (int row = 0; row < dataSourceItemModel->rowCount(); ++row) { + QModelIndex valueIndex = dataSourceItemModel->index(row, 0); + QVariant valueData = dataSourceItemModel->data(valueIndex, Qt::DisplayRole); + pxr::TfToken reprName(valueData.toString().toStdString()); + + if (reprName == pxr::HdReprTokens->hull || + reprName == pxr::HdReprTokens->smoothHull || + reprName == pxr::HdReprTokens->refined) { + ++numSurfReprs; + } else if (reprName == pxr::HdReprTokens->refinedWire || + reprName == pxr::HdReprTokens->wire) { + ++numWireReprs; + } else if (reprName == pxr::HdReprTokens->refinedWireOnSurf || + reprName == pxr::HdReprTokens->wireOnSurf) { + ++numWireReprs; + ++numSurfReprs; + } else if (reprName == pxr::HdReprTokens->points) { + ++numPointReprs; + } + } + + // Verify that we don't draw the same geometry more than once + EXPECT_LE(numPointReprs, 1); + EXPECT_LE(numWireReprs, 1); + EXPECT_LE(numSurfReprs, 1); + } + } + } +} + void AdskHydraSceneBrowserTestFixture::ComparePrimHierarchy( bool compareDataSourceHierarchy, bool compareDataSourceValues) diff --git a/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTestFixture.h b/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTestFixture.h index df0b285521..e37ef2276b 100644 --- a/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTestFixture.h +++ b/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTestFixture.h @@ -53,6 +53,8 @@ class AdskHydraSceneBrowserTestFixture : public ::testing::Test bool compareDataSourceHierarchy = false, bool compareDataSourceValues = false); + void VerifySceneCorrectness(); + void CompareDataSourceHierarchy(DataSourceEntry rootDataSourceEntry, bool compareValues = false); diff --git a/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTesting.cpp b/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTesting.cpp index 93ff0cf277..dff3b4e7e1 100644 --- a/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTesting.cpp +++ b/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTesting.cpp @@ -43,6 +43,11 @@ bool RunFullSceneIndexComparisonTest(pxr::HdSceneIndexBasePtr referenceSceneInde AdskHydraSceneBrowserTestFixture::SetReferenceSceneIndex(referenceSceneIndex); return RunTestsWithFilter("AdskHydraSceneBrowserTestFixture.FullSceneIndexComparison"); } +bool RunSceneCorrectnessTest(pxr::HdSceneIndexBasePtr referenceSceneIndex) +{ + AdskHydraSceneBrowserTestFixture::SetReferenceSceneIndex(referenceSceneIndex); + return RunTestsWithFilter("AdskHydraSceneBrowserTestFixture.VerifySceneCorrectness"); +} } // namespace AdskHydraSceneBrowserTesting TEST_F(AdskHydraSceneBrowserTestFixture, FullSceneIndexComparison) @@ -52,3 +57,8 @@ TEST_F(AdskHydraSceneBrowserTestFixture, FullSceneIndexComparison) bool compareDataSourceValues = true; ComparePrimHierarchy(compareDataSourceHierarchy, compareDataSourceValues); } + +TEST_F(AdskHydraSceneBrowserTestFixture, VerifySceneCorrectness) +{ + VerifySceneCorrectness(); +} diff --git a/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTesting.h b/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTesting.h index 41047bcc3d..defee52ce7 100644 --- a/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTesting.h +++ b/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTesting.h @@ -23,6 +23,9 @@ namespace AdskHydraSceneBrowserTesting { HDUITEST_API bool RunFullSceneIndexComparisonTest(pxr::HdSceneIndexBasePtr referenceSceneIndex); + +HDUITEST_API +bool RunSceneCorrectnessTest(pxr::HdSceneIndexBasePtr referenceSceneIndex); } // namespace AdskHydraSceneBrowserTesting #endif // ADSK_HYDRA_SCENE_BROWSER_TESTING_H diff --git a/lib/flowViewport/sceneIndex/fvpWireframeSelectionHighlightSceneIndex.cpp b/lib/flowViewport/sceneIndex/fvpWireframeSelectionHighlightSceneIndex.cpp index 75ed0e9355..fe56365453 100644 --- a/lib/flowViewport/sceneIndex/fvpWireframeSelectionHighlightSceneIndex.cpp +++ b/lib/flowViewport/sceneIndex/fvpWireframeSelectionHighlightSceneIndex.cpp @@ -33,15 +33,7 @@ const HdRetainedContainerDataSourceHandle sSelectedDisplayStyleDataSource HdRetainedContainerDataSource::New( HdLegacyDisplayStyleSchemaTokens->reprSelector, HdRetainedTypedSampledDataSource>::New( - { HdReprTokens->refinedWireOnSurf, HdReprTokens->wireOnSurf, TfToken() }))); - -const HdRetainedContainerDataSourceHandle sUnselectedDisplayStyleDataSource - = HdRetainedContainerDataSource::New( - HdLegacyDisplayStyleSchemaTokens->displayStyle, - HdRetainedContainerDataSource::New( - HdLegacyDisplayStyleSchemaTokens->reprSelector, - HdRetainedTypedSampledDataSource>::New( - { HdReprTokens->refined, HdReprTokens->refined, TfToken() }))); + { HdReprTokens->refinedWireOnSurf, TfToken(), TfToken() }))); const HdDataSourceLocator reprSelectorLocator( HdLegacyDisplayStyleSchemaTokens->displayStyle, @@ -88,10 +80,10 @@ WireframeSelectionHighlightSceneIndex::GetPrim(const SdfPath &primPath) const // index to convert implicit surfaces (e.g. USD cube / cone / sphere / // capsule primitive types) to meshes. if (!isExcluded(primPath) && prim.primType == HdPrimTypeTokens->mesh) { - prim.dataSource = HdOverlayContainerDataSource::New( - { prim.dataSource, _selection->HasFullySelectedAncestorInclusive(primPath) ? - sSelectedDisplayStyleDataSource : - sUnselectedDisplayStyleDataSource }); + if (_selection->HasFullySelectedAncestorInclusive(primPath)) { + prim.dataSource = HdOverlayContainerDataSource::New( + { prim.dataSource, sSelectedDisplayStyleDataSource }); + } } return prim; } diff --git a/plugin/mayaHydraSceneBrowserTest/mayaHydraSceneBrowserTestCmd.cpp b/plugin/mayaHydraSceneBrowserTest/mayaHydraSceneBrowserTestCmd.cpp index 394481b53a..b1f34c4aeb 100644 --- a/plugin/mayaHydraSceneBrowserTest/mayaHydraSceneBrowserTestCmd.cpp +++ b/plugin/mayaHydraSceneBrowserTest/mayaHydraSceneBrowserTestCmd.cpp @@ -31,6 +31,14 @@ using namespace MAYAHYDRA_NS; const MString mayaHydraSceneBrowserTestCmd::name("mayaHydraSceneBrowserTest"); +namespace { +void DisplayResult(bool didTestSucceed, const char* testDisplayName) +{ + MString testResultString = didTestSucceed ? MString(" test result : PASS") : MString(" test result : FAIL"); + MGlobal::displayInfo(testDisplayName + testResultString); +} +} // namespace + MStatus mayaHydraSceneBrowserTestCmd::doIt(const MArgList& args) { // Retrieve the scene index @@ -44,13 +52,17 @@ MStatus mayaHydraSceneBrowserTestCmd::doIt(const MArgList& args) // Run comparison test bool didTestSucceed = AdskHydraSceneBrowserTesting::RunFullSceneIndexComparisonTest(sceneIndices.front()); + bool didAllTestsSucceed = didTestSucceed; + DisplayResult(didTestSucceed, "Hydra Scene Browser comparison"); - // Display result - MString testResultString = didTestSucceed ? MString("PASS") : MString("FAIL"); - MGlobal::displayInfo("Hydra Scene Browser comparison test result : " + testResultString); + // Run correctness test + didTestSucceed + = AdskHydraSceneBrowserTesting::RunSceneCorrectnessTest(sceneIndices.front()); + didAllTestsSucceed |= didTestSucceed; + DisplayResult(didTestSucceed, "Hydra Scene correctness"); // Return result - return didTestSucceed ? MS::kSuccess : MS::kFailure; + return didAllTestsSucceed ? MS::kSuccess : MS::kFailure; } MStatus initializePlugin(MObject obj) From 5ded0cbded85060c2079274595795caa0f027f69 Mon Sep 17 00:00:00 2001 From: Ivan Vlasov Date: Mon, 4 Mar 2024 13:51:35 -0500 Subject: [PATCH 2/4] Fixing an automation test --- .../cpp/testWireframeSelectionHighlightSceneIndex.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/lib/mayaUsd/render/mayaToHydra/cpp/testWireframeSelectionHighlightSceneIndex.cpp b/test/lib/mayaUsd/render/mayaToHydra/cpp/testWireframeSelectionHighlightSceneIndex.cpp index cb418d68ae..f29f4a98d8 100644 --- a/test/lib/mayaUsd/render/mayaToHydra/cpp/testWireframeSelectionHighlightSceneIndex.cpp +++ b/test/lib/mayaUsd/render/mayaToHydra/cpp/testWireframeSelectionHighlightSceneIndex.cpp @@ -82,7 +82,7 @@ bool hasSelectionHighlight(const HdSceneIndexPrim& prim) return false; } - static VtArray expected({HdReprTokens->refinedWireOnSurf, HdReprTokens->wireOnSurf, TfToken()}); + static VtArray expected({HdReprTokens->refinedWireOnSurf, TfToken(), TfToken()}); return taDs->GetValue(0) == expected; } From 02d64ae7d31d3c8156be6878529bf7dd7cc1ae3f Mon Sep 17 00:00:00 2001 From: Ivan Vlasov Date: Wed, 6 Mar 2024 11:17:50 -0500 Subject: [PATCH 3/4] Reimplementing the automation test --- .../mayaUsd/render/mayaToHydra/CMakeLists.txt | 1 + .../render/mayaToHydra/cpp/CMakeLists.txt | 1 + .../mayaToHydra/cpp/testSceneCorrectness.cpp | 136 ++++++++++++++++++ .../mayaToHydra/cpp/testSceneCorrectness.py | 50 +++++++ 4 files changed, 188 insertions(+) create mode 100644 test/lib/mayaUsd/render/mayaToHydra/cpp/testSceneCorrectness.cpp create mode 100644 test/lib/mayaUsd/render/mayaToHydra/cpp/testSceneCorrectness.py diff --git a/test/lib/mayaUsd/render/mayaToHydra/CMakeLists.txt b/test/lib/mayaUsd/render/mayaToHydra/CMakeLists.txt index 70e5a195fa..046e6ae0c2 100644 --- a/test/lib/mayaUsd/render/mayaToHydra/CMakeLists.txt +++ b/test/lib/mayaUsd/render/mayaToHydra/CMakeLists.txt @@ -42,6 +42,7 @@ set(INTERACTIVE_TEST_SCRIPT_FILES cpp/testFlowViewportAPIAddPrims.py cpp/testUsdStageLayerMuting.py cpp/testFlowViewportAPIFilterPrims.py + cpp/testSceneCorrectness.py cpp/testPrimInstancing.py ) diff --git a/test/lib/mayaUsd/render/mayaToHydra/cpp/CMakeLists.txt b/test/lib/mayaUsd/render/mayaToHydra/cpp/CMakeLists.txt index 43833d72eb..270b80abb3 100644 --- a/test/lib/mayaUsd/render/mayaToHydra/cpp/CMakeLists.txt +++ b/test/lib/mayaUsd/render/mayaToHydra/cpp/CMakeLists.txt @@ -27,6 +27,7 @@ target_sources(${TARGET_NAME} testUsdStageLayerMuting.cpp testMeshAdapterTransform.cpp testFlowViewportAPIFilterPrims.cpp + testSceneCorrectness.cpp testPrimInstancing.cpp ) diff --git a/test/lib/mayaUsd/render/mayaToHydra/cpp/testSceneCorrectness.cpp b/test/lib/mayaUsd/render/mayaToHydra/cpp/testSceneCorrectness.cpp new file mode 100644 index 0000000000..5394cd3a40 --- /dev/null +++ b/test/lib/mayaUsd/render/mayaToHydra/cpp/testSceneCorrectness.cpp @@ -0,0 +1,136 @@ +// Copyright 2024 Autodesk +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include "testUtils.h" + +#include + +#include + +#include + +PXR_NAMESPACE_USING_DIRECTIVE + +namespace { + +struct DataSourceEntry +{ + pxr::TfToken name; + pxr::HdDataSourceBaseHandle dataSource; +}; + +void VerifyDataSource(DataSourceEntry rootDataSourceEntry) +{ + // Traverse the hierarchy and verify + std::stack dataSourceStack({ rootDataSourceEntry }); + while (!dataSourceStack.empty()) { + DataSourceEntry dataSourceEntry = dataSourceStack.top(); + + // Verify representation selector's correctness + if (dataSourceEntry.name == "reprSelector") { + if (auto sampledDataSource + = pxr::HdSampledDataSource::Cast(dataSourceEntry.dataSource)) { + + pxr::VtValue value = sampledDataSource->GetValue(0.0f); + if (value.IsHolding>()) { + auto array = value.UncheckedGet>(); + + int numPointReprs = 0; + int numWireReprs = 0; + int numSurfReprs = 0; + + // Count representations in use + for (size_t j = 0; j < array.size(); ++j) { + pxr::TfToken reprName(array[j]); + + if (reprName == pxr::HdReprTokens->hull || + reprName == pxr::HdReprTokens->smoothHull || + reprName == pxr::HdReprTokens->refined) { + ++numSurfReprs; + } else if (reprName == pxr::HdReprTokens->refinedWire || + reprName == pxr::HdReprTokens->wire) { + ++numWireReprs; + } else if (reprName == pxr::HdReprTokens->refinedWireOnSurf || + reprName == pxr::HdReprTokens->wireOnSurf) { + ++numWireReprs; + ++numSurfReprs; + } else if (reprName == pxr::HdReprTokens->points) { + ++numPointReprs; + } + } + + // Verify that we don't draw the same geometry more than once + EXPECT_LE(numPointReprs, 1); + EXPECT_LE(numWireReprs, 1); + EXPECT_LE(numSurfReprs, 1); + } + } + } + + // Prepare next step + dataSourceStack.pop(); + if (auto containerDataSource + = pxr::HdContainerDataSource::Cast(dataSourceEntry.dataSource)) { + pxr::TfTokenVector childNames = containerDataSource->GetNames(); + for (auto itChildNames = childNames.rbegin(); itChildNames != childNames.rend(); + itChildNames++) { + pxr::TfToken dataSourceName = *itChildNames; + pxr::HdDataSourceBaseHandle dataSource = containerDataSource->Get(dataSourceName); + if (dataSource) { + dataSourceStack.push({ dataSourceName, dataSource }); + } + } + } else if ( + auto vectorDataSource = pxr::HdVectorDataSource::Cast(dataSourceEntry.dataSource)) { + for (size_t iElement = 0; iElement < vectorDataSource->GetNumElements(); iElement++) { + size_t reversedElementIndex = vectorDataSource->GetNumElements() - 1 - iElement; + pxr::TfToken dataSourceName = pxr::TfToken(std::to_string(reversedElementIndex)); + pxr::HdDataSourceBaseHandle dataSource + = vectorDataSource->GetElement(reversedElementIndex); + if (dataSource) { + dataSourceStack.push({ dataSourceName, dataSource }); + } + } + } + } +} + +} // namespace + +TEST(HydraScene, testHydraSceneCorrectness) +{ + // Retrieve the scene index + const SceneIndicesVector& sceneIndices = GetTerminalSceneIndices(); + EXPECT_TRUE(!sceneIndices.empty()); + pxr::HdSceneIndexBasePtr sceneIndex = sceneIndices.front(); + + // Traverse the hierarchy + std::stack primPathsStack({ pxr::SdfPath::AbsoluteRootPath() }); + while (!primPathsStack.empty()) { + pxr::SdfPath primPath = primPathsStack.top(); + pxr::HdSceneIndexPrim prim = sceneIndex->GetPrim(primPath); + + // Verify the data source + VerifyDataSource({ primPath.GetNameToken(), prim.dataSource }); + + // Prepare next step + primPathsStack.pop(); + pxr::SdfPathVector childPaths = sceneIndex->GetChildPrimPaths(primPath); + for (auto itChildPaths = childPaths.rbegin(); itChildPaths != childPaths.rend(); + itChildPaths++) { + primPathsStack.push(*itChildPaths); + } + } +} diff --git a/test/lib/mayaUsd/render/mayaToHydra/cpp/testSceneCorrectness.py b/test/lib/mayaUsd/render/mayaToHydra/cpp/testSceneCorrectness.py new file mode 100644 index 0000000000..cf9a27755e --- /dev/null +++ b/test/lib/mayaUsd/render/mayaToHydra/cpp/testSceneCorrectness.py @@ -0,0 +1,50 @@ +# Copyright 2024 Autodesk +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import maya.cmds as cmds + +import fixturesUtils +import mtohUtils +import unittest + +import testUtils +from testUtils import PluginLoaded + +class TestSceneCorrectness(mtohUtils.MayaHydraBaseTestCase): + # MayaHydraBaseTestCase.setUpClass requirement. + _file = __file__ + + def loadUsdScene(self): + import usdUtils + usdScenePath = testUtils.getTestScene('testStagePayloadsReferences', 'cube.usda') + usdUtils.createStageFromFile(usdScenePath) + self.setHdStormRenderer() + + @unittest.skipUnless(mtohUtils.checkForMayaUsdPlugin(), "Requires Maya USD Plugin.") + def test_HydraFromUsdSceneCorrectness(self): + self.loadUsdScene() + cmds.select(all=True) + cmds.refresh() + with PluginLoaded('mayaHydraCppTests'): + cmds.mayaHydraCppTest(f="HydraScene.testHydraSceneCorrectness") + + def test_HydraFromMayaSceneCorrectness(self): + self.makeCubeScene(camDist=6) + cmds.select(all=True) + cmds.refresh() + with PluginLoaded('mayaHydraCppTests'): + cmds.mayaHydraCppTest(f="HydraScene.testHydraSceneCorrectness") + +if __name__ == '__main__': + fixturesUtils.runTests(globals()) From ce4f1d9a24924a333f0299087cda5ad8811737dd Mon Sep 17 00:00:00 2001 From: Ivan Vlasov Date: Wed, 6 Mar 2024 11:27:35 -0500 Subject: [PATCH 4/4] Removing the autotest that was added to HydraSceneBrowserTest because it's no longer needed --- .../test/adskHydraSceneBrowserTestFixture.cpp | 55 ------------------- .../test/adskHydraSceneBrowserTestFixture.h | 2 - .../test/adskHydraSceneBrowserTesting.cpp | 10 ---- .../test/adskHydraSceneBrowserTesting.h | 3 - .../mayaHydraSceneBrowserTestCmd.cpp | 20 ++----- 5 files changed, 4 insertions(+), 86 deletions(-) diff --git a/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTestFixture.cpp b/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTestFixture.cpp index 6c48fb1caf..0e9e93c24f 100644 --- a/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTestFixture.cpp +++ b/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTestFixture.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include @@ -91,60 +90,6 @@ void AdskHydraSceneBrowserTestFixture::SetReferenceSceneIndex( sceneIndex = referenceSceneIndex; } -void AdskHydraSceneBrowserTestFixture::VerifySceneCorrectness() -{ - // Traverse prim hierarchy - QTreeWidgetItemIterator itPrimsTreeWidget = GetIteratorForTree(_primHierarchyWidget); - for (; *itPrimsTreeWidget; itPrimsTreeWidget++) { - QTreeWidgetItem* primQtItem = *itPrimsTreeWidget; - _primHierarchyWidget->setCurrentItem(primQtItem); - - // Traverse data source hierarchy - QTreeWidgetItemIterator itDataSourceTreeWidget = GetIteratorForTree(_dataSourceHierarchyWidget); - for (; *itDataSourceTreeWidget; itDataSourceTreeWidget++) { - QTreeWidgetItem* dataSourceQtItem = *itDataSourceTreeWidget; - - // Verify representation selector's correctness - if (dataSourceQtItem->text(0) == "reprSelector") { - _dataSourceHierarchyWidget->setCurrentItem(dataSourceQtItem); - - int numPointReprs = 0; - int numWireReprs = 0; - int numSurfReprs = 0; - - // Count representations in use - _dataSourceValueView->expandAll(); - QAbstractItemModel* dataSourceItemModel = _dataSourceValueView->model(); - for (int row = 0; row < dataSourceItemModel->rowCount(); ++row) { - QModelIndex valueIndex = dataSourceItemModel->index(row, 0); - QVariant valueData = dataSourceItemModel->data(valueIndex, Qt::DisplayRole); - pxr::TfToken reprName(valueData.toString().toStdString()); - - if (reprName == pxr::HdReprTokens->hull || - reprName == pxr::HdReprTokens->smoothHull || - reprName == pxr::HdReprTokens->refined) { - ++numSurfReprs; - } else if (reprName == pxr::HdReprTokens->refinedWire || - reprName == pxr::HdReprTokens->wire) { - ++numWireReprs; - } else if (reprName == pxr::HdReprTokens->refinedWireOnSurf || - reprName == pxr::HdReprTokens->wireOnSurf) { - ++numWireReprs; - ++numSurfReprs; - } else if (reprName == pxr::HdReprTokens->points) { - ++numPointReprs; - } - } - - // Verify that we don't draw the same geometry more than once - EXPECT_LE(numPointReprs, 1); - EXPECT_LE(numWireReprs, 1); - EXPECT_LE(numSurfReprs, 1); - } - } - } -} - void AdskHydraSceneBrowserTestFixture::ComparePrimHierarchy( bool compareDataSourceHierarchy, bool compareDataSourceValues) diff --git a/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTestFixture.h b/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTestFixture.h index e37ef2276b..df0b285521 100644 --- a/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTestFixture.h +++ b/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTestFixture.h @@ -53,8 +53,6 @@ class AdskHydraSceneBrowserTestFixture : public ::testing::Test bool compareDataSourceHierarchy = false, bool compareDataSourceValues = false); - void VerifySceneCorrectness(); - void CompareDataSourceHierarchy(DataSourceEntry rootDataSourceEntry, bool compareValues = false); diff --git a/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTesting.cpp b/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTesting.cpp index dff3b4e7e1..93ff0cf277 100644 --- a/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTesting.cpp +++ b/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTesting.cpp @@ -43,11 +43,6 @@ bool RunFullSceneIndexComparisonTest(pxr::HdSceneIndexBasePtr referenceSceneInde AdskHydraSceneBrowserTestFixture::SetReferenceSceneIndex(referenceSceneIndex); return RunTestsWithFilter("AdskHydraSceneBrowserTestFixture.FullSceneIndexComparison"); } -bool RunSceneCorrectnessTest(pxr::HdSceneIndexBasePtr referenceSceneIndex) -{ - AdskHydraSceneBrowserTestFixture::SetReferenceSceneIndex(referenceSceneIndex); - return RunTestsWithFilter("AdskHydraSceneBrowserTestFixture.VerifySceneCorrectness"); -} } // namespace AdskHydraSceneBrowserTesting TEST_F(AdskHydraSceneBrowserTestFixture, FullSceneIndexComparison) @@ -57,8 +52,3 @@ TEST_F(AdskHydraSceneBrowserTestFixture, FullSceneIndexComparison) bool compareDataSourceValues = true; ComparePrimHierarchy(compareDataSourceHierarchy, compareDataSourceValues); } - -TEST_F(AdskHydraSceneBrowserTestFixture, VerifySceneCorrectness) -{ - VerifySceneCorrectness(); -} diff --git a/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTesting.h b/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTesting.h index defee52ce7..41047bcc3d 100644 --- a/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTesting.h +++ b/lib/adskHydraSceneBrowser/test/adskHydraSceneBrowserTesting.h @@ -23,9 +23,6 @@ namespace AdskHydraSceneBrowserTesting { HDUITEST_API bool RunFullSceneIndexComparisonTest(pxr::HdSceneIndexBasePtr referenceSceneIndex); - -HDUITEST_API -bool RunSceneCorrectnessTest(pxr::HdSceneIndexBasePtr referenceSceneIndex); } // namespace AdskHydraSceneBrowserTesting #endif // ADSK_HYDRA_SCENE_BROWSER_TESTING_H diff --git a/plugin/mayaHydraSceneBrowserTest/mayaHydraSceneBrowserTestCmd.cpp b/plugin/mayaHydraSceneBrowserTest/mayaHydraSceneBrowserTestCmd.cpp index b1f34c4aeb..394481b53a 100644 --- a/plugin/mayaHydraSceneBrowserTest/mayaHydraSceneBrowserTestCmd.cpp +++ b/plugin/mayaHydraSceneBrowserTest/mayaHydraSceneBrowserTestCmd.cpp @@ -31,14 +31,6 @@ using namespace MAYAHYDRA_NS; const MString mayaHydraSceneBrowserTestCmd::name("mayaHydraSceneBrowserTest"); -namespace { -void DisplayResult(bool didTestSucceed, const char* testDisplayName) -{ - MString testResultString = didTestSucceed ? MString(" test result : PASS") : MString(" test result : FAIL"); - MGlobal::displayInfo(testDisplayName + testResultString); -} -} // namespace - MStatus mayaHydraSceneBrowserTestCmd::doIt(const MArgList& args) { // Retrieve the scene index @@ -52,17 +44,13 @@ MStatus mayaHydraSceneBrowserTestCmd::doIt(const MArgList& args) // Run comparison test bool didTestSucceed = AdskHydraSceneBrowserTesting::RunFullSceneIndexComparisonTest(sceneIndices.front()); - bool didAllTestsSucceed = didTestSucceed; - DisplayResult(didTestSucceed, "Hydra Scene Browser comparison"); - // Run correctness test - didTestSucceed - = AdskHydraSceneBrowserTesting::RunSceneCorrectnessTest(sceneIndices.front()); - didAllTestsSucceed |= didTestSucceed; - DisplayResult(didTestSucceed, "Hydra Scene correctness"); + // Display result + MString testResultString = didTestSucceed ? MString("PASS") : MString("FAIL"); + MGlobal::displayInfo("Hydra Scene Browser comparison test result : " + testResultString); // Return result - return didAllTestsSucceed ? MS::kSuccess : MS::kFailure; + return didTestSucceed ? MS::kSuccess : MS::kFailure; } MStatus initializePlugin(MObject obj)