Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
pinzart90 committed Jan 10, 2024
1 parent e4dcf57 commit 9ebd4b0
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/DynamoCoreWpf/Utilities/WebView2Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ namespace Dynamo.Wpf.Utilities
public class DynamoWebView2 : WebView2
{
#region API/Data used for debugging/testing
private string stamp;
private string tag;
#endregion

public DynamoWebView2() : base()
{
stamp = TestUtilities.WebView2Stamp;
tag = TestUtilities.WebView2Tag;
}

protected override void Dispose(bool disposing)
{
if (System.Environment.CurrentManagedThreadId != Dispatcher.Thread.ManagedThreadId)
{
System.Console.WriteLine($"WebView2 instance with stamp {stamp} is being disposed of on non-UI thread");
System.Console.WriteLine($"WebView2 instance with stamp {tag} is being disposed of on non-UI thread");
}
// We should dispose of webview2 only in the UI thread.
// Dispose can be called from the Finalizer (which can run on a non UI thread)
Expand All @@ -37,7 +37,7 @@ protected override void Dispose(bool disposing)
}
else
{
System.Console.WriteLine($"WebView2 instance with stamp {stamp} is being disposed of but has no valid Dispatcher");
System.Console.WriteLine($"WebView2 instance with stamp {tag} is being disposed of but has no valid Dispatcher");
// Should we still try to dispose ? (might crash if not on UI thread)
base.Dispose(disposing);
}
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoUtilities/TestUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ namespace DynamoUtilities
internal static class TestUtilities
{
// Simple string that we can store in DynamoWebView2 instances so that we can track them down more easily
internal static string WebView2Stamp;
internal static string WebView2Tag;
}
}
4 changes: 2 additions & 2 deletions test/DynamoCoreTests/UnitTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public virtual void Setup()
{

System.Console.WriteLine($"PID {Process.GetCurrentProcess().Id} Start test: {TestContext.CurrentContext.Test.Name}");
TestUtilities.WebView2Stamp = TestContext.CurrentContext.Test.Name;
TestUtilities.WebView2Tag = TestContext.CurrentContext.Test.Name;

SetupDirectories();

Expand Down Expand Up @@ -104,7 +104,7 @@ public virtual void Cleanup()
{
AppDomain.CurrentDomain.AssemblyResolve -= assemblyHelper.ResolveAssembly;
}
TestUtilities.WebView2Stamp = string.Empty;
TestUtilities.WebView2Tag = string.Empty;
System.Console.WriteLine($"PID {Process.GetCurrentProcess().Id} Finished test: {TestContext.CurrentContext.Test.Name}");
}

Expand Down
4 changes: 2 additions & 2 deletions test/DynamoCoreWpfTests/DynamoTestUIBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected string ExecutingDirectory
public virtual void Start()
{
System.Console.WriteLine($"PID {Process.GetCurrentProcess().Id} Start test: {TestContext.CurrentContext.Test.Name}");
TestUtilities.WebView2Stamp = TestContext.CurrentContext.Test.Name;
TestUtilities.WebView2Tag = TestContext.CurrentContext.Test.Name;

var assemblyPath = Assembly.GetExecutingAssembly().Location;
preloader = new Preloader(Path.GetDirectoryName(assemblyPath));
Expand Down Expand Up @@ -144,7 +144,7 @@ public void Exit()
Console.WriteLine(ex.StackTrace);
}

TestUtilities.WebView2Stamp = string.Empty;
TestUtilities.WebView2Tag = string.Empty;
System.Console.WriteLine($"PID {Process.GetCurrentProcess().Id} Finished test: {TestContext.CurrentContext.Test.Name}");
}

Expand Down
4 changes: 2 additions & 2 deletions test/DynamoCoreWpfTests/SplashScreenTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ internal class SplashScreenTests
[SetUp]
public void SetUp()
{
TestUtilities.WebView2Stamp = TestContext.CurrentContext.Test.Name;
TestUtilities.WebView2Tag = TestContext.CurrentContext.Test.Name;
}

[TearDown]
public void CleanUp()
{
TestUtilities.WebView2Stamp = string.Empty;
TestUtilities.WebView2Tag = string.Empty;
}

[Test]
Expand Down
4 changes: 2 additions & 2 deletions test/Libraries/SystemTestServices/SystemTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected string ExecutingDirectory
public virtual void Setup()
{
System.Console.WriteLine($"PID {Process.GetCurrentProcess().Id} Start test: {TestContext.CurrentContext.Test.Name}");
TestUtilities.WebView2Stamp = TestContext.CurrentContext.Test.Name;
TestUtilities.WebView2Tag = TestContext.CurrentContext.Test.Name;

var testConfig = GetTestSessionConfiguration();

Expand Down Expand Up @@ -141,7 +141,7 @@ public virtual void TearDown()
Console.WriteLine(ex.StackTrace);
}

TestUtilities.WebView2Stamp = string.Empty;
TestUtilities.WebView2Tag = string.Empty;
System.Console.WriteLine($"PID {Process.GetCurrentProcess().Id} Finished test: {TestContext.CurrentContext.Test.Name} ");
}

Expand Down

0 comments on commit 9ebd4b0

Please sign in to comment.