From f819fdd1cf10d5d7884b7f97457425f400618f83 Mon Sep 17 00:00:00 2001 From: "ADS\\deboisj" Date: Thu, 26 Nov 2026 09:32:50 -0500 Subject: [PATCH 1/6] EMSUSD-4334: Add failing test for stale target icon with a visible session layer --- .../lib/usdLayerEditor/cpp/stubSessionState.h | 8 ++++- .../usdLayerEditor/cpp/testLayerTreeModel.cpp | 34 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/test/lib/usdLayerEditor/cpp/stubSessionState.h b/test/lib/usdLayerEditor/cpp/stubSessionState.h index a57e532285..f4c633ceb4 100644 --- a/test/lib/usdLayerEditor/cpp/stubSessionState.h +++ b/test/lib/usdLayerEditor/cpp/stubSessionState.h @@ -52,10 +52,15 @@ class StubSessionState : public SessionState void setupCreateMenu(QMenu* menu) override; void rootLayerPathChanged(std::string const& path) override; bool autoObserveUfeSelection() const override { return false; } - bool autoHideSessionLayer() const override { return false; } + bool autoHideSessionLayer() const override { return _autoHide; } bool isEditForwardMode() const override { return _isEFModeActive; } void setIsEditForwardMode(bool v); + void setAutoHide(bool hide) + { + _autoHide = hide; + SessionState::setAutoHideSessionLayer(hide); + } // Test helpers void addStage(PXR_NS::UsdStageRefPtr stage); @@ -74,6 +79,7 @@ class StubSessionState : public SessionState StubCommandHook _commandHookImpl; private: + bool _autoHide { false }; bool _isEFModeActive { false }; std::vector _stages; StageEntry makeEntry(PXR_NS::UsdStageRefPtr stage, const std::string& id); diff --git a/test/lib/usdLayerEditor/cpp/testLayerTreeModel.cpp b/test/lib/usdLayerEditor/cpp/testLayerTreeModel.cpp index 8a931371dd..7c2a80ac12 100644 --- a/test/lib/usdLayerEditor/cpp/testLayerTreeModel.cpp +++ b/test/lib/usdLayerEditor/cpp/testLayerTreeModel.cpp @@ -383,4 +383,38 @@ TEST_F(LayerTreeModelTest, SelectedLayerDataChanged_NotEmittedOnPlainRefresh) << "selectedLayerDataChangedSignal should not fire for a non-data-change rebuild"; } +// ── auto-hide session layer: target icon ─────────────────────────────────────── + +// EMSUSD-4334: a dirty session layer stays visible under auto-hide, so changing the edit target +// to or from it must still refresh which item is drawn as the target. +class LayerTreeModelAutoHideTest : public LayerEditorTestFixture +{ +protected: + void SetUp() override + { + LayerEditorTestFixture::SetUp(); + SdfPrimSpec::New( + _sessionState.stage()->GetSessionLayer(), "RenderSetupEdit", SdfSpecifierDef); + _sessionState.setAutoHide(true); + QApplication::processEvents(); + } + + bool isTarget(const QModelIndex& index) + { + return treeModel()->layerItemFromIndex(index)->isTargetLayer(); + } +}; + +TEST_F(LayerTreeModelAutoHideTest, TargetingVisibleSessionLayerMarksItAsTarget) +{ + ASSERT_TRUE(treeModel()->layerItemFromIndex(sessionLayerIndex())->isSessionLayer()); + + const auto stage = _sessionState.stage(); + stage->SetEditTarget(stage->GetSessionLayer()); + QApplication::processEvents(); + + EXPECT_TRUE(isTarget(sessionLayerIndex())); + EXPECT_FALSE(isTarget(rootLayerIndex())); +} + } // namespace UsdLayerEditor From 7452a2583b9e1b715ad65d2b452795ea1184808f Mon Sep 17 00:00:00 2001 From: "ADS\\deboisj" Date: Thu, 26 Nov 2026 09:36:42 -0500 Subject: [PATCH 2/6] EMSUSD-4334: Let the deferred rebuilds run in the failing test --- test/lib/usdLayerEditor/cpp/testLayerTreeModel.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/lib/usdLayerEditor/cpp/testLayerTreeModel.cpp b/test/lib/usdLayerEditor/cpp/testLayerTreeModel.cpp index 7c2a80ac12..4efba2cb7d 100644 --- a/test/lib/usdLayerEditor/cpp/testLayerTreeModel.cpp +++ b/test/lib/usdLayerEditor/cpp/testLayerTreeModel.cpp @@ -396,7 +396,14 @@ class LayerTreeModelAutoHideTest : public LayerEditorTestFixture SdfPrimSpec::New( _sessionState.stage()->GetSessionLayer(), "RenderSetupEdit", SdfSpecifierDef); _sessionState.setAutoHide(true); - QApplication::processEvents(); + settle(); + } + + // An edit target change defers a rebuild, which defers again: one pass is not enough. + static void settle() + { + for (int pass = 0; pass < 3; ++pass) + QApplication::processEvents(); } bool isTarget(const QModelIndex& index) @@ -411,7 +418,7 @@ TEST_F(LayerTreeModelAutoHideTest, TargetingVisibleSessionLayerMarksItAsTarget) const auto stage = _sessionState.stage(); stage->SetEditTarget(stage->GetSessionLayer()); - QApplication::processEvents(); + settle(); EXPECT_TRUE(isTarget(sessionLayerIndex())); EXPECT_FALSE(isTarget(rootLayerIndex())); From aad5885a32dfd7b8c024d9f8f9b8857ee06984b5 Mon Sep 17 00:00:00 2001 From: "ADS\\deboisj" Date: Thu, 26 Nov 2026 09:38:15 -0500 Subject: [PATCH 3/6] EMSUSD-4334: Refresh the target layer icon when a rebuild finds the layers unchanged --- lib/usdLayerEditor/ui/layerTreeModel.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/usdLayerEditor/ui/layerTreeModel.cpp b/lib/usdLayerEditor/ui/layerTreeModel.cpp index 8694b49538..ae9584295a 100644 --- a/lib/usdLayerEditor/ui/layerTreeModel.cpp +++ b/lib/usdLayerEditor/ui/layerTreeModel.cpp @@ -405,6 +405,8 @@ void LayerTreeModel::rebuildModel(bool refreshLockState /*= false*/) || (newSessionItem && newSessionItem->isIdenticalItem(oldSessionItem)); if (!refreshLockState && rootIdentical && sessionIdentical) { + // The layers are unchanged, but the edit target that triggered this rebuild may not be. + updateTargetLayer(InRebuildModel::Yes); return; } From 48d4743afc8d01817b29309ba610ad91a43f924b Mon Sep 17 00:00:00 2001 From: "ADS\\deboisj" Date: Thu, 26 Nov 2026 09:41:14 -0500 Subject: [PATCH 4/6] EMSUSD-4334: Reuse the session state auto-hide flag in the test stub --- test/lib/usdLayerEditor/cpp/stubSessionState.cpp | 3 +++ test/lib/usdLayerEditor/cpp/stubSessionState.h | 7 ------- test/lib/usdLayerEditor/cpp/testLayerTreeModel.cpp | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/test/lib/usdLayerEditor/cpp/stubSessionState.cpp b/test/lib/usdLayerEditor/cpp/stubSessionState.cpp index fd6d9d6439..e7badd05c6 100644 --- a/test/lib/usdLayerEditor/cpp/stubSessionState.cpp +++ b/test/lib/usdLayerEditor/cpp/stubSessionState.cpp @@ -28,6 +28,9 @@ namespace UsdLayerEditor { StubSessionState::StubSessionState() : _commandHookImpl(this) { + // Tests always show the session layer unless they turn auto-hide on. + _autoHideSessionLayer = false; + // Two in-memory stages, each with one anonymous sublayer. for (int i = 0; i < 2; ++i) { auto stage = PXR_NS::UsdStage::CreateInMemory(); diff --git a/test/lib/usdLayerEditor/cpp/stubSessionState.h b/test/lib/usdLayerEditor/cpp/stubSessionState.h index f4c633ceb4..f58cdfe2b8 100644 --- a/test/lib/usdLayerEditor/cpp/stubSessionState.h +++ b/test/lib/usdLayerEditor/cpp/stubSessionState.h @@ -52,15 +52,9 @@ class StubSessionState : public SessionState void setupCreateMenu(QMenu* menu) override; void rootLayerPathChanged(std::string const& path) override; bool autoObserveUfeSelection() const override { return false; } - bool autoHideSessionLayer() const override { return _autoHide; } bool isEditForwardMode() const override { return _isEFModeActive; } void setIsEditForwardMode(bool v); - void setAutoHide(bool hide) - { - _autoHide = hide; - SessionState::setAutoHideSessionLayer(hide); - } // Test helpers void addStage(PXR_NS::UsdStageRefPtr stage); @@ -79,7 +73,6 @@ class StubSessionState : public SessionState StubCommandHook _commandHookImpl; private: - bool _autoHide { false }; bool _isEFModeActive { false }; std::vector _stages; StageEntry makeEntry(PXR_NS::UsdStageRefPtr stage, const std::string& id); diff --git a/test/lib/usdLayerEditor/cpp/testLayerTreeModel.cpp b/test/lib/usdLayerEditor/cpp/testLayerTreeModel.cpp index 4efba2cb7d..154c95476f 100644 --- a/test/lib/usdLayerEditor/cpp/testLayerTreeModel.cpp +++ b/test/lib/usdLayerEditor/cpp/testLayerTreeModel.cpp @@ -395,7 +395,7 @@ class LayerTreeModelAutoHideTest : public LayerEditorTestFixture LayerEditorTestFixture::SetUp(); SdfPrimSpec::New( _sessionState.stage()->GetSessionLayer(), "RenderSetupEdit", SdfSpecifierDef); - _sessionState.setAutoHide(true); + _sessionState.setAutoHideSessionLayer(true); settle(); } From 983bd8c65ff4e1a153c9718aa133294a373f3659 Mon Sep 17 00:00:00 2001 From: "ADS\\deboisj" Date: Thu, 26 Nov 2026 09:44:38 -0500 Subject: [PATCH 5/6] EMSUSD-4334: Address review findings --- test/lib/usdLayerEditor/cpp/testFixture.cpp | 2 +- .../usdLayerEditor/cpp/testLayerTreeModel.cpp | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/test/lib/usdLayerEditor/cpp/testFixture.cpp b/test/lib/usdLayerEditor/cpp/testFixture.cpp index 66d89f98b3..013742e9ab 100644 --- a/test/lib/usdLayerEditor/cpp/testFixture.cpp +++ b/test/lib/usdLayerEditor/cpp/testFixture.cpp @@ -149,7 +149,7 @@ LayerTreeModel* LayerEditorTestFixture::treeModel() { return layerTree()->layerT QModelIndex LayerEditorTestFixture::sessionLayerIndex() { - // The stub always shows the session layer (autoHideSessionLayer=false). + // The stub shows the session layer unless a test turns auto-hide on. // It is always the first top-level item in the tree. return treeModel()->index(0, 0); } diff --git a/test/lib/usdLayerEditor/cpp/testLayerTreeModel.cpp b/test/lib/usdLayerEditor/cpp/testLayerTreeModel.cpp index 154c95476f..7a0180911a 100644 --- a/test/lib/usdLayerEditor/cpp/testLayerTreeModel.cpp +++ b/test/lib/usdLayerEditor/cpp/testLayerTreeModel.cpp @@ -92,7 +92,7 @@ TEST_F(LayerTreeModelTest, CanDrop_ReturnsFalseForNullMimeData) TEST_F(LayerTreeModelTest, Rebuild_AlwaysShowsSessionLayerWhenAutoHideFalse) { - // StubSessionState::autoHideSessionLayer() returns false. + // StubSessionState starts with auto-hide off. // Session layer must always be the first top-level item. treeModel()->forceRefresh(); QApplication::processEvents(); @@ -424,4 +424,18 @@ TEST_F(LayerTreeModelAutoHideTest, TargetingVisibleSessionLayerMarksItAsTarget) EXPECT_FALSE(isTarget(rootLayerIndex())); } +TEST_F(LayerTreeModelAutoHideTest, TargetingRootLayerAgainMovesTheTargetOffTheSessionLayer) +{ + const auto stage = _sessionState.stage(); + stage->SetEditTarget(stage->GetSessionLayer()); + settle(); + ASSERT_TRUE(isTarget(sessionLayerIndex())); + + stage->SetEditTarget(stage->GetRootLayer()); + settle(); + + EXPECT_TRUE(isTarget(rootLayerIndex())); + EXPECT_FALSE(isTarget(sessionLayerIndex())); +} + } // namespace UsdLayerEditor From d62012d1897a6aa5806e0454729e5de0abeb802d Mon Sep 17 00:00:00 2001 From: "ADS\\deboisj" Date: Thu, 26 Nov 2026 10:00:51 -0500 Subject: [PATCH 6/6] Remove the ticket key from a test comment --- test/lib/usdLayerEditor/cpp/testLayerTreeModel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/lib/usdLayerEditor/cpp/testLayerTreeModel.cpp b/test/lib/usdLayerEditor/cpp/testLayerTreeModel.cpp index 7a0180911a..91fca69aed 100644 --- a/test/lib/usdLayerEditor/cpp/testLayerTreeModel.cpp +++ b/test/lib/usdLayerEditor/cpp/testLayerTreeModel.cpp @@ -385,8 +385,8 @@ TEST_F(LayerTreeModelTest, SelectedLayerDataChanged_NotEmittedOnPlainRefresh) // ── auto-hide session layer: target icon ─────────────────────────────────────── -// EMSUSD-4334: a dirty session layer stays visible under auto-hide, so changing the edit target -// to or from it must still refresh which item is drawn as the target. +// A dirty session layer stays visible under auto-hide, so changing the edit target to or from it +// must still refresh which item is drawn as the target. class LayerTreeModelAutoHideTest : public LayerEditorTestFixture { protected: