diff --git a/azure-pipelines-integrationtests.yml b/azure-pipelines-integrationtests.yml index 4fba4ca36f..43253ac6be 100644 --- a/azure-pipelines-integrationtests.yml +++ b/azure-pipelines-integrationtests.yml @@ -18,9 +18,9 @@ jobs: version: 6.0.401 - task: UseDotNet@2 - displayName: 'Use .NET Core SDK 7.0.100-rc.2.22477.23' + displayName: 'Use .NET Core SDK 7.0.100' inputs: - version: 7.0.100-rc.2.22477.23 + version: 7.0.100 - script: system_profiler SPDisplaysDataType |grep Resolution @@ -32,7 +32,7 @@ jobs: rm -rf $(osascript -e "POSIX path of (path to application id \"net.avaloniaui.avalonia.integrationtestapp\")") pkill IntegrationTestApp ./samples/IntegrationTestApp/bundle.sh - open -n ./samples/IntegrationTestApp/bin/Debug/net6.0/osx-arm64/publish/IntegrationTestApp.app + open -n ./samples/IntegrationTestApp/bin/Debug/net7.0/osx-arm64/publish/IntegrationTestApp.app pkill IntegrationTestApp - task: DotNetCoreCLI@2 @@ -56,9 +56,9 @@ jobs: version: 6.0.401 - task: UseDotNet@2 - displayName: 'Use .NET Core SDK 7.0.100-rc.2.22477.23' + displayName: 'Use .NET Core SDK 7.0.100' inputs: - version: 7.0.100-rc.2.22477.23 + version: 7.0.100 - task: Windows Application Driver@0 inputs: diff --git a/samples/IntegrationTestApp/IntegrationTestApp.csproj b/samples/IntegrationTestApp/IntegrationTestApp.csproj index 4284399357..0a761d70ba 100644 --- a/samples/IntegrationTestApp/IntegrationTestApp.csproj +++ b/samples/IntegrationTestApp/IntegrationTestApp.csproj @@ -1,7 +1,7 @@  WinExe - net6.0 + net7.0 enable diff --git a/src/Avalonia.OpenGL/Egl/EglPlatformOpenGlInterface.cs b/src/Avalonia.OpenGL/Egl/EglPlatformOpenGlInterface.cs index a6d8c1e98d..a1ac2a9d37 100644 --- a/src/Avalonia.OpenGL/Egl/EglPlatformOpenGlInterface.cs +++ b/src/Avalonia.OpenGL/Egl/EglPlatformOpenGlInterface.cs @@ -44,10 +44,13 @@ namespace Avalonia.OpenGL.Egl public IGlContext CreateContext() => Display.CreateContext(null); public IGlContext CreateSharedContext() => Display.CreateContext(PrimaryEglContext); - + public EglSurface CreateWindowSurface(IntPtr window) { + if (window == IntPtr.Zero) + throw new OpenGlException($"Window {window} is invalid."); + using (PrimaryContext.MakeCurrent()) { var s = Display.EglInterface.CreateWindowSurface(Display.Handle, Display.Config, window, diff --git a/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs b/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs index dd3badb2d8..f34e25299c 100644 --- a/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs +++ b/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs @@ -242,7 +242,7 @@ namespace Avalonia.Skia "Current GPU acceleration backend does not support OpenGL integration"); } - public IGlyphRunImpl CreateGlyphRun(IGlyphTypeface glyphTypeface, double fontRenderingEmSize, IReadOnlyList glyphIndices, + public IGlyphRunImpl CreateGlyphRun(IGlyphTypeface glyphTypeface, double fontRenderingEmSize, IReadOnlyList glyphIndices, IReadOnlyList glyphAdvances, IReadOnlyList glyphOffsets) { if (glyphTypeface == null) @@ -273,7 +273,7 @@ namespace Avalonia.Skia var count = glyphIndices.Count; - if(glyphOffsets != null && glyphAdvances != null) + if (glyphOffsets != null && glyphAdvances != null) { var runBuffer = builder.AllocatePositionedRun(font, count); @@ -295,7 +295,7 @@ namespace Avalonia.Skia } else { - if(glyphAdvances != null) + if (glyphAdvances != null) { var runBuffer = builder.AllocateHorizontalRun(font, count, 0); @@ -304,7 +304,7 @@ namespace Avalonia.Skia var currentX = 0.0; - for (int i = 0; i < glyphOffsets.Count; i++) + for (int i = 0; i < glyphAdvances.Count; i++) { glyphSpan[i] = glyphIndices[i]; @@ -319,7 +319,7 @@ namespace Avalonia.Skia var glyphSpan = runBuffer.GetGlyphSpan(); - for (int i = 0; i < glyphOffsets.Count; i++) + for (int i = 0; i < glyphIndices.Count; i++) { glyphSpan[i] = glyphIndices[i]; } diff --git a/tests/Avalonia.IntegrationTests.Appium/GestureTests.cs b/tests/Avalonia.IntegrationTests.Appium/GestureTests.cs index 205ad6b8cf..9745f993cb 100644 --- a/tests/Avalonia.IntegrationTests.Appium/GestureTests.cs +++ b/tests/Avalonia.IntegrationTests.Appium/GestureTests.cs @@ -82,7 +82,7 @@ namespace Avalonia.IntegrationTests.Appium new Actions(_session).ClickAndHold(border).Release().Perform(); - Thread.Sleep(100); + Thread.Sleep(50); // DoubleTapped is raised on second pointer press, not release. new Actions(_session).ClickAndHold(border).Perform(); @@ -93,7 +93,8 @@ namespace Avalonia.IntegrationTests.Appium } finally { - new Actions(_session).Release(border).Perform(); + + new Actions(_session).MoveToElement(lastGesture).Release().Perform(); } } @@ -118,12 +119,15 @@ namespace Avalonia.IntegrationTests.Appium // #8733 var border = _session.FindElementByAccessibilityId("GestureBorder"); var lastGesture = _session.FindElementByAccessibilityId("LastGesture"); - + new Actions(_session) .MoveToElement(border) .DoubleClick() - .DoubleClick() .Perform(); + + Thread.Sleep(100); + + new Actions(_session).MoveToElement(lastGesture, 200, 200).DoubleClick().Perform(); Assert.Equal("DoubleTapped2", lastGesture.Text); } @@ -147,9 +151,9 @@ namespace Avalonia.IntegrationTests.Appium var device = new PointerInputDevice(PointerKind.Mouse); var b = new ActionBuilder(); - b.AddAction(device.CreatePointerMove(border, 50, 50, TimeSpan.FromMilliseconds(100))); + b.AddAction(device.CreatePointerMove(border, 50, 50, TimeSpan.FromMilliseconds(50))); b.AddAction(device.CreatePointerDown(MouseButton.Right)); - b.AddAction(device.CreatePointerMove(border, 2, 2, TimeSpan.FromMilliseconds(100))); + b.AddAction(device.CreatePointerMove(border, 52, 52, TimeSpan.FromMilliseconds(50))); b.AddAction(device.CreatePointerUp(MouseButton.Right)); _session.PerformActions(b.ToActionSequenceList()); diff --git a/tests/Avalonia.IntegrationTests.Appium/TestAppFixture.cs b/tests/Avalonia.IntegrationTests.Appium/TestAppFixture.cs index b3385d8ee7..d71f9e9bcc 100644 --- a/tests/Avalonia.IntegrationTests.Appium/TestAppFixture.cs +++ b/tests/Avalonia.IntegrationTests.Appium/TestAppFixture.cs @@ -11,7 +11,7 @@ namespace Avalonia.IntegrationTests.Appium { public class TestAppFixture : IDisposable { - private const string TestAppPath = @"..\..\..\..\..\samples\IntegrationTestApp\bin\Debug\net6.0\IntegrationTestApp.exe"; + private const string TestAppPath = @"..\..\..\..\..\samples\IntegrationTestApp\bin\Debug\net7.0\IntegrationTestApp.exe"; private const string TestAppBundleId = "net.avaloniaui.avalonia.integrationtestapp"; public TestAppFixture() diff --git a/tests/Avalonia.IntegrationTests.Appium/WindowTests_MacOS.cs b/tests/Avalonia.IntegrationTests.Appium/WindowTests_MacOS.cs index 2dd849bee1..05ed0616a8 100644 --- a/tests/Avalonia.IntegrationTests.Appium/WindowTests_MacOS.cs +++ b/tests/Avalonia.IntegrationTests.Appium/WindowTests_MacOS.cs @@ -180,10 +180,23 @@ namespace Avalonia.IntegrationTests.Appium Assert.False(miniaturizeButton.Enabled); } } + + [PlatformTheory(TestPlatforms.MacOS)] + [InlineData(ShowWindowMode.Owned)] + public void Minimize_Button_Disabled_Owned_Window(ShowWindowMode mode) + { + using (OpenWindow(new PixelSize(200, 100), mode, WindowStartupLocation.Manual)) + { + var secondaryWindow = GetWindow("SecondaryWindow"); + var (_, miniaturizeButton, _) = secondaryWindow.GetChromeButtons(); + + Assert.Equal(false, miniaturizeButton.Enabled); + } + } + [PlatformTheory(TestPlatforms.MacOS)] [InlineData(ShowWindowMode.NonOwned)] - [InlineData(ShowWindowMode.Owned)] public void Minimize_Button_Minimizes_Window(ShowWindowMode mode) { using (OpenWindow(new PixelSize(200, 100), mode, WindowStartupLocation.Manual)) diff --git a/tests/Avalonia.IntegrationTests.Appium/macos-clean-build-test.sh b/tests/Avalonia.IntegrationTests.Appium/macos-clean-build-test.sh index 14e765d16a..dc4619f35c 100755 --- a/tests/Avalonia.IntegrationTests.Appium/macos-clean-build-test.sh +++ b/tests/Avalonia.IntegrationTests.Appium/macos-clean-build-test.sh @@ -10,7 +10,7 @@ pkill IntegrationTestApp rm -rf $(osascript -e "POSIX path of (path to application id \"net.avaloniaui.avalonia.integrationtestapp\")") pkill IntegrationTestApp ./samples/IntegrationTestApp/bundle.sh -open -n ./samples/IntegrationTestApp/bin/Debug/net6.0/osx-arm64/publish/IntegrationTestApp.app +open -n ./samples/IntegrationTestApp/bin/Debug/net7.0/osx-arm64/publish/IntegrationTestApp.app pkill IntegrationTestApp open -b net.avaloniaui.avalonia.integrationtestapp dotnet test tests/Avalonia.IntegrationTests.Appium/ -l "console;verbosity=detailed" diff --git a/tests/Avalonia.IntegrationTests.Appium/readme.md b/tests/Avalonia.IntegrationTests.Appium/readme.md index ee630a31fd..f54720920d 100644 --- a/tests/Avalonia.IntegrationTests.Appium/readme.md +++ b/tests/Avalonia.IntegrationTests.Appium/readme.md @@ -18,7 +18,7 @@ - Install Appium: https://appium.io/ - Give [Xcode helper the required permissions](https://apple.stackexchange.com/questions/334008) - `cd samples/IntegrationTestApp` then `./bundle.sh` to create an app bundle for `IntegrationTestApp` -- Register the app bundle by running `open -n ./bin/Debug/net6.0/osx-arm64/publish/IntegrationTestApp.app` +- Register the app bundle by running `open -n ./bin/Debug/net7.0/osx-arm64/publish/IntegrationTestApp.app` ### Running diff --git a/tests/Avalonia.RenderTests/Media/GlyphRunTests.cs b/tests/Avalonia.RenderTests/Media/GlyphRunTests.cs index 1b0193bfdb..31e485448e 100644 --- a/tests/Avalonia.RenderTests/Media/GlyphRunTests.cs +++ b/tests/Avalonia.RenderTests/Media/GlyphRunTests.cs @@ -50,6 +50,66 @@ namespace Avalonia.Direct2D1.RenderTests.Media CompareImages(); } + [Win32Fact("For consistent results")] + public async Task Should_Render_GlyphRun_UnPositioned() + { + var control = new UnPositionedGlyphRunControl + { + [TextElement.ForegroundProperty] = new LinearGradientBrush + { + StartPoint = new RelativePoint(0, 0.5, RelativeUnit.Relative), + EndPoint = new RelativePoint(1, 0.5, RelativeUnit.Relative), + GradientStops = + { + new GradientStop { Color = Colors.Red, Offset = 0 }, + new GradientStop { Color = Colors.Blue, Offset = 1 } + } + } + }; + + Decorator target = new Decorator + { + Padding = new Thickness(8), + Width = 190, + Height = 120, + Child = control + }; + + await RenderToFile(target); + + CompareImages(); + } + + [Win32Fact("For consistent results")] + public async Task Should_Render_GlyphRun_Positioned() + { + var control = new PositionedGlyphRunControl + { + [TextElement.ForegroundProperty] = new LinearGradientBrush + { + StartPoint = new RelativePoint(0, 0.5, RelativeUnit.Relative), + EndPoint = new RelativePoint(1, 0.5, RelativeUnit.Relative), + GradientStops = + { + new GradientStop { Color = Colors.Red, Offset = 0 }, + new GradientStop { Color = Colors.Blue, Offset = 1 } + } + } + }; + + Decorator target = new Decorator + { + Padding = new Thickness(8), + Width = 190, + Height = 120, + Child = control + }; + + await RenderToFile(target); + + CompareImages(); + } + public class GlyphRunGeometryControl : Control { public GlyphRunGeometryControl() @@ -74,5 +134,58 @@ namespace Avalonia.Direct2D1.RenderTests.Media context.DrawGeometry(foreground, null, Geometry); } } + + public class UnPositionedGlyphRunControl : Control + { + public UnPositionedGlyphRunControl() + { + var glyphTypeface = new Typeface(TestFontFamily).GlyphTypeface; + + var glyphIndices = new[] { glyphTypeface.GetGlyph('A'), glyphTypeface.GetGlyph('B'), glyphTypeface.GetGlyph('C') }; + + var characters = new[] { 'A', 'B', 'C' }; + + GlyphRun = new GlyphRun(glyphTypeface, 100, characters, glyphIndices); + } + + public GlyphRun GlyphRun { get; } + + public override void Render(DrawingContext context) + { + var foreground = TextElement.GetForeground(this); + + context.DrawGlyphRun(foreground, GlyphRun); + } + } + + public class PositionedGlyphRunControl : Control + { + public PositionedGlyphRunControl() + { + var glyphTypeface = new Typeface(TestFontFamily).GlyphTypeface; + + var glyphIndices = new[] { glyphTypeface.GetGlyph('A'), glyphTypeface.GetGlyph('B'), glyphTypeface.GetGlyph('C') }; + + var scale = 100.0 / glyphTypeface.Metrics.DesignEmHeight; + + var advance = glyphTypeface.GetGlyphAdvance(glyphIndices[0]) * scale; + + var advances = new[] { advance, advance, advance}; + + var characters = new[] { 'A', 'B', 'C' }; + + GlyphRun = new GlyphRun(glyphTypeface, 100, characters, glyphIndices, advances); + } + + public GlyphRun GlyphRun { get; } + + public override void Render(DrawingContext context) + { + var foreground = TextElement.GetForeground(this); + + context.DrawGlyphRun(foreground, GlyphRun); + } + } + } } diff --git a/tests/TestFiles/Direct2D1/Media/GlyphRun/Should_Render_GlyphRun_Positioned.expected.png b/tests/TestFiles/Direct2D1/Media/GlyphRun/Should_Render_GlyphRun_Positioned.expected.png new file mode 100644 index 0000000000..913266b652 Binary files /dev/null and b/tests/TestFiles/Direct2D1/Media/GlyphRun/Should_Render_GlyphRun_Positioned.expected.png differ diff --git a/tests/TestFiles/Direct2D1/Media/GlyphRun/Should_Render_GlyphRun_UnPositioned.expected.png b/tests/TestFiles/Direct2D1/Media/GlyphRun/Should_Render_GlyphRun_UnPositioned.expected.png new file mode 100644 index 0000000000..913266b652 Binary files /dev/null and b/tests/TestFiles/Direct2D1/Media/GlyphRun/Should_Render_GlyphRun_UnPositioned.expected.png differ diff --git a/tests/TestFiles/Skia/Media/GlyphRun/Should_Render_GlyphRun_Positioned.expected.png b/tests/TestFiles/Skia/Media/GlyphRun/Should_Render_GlyphRun_Positioned.expected.png new file mode 100644 index 0000000000..4b8371541e Binary files /dev/null and b/tests/TestFiles/Skia/Media/GlyphRun/Should_Render_GlyphRun_Positioned.expected.png differ diff --git a/tests/TestFiles/Skia/Media/GlyphRun/Should_Render_GlyphRun_UnPositioned.expected.png b/tests/TestFiles/Skia/Media/GlyphRun/Should_Render_GlyphRun_UnPositioned.expected.png new file mode 100644 index 0000000000..4b8371541e Binary files /dev/null and b/tests/TestFiles/Skia/Media/GlyphRun/Should_Render_GlyphRun_UnPositioned.expected.png differ