Skip to content

Commit

Permalink
DYN-1706 Make Automatic Run Type honor RunEnabled settings (#9680)
Browse files Browse the repository at this point in the history
* Run Settings fix

* Adding manual check

* Adding test

* TODO comment for future

* Adding comments and sort Usings
  • Loading branch information
reddyashish authored Apr 29, 2019
1 parent 8166a4a commit 76c7b61
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/DynamoCore/Graph/Workspaces/HomeWorkspaceModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public class HomeWorkspaceModel : WorkspaceModel
private PulseMaker pulseMaker;
private readonly bool verboseLogging;
private bool graphExecuted;

// To check whether task is completed or not.
private bool executingTask;

private IEnumerable<KeyValuePair<Guid, List<CallSite.RawTraceData>>> historicalTraceData;

/// <summary>
Expand Down Expand Up @@ -331,9 +335,16 @@ internal override void RequestRun()
{
base.RequestRun();

if (RunSettings.RunEnabled && RunSettings.RunType != RunType.Manual)
if (RunSettings.RunType != RunType.Manual)
{
Run();
// TODO for Dynamo 3.0: The boolean "executingTask" that is used here is a make-do fix.
// We will be needing a separate variable(boolean flag) to check whether run can be enabled from external applications
// and not confuse it with the internal flag RunEnabled which is associated with the Run button in Dynamo.
// Make this RunSettings.RunEnabled private, introduce the new flag and remove the "executingTask" variable.
if (RunSettings.RunEnabled || executingTask)
{
Run();
}
}
}

Expand Down Expand Up @@ -580,6 +591,8 @@ private void OnUpdateGraphCompleted(AsyncTask task)
// Notify listeners (optional) of completion.
RunSettings.RunEnabled = true; // Re-enable 'Run' button.

executingTask = false; // setting back to false

//set the node execution preview to false;
OnSetNodeDeltaState(new DeltaComputeStateEventArgs(new List<Guid>(), graphExecuted));

Expand Down Expand Up @@ -663,6 +676,10 @@ public void Run()

OnEvaluationStarted(EventArgs.Empty);
scheduler.ScheduleForExecution(task);

// Setting this to true as the task is scheduled now and will be
// set back to false once the OnUpdateGraphCompleted event is executed.
executingTask = true;
}
else
{
Expand Down
19 changes: 19 additions & 0 deletions test/DynamoCoreWpfTests/RecordedTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,25 @@ public void TestPreviewToggleConnectionMultiOutputNode()
});
}

[Test, RequiresSTA]
public void TestAddingAndRemovingConnectors()
{
RunCommandsFromFile("TestAddingAndRemovingConnectors.xml", (commandTag) =>
{
if (commandTag == "FirstRun")
{
AssertPreviewValue("42001c91-7faa-43a5-9978-eea5e0a2bd0c", "abc");
}
else if (commandTag == "SecondRun")
{
AssertPreviewValue("42001c91-7faa-43a5-9978-eea5e0a2bd0c", "12345");
}
else if (commandTag == "ThirdRun")
{
AssertPreviewValue("42001c91-7faa-43a5-9978-eea5e0a2bd0c", "abc");
}
});
}
#endregion
}

