Skip to content

Commit

Permalink
Enable Mac Catalyst Core Device Tests in CI (#17232)
Browse files Browse the repository at this point in the history
* Enable Mac Catalyst Core Device Tests in CI

* Enable CI run for Core tests

* Fix not finding NSWindow in headless scenario

* Update AssertionExtensions.iOS.cs

* Update SearchBarHandlerTests.cs
  • Loading branch information
jfversluis authored Sep 7, 2023
1 parent b1729b3 commit 2068ae8
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 11 deletions.
3 changes: 1 addition & 2 deletions eng/pipelines/device-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ stages:
windowsPackageId: 'com.microsoft.maui.core.devicetests'
android: $(System.DefaultWorkingDirectory)/src/Core/tests/DeviceTests/Core.DeviceTests.csproj
ios: $(System.DefaultWorkingDirectory)/src/Core/tests/DeviceTests/Core.DeviceTests.csproj
# Skip this one for Mac Catalyst for now, it's crashing
catalyst: #$(System.DefaultWorkingDirectory)/src/Core/tests/DeviceTests/Core.DeviceTests.csproj
catalyst: $(System.DefaultWorkingDirectory)/src/Core/tests/DeviceTests/Core.DeviceTests.csproj
windows: $(System.DefaultWorkingDirectory)/src/Core/tests/DeviceTests/Core.DeviceTests.csproj
- name: controls
desc: Controls
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Microsoft.Maui.DeviceTests
public partial class SearchBarHandlerTests : CoreHandlerTestBase<SearchBarHandler, SearchBarStub>
{
[Theory(DisplayName = "Background Initializes Correctly"
#if IOS
#if IOS || MACCATALYST
, Skip = "This test is currently invalid on iOS https://github.com/dotnet/maui/issues/13693"
#endif
)]
Expand Down
30 changes: 25 additions & 5 deletions src/Core/tests/DeviceTests/Handlers/Window/WindowHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ await RunWindowTest(window, async handler =>
});
}

[Fact]
[Fact(
#if MACCATALYST
Skip = "Causes Catalyst test run to hang"
#endif
)]
public async Task WindowSupportsEmptyPage()
{
var window = new Window(new ContentPage());
Expand All @@ -72,7 +76,11 @@ await RunWindowTest(window, handler =>
});
}

[Theory]
[Theory(
#if MACCATALYST
Skip = "Causes Catalyst test run to hang"
#endif
)]
[InlineData(150, 300)]
[InlineData(200, 300)]
[InlineData(500, 500)]
Expand All @@ -99,7 +107,11 @@ await RunWindowTest(window, async handler =>
});
}

[Theory]
[Theory(
#if MACCATALYST
Skip = "Causes Catalyst test run to hang"
#endif
)]
[InlineData(150, 300)]
[InlineData(200, 300)]
[InlineData(500, 500)]
Expand All @@ -126,7 +138,11 @@ await RunWindowTest(window, async handler =>
});
}

[Theory]
[Theory(
#if MACCATALYST
Skip = "Causes Catalyst test run to hang"
#endif
)]
[InlineData(150, 150)]
[InlineData(200, 200)]
[InlineData(500, 300)]
Expand All @@ -153,7 +169,11 @@ await RunWindowTest(window, async handler =>
});
}

[Theory]
[Theory(
#if MACCATALYST
Skip = "Causes Catalyst test run to hang"
#endif
)]
[InlineData(150, 150)]
[InlineData(200, 200)]
[InlineData(500, 300)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ public partial class WindowHandlerTests : CoreHandlerTestBase
{
#if MACCATALYST

[Fact]
[Fact(
#if MACCATALYST
Skip = "Causes Catalyst test run to hang"
#endif
)]
public async Task TitleSetsOnWindow()
{
var window = new Window
Expand All @@ -32,7 +36,11 @@ await RunWindowTest(window, handler =>
}


[Fact]
[Fact(
#if MACCATALYST
Skip = "Causes Catalyst test run to hang"
#endif
)]
public async Task ContentIsSetInitially()
{
var window = new Window
Expand All @@ -58,7 +66,11 @@ await RunWindowTest(window, handler =>
});
}

[Fact]
[Fact(
#if MACCATALYST
Skip = "Causes Catalyst test run to hang"
#endif
)]
public async Task WindowSupportsEmptyPage_Platform()
{
var window = new Window(new ContentPage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ static MauiTestApplicationDelegate()
{
EnvVars[envvar] = Environment.GetEnvironmentVariable(envvar);
}

// Add entry to indicate we're running headless
EnvVars.Add("headlessrunner", "true");
}

static void SetEnvironmentVariables()
Expand Down
8 changes: 8 additions & 0 deletions src/TestUtils/src/DeviceTests/AssertionExtensions.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,14 @@ public static void AssertEqual(this CATransform3D expected, CATransform3D actual
{
foreach (var window in windowScene.Windows)
{
#if MACCATALYST
// When running headless (on CI or local) Mac Catalyst has trouble finding the window through the method below.
// Added an env variable to accommodate for this and just return the first window found.
if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("headlessrunner")))
{
return window;
}
#endif
if (window.IsKeyWindow)
{
return window;
Expand Down

0 comments on commit 2068ae8

Please sign in to comment.