Skip to content

Commit

Permalink
fix macos tests, images come out slightly different
Browse files Browse the repository at this point in the history
  • Loading branch information
maxxfrazer committed Dec 20, 2023
1 parent 8b431ac commit 1601bec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Sources/RealityUI/RUITexture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ public struct RUITexture {
throw TextureError.cgImageFailed
}
#else
guard let symbolImage = UIImage(
guard var symbolImage = UIImage(
systemSymbolName: systemName, accessibilityDescription: nil
)?.withSymbolConfiguration(config) else { throw TextureError.invalidSystemName }
) else { throw TextureError.invalidSystemName }
if let config, let imgWithConfig = symbolImage.withSymbolConfiguration(config) {
symbolImage = imgWithConfig
}
guard let cgImage = symbolImage.cgImage(
forProposedRect: nil, context: nil, hints: nil
) else { throw TextureError.cgImageFailed }
Expand Down
4 changes: 4 additions & 0 deletions Tests/RealityUITests/RUITextureTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ final class RUITextureTests: XCTestCase {
let tex = try await RUITexture.generateTexture(systemName: "pencil", pointSize: 20)
let xcMainThread = XCTestExpectation(description: "main async called")
DispatchQueue.main.async {
#if os(iOS)
XCTAssertEqual(tex.width, 48, accuracy: 1)
XCTAssertEqual(tex.height, 48, accuracy: 1)
#elseif os(macOS)
XCTAssertEqual(tex.width, tex.height, accuracy: 2)
#endif
xcMainThread.fulfill()
}
await fulfillment(of: [xcMainThread])
Expand Down

0 comments on commit 1601bec

Please sign in to comment.