Skip to content
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

ci: Add macOS desktop runtime tests #17333

Merged
merged 25 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8d2e055
ci: Add macOS desktop runtime tests
jeromelaban Jun 27, 2024
29fb75d
chore: Adjust command line
jeromelaban Jun 27, 2024
2e2b0b5
Merge branch 'master' into dev/jela/macos-generic-test
spouliot Nov 3, 2024
0ea57fa
fix: Fix When_Window_Closed_Is_Handled on macOS/skia
spouliot Nov 3, 2024
dac31e8
fix(tests): When_Copy_Paste on macOS/skia
spouliot Nov 3, 2024
6f79a81
fix(tests): Check_FontFallback_Shaping on macOS/skia
spouliot Nov 4, 2024
3d19d61
fix(tests): When_Ctrl_A on macOS/skia
spouliot Nov 4, 2024
8fc014a
fix(tests): When_Ctrl_Backspace on macOS/skia
spouliot Nov 4, 2024
8547cbd
fix(tests): When_Ctrl_Delete on macOS/skia
spouliot Nov 4, 2024
3e1c56c
fix(tests): When_Ctrl_Delete_Undo_Redo on macOS/skia
spouliot Nov 4, 2024
6acb0cd
fix(tests): When_Ctrl_End_ScrollViewer_Vertical_Offset on macOS/skia
spouliot Nov 4, 2024
ff2386c
fix(tests): When_Ctrl_Home_End on macOS/skia
spouliot Nov 4, 2024
d5f60ec
fix(tests): When_Cut_Paste on macOS/skia
spouliot Nov 4, 2024
7e21bee
fix(tests): Fix several Given_TextBox tests on macOS/skia
spouliot Nov 4, 2024
ba5867b
fix(tests): Fix When_Undo_Redo_Keyboard_Basic on macOS/skia
spouliot Nov 4, 2024
2316d6c
fix(tests): Fix When_Selection_With_Keyboard_NoMod_Ctrl_And_Shift on …
spouliot Nov 4, 2024
20df9bd
fix(tests): Fix When_Scrolling_Updates_After_Backspace on macOS/skia
spouliot Nov 4, 2024
647a7ac
fix(tests): Fix When_Paste_While_Pointer_Held on macOS/skia
spouliot Nov 4, 2024
431d124
fix(tests): Tolerate 2 pixels diff (happens on CI) for Check_FontFall…
spouliot Nov 4, 2024
313b0e4
Merge branch 'master' into dev/jela/macos-generic-test
spouliot Nov 4, 2024
10e637e
fix(tests): Fix When_IsTextSelectionEnabled_Keyboard_SelectAll_Copy o…
spouliot Nov 4, 2024
8be8374
fix(tests): Fix When_Large_List_Scroll_To_End_Then_Back_Up_TryClick o…
spouliot Nov 4, 2024
1e19156
chore: restore extra > at the end of XML since it fails without it
spouliot Nov 5, 2024
824ecbf
Merge branch 'master' into dev/jela/macos-generic-test
spouliot Nov 5, 2024
2a6a7f9
chore: fix xml comment
spouliot Nov 5, 2024
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
45 changes: 45 additions & 0 deletions build/ci/.azure-devops-skia-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -448,3 +448,48 @@ jobs:
testResultsFiles: '$(build.sourcesdirectory)/build/skia-linux-runtime-tests-results.xml'
failTaskOnFailedTests: true
failTaskOnMissingResultsFile: true

- job: Skia_macos_Runtime_Tests_Build
displayName: 'Run Skia macOS Runtime Tests'
timeoutInMinutes: 60

pool:
vmImage: ${{ parameters.vmMacImage }}

dependsOn: Skia_Tests_Build

variables:
SamplesAppArtifactName: skia-generic-samples-app-$(XAML_FLAVOR_BUILD)
SamplesAppArtifactPath: $(build.sourcesdirectory)/build/$(SamplesAppArtifactName)

UNO_UWP_BUILD: ${{ parameters.UNO_UWP_BUILD }}
XAML_FLAVOR_BUILD: ${{ parameters.XAML_FLAVOR_BUILD }}

steps:

- template: templates/download-winui-converted-tree.yml

- task: DownloadBuildArtifacts@0
inputs:
artifactName: $(SamplesAppArtifactName)
downloadPath: '$(build.sourcesdirectory)/build'

- template: templates/dotnet-install.yml

- script: |
cd $(SamplesAppArtifactPath)
dotnet SamplesApp.Skia.Generic.dll --runtime-tests=$(build.sourcesdirectory)/build/skia-macos-runtime-tests-results.xml

displayName: Run Skia $(XAML_FLAVOR_BUILD) Runtime Tests
env:
SamplesAppArtifactPath: $(SamplesAppArtifactPath)
SamplesAppArtifactName: $(SamplesAppArtifactName)

- task: PublishTestResults@2
condition: always()
inputs:
testRunTitle: 'Skia macOS $(XAML_FLAVOR_BUILD) Runtime Tests'
testResultsFormat: 'NUnit'
testResultsFiles: '$(build.sourcesdirectory)/build/skia-macos-runtime-tests-results.xml'
failTaskOnFailedTests: true
failTaskOnMissingResultsFile: true
1 change: 1 addition & 0 deletions src/Uno.UI.Runtime.Skia.MacOS/MacOSWindowWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ protected override void ShowCore()
public override void Close()
{
NativeUno.uno_window_close(_window.Handle);
base.Close();
}

