From 2496678e56ea3bcd58802d198ebb9d1fe4e8c37d Mon Sep 17 00:00:00 2001 From: jesusalvino <96534278+jesusalvino@users.noreply.github.com> Date: Fri, 17 Mar 2023 09:35:43 -0500 Subject: [PATCH] Fixing Ghost warning (#13820) * Fixing Ghost warning * Keeping the Warning Color for the new state * Adding the Unit test * Revert "Keeping the Warning Color for the new state" This reverts commit 40e964370afdb1f35fa7bb61c5d5191ca7f59ba5. * Revert "Fixing Ghost warning" This reverts commit 04c14c1938616041a221406ba13015ea4da90867. * Updates, Implementation and Test --- .../ViewModels/Core/NodeViewModel.cs | 9 +- test/DynamoCoreWpfTests/NodeViewTests.cs | 36 ++- test/UI/DisplayImage.dyn | 239 ++++++++++++++++++ 3 files changed, 281 insertions(+), 3 deletions(-) create mode 100644 test/UI/DisplayImage.dyn diff --git a/src/DynamoCoreWpf/ViewModels/Core/NodeViewModel.cs b/src/DynamoCoreWpf/ViewModels/Core/NodeViewModel.cs index 103cc613d3e..0e06a22aa85 100644 --- a/src/DynamoCoreWpf/ViewModels/Core/NodeViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Core/NodeViewModel.cs @@ -899,7 +899,14 @@ private void Logic_NodeMessagesClearing(NodeModel obj) // 1. Compile-time warnings in CBNs // 2. Obsolete nodes with warnings // 3. Dummy or unresolved nodes - if (nodeLogic.State == ElementState.Error || nodeLogic.State == ElementState.PersistentWarning || ErrorBubble == null) return; + if (nodeLogic.State == ElementState.Error || nodeLogic.State == ElementState.PersistentWarning) return; + + // For certain nodes without ErrorBubble in place, handle color overlay specifically + if (ErrorBubble == null) + { + HandleColorOverlayChange(); + return; + } if (DynamoViewModel.UIDispatcher != null) { diff --git a/test/DynamoCoreWpfTests/NodeViewTests.cs b/test/DynamoCoreWpfTests/NodeViewTests.cs index cafc2d8c964..146cdd9820e 100644 --- a/test/DynamoCoreWpfTests/NodeViewTests.cs +++ b/test/DynamoCoreWpfTests/NodeViewTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.IO; @@ -405,6 +405,38 @@ public void ZoomChangeVisibilityTest() Assert.AreEqual(nodeViewWarningWarningFrozenHidden.nodeColorOverlayZoomOut.Visibility, System.Windows.Visibility.Collapsed); } + [Test] + public void ZoomWarningFileFromPathTest() + { + // Arrange + Open(@"UI\DisplayImage.dyn"); + + NodeView filePathNode = NodeViewWithGuid(Guid.Parse("5a424eaa78c84cffaef5469c034de703").ToString()); + NodeView fileFromPathNode = NodeViewWithGuid(Guid.Parse("eeeadd2b09294b5fbe3ea2668b99777a").ToString()); + NodeView imageReadFromFileNode = NodeViewWithGuid(Guid.Parse("8d82e3934d0e464cb810ddc7389ab0ae").ToString()); + + // Get a reference to the NodeViewModels and the current workspace + NodeViewModel filePathNodeViewModel = filePathNode.DataContext as NodeViewModel; + NodeViewModel fileFromPathNodeViewModel = (fileFromPathNode.DataContext as NodeViewModel); + NodeViewModel imageReadFromFileNodeViewModel = imageReadFromFileNode.DataContext as NodeViewModel; + + WorkspaceViewModel wvm = filePathNodeViewModel.WorkspaceViewModel as WorkspaceViewModel; + + // Zoom out, less than 0.4 + wvm.Zoom = 0.3; + + Assert.AreEqual(fileFromPathNode.nodeColorOverlayZoomOut.Visibility, System.Windows.Visibility.Visible); + Assert.AreEqual(fileFromPathNode.zoomGlyphsGrid.Visibility, System.Windows.Visibility.Visible); + + // Fix the image path and re run the engine + filePathNodeViewModel.NodeModel.UpdateValue(new Dynamo.Graph.UpdateValueParams("Value", ".\\Bricks.PNG")); + + wvm.Zoom = 0.6; + + Assert.AreEqual(fileFromPathNode.nodeColorOverlayZoomOut.Visibility, System.Windows.Visibility.Collapsed); + Assert.AreEqual(fileFromPathNode.zoomGlyphsGrid.Visibility, System.Windows.Visibility.Collapsed); + } + /// /// Tests the GetWarningColor method to ensure that the node's WarningBar displays /// the proper colors when a node is displaying Info/Warning/Error messages. @@ -607,4 +639,4 @@ public void TestPortDefaultValueMarket_Visibility() Assert.AreEqual(outPort_Without_Function.ValueMarkerWidth, outPort_Without_Function.ValueMarkerWidthWithoutFunction); } } -} \ No newline at end of file +} diff --git a/test/UI/DisplayImage.dyn b/test/UI/DisplayImage.dyn new file mode 100644 index 00000000000..09c4c5effd7 --- /dev/null +++ b/test/UI/DisplayImage.dyn @@ -0,0 +1,239 @@ +{ + "Uuid": "1f5822e6-f571-49f3-b3d0-1563463dd413", + "IsCustomNode": false, + "Description": "", + "Name": "DisplayImage", + "ElementResolver": { + "ResolutionMap": {} + }, + "Inputs": [], + "Outputs": [], + "Nodes": [ + { + "ConcreteType": "CoreNodeModels.Input.Filename, CoreNodeModels", + "Id": "5a424eaa78c84cffaef5469c034de703", + "NodeType": "ExtensionNode", + "Inputs": [], + "Outputs": [ + { + "Id": "9df84a67c8d847cd9c818d6f0091d009", + "Name": "", + "Description": "File Path", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Allows you to select a file on the system and returns its file path", + "HintPath": "itdoesnotexist.PNG", + "InputValue": ".\\itdoesnotexist.PNG" + }, + { + "ConcreteType": "CoreNodeModels.Input.FileObject, CoreNodeModels", + "Id": "eeeadd2b09294b5fbe3ea2668b99777a", + "NodeType": "ExtensionNode", + "Inputs": [ + { + "Id": "60510ef2339b432ba5b22000927716d7", + "Name": "path", + "Description": "Path to the file.", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "a3b7e85ec31a411abe7d95bdac28aebc", + "Name": "file", + "Description": "File object", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Creates a file object from the given path" + }, + { + "ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore", + "Id": "8d82e3934d0e464cb810ddc7389ab0ae", + "NodeType": "FunctionNode", + "Inputs": [ + { + "Id": "811aee997ed343aa858171a49bc73e3d", + "Name": "file", + "Description": "File object to load image from\n\nvar", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "7023d4943db8442ab181d252c7b05831", + "Name": "image", + "Description": "Image object from file", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "FunctionSignature": "DSCore.IO.Image.ReadFromFile@var", + "Replication": "Auto", + "Description": "Loads the file as a bitmap.\n\nImage.ReadFromFile (file: var): var" + }, + { + "ConcreteType": "CoreNodeModels.WatchImageCore, CoreNodeModels", + "Id": "2aaf0ef3f7e04f0fb9b8b01ae48b60d6", + "NodeType": "ExtensionNode", + "Inputs": [ + { + "Id": "d72318275ee84c649cc8eb450501ac5e", + "Name": "image", + "Description": "Image for visualization", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "238c79fd3de247ca8218a53cb2ab1cc0", + "Name": "image", + "Description": "Image for visualization", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Previews an image" + } + ], + "Connectors": [ + { + "Start": "9df84a67c8d847cd9c818d6f0091d009", + "End": "60510ef2339b432ba5b22000927716d7", + "Id": "9fbbd1b6a983440ebbafb4bbc8a1fda3", + "IsHidden": "False" + }, + { + "Start": "a3b7e85ec31a411abe7d95bdac28aebc", + "End": "811aee997ed343aa858171a49bc73e3d", + "Id": "038a6fed7465486a8c9b253cdb9e8b1b", + "IsHidden": "False" + }, + { + "Start": "7023d4943db8442ab181d252c7b05831", + "End": "d72318275ee84c649cc8eb450501ac5e", + "Id": "67f785414dc74426bb8901bce334112c", + "IsHidden": "False" + } + ], + "Dependencies": [], + "NodeLibraryDependencies": [ + { + "Name": "Bricks.PNG", + "ReferenceType": "External", + "Nodes": [ + "5a424eaa78c84cffaef5469c034de703" + ] + } + ], + "Thumbnail": "", + "GraphDocumentationURL": null, + "ExtensionWorkspaceData": [ + { + "ExtensionGuid": "28992e1d-abb9-417f-8b1b-05e053bee670", + "Name": "Properties", + "Version": "2.18", + "Data": {} + } + ], + "Author": "", + "Linting": { + "activeLinter": "None", + "activeLinterId": "7b75fb44-43fd-4631-a878-29f4d5d8399a", + "warningCount": 0, + "errorCount": 0 + }, + "Bindings": [], + "View": { + "Dynamo": { + "ScaleFactor": 1.0, + "HasRunWithoutCrash": true, + "IsVisibleInDynamoLibrary": true, + "Version": "2.18.0.4326", + "RunType": "Automatic", + "RunPeriod": "1000" + }, + "Camera": { + "Name": "_Background Preview", + "EyeX": -17.0, + "EyeY": 24.0, + "EyeZ": 50.0, + "LookX": 12.0, + "LookY": -13.0, + "LookZ": -58.0, + "UpX": 0.0, + "UpY": 1.0, + "UpZ": 0.0 + }, + "ConnectorPins": [], + "NodeViews": [ + { + "Id": "5a424eaa78c84cffaef5469c034de703", + "Name": "File Path", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "ShowGeometry": true, + "X": 148.5, + "Y": 396.0 + }, + { + "Id": "eeeadd2b09294b5fbe3ea2668b99777a", + "Name": "File From Path", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "ShowGeometry": true, + "X": 452.5, + "Y": 394.0 + }, + { + "Id": "8d82e3934d0e464cb810ddc7389ab0ae", + "Name": "Image.ReadFromFile", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "ShowGeometry": true, + "X": 749.5, + "Y": 390.0 + }, + { + "Id": "2aaf0ef3f7e04f0fb9b8b01ae48b60d6", + "Name": "Watch Image", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "ShowGeometry": true, + "X": 1087.5, + "Y": 391.0 + } + ], + "Annotations": [], + "X": 677.747002299156, + "Y": 207.86594408547023, + "Zoom": 0.43202951305004778 + } +} \ No newline at end of file