Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
pinzart90 committed Jan 23, 2025
1 parent c866d0a commit 7f4e85c
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ async void InitializeAsync()
//This indicates in which location will be created the WebView2 cache folder
documentationBrowser.CreationProperties = new CoreWebView2CreationProperties()
{
UserDataFolder = WebBrowserUserDataFolder
UserDataFolder = DynamoModel.IsTestMode ? TestUtilities.UserDataFolderDuringTests() : WebBrowserUserDataFolder
};
}

Expand Down
5 changes: 3 additions & 2 deletions src/DynamoCoreWpf/Utilities/ResourceUtilities.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using Dynamo.Logging;
using Dynamo.Models;
using Dynamo.Wpf.Properties;
using Dynamo.Wpf.UI.GuidedTour;
using Dynamo.Wpf.Utilities;
using DynamoUtilities;
using Microsoft.Web.WebView2.Wpf;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -598,7 +599,7 @@ internal static async Task<object> ExecuteJSFunction(UIElement MainWindow, objec
//This indicates in which location will be created the WebView2 cache folder
webBrowserComponent.CreationProperties = new CoreWebView2CreationProperties()
{
UserDataFolder = userDataFolder
UserDataFolder = DynamoModel.IsTestMode ? TestUtilities.UserDataFolderDuringTests(nameof(ResourceUtilities)) : userDataFolder
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/Views/HomePage/HomePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private async void UserControl_Loaded(object sender, System.Windows.RoutedEventA

dynWebView.CreationProperties = new CoreWebView2CreationProperties
{
UserDataFolder = webBrowserUserDataFolder.FullName
UserDataFolder = DynamoModel.IsTestMode ? TestUtilities.UserDataFolderDuringTests(nameof(HomePage)) : webBrowserUserDataFolder.FullName
};

//ContentRendered ensures that the webview2 component is visible.
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/Views/SplashScreen/SplashScreen.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ protected override async void OnContentRendered(EventArgs e)

webView.CreationProperties = new CoreWebView2CreationProperties
{
UserDataFolder = webBrowserUserDataFolder.FullName
UserDataFolder = DynamoModel.IsTestMode ? TestUtilities.UserDataFolderDuringTests(nameof(SplashScreen)) : webBrowserUserDataFolder.FullName
};

//ContentRendered ensures that the webview2 component is visible.
Expand Down
9 changes: 9 additions & 0 deletions src/DynamoUtilities/TestUtilities.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

Expand All @@ -11,5 +14,11 @@ 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 WebView2Tag;

internal static string UserDataFolderDuringTests(string appName)
{
var directory = new DirectoryInfo(Assembly.GetExecutingAssembly().Location);
return Path.Combine(directory.Parent.Parent.Parent.FullName, "test", $"webview2_{Environment.ProcessId}_{appName}_appdata");
}
}
}
2 changes: 1 addition & 1 deletion src/LibraryViewExtensionWebView2/LibraryViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ async void InitializeAsync()
//This indicates in which location will be created the WebView2 cache folder
this.browser.CreationProperties = new CoreWebView2CreationProperties()
{
UserDataFolder = WebBrowserUserDataFolder
UserDataFolder = DynamoModel.IsTestMode ? TestUtilities.UserDataFolderDuringTests(nameof(LibraryViewController)) : WebBrowserUserDataFolder
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/Notifications/NotificationCenterController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private async void InitializeBrowserAsync(object sender, RoutedEventArgs e)
//This indicates in which location will be created the WebView2 cache folder
notificationUIPopup.webView.CreationProperties = new CoreWebView2CreationProperties()
{
UserDataFolder = webBrowserUserDataFolder.FullName
UserDataFolder = DynamoModel.IsTestMode ? TestUtilities.UserDataFolderDuringTests(nameof(NotificationCenterController)) : webBrowserUserDataFolder.FullName
};
}
notificationUIPopup.webView.CoreWebView2InitializationCompleted += WebView_CoreWebView2InitializationCompleted;
Expand Down

0 comments on commit 7f4e85c

Please sign in to comment.