public override void Move(PointInt32 position)
Expand Down
9 changes: 6 additions & 3 deletions src/Uno.UI.RuntimeTests/Helpers/ImageAssert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,16 +258,19 @@ private static async Task<bool> AreRenderTargetBitmapsEqualAsync(RenderTargetBit
/// If the error is greater than or equal to 0.022, the differences are visible to human eyes.
/// <paramref name="actual">The image to compare with reference</paramref>
/// <paramref name="expected">Reference image.</paramref>
/// <paramref name="imperceptibilityThreshold">It is the threshold beyond which the compared images are not considered equal. Default value is 0.022.</paramref>>
/// <paramref name="imperceptibilityThreshold">It is the threshold beyond which the compared images are not considered equal. Default value is 0.022.</paramref>
/// <paramref name="resolutionTolerance">Limits of resolution (in pixels) difference between the bitmaps</paramref>
/// </summary>
public static async Task AreSimilarAsync(RawBitmap actual, RawBitmap expected, double imperceptibilityThreshold = 0.022)
public static async Task AreSimilarAsync(RawBitmap actual, RawBitmap expected, double imperceptibilityThreshold = 0.022, int resolutionTolerance = 0)
{
await actual.Populate();
await expected.Populate();

using var assertionScope = new AssertionScope("ImageAssert");

if (actual.Width != expected.Width || actual.Height != expected.Height)
var dx = Math.Abs(actual.Width - expected.Width);
var dy = Math.Abs(actual.Height - expected.Height);
if (dx > resolutionTolerance || dy > resolutionTolerance)
{
assertionScope.FailWith($"Images have different resolutions. {Environment.NewLine}expected:({expected.Width},{expected.Height}){Environment.NewLine}actual :({actual.Width},{actual.Height})");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1988,11 +1988,13 @@ string RandomString(int length)
// since this is originally a virtualization issue and references
// could be to different things than those shown on the screen.
var si = await UITestHelper.ScreenShot(list, true);
ImageAssert.HasColorAt(si, 70, 65, Colors.FromARGB("#1A69A6")); // selected
// on macOS/metal we get the color #1A6AA7 which is quite close but not identical
var tolerance = (byte)(OperatingSystem.IsMacOS() ? 1 : 0);
ImageAssert.HasColorAt(si, 70, 65, Colors.FromARGB("#1A69A6"), tolerance); // selected

// check starting from below the second item that nothing looks selected or hovered
ImageAssert.DoesNotHaveColorInRectangle(si, new Rectangle(100, 110, si.Width - 100, si.Height - 110), Colors.FromARGB("#1A69A6")); // selected
ImageAssert.DoesNotHaveColorInRectangle(si, new Rectangle(100, 110, si.Width - 100, si.Height - 110), Colors.FromARGB("#FFE6E6E6")); // hovered
ImageAssert.DoesNotHaveColorInRectangle(si, new Rectangle(100, 110, si.Width - 100, si.Height - 110), Colors.FromARGB("#1A69A6"), tolerance); // selected
ImageAssert.DoesNotHaveColorInRectangle(si, new Rectangle(100, 110, si.Width - 100, si.Height - 110), Colors.FromARGB("#FFE6E6E6"), tolerance); // hovered
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,8 @@ public async Task Check_FontFallback_Shaping()
await UITestHelper.Load(expected);
var screenshot2 = await UITestHelper.ScreenShot(expected);

Assert.AreEqual(screenshot2.Width, screenshot1.Width);
Assert.AreEqual(screenshot2.Height, screenshot1.Height);

await ImageAssert.AreSimilarAsync(screenshot1, screenshot2, imperceptibilityThreshold: 0.15);
// we tolerate a 2 pixels difference between the bitmaps due to font differences
await ImageAssert.AreSimilarAsync(screenshot1, screenshot2, imperceptibilityThreshold: 0.18, resolutionTolerance: 2);
}
#endif

Expand Down Expand Up @@ -1264,7 +1262,8 @@ public async Task When_IsTextSelectionEnabled_Keyboard_SelectAll_Copy()
mouse.Release();
await WindowHelper.WaitForIdle();

SUT.SafeRaiseEvent(UIElement.KeyDownEvent, new KeyRoutedEventArgs(SUT, VirtualKey.A, VirtualKeyModifiers.Control));
var mod = OperatingSystem.IsMacOS() ? VirtualKeyModifiers.Windows : VirtualKeyModifiers.Control;
SUT.SafeRaiseEvent(UIElement.KeyDownEvent, new KeyRoutedEventArgs(SUT, VirtualKey.A, mod));
await WindowHelper.WaitForIdle();

var bitmap = await UITestHelper.ScreenShot(SUT);
Expand All @@ -1278,7 +1277,7 @@ public async Task When_IsTextSelectionEnabled_Keyboard_SelectAll_Copy()
SUT.SelectionHighlightColor.Color);
}

SUT.SafeRaiseEvent(UIElement.KeyDownEvent, new KeyRoutedEventArgs(SUT, VirtualKey.C, VirtualKeyModifiers.Control));
SUT.SafeRaiseEvent(UIElement.KeyDownEvent, new KeyRoutedEventArgs(SUT, VirtualKey.C, mod));
await WindowHelper.WaitForIdle();

Assert.AreEqual(SUT.Text, await Clipboard.GetContent()!.GetTextAsync());
Expand Down
Loading
Loading