Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
69ec49d
added runner project
pictos Sep 8, 2023
5513c8e
Added UITest capabilities
pictos Sep 15, 2023
c61f20b
Test runner ci (#1446)
VladislavAntonyuk Oct 5, 2023
9f1b099
Merge branch 'main' into pj/device-test-runner
pictos Oct 17, 2023
2b2c1f9
Merge branch 'main' into pj/device-test-runner
VladislavAntonyuk Nov 26, 2023
f3af8fc
Merge branch 'main' into pj/device-test-runner
VladislavAntonyuk Dec 8, 2023
9d3383b
Merge branch 'main' into pj/device-test-runner
VladislavAntonyuk Feb 8, 2024
a3b5683
Merge branch 'main' into pj/device-test-runner
TheCodeTraveler Mar 26, 2024
0770d65
Merge branch 'main' into pj/device-test-runner
TheCodeTraveler Sep 20, 2024
d030aa6
Update to .NET 8
TheCodeTraveler Sep 20, 2024
a1314f4
Update azure-pipelines.yml
TheCodeTraveler Sep 20, 2024
64b65ce
Update azure-pipelines.yml
TheCodeTraveler Sep 20, 2024
c4b6dfb
Remove Unnecessary Code
TheCodeTraveler Sep 20, 2024
ff05284
Update install step
TheCodeTraveler Sep 20, 2024
3a0f4d2
Update azure-pipelines.yml
TheCodeTraveler Sep 20, 2024
62fc85a
Remove Redundant Folder
TheCodeTraveler Sep 20, 2024
a1bebd8
Update azure-pipelines.yml
TheCodeTraveler Sep 20, 2024
cc8d4c3
Update azure-pipelines.yml
TheCodeTraveler Sep 21, 2024
8050559
Run Unit Tests after all projects have been compiled
TheCodeTraveler Sep 21, 2024
a6853e5
Fix App Identifier
TheCodeTraveler Sep 21, 2024
073f310
Merge branch 'main' into pj/device-test-runner
TheCodeTraveler Oct 1, 2024
9aaec9b
Update to xcode 16
bijington Oct 1, 2024
7dd4b5c
Update src/CommunityToolkit.Maui.DeviceTests/Platforms/MacCatalyst/Ap…
TheCodeTraveler Dec 10, 2024
c0b64c6
Update src/CommunityToolkit.Maui.DeviceTests/MainPage.xaml.cs
TheCodeTraveler Dec 10, 2024
7a035ae
Merge branch 'main' into pj/device-test-runner
TheCodeTraveler Dec 18, 2024
6c7fb61
Merge branch 'main' into pj/device-test-runner
ne0rrmatrix Jan 28, 2025
76db87e
Merge branch 'main' into pj/device-test-runner
ne0rrmatrix Feb 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
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();
}
}
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>
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();
}
}
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");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-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);net7.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
<RootNamespace>CommunityToolkit.Maui.DeviceTests</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>

<!-- Display name -->
<ApplicationTitle>CommunityToolkit.Maui.DeviceTests</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>com.companyname.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>
</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="7.0.0" />
<PackageReference Include="DeviceRunners.VisualRunners.Maui" Version="0.1.0-preview.1" />
<PackageReference Include="DeviceRunners.VisualRunners.Xunit" Version="0.1.0-preview.1" />
<PackageReference Include="DeviceRunners.XHarness.Maui" Version="0.1.0-preview.1" />
<PackageReference Include="DeviceRunners.XHarness.Xunit" Version="0.1.0-preview.1" />
<PackageReference Include="DeviceRunners.UITesting.Maui" Version="0.1.0-preview.1" />
<PackageReference Include="DeviceRunners.UITesting.Xunit" Version="0.1.0-preview.1" />
<PackageReference Include="xunit" Version="2.5.0-pre.44" />
<PackageReference Include="xunit.runner.utility" Version="2.5.0-pre.44" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\CommunityToolkit.Maui.Core\CommunityToolkit.Maui.Core.csproj" />
<ProjectReference Include="..\..\CommunityToolkit.Maui\CommunityToolkit.Maui.csproj" />
</ItemGroup>

<ItemGroup>
<MauiXaml Update="Tests\UITests\StatusBarTestPage.xaml">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be removed

<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>
</Project>
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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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);
}
}

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();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Android.App;
using Android.Content.PM;
using Android.OS;

namespace CommunityToolkit.Maui.DeviceTests;
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
public class MainActivity : MauiAppCompatActivity
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Android.App;
using Android.Runtime;

namespace CommunityToolkit.Maui.DeviceTests;
[Application]
public class MainApplication : MauiApplication
{
public MainApplication(IntPtr handle, JniHandleOwnership ownership)
: base(handle, ownership)
{
}

protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#512BD4</color>
<color name="colorPrimaryDark">#2B0B98</color>
<color name="colorAccent">#2B0B98</color>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Foundation;

namespace CommunityToolkit.Maui.DeviceTests;
[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>arm64</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/appicon.appiconset</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using ObjCRuntime;
using UIKit;

namespace CommunityToolkit.Maui.DeviceTests;
public class Program
{
// This is the main entry point of the application.
static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, typeof(AppDelegate));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using Microsoft.Maui;
using Microsoft.Maui.Hosting;

namespace CommunityToolkit.Maui.DeviceTests;
class Program : MauiApplication
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();

static void Main(string[] args)
{
var app = new Program();
app.Run(args);
}
}
Loading