Skip to content

Commit

Permalink
Add tests for BlazorForm
Browse files Browse the repository at this point in the history
  • Loading branch information
budcribar committed Feb 23, 2024
1 parent af188e7 commit 2f07cc6
Show file tree
Hide file tree
Showing 4 changed files with 481 additions and 9 deletions.
34 changes: 30 additions & 4 deletions src/RemoteBlazorWebView.WinForms/BlazorWebView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ public Uri? GrpcBaseUri
get => _grpcBaseUri;
set
{
if (RequiredStartupPropertiesSet)
throw new ArgumentException("GrpcBaseUri must be set before HostPage");
_grpcBaseUri = value;
Invalidate();
StartWebViewCoreIfPossible();
}
}

Expand All @@ -60,9 +61,10 @@ public Uri? ServerUri
get => _serverUri;
set
{
if (RequiredStartupPropertiesSet)
throw new ArgumentException("ServerUri must be set before HostPage");
_serverUri = value;
Invalidate();
StartWebViewCoreIfPossible();
}
}

Expand Down Expand Up @@ -133,6 +135,8 @@ public uint PingIntervalSeconds
get => _pingIntervalSeconds;
set
{
if (RequiredStartupPropertiesSet)
throw new ArgumentException("PingIntervalSeconds must be set before HostPage");
_pingIntervalSeconds = value;
Invalidate();
}
Expand All @@ -147,10 +151,11 @@ public string Group
{
get => _group;
set
{
{
if (RequiredStartupPropertiesSet)
throw new ArgumentException("Group must be set before HostPage");
_group = value;
Invalidate();
//StartWebViewCoreIfPossible();
}
}
private void ResetGroup() => _group = "test";
Expand All @@ -168,6 +173,8 @@ public string Markup
get => _markup;
set
{
if (RequiredStartupPropertiesSet)
throw new ArgumentException("Markup must be set before HostPage");
_markup = value;
Invalidate();
}
Expand All @@ -191,11 +198,30 @@ public bool EnableMirrors
get => _enableMirrors;
set
{
if (RequiredStartupPropertiesSet)
throw new ArgumentException("EnableMirrors must be set before HostPage");
_enableMirrors = value;
Invalidate();
}
}

public override string? HostPage
{
get => base.HostPage;
set
{
var markup = Markup;
// Set a default Markup if necessary
if (ServerUri != null && Id != Guid.Empty && string.IsNullOrEmpty(markup))
Markup = RemoteWebView.RemoteWebView.GenMarkup(ServerUri, Id);

// Default to the http server
if (GrpcBaseUri == null)
GrpcBaseUri = ServerUri;

base.HostPage = value;
}
}

public override WebView2WebViewManager CreateWebViewManager(WebView2Control webview, IServiceProvider services, Dispatcher dispatcher, IFileProvider fileProvider, JSComponentConfigurationStore store, string hostPageRelativePath,string hostPagePathWithinFileProvider, Action<UrlLoadingEventArgs> externalNavigationStarting, Action<BlazorWebViewInitializingEventArgs> blazorWebViewInitializing, Action<BlazorWebViewInitializedEventArgs> blazorWebViewInitialized, ILogger logger)
{
Expand Down
2 changes: 1 addition & 1 deletion src/RemoteBlazorWebView.WinForms/BlazorWebViewFormBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected override void OnCreateControl()
/// </summary>
[Category("Behavior")]
[Description(@"Path to the host page within the application's static files. Example: wwwroot\index.html.")]
public string? HostPage
public virtual string? HostPage
{
get => _hostPage;
set
Expand Down
Loading

0 comments on commit 2f07cc6

Please sign in to comment.