From d5e6c9b4efbf30d8b547017bd3193bf71585b4b4 Mon Sep 17 00:00:00 2001 From: pinzart90 <46732933+pinzart90@users.noreply.github.com> Date: Thu, 7 Dec 2023 23:41:24 -0500 Subject: [PATCH] update (#14710) Co-authored-by: pinzart --- .../DocumentationBrowserView.xaml.cs | 10 +++++++++- src/Notifications/NotificationCenterController.cs | 15 ++++++++++++++- test/DynamoCoreWpfTests/Utility/DispatcherUtil.cs | 6 ++---- .../DocumentationBrowserViewExtensionTests.cs | 3 +++ 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/DocumentationBrowserViewExtension/DocumentationBrowserView.xaml.cs b/src/DocumentationBrowserViewExtension/DocumentationBrowserView.xaml.cs index b3990d9d288..d3cc6fb3304 100644 --- a/src/DocumentationBrowserViewExtension/DocumentationBrowserView.xaml.cs +++ b/src/DocumentationBrowserViewExtension/DocumentationBrowserView.xaml.cs @@ -6,6 +6,7 @@ using System.Windows; using System.Windows.Controls; using Dynamo.Logging; +using Dynamo.Models; using Dynamo.Utilities; using DynamoUtilities; using Microsoft.Web.WebView2.Core; @@ -216,7 +217,14 @@ public void Dispose() #region ILogSource Implementation private void Log(string message) { - viewModel.MessageLogged?.Invoke(LogMessage.Info(message)); + if (DynamoModel.IsTestMode) + { + System.Console.WriteLine(message); + } + else + { + viewModel?.MessageLogged?.Invoke(LogMessage.Info(message)); + } } #endregion } diff --git a/src/Notifications/NotificationCenterController.cs b/src/Notifications/NotificationCenterController.cs index c66e7cd415e..b8febcc30a2 100644 --- a/src/Notifications/NotificationCenterController.cs +++ b/src/Notifications/NotificationCenterController.cs @@ -19,6 +19,7 @@ using Microsoft.Web.WebView2.Wpf; using Dynamo.Utilities; using Dynamo.Configuration; +using Dynamo.Models; namespace Dynamo.Notifications { @@ -345,10 +346,22 @@ public void Dispose() { if (initState == AsyncMethodState.Started) { - logger?.Log("NotificationCenterController is being disposed but async initialization is still not done"); + Log("NotificationCenterController is being disposed but async initialization is still not done"); } Dispose(true); GC.SuppressFinalize(this); } + + private void Log(string msg) + { + if (DynamoModel.IsTestMode) + { + System.Console.WriteLine(msg); + } + else + { + logger?.Log(msg); + } + } } } diff --git a/test/DynamoCoreWpfTests/Utility/DispatcherUtil.cs b/test/DynamoCoreWpfTests/Utility/DispatcherUtil.cs index b7e21cddb75..18812562d00 100644 --- a/test/DynamoCoreWpfTests/Utility/DispatcherUtil.cs +++ b/test/DynamoCoreWpfTests/Utility/DispatcherUtil.cs @@ -14,7 +14,6 @@ public static class DispatcherUtil /// /// Force the Dispatcher to empty it's queue /// - [SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)] public static void DoEvents() { var frame = new DispatcherFrame(); @@ -24,14 +23,13 @@ public static void DoEvents() } /// - /// Force the Dispatcher to empty it's queue every 100 ms for a maximum 4 seconds or until + /// Force the Dispatcher to empty it's queue every 100 ms for a maximum 20 seconds or until /// the check function returns true. /// /// When check returns true, the even loop is stopped. - [SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)] public static void DoEventsLoop(Func check = null) { - const int max_count = 40; + const int max_count = 200; int count = 0; while (true) diff --git a/test/DynamoCoreWpfTests/ViewExtensions/DocumentationBrowserViewExtensionTests.cs b/test/DynamoCoreWpfTests/ViewExtensions/DocumentationBrowserViewExtensionTests.cs index e3abc8f4ee7..7f83886ce9a 100644 --- a/test/DynamoCoreWpfTests/ViewExtensions/DocumentationBrowserViewExtensionTests.cs +++ b/test/DynamoCoreWpfTests/ViewExtensions/DocumentationBrowserViewExtensionTests.cs @@ -206,6 +206,9 @@ public void CanHandleDocsEventTriggeredFromDynamoViewModel() // Act var tabsBeforeExternalEventTrigger = this.ViewModel.SideBarTabItems.Count; this.ViewModel.OpenDocumentationLinkCommand.Execute(docsEvent); + + WaitForWebView2Initialization(); + var tabsAfterExternalEventTrigger = this.ViewModel.SideBarTabItems.Count; var htmlContent = GetSidebarDocsBrowserContents();