-
Notifications
You must be signed in to change notification settings - Fork 635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle memory outage on render (cherry pick) #10569
Merged
mmisol
merged 2 commits into
DynamoDS:helix-upgrade
from
mmisol:render_memory_outage_cp
Apr 14, 2020
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using Dynamo.Models; | ||
using Dynamo.ViewModels; | ||
using Dynamo.Wpf.Rendering; | ||
using Dynamo.Wpf.ViewModels.Watch3D; | ||
using DynamoCoreWpfTests.Utility; | ||
using HelixToolkit.Wpf.SharpDX; | ||
using Moq; | ||
using Moq.Protected; | ||
using NUnit.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace WpfVisualizationTests | ||
{ | ||
[TestFixture] | ||
public class Preview3DMemoryOutageTest : VisualizationTest | ||
{ | ||
private Mock<DynamoModel> modelMock; | ||
|
||
/// <summary> | ||
/// Creates a mock DynamoModel that does not show a task dialog but instead sets its call | ||
/// as a verifiable call. | ||
/// </summary> | ||
/// <param name="configuration">Default DynamoModel configuration</param> | ||
/// <returns>Mock DynamoModel</returns> | ||
protected override DynamoModel CreateModel(DynamoModel.IStartConfiguration configuration) | ||
{ | ||
modelMock = new Mock<DynamoModel>(configuration) | ||
{ | ||
CallBase = true | ||
}; | ||
modelMock.Setup(m => m.OnRequestTaskDialog(It.IsAny<object>(), It.IsAny<TaskDialogEventArgs>())) | ||
.Callback(() => { }) // Prevent dialog from blocking the test | ||
.Verifiable(); | ||
|
||
return modelMock.Object; | ||
} | ||
|
||
/// <summary> | ||
/// Sets up a mock HelixWatch3DViewModel which will throw OutOfMemoryException when rendering. | ||
/// </summary> | ||
/// <returns>DynamoViewModel configuration referencing the mock 3D preview</returns> | ||
protected override DynamoViewModel.StartConfiguration CreateViewModelStartConfiguration() | ||
{ | ||
var watch3DMock = new Mock<HelixWatch3DViewModel>(null, new Watch3DViewModelStartupParams(Model)) | ||
{ | ||
CallBase = true | ||
}; | ||
watch3DMock.Protected().Setup("AggregateRenderPackages", ItExpr.IsAny<IEnumerable<HelixRenderPackage>>()).Throws<OutOfMemoryException>(); | ||
return new DynamoViewModel.StartConfiguration() | ||
{ | ||
Watch3DViewModel = watch3DMock.Object | ||
}; | ||
} | ||
|
||
/// <summary> | ||
/// Opens any file that produces geometry and checks that the 3D preview is disabled after the error | ||
/// and also that a dialog is shown. | ||
/// </summary> | ||
[Test] | ||
public void HandlesRenderMemoryOutageGracefully() | ||
{ | ||
Assert.Greater(ViewModel.Watch3DViewModels.Count(), 0); | ||
Assert.True(ViewModel.Watch3DViewModels.All(w => w.Active)); | ||
|
||
OpenVisualizationTest("ASM_cuboid.dyn"); | ||
|
||
Assert.True(ViewModel.Watch3DViewModels.All(w => !w.Active)); | ||
modelMock.Verify(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has the effect of exposing this method to the API in any derived class, as this is currently a public class - (In the current API) Of course we'd like to do a refactor and change our API policies as we have been discussing but for now I'm a bit hesitant.
If this method was made internal could it be mocked?
If it has to become protected then we can use an interface as the argument type and check the type inside the method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently this could be done https://stackoverflow.com/a/2823554. Let me give that a try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mjkkirschner That worked! Would you take one last look?