Web source: fix rendering — fixed 1920×1080 viewport (OBS pattern), Stretch=Uniform, startup registration
This commit is contained in:
@@ -20,7 +20,29 @@ public sealed class WebView2ManagerTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WebView2_Control_Size_Tracks_Source_Dimensions()
|
||||
public void WebView2_Control_Size_Is_Fixed_At_Canvas_Resolution()
|
||||
{
|
||||
_app.Run(() =>
|
||||
{
|
||||
var panel = new Canvas();
|
||||
var source = new Source
|
||||
{
|
||||
Type = SourceType.WebSource,
|
||||
Width = 640,
|
||||
Height = 480,
|
||||
};
|
||||
|
||||
using var manager = new WebView2Manager(panel, Dispatcher.CurrentDispatcher);
|
||||
manager.Register(source);
|
||||
|
||||
var webView = panel.Children.OfType<WebView2>().First();
|
||||
Assert.Equal(1920.0, webView.Width);
|
||||
Assert.Equal(1080.0, webView.Height);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WebView2_Control_Size_Does_Not_Track_Source_Dimensions()
|
||||
{
|
||||
_app.Run(() =>
|
||||
{
|
||||
@@ -36,66 +58,12 @@ public sealed class WebView2ManagerTests
|
||||
manager.Register(source);
|
||||
|
||||
var webView = panel.Children.OfType<WebView2>().First();
|
||||
Assert.Equal(640.0, webView.Width);
|
||||
Assert.Equal(480.0, webView.Height);
|
||||
|
||||
source.Width = 1024;
|
||||
source.Height = 768;
|
||||
|
||||
Assert.Equal(1024.0, webView.Width);
|
||||
Assert.Equal(768.0, webView.Height);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WebView2_Control_Size_Does_Not_Drift_On_Minor_Rounding()
|
||||
{
|
||||
_app.Run(() =>
|
||||
{
|
||||
var panel = new Canvas();
|
||||
var source = new Source
|
||||
{
|
||||
Type = SourceType.WebSource,
|
||||
Width = 640,
|
||||
Height = 480,
|
||||
};
|
||||
|
||||
using var manager = new WebView2Manager(panel, Dispatcher.CurrentDispatcher);
|
||||
manager.Register(source);
|
||||
|
||||
var webView = panel.Children.OfType<WebView2>().First();
|
||||
|
||||
source.Width = 640.4;
|
||||
Assert.Equal(640.0, webView.Width);
|
||||
|
||||
source.Height = 480.4;
|
||||
Assert.Equal(480.0, webView.Height);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WebView2_Control_Size_Minimum_Is_One()
|
||||
{
|
||||
_app.Run(() =>
|
||||
{
|
||||
var panel = new Canvas();
|
||||
var source = new Source
|
||||
{
|
||||
Type = SourceType.WebSource,
|
||||
Width = 640,
|
||||
Height = 480,
|
||||
};
|
||||
|
||||
using var manager = new WebView2Manager(panel, Dispatcher.CurrentDispatcher);
|
||||
manager.Register(source);
|
||||
|
||||
var webView = panel.Children.OfType<WebView2>().First();
|
||||
|
||||
source.Width = 0;
|
||||
source.Height = 0;
|
||||
|
||||
Assert.Equal(1.0, webView.Width);
|
||||
Assert.Equal(1.0, webView.Height);
|
||||
Assert.Equal(1920.0, webView.Width);
|
||||
Assert.Equal(1080.0, webView.Height);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user