Repository Public MIT
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project : SP GlassKit7// File : Tests/SPGlassComponentsTests/GlassButtonsTests.swift8// Module : Tests9// Repository : https://git.spboucher.ai/sp-glasskit10// Project Website : https://glass.spboucher.ai11// Created : 2026-12-0212// Last Modified : 2026-12-0213//14// Author : Simon-Pierre Boucher15// Position : Professor of Finance16// Institution : Université du Québec en Outaouais (UQO)17// Organization : SP Boucher18// Website : https://spboucher.ai19// Git : https://git.spboucher.ai20//21// Preferred Contact: contact@spboucher.ai22// Development : dev@spboucher.ai23// Support : support@spboucher.ai24// Security/Admin : admin@spboucher.ai25//26// Copyright (c) 202627// Simon-Pierre Boucher28// All rights reserved where applicable. This file is governed by the29// applicable project license, copyright notices and relevant law.30// Existing third-party rights and notices remain unaffected.31//32// License : MIT33//34// Do not embed credentials, private keys, access tokens,35// certificates or confidential personal information.36//37// =============================================================================38// END OF SP BOUCHER SOURCE HEADER39// =============================================================================4041import SwiftUI42import Testing43import SPGlassCore44import SPGlassTokens45@testable import SPGlassComponents4647@Suite("Buttons")48struct GlassButtonsTests {49 @Test("Icon buttons keep the platform's minimum hit target at every size", arguments: GlassPlatform.allCases, GlassControlSize.allCases)50 func hitTarget(platform: GlassPlatform, size: GlassControlSize) {51 let metrics = GlassControlMetrics(platform: platform)52 #expect(GlassIconButtonMetrics.hitTarget(size, metrics: metrics) >= metrics.minimumHitTarget)53 #expect(GlassIconButtonMetrics.symbolFrame(size, metrics: metrics) > metrics.iconSize(size))54 if platform != .macOS {55 #expect(GlassIconButtonMetrics.hitTarget(size, metrics: metrics) >= 44)56 }57 }5859 @Test func controlSizesMapToSystemSizes() {60 #expect(GlassControlSize.small.controlSize == .small)61 #expect(GlassControlSize.regular.controlSize == .regular)62 #expect(GlassControlSize.large.controlSize == .large)63 }6465 @Test func floatingPositionsUseDirectionAwareAlignments() {66 #expect(GlassFloatingPosition.bottomTrailing.alignment == .bottomTrailing)67 #expect(GlassFloatingPosition.bottomLeading.alignment == .bottomLeading)68 #expect(GlassFloatingPosition.bottomCenter.alignment == .bottom)69 #expect(GlassFloatingPosition.topTrailing.alignment == .topTrailing)70 #expect(GlassFloatingPosition.topLeading.alignment == .topLeading)71 #expect(GlassFloatingPosition.allCases.count == 5)72 }7374 @Test func variantsAreTheTwoSystemGlassStyles() {75 #expect(GlassButtonVariant.allCases == [.regular, .prominent])76 }77}78