Skip to content

Add support for devices with a notch and corresponding tests #444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Source/Device.generated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,17 @@ public enum Device {
return isOneOf(Device.allDevicesWithDynamicIsland) || isOneOf(Device.allDevicesWithDynamicIsland.map(Device.simulator))
}

/// All devices that have a notch.
public static var allDevicesWithNotch: [Device] {
return [.iPhoneX, .iPhoneXS, .iPhoneXSMax, .iPhoneXR, .iPhone11, .iPhone11Pro, .iPhone11ProMax, .iPhone12, .iPhone12Mini, .iPhone12Pro, .iPhone12ProMax, .iPhone13, .iPhone13Mini, .iPhone13Pro, .iPhone13ProMax, .iPhone14, .iPhone14Plus
]
}

/// Returns whether or not the device has a notch.
public var hasNotch: Bool {
return isOneOf(allDevicesWithNotch) || isOneOf(allDevicesWithNotch.map(Device.simulator))
}

/// All devices that have 3D Touch support.
public static var allDevicesWith3dTouchSupport: [Device] {
return [.iPhone6s, .iPhone6sPlus, .iPhone7, .iPhone7Plus, .iPhone8, .iPhone8Plus, .iPhoneX, .iPhoneXS, .iPhoneXSMax]
Expand Down
25 changes: 25 additions & 0 deletions Tests/Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,31 @@ class DeviceKitTests: XCTestCase {
}
}

func testHasNotch() {
let notchDevices: [Device] = [
.iPhoneX,
.iPhoneXS,
.iPhoneXSMax,
.iPhoneXR,
.iPhone11,
.iPhone11Pro,
.iPhone11ProMax,
.iPhone12,
.iPhone12Mini,
.iPhone12Pro,
.iPhone12ProMax,
.iPhone13,
.iPhone13Mini,
.iPhone13Pro,
.iPhone13ProMax,
.iPhone14,
.iPhone14Plus
]
for device in Device.allRealDevices {
XCTAssertTrue(device.hasNotch == device.isOneOf(notchDevices), "testHasNotch failed for \(device.description)")
}
}

func testHas5gSupport() {
let has5gDevices: [Device] = [
.iPhone12,
Expand Down