Skip to content

Commit fa7572b

Browse files
Add GRContext Metal backend test
1 parent cc74520 commit fa7572b

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

tests/SkiaSharp.Tests.Devices/Tests/iOS/iOSExtensionsTests.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
using CoreGraphics;
1+
using System;
2+
using CoreGraphics;
23
using Foundation;
4+
using Metal;
35
using Xunit;
46

57
namespace SkiaSharp.Views.iOS.Tests
@@ -99,5 +101,28 @@ public void CGRectToSKRect(int x, int y, int w, int h)
99101

100102
Assert.Equal(expected, actual);
101103
}
104+
105+
[Fact]
106+
public void GRContextDoesNotCrash()
107+
{
108+
CreateAndDisposeMetalGRContext();
109+
CreateAndDisposeMetalGRContext();
110+
}
111+
112+
private static void CreateAndDisposeMetalGRContext()
113+
{
114+
var device = MTLDevice.SystemDefault!;
115+
using (var backendContext = new GRMtlBackendContext()
116+
{
117+
Device = device,
118+
Queue = device.CreateCommandQueue(),
119+
})
120+
{
121+
using var context = GRContext.CreateMetal(backendContext);
122+
}
123+
124+
GC.Collect();
125+
GC.WaitForPendingFinalizers();
126+
}
102127
}
103128
}

0 commit comments

Comments
 (0)