-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
E2E test apps for WinForms and WPF BlazorWebView (#31021)
- Loading branch information
1 parent
e640e79
commit 7211288
Showing
16 changed files
with
426 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Windows.Forms; | ||
using System.Net.Http; | ||
using Microsoft.AspNetCore.Components.WebView.WindowsForms; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace WinFormsTestApp | ||
{ | ||
public partial class Form1 : Form | ||
{ | ||
public Form1() | ||
{ | ||
var serviceCollection = new ServiceCollection(); | ||
serviceCollection.AddBlazorWebView(); | ||
serviceCollection.AddSingleton<HttpClient>(); | ||
InitializeComponent(); | ||
|
||
blazorWebView1.HostPage = @"wwwroot\webviewhost.html"; | ||
blazorWebView1.Services = serviceCollection.BuildServiceProvider(); | ||
blazorWebView1.RootComponents.Add<BasicTestApp.Index>("root"); | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Windows.Forms; | ||
|
||
namespace WinFormsTestApp | ||
{ | ||
static class Program | ||
{ | ||
/// <summary> | ||
/// The main entry point for the application. | ||
/// </summary> | ||
[STAThread] | ||
static void Main() | ||
{ | ||
AppDomain.CurrentDomain.UnhandledException += (sender, error) => | ||
{ | ||
MessageBox.Show(text: error.ExceptionObject.ToString(), caption: "Error"); | ||
}; | ||
|
||
Application.SetHighDpiMode(HighDpiMode.SystemAware); | ||
Application.EnableVisualStyles(); | ||
Application.SetCompatibleTextRenderingDefault(false); | ||
Application.Run(new Form1()); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...mponents/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/WinFormsTestApp.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Razor"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>$(DefaultNetCoreTargetFramework)-windows</TargetFramework> | ||
<OutputType>WinExe</OutputType> | ||
<UseWindowsForms>true</UseWindowsForms> | ||
<IsShippingPackage>false</IsShippingPackage> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\..\..\test\testassets\BasicTestApp\BasicTestApp.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Reference Include="Microsoft.AspNetCore.Components.WebView.WindowsForms" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Content Update="wwwroot\**"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
|
||
</Project> |
26 changes: 26 additions & 0 deletions
26
src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/wwwroot/css/app.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#blazor-error-ui { | ||
background: lightyellow; | ||
bottom: 0; | ||
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); | ||
display: none; | ||
left: 0; | ||
padding: 0.6rem 1.25rem 0.7rem 1.25rem; | ||
position: fixed; | ||
width: 100%; | ||
z-index: 1000; | ||
} | ||
|
||
#blazor-error-ui .dismiss { | ||
cursor: pointer; | ||
position: absolute; | ||
right: 0.75rem; | ||
top: 0.5rem; | ||
} | ||
|
||
.valid.modified:not([type=checkbox]) { | ||
outline: 1px solid #26b050; | ||
} | ||
|
||
.invalid { | ||
outline: 1px solid red; | ||
} |
51 changes: 51 additions & 0 deletions
51
...onents/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/wwwroot/webviewhost.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> | ||
<title>WinFormsTestApp</title> | ||
<base href="/" /> | ||
<link href="css/app.css" rel="stylesheet" /> | ||
</head> | ||
|
||
<body> | ||
<!-- The content here is duplicated from index.html in BasicTestApp --> | ||
|
||
<root>Loading...</root> | ||
|
||
<!-- Explicit display:none required so StartupErrorNotificationTest can observe it change --> | ||
<div id="blazor-error-ui" style="display: none;"> | ||
An unhandled error has occurred. | ||
<a href class='reload'>Reload</a> | ||
<a class='dismiss' style="cursor: pointer;">🗙</a> | ||
</div> | ||
|
||
<!-- Used for specific test cases --> | ||
<script src="js/jsinteroptests.js"></script> | ||
<script src="js/renderattributestest.js"></script> | ||
<script src="js/webComponentPerformingJsInterop.js"></script> | ||
<script src="js/customLinkElement.js"></script> | ||
|
||
<script> | ||
// Used by ElementRefComponent | ||
function setElementValue(element, newValue) { | ||
element.value = newValue; | ||
return element.value; | ||
} | ||
|
||
function navigationManagerNavigate() { | ||
Blazor.navigateTo('/subdir/some-path'); | ||
} | ||
|
||
function getCurrentUrl() { | ||
return location.href; | ||
} | ||
</script> | ||
<script src="_framework/blazor.webview.js"></script> | ||
|
||
<!-- Used by ExternalContentPackage --> | ||
<script src="_content/TestContentPackage/prompt.js"></script> | ||
</body> | ||
|
||
</html> |
10 changes: 10 additions & 0 deletions
10
src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/App.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Application x:Class="WpfTestApp.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="clr-namespace:WpfTestApp" | ||
StartupUri="MainWindow.xaml" | ||
Startup="Application_Startup"> | ||
<Application.Resources> | ||
|
||
</Application.Resources> | ||
</Application> |
22 changes: 22 additions & 0 deletions
22
src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/App.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Windows; | ||
|
||
namespace WpfTestApp | ||
{ | ||
/// <summary> | ||
/// Interaction logic for App.xaml | ||
/// </summary> | ||
public partial class App : Application | ||
{ | ||
private void Application_Startup(object sender, StartupEventArgs e) | ||
{ | ||
AppDomain.CurrentDomain.UnhandledException += (sender, error) => | ||
{ | ||
MessageBox.Show(error.ExceptionObject.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error); | ||
}; | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/MainWindow.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Window x:Class="WpfTestApp.MainWindow" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:basictestapp="clr-namespace:BasicTestApp;assembly=BasicTestApp" | ||
xmlns:blazor="clr-namespace:Microsoft.AspNetCore.Components.WebView.Wpf;assembly=Microsoft.AspNetCore.Components.WebView.Wpf" | ||
mc:Ignorable="d" | ||
Title="MainWindow" Height="450" Width="800"> | ||
<blazor:BlazorWebView HostPage="wwwroot\webviewhost.html" Services="{StaticResource services}"> | ||
<blazor:BlazorWebView.RootComponents> | ||
<blazor:RootComponent Selector="root" ComponentType="{x:Type basictestapp:Index}" /> | ||
</blazor:BlazorWebView.RootComponents> | ||
</blazor:BlazorWebView> | ||
</Window> |
25 changes: 25 additions & 0 deletions
25
src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/MainWindow.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Net.Http; | ||
using System.Windows; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace WpfTestApp | ||
{ | ||
/// <summary> | ||
/// Interaction logic for MainWindow.xaml | ||
/// </summary> | ||
public partial class MainWindow : Window | ||
{ | ||
public MainWindow() | ||
{ | ||
var serviceCollection = new ServiceCollection(); | ||
serviceCollection.AddBlazorWebView(); | ||
serviceCollection.AddSingleton<HttpClient>(); | ||
Resources.Add("services", serviceCollection.BuildServiceProvider()); | ||
|
||
InitializeComponent(); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/WpfTestApp.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Razor"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>$(DefaultNetCoreTargetFramework)-windows</TargetFramework> | ||
<OutputType>WinExe</OutputType> | ||
<UseWPF>true</UseWPF> | ||
<IsShippingPackage>false</IsShippingPackage> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\..\..\test\testassets\BasicTestApp\BasicTestApp.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Reference Include="Microsoft.AspNetCore.Components.WebView.Wpf" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Content Update="wwwroot\**"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.