@@ -5,6 +5,17 @@ import XCTest
55
66@ testable import Buzz
77
8+ private extension UIColor {
9+ convenience init ( hex : UInt32 ) {
10+ self . init (
11+ red : CGFloat ( ( hex >> 16 ) & 0xFF ) / 255 ,
12+ green : CGFloat ( ( hex >> 8 ) & 0xFF ) / 255 ,
13+ blue : CGFloat ( hex & 0xFF ) / 255 ,
14+ alpha : 1
15+ )
16+ }
17+ }
18+
819class RunnerTests : XCTestCase {
920
1021 func testNavigationGlassButtonExpandsToConfiguredHitTarget ( ) {
@@ -25,25 +36,60 @@ class RunnerTests: XCTestCase {
2536 XCTAssertFalse ( button . point ( inside : CGPoint ( x : - 1 , y : 20 ) , with : nil ) )
2637 }
2738
28- func testNavigationGlassFallbackUsesDarkSurfaceForWhiteGlyphInLightMode ( ) {
39+ func testNavigationGlassFallbackContrastsSupportedAccentsInLightMode ( ) {
40+ let accents : [ ( name : String , color : UIColor , usesDarkSurface : Bool ) ] = [
41+ ( " Neutral " , UIColor ( hex : 0x000000 ) , false ) ,
42+ ( " Blue " , UIColor ( hex : 0x3B82F6 ) , false ) ,
43+ ( " Cyan " , UIColor ( hex : 0x06B6D4 ) , true ) ,
44+ ( " Green " , UIColor ( hex : 0x22C55E ) , true ) ,
45+ ( " Orange " , UIColor ( hex : 0xF97316 ) , true ) ,
46+ ( " Red " , UIColor ( hex : 0xEF4444 ) , false ) ,
47+ ( " Pink " , UIColor ( hex : 0xEC4899 ) , false ) ,
48+ ( " Lilac " , UIColor ( hex : 0xC0A2F1 ) , true ) ,
49+ ( " Purple " , UIColor ( hex : 0xA855F7 ) , false ) ,
50+ ( " Indigo " , UIColor ( hex : 0x6366F1 ) , false ) ,
51+ ]
52+
53+ for accent in accents {
54+ XCTAssertEqual (
55+ NavigationGlassButtonPlatformView . usesDarkFallbackSurface (
56+ foregroundColor : accent . color ,
57+ interfaceStyle : . light
58+ ) ,
59+ accent . usesDarkSurface ,
60+ accent . name
61+ )
62+ }
2963 XCTAssertTrue (
3064 NavigationGlassButtonPlatformView . usesDarkFallbackSurface (
3165 foregroundColor : . white ,
3266 interfaceStyle : . light
3367 )
3468 )
35- XCTAssertFalse (
36- NavigationGlassButtonPlatformView . usesDarkFallbackSurface (
37- foregroundColor : . white ,
38- interfaceStyle : . dark
39- )
40- )
41- XCTAssertFalse (
42- NavigationGlassButtonPlatformView . usesDarkFallbackSurface (
43- foregroundColor : . systemBlue ,
44- interfaceStyle : . light
69+ }
70+
71+ func testNavigationGlassFallbackKeepsSystemSurfaceInDarkMode ( ) {
72+ let darkAccents = [
73+ UIColor ( hex : 0xE1E4E8 ) ,
74+ UIColor ( hex : 0x60A5FA ) ,
75+ UIColor ( hex : 0x22D3EE ) ,
76+ UIColor ( hex : 0x4ADE80 ) ,
77+ UIColor ( hex : 0xFB923C ) ,
78+ UIColor ( hex : 0xF87171 ) ,
79+ UIColor ( hex : 0xF472B6 ) ,
80+ UIColor ( hex : 0xC0A2F1 ) ,
81+ UIColor ( hex : 0xC084FC ) ,
82+ UIColor ( hex : 0x818CF8 ) ,
83+ ]
84+
85+ for accent in darkAccents {
86+ XCTAssertFalse (
87+ NavigationGlassButtonPlatformView . usesDarkFallbackSurface (
88+ foregroundColor : accent ,
89+ interfaceStyle : . dark
90+ )
4591 )
46- )
92+ }
4793 }
4894
4995 func testRelativeTrackInsertionTimesPreserveAudioDelay ( ) {
0 commit comments