Prove per Windows con WebView2 vero, e la prova che riproduce l'avvio mancato
Nuovo progetto tests/Febe.Tests.Windows (net10.0-windows, WPF, solo MSTest e riferimenti ai progetti): un thread STA con un Dispatcher di WPF vero, come il thread dell'interfaccia di Febe.exe, e il browser di Febe costruito come lo costruisce la composizione e avviato da un thread del pool, come fa FebeApp. Si compila anche da Linux (EnableWindowsTargeting, come Febe.Desktop) perché la CI compila tutta la soluzione, ma gira solo su Windows; dove manca il runtime WebView2 le prove risultano inconcludenti. La prima prova riproduce il registro di Alberto del 14 e del 19 ottobre: «WebView2 non parte (InvalidOperationException: CoreWebView2Environment members can only be accessed from the UI thread.)» a ogni tentativo. Con il codice di questo commit fallisce così; la correzione è nel commit seguente. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
edade61b72
commit
a25f60970d
10 files changed
+375
No files matched your search
@@ -0,0 +1,39 @@
|
||||
namespace Febe.Tests.Windows.Support;
|
||||
|
||||
/// <summary>
|
||||
/// A temporary folder under <see cref="Path.GetTempPath"/> (TEMP: on Alberto's PC a work folder outside drive C:),
|
||||
/// removed at the end of the test. WebView2 may hold a file of its profile for a moment after it closed: removal is
|
||||
/// retried and a leftover folder is not an error.
|
||||
/// </summary>
|
||||
internal sealed class TestFolder : IDisposable
|
||||
{
|
||||
public TestFolder(string prefix)
|
||||
{
|
||||
Path = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "febe-prove-windows", prefix + "-" + Guid.NewGuid().ToString("N")[..10]);
|
||||
Directory.CreateDirectory(Path);
|
||||
}
|
||||
|
||||
public string Path { get; }
|
||||
|
||||
public string Combine(params string[] parts) => System.IO.Path.Combine([Path, .. parts]);
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
for (var attempt = 0; attempt < 10; attempt++)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Directory.Exists(Path))
|
||||
{
|
||||
Directory.Delete(Path, recursive: true);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
|
||||
{
|
||||
Thread.Sleep(300);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user