-
Notifications
You must be signed in to change notification settings - Fork 10.3k
E2E test apps for WinForms and WPF BlazorWebView #31021
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
76480ff
Begin defining WinFormsTestApp
SteveSandersonMS 8a5c77f
Render a Blazor component
SteveSandersonMS 0bb757f
Render a BasicTestApp.Index
SteveSandersonMS 9da9414
Embiggen the window
SteveSandersonMS 0282f36
Minor tweaks to make more of the E2E test cases run properly
SteveSandersonMS 9eff7c8
WPF version of test app
SteveSandersonMS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Give it a proper name, otherwise it's like
Class1
and people will ignore it or delete it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was following on from the conventions in other projects like in
BlazorWinFormsApp
. Doesn't seem problematic right now but we could certainly change them all at some point.