Expand Down
61 changes: 61 additions & 0 deletions test/core/recorded/TestAddingAndRemovingConnectors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<Commands ExitAfterPlayback="true" PauseAfterPlaybackInMs="10" CommandIntervalInMs="20">
<SelectModelCommand Modifiers="0">
<ModelGuid>00000000-0000-0000-0000-000000000000</ModelGuid>
</SelectModelCommand>
<CreateNodeCommand X="190" Y="167" DefaultPosition="false" TransformCoordinates="true">
<ModelGuid>0be4c94a-da23-4178-9f52-cb612062dcec</ModelGuid>
<Dynamo.Graph.Nodes.CodeBlockNodeModel guid="0be4c94a-da23-4178-9f52-cb612062dcec" type="Dynamo.Graph.Nodes.CodeBlockNodeModel" nickname="Code Block" x="98" y="136" isVisible="true" lacing="Disabled" isSelectedInput="False" isSelectedOutput="False" IsFrozen="false" isPinned="false" CodeText="&quot;abc&quot;;" ShouldFocus="false">
<OutPortInfo LineIndex="0" />
</Dynamo.Graph.Nodes.CodeBlockNodeModel>
</CreateNodeCommand>
<SelectModelCommand Modifiers="0">
<ModelGuid>00000000-0000-0000-0000-000000000000</ModelGuid>
</SelectModelCommand>
<UpdateModelValueCommand Name="Code" Value="&quot;abc&quot;" WorkspaceGuid="b3fe6494-214a-4f04-8dd8-88aa6778e7a8">
<ModelGuid>0be4c94a-da23-4178-9f52-cb612062dcec</ModelGuid>
</UpdateModelValueCommand>
<SelectInRegionCommand X="319" Y="225" Width="1" Height="0" IsCrossSelection="false" />
<CreateNodeCommand X="320" Y="225" DefaultPosition="false" TransformCoordinates="true">
<ModelGuid>42001c91-7faa-43a5-9978-eea5e0a2bd0c</ModelGuid>
<Dynamo.Graph.Nodes.ZeroTouch.DSVarArgFunction guid="42001c91-7faa-43a5-9978-eea5e0a2bd0c" type="Dynamo.Graph.Nodes.ZeroTouch.DSVarArgFunction" nickname="String.Concat" x="320" y="225" isVisible="true" lacing="Auto" isSelectedInput="False" isSelectedOutput="False" IsFrozen="false" isPinned="false" assembly="DSCoreNodes.dll" function="DSCore.String.Concat@string[]" inputcount="1">
<PortInfo index="0" default="False" />
</Dynamo.Graph.Nodes.ZeroTouch.DSVarArgFunction>
</CreateNodeCommand>
<SelectModelCommand Modifiers="0">
<ModelGuid>00000000-0000-0000-0000-000000000000</ModelGuid>
</SelectModelCommand>
<CreateNodeCommand X="146" Y="331" DefaultPosition="false" TransformCoordinates="true">
<ModelGuid>4aa6ef10-0a0a-414c-8a47-b059b02d05af</ModelGuid>
<Dynamo.Graph.Nodes.CodeBlockNodeModel guid="4aa6ef10-0a0a-414c-8a47-b059b02d05af" type="Dynamo.Graph.Nodes.CodeBlockNodeModel" nickname="Code Block" x="54" y="300" isVisible="true" lacing="Disabled" isSelectedInput="False" isSelectedOutput="False" IsFrozen="false" isPinned="false" CodeText="&quot;12345&quot;;" ShouldFocus="false">
<OutPortInfo LineIndex="0" />
</Dynamo.Graph.Nodes.CodeBlockNodeModel>
</CreateNodeCommand>
<SelectModelCommand Modifiers="0">
<ModelGuid>00000000-0000-0000-0000-000000000000</ModelGuid>
</SelectModelCommand>
<UpdateModelValueCommand Name="Code" Value="&quot;12345&quot;" WorkspaceGuid="b3fe6494-214a-4f04-8dd8-88aa6778e7a8">
<ModelGuid>4aa6ef10-0a0a-414c-8a47-b059b02d05af</ModelGuid>
</UpdateModelValueCommand>
<SelectInRegionCommand X="146" Y="331" Width="0" Height="0" IsCrossSelection="false" />
<MakeConnectionCommand PortIndex="0" Type="1" ConnectionMode="0">
<ModelGuid>0be4c94a-da23-4178-9f52-cb612062dcec</ModelGuid>
</MakeConnectionCommand>
<MakeConnectionCommand PortIndex="0" Type="0" ConnectionMode="1">
<ModelGuid>42001c91-7faa-43a5-9978-eea5e0a2bd0c</ModelGuid>
</MakeConnectionCommand>
<PausePlaybackCommand Tag="FirstRun" PauseDurationInMs="20" />
<MakeConnectionCommand PortIndex="0" Type="1" ConnectionMode="0">
<ModelGuid>4aa6ef10-0a0a-414c-8a47-b059b02d05af</ModelGuid>
</MakeConnectionCommand>
<MakeConnectionCommand PortIndex="0" Type="0" ConnectionMode="1">
<ModelGuid>42001c91-7faa-43a5-9978-eea5e0a2bd0c</ModelGuid>
</MakeConnectionCommand>
<PausePlaybackCommand Tag="SecondRun" PauseDurationInMs="20" />
<MakeConnectionCommand PortIndex="0" Type="1" ConnectionMode="0">
<ModelGuid>0be4c94a-da23-4178-9f52-cb612062dcec</ModelGuid>
</MakeConnectionCommand>
<MakeConnectionCommand PortIndex="0" Type="0" ConnectionMode="1">
<ModelGuid>42001c91-7faa-43a5-9978-eea5e0a2bd0c</ModelGuid>
</MakeConnectionCommand>
<PausePlaybackCommand Tag="ThirdRun" PauseDurationInMs="20" />
</Commands>

0 comments on commit 76c7b61

Please sign in to comment.