-
Notifications
You must be signed in to change notification settings - Fork 636
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
Switch off 3D rendering on out of memory #10535
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8708787
WIP
mmisol e6730b2
Create test and make method internal
mmisol 83bae96
Merge remote-tracking branch 'origin' into render_out_of_memory
mmisol 64a87ef
Change message shown to user
mmisol 8bc14a1
Change message slightly and remove last part
mmisol 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,74 @@ | ||
using Dynamo.Models; | ||
using Dynamo.ViewModels; | ||
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("OnRequestAttachToScene", ItExpr.IsAny<Model3D>()).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.
unfortunately this method will likely be removed / unused in the helix-upgrade branch - it might be possible to retain it and redirect it to do something useful with the new helix api though.
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.
Will this affect us when we cherry pick this test into helix-upgrade now?
To build this as a unit test I just needed an overridable method called from
AggregateRenderPackages
. I guess I could use another method with these characteristics in helix-upgrade if it exists, or I could add this one with no behaviour if not. Does that sound ok?