-
Notifications
You must be signed in to change notification settings - Fork 439
Device test runner #1444
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
Draft
pictos
wants to merge
27
commits into
main
Choose a base branch
from
pj/device-test-runner
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Device test runner #1444
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
69ec49d
added runner project
pictos 5513c8e
Added UITest capabilities
pictos c61f20b
Test runner ci (#1446)
VladislavAntonyuk 9f1b099
Merge branch 'main' into pj/device-test-runner
pictos 2b2c1f9
Merge branch 'main' into pj/device-test-runner
VladislavAntonyuk f3af8fc
Merge branch 'main' into pj/device-test-runner
VladislavAntonyuk 9d3383b
Merge branch 'main' into pj/device-test-runner
VladislavAntonyuk a3b5683
Merge branch 'main' into pj/device-test-runner
TheCodeTraveler 0770d65
Merge branch 'main' into pj/device-test-runner
TheCodeTraveler d030aa6
Update to .NET 8
TheCodeTraveler a1314f4
Update azure-pipelines.yml
TheCodeTraveler 64b65ce
Update azure-pipelines.yml
TheCodeTraveler c4b6dfb
Remove Unnecessary Code
TheCodeTraveler ff05284
Update install step
TheCodeTraveler 3a0f4d2
Update azure-pipelines.yml
TheCodeTraveler 62fc85a
Remove Redundant Folder
TheCodeTraveler a1bebd8
Update azure-pipelines.yml
TheCodeTraveler cc8d4c3
Update azure-pipelines.yml
TheCodeTraveler 8050559
Run Unit Tests after all projects have been compiled
TheCodeTraveler a6853e5
Fix App Identifier
TheCodeTraveler 073f310
Merge branch 'main' into pj/device-test-runner
TheCodeTraveler 9aaec9b
Update to xcode 16
bijington 7dd4b5c
Update src/CommunityToolkit.Maui.DeviceTests/Platforms/MacCatalyst/Ap…
TheCodeTraveler c0b64c6
Update src/CommunityToolkit.Maui.DeviceTests/MainPage.xaml.cs
TheCodeTraveler 7a035ae
Merge branch 'main' into pj/device-test-runner
TheCodeTraveler 6c7fb61
Merge branch 'main' into pj/device-test-runner
ne0rrmatrix 76db87e
Merge branch 'main' into pj/device-test-runner
ne0rrmatrix 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
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,14 @@ | ||
<?xml version = "1.0" encoding = "UTF-8" ?> | ||
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:local="clr-namespace:CommunityToolkit.Maui.DeviceTests" | ||
x:Class="CommunityToolkit.Maui.DeviceTests.App"> | ||
<Application.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<ResourceDictionary Source="Resources/Styles/Colors.xaml" /> | ||
<ResourceDictionary Source="Resources/Styles/Styles.xaml" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
</ResourceDictionary> | ||
</Application.Resources> | ||
</Application> |
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,11 @@ | ||
namespace CommunityToolkit.Maui.DeviceTests; | ||
|
||
public partial class App : Application | ||
{ | ||
public App() | ||
{ | ||
InitializeComponent(); | ||
|
||
MainPage = new AppShell(); | ||
} | ||
} |
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,14 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<Shell | ||
x:Class="CommunityToolkit.Maui.DeviceTests.AppShell" | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:local="clr-namespace:CommunityToolkit.Maui.DeviceTests" | ||
Shell.FlyoutBehavior="Disabled"> | ||
|
||
<ShellContent | ||
Title="Home" | ||
ContentTemplate="{DataTemplate local:MainPage}" | ||
Route="MainPage" /> | ||
|
||
</Shell> |
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,9 @@ | ||
namespace CommunityToolkit.Maui.DeviceTests; | ||
|
||
public partial class AppShell : Shell | ||
{ | ||
public AppShell() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} |
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,49 @@ | ||
using Xunit; | ||
|
||
namespace CommunityToolkit.Maui.DeviceTests; | ||
[Collection("UITests")] | ||
public abstract class UITests<T> : IAsyncLifetime | ||
where T : Page | ||
{ | ||
protected T CurrentPage { get; private set; } = default!; | ||
|
||
protected IMauiContext MauiContext { get; private set; } = default!; | ||
|
||
public async Task InitializeAsync() | ||
{ | ||
Routing.RegisterRoute("uitests", typeof(T)); | ||
|
||
await Shell.Current.GoToAsync("uitests"); | ||
|
||
CurrentPage = (T)Shell.Current.CurrentPage; | ||
MauiContext = CurrentPage.Handler!.MauiContext!; | ||
if (CurrentPage.IsLoaded) | ||
{ | ||
return; | ||
} | ||
|
||
var tcs = new TaskCompletionSource(); | ||
CurrentPage.Loaded += OnLoaded; | ||
|
||
await Task.WhenAny(tcs.Task, Task.Delay(1000)); | ||
|
||
CurrentPage.Loaded -= OnLoaded; | ||
|
||
Assert.True(CurrentPage.IsLoaded); | ||
|
||
void OnLoaded(object? sender, EventArgs e) | ||
{ | ||
CurrentPage.Loaded -= OnLoaded; | ||
tcs.SetResult(); | ||
} | ||
} | ||
|
||
public async Task DisposeAsync() | ||
{ | ||
CurrentPage = null!; | ||
|
||
await Shell.Current.GoToAsync(".."); | ||
|
||
Routing.UnRegisterRoute("uitests"); | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
src/CommunityToolkit.Maui.DeviceTests/CommunityToolkit.Maui.DeviceTests.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,70 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>$(NetVersion)-ios;$(NetVersion)-android;$(NetVersion)-maccatalyst</TargetFrameworks> | ||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);$(NetVersion)-windows10.0.19041.0</TargetFrameworks> | ||
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET --> | ||
<!-- <TargetFrameworks>$(TargetFrameworks);$(NetVersion)-tizen</TargetFrameworks> --> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>CommunityToolkit.Maui.DeviceTests</RootNamespace> | ||
<UseMaui>true</UseMaui> | ||
<SingleProject>true</SingleProject> | ||
|
||
<!-- Display name --> | ||
<ApplicationTitle>CommunityToolkit.Maui.DeviceTests</ApplicationTitle> | ||
|
||
<!-- App Identifier --> | ||
<ApplicationId>com.microsoft.CommunityToolkit.Maui.DeviceTests</ApplicationId> | ||
<ApplicationIdGuid>b9372eea-e8b8-45fb-b785-6ffb8eb6c099</ApplicationIdGuid> | ||
|
||
<!-- Versions --> | ||
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> | ||
<ApplicationVersion>1</ApplicationVersion> | ||
|
||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion> | ||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion> | ||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion> | ||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion> | ||
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion> | ||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion> | ||
<NoWarn>$(NoWarn);NU1605</NoWarn> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<!-- App Icon --> | ||
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" /> | ||
|
||
<!-- Splash Screen --> | ||
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" /> | ||
|
||
<!-- Images --> | ||
<MauiImage Include="Resources\Images\*" /> | ||
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" /> | ||
|
||
<!-- Custom Fonts --> | ||
<MauiFont Include="Resources\Fonts\*" /> | ||
|
||
<!-- Raw Assets (also remove the "Resources\Raw" prefix) --> | ||
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" /> | ||
<PackageReference Include="DeviceRunners.VisualRunners.Maui" Version="0.1.0-preview.2" /> | ||
<PackageReference Include="DeviceRunners.VisualRunners.Xunit" Version="0.1.0-preview.2" /> | ||
<PackageReference Include="DeviceRunners.XHarness.Maui" Version="0.1.0-preview.2" /> | ||
<PackageReference Include="DeviceRunners.XHarness.Xunit" Version="0.1.0-preview.2" /> | ||
<PackageReference Include="DeviceRunners.UITesting.Maui" Version="0.1.0-preview.2" /> | ||
<PackageReference Include="DeviceRunners.UITesting.Xunit" Version="0.1.0-preview.2" /> | ||
<PackageReference Include="xunit" Version="2.9.0" /> | ||
<PackageReference Include="xunit.runner.utility" Version="2.9.0" /> | ||
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiPackageVersion)" /> | ||
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiPackageVersion)" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\CommunityToolkit.Maui.Core\CommunityToolkit.Maui.Core.csproj" /> | ||
<ProjectReference Include="..\CommunityToolkit.Maui\CommunityToolkit.Maui.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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,41 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="CommunityToolkit.Maui.DeviceTests.MainPage"> | ||
|
||
<ScrollView> | ||
<VerticalStackLayout | ||
Spacing="25" | ||
Padding="30,0" | ||
VerticalOptions="Center"> | ||
|
||
<Image | ||
Source="dotnet_bot.png" | ||
SemanticProperties.Description="Cute dot net bot waving hi to you!" | ||
HeightRequest="200" | ||
HorizontalOptions="Center" /> | ||
|
||
<Label | ||
Text="Hello, World!" | ||
SemanticProperties.HeadingLevel="Level1" | ||
FontSize="32" | ||
HorizontalOptions="Center" /> | ||
|
||
<Label | ||
Text="Welcome to .NET Multi-platform App UI" | ||
SemanticProperties.HeadingLevel="Level2" | ||
SemanticProperties.Description="Welcome to dot net Multi platform App U I" | ||
FontSize="18" | ||
HorizontalOptions="Center" /> | ||
|
||
<Button | ||
x:Name="CounterBtn" | ||
Text="Click me" | ||
SemanticProperties.Hint="Counts the number of times you click" | ||
Clicked="OnCounterClicked" | ||
HorizontalOptions="Center" /> | ||
|
||
</VerticalStackLayout> | ||
</ScrollView> | ||
|
||
</ContentPage> |
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 @@ | ||
namespace CommunityToolkit.Maui.DeviceTests; | ||
|
||
public partial class MainPage : ContentPage | ||
{ | ||
int count = 0; | ||
|
||
public MainPage() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void OnCounterClicked(object sender, EventArgs e) | ||
{ | ||
count++; | ||
|
||
if (count == 1) | ||
{ | ||
CounterBtn.Text = $"Clicked {count} time"; | ||
} | ||
else | ||
{ | ||
CounterBtn.Text = $"Clicked {count} times"; | ||
} | ||
|
||
SemanticScreenReader.Announce(CounterBtn.Text); | ||
} | ||
} | ||
|
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,34 @@ | ||
using CommunityToolkit.Maui.DeviceTests.Tests; | ||
using DeviceRunners.UITesting; | ||
using DeviceRunners.VisualRunners; | ||
using DeviceRunners.XHarness; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace CommunityToolkit.Maui.DeviceTests; | ||
public static class MauiProgram | ||
{ | ||
public static MauiApp CreateMauiApp() | ||
{ | ||
var builder = MauiApp.CreateBuilder(); | ||
builder | ||
.ConfigureUITesting() | ||
.UseXHarnessTestRunner(conf => conf | ||
.AddTestAssembly(typeof(MauiProgram).Assembly) | ||
.AddXunit()) | ||
.UseVisualTestRunner(conf => conf | ||
.AddTestAssembly(typeof(MauiProgram).Assembly) | ||
.AddXunit()) | ||
.UseMauiApp<App>() | ||
.ConfigureFonts(fonts => | ||
{ | ||
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); | ||
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); | ||
}); | ||
|
||
#if DEBUG | ||
builder.Logging.AddDebug(); | ||
#endif | ||
|
||
return builder.Build(); | ||
} | ||
} |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.