Skip to content
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

more fixes for webview2 tests #14710

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this actually make it into the test log?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YEs, it does

}
else
{
viewModel?.MessageLogged?.Invoke(LogMessage.Info(message));
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some tests do not initialize one of MessageLogged field and so skip logging

}
#endregion
}
Expand Down
15 changes: 14 additions & 1 deletion src/Notifications/NotificationCenterController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using Microsoft.Web.WebView2.Wpf;
using Dynamo.Utilities;
using Dynamo.Configuration;
using Dynamo.Models;

namespace Dynamo.Notifications
{
Expand Down Expand Up @@ -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);
}
}
}
}
6 changes: 2 additions & 4 deletions test/DynamoCoreWpfTests/Utility/DispatcherUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public static class DispatcherUtil
/// <summary>
/// Force the Dispatcher to empty it's queue
/// </summary>
[SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
public static void DoEvents()
{
var frame = new DispatcherFrame();
Expand All @@ -24,14 +23,13 @@ public static void DoEvents()
}

/// <summary>
/// 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.
/// </summary>
/// <param name="check">When check returns true, the even loop is stopped.</param>
[SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
public static void DoEventsLoop(Func<bool> check = null)
{
const int max_count = 40;
const int max_count = 200;

int count = 0;
while (true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down