Skip to content

Commit

Permalink
Merge pull request #34 from Nirma/newiPads
Browse files Browse the repository at this point in the history
Add new iPads!
  • Loading branch information
Nirma authored Mar 27, 2019
2 parents 135fa30 + f517986 commit b70d17e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Sources/DeviceModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public enum DeviceModel {

case iPadFirstGen, iPadSecondGen, iPadThirdGen, iPadFourthGen, iPadFifthGen, iPadSixthGen

case iPadAir, iPadAir2
case iPadAir, iPadAir2, iPadAir3

case iPadMini, iPadMini2, iPadMini3, iPadMini4
case iPadMini, iPadMini2, iPadMini3, iPadMini4, iPadMini5

case iPadPro9_7Inch, iPadPro10_5Inch, iPadPro11Inch, iPadPro12_9Inch, iPadPro12_9Inch_SecondGen, iPadPro12_9Inch_ThirdGen

Expand Down Expand Up @@ -120,10 +120,12 @@ extension DeviceModel {
case (7, 5), (7, 6): return .iPadSixthGen
case (4, 1), (4, 2), (4, 3): return .iPadAir
case (5, 3), (5, 4): return .iPadAir2
case (11, 3), (11, 4): return .iPadAir3
case (2, 5), (2, 6), (2, 7): return .iPadMini
case (4, 4), (4, 5), (4, 6): return .iPadMini2
case (4, 7), (4, 8), (4, 9): return .iPadMini3
case (5, 1), (5, 2): return .iPadMini4
case (11, 1), (11, 2): return .iPadMini5
case (6, 3), (6, 4): return .iPadPro9_7Inch
case (7, 3), (7, 4): return .iPadPro10_5Inch
case (8, 1), (8, 2), (8, 3), (8, 4): return .iPadPro11Inch
Expand Down Expand Up @@ -187,6 +189,7 @@ extension DeviceModel {
case "iPad (6th generation)": return .iPadSixthGen
case "iPad Air": return .iPadAir
case "iPad Air 2": return .iPadAir2
case "iPad Air 3": return .iPadAir3
case "iPad Pro (9.7-inch)": return .iPadPro9_7Inch
case "iPad Pro (10.5-inch)": return .iPadPro10_5Inch
case "iPad Pro (11-inch)": return .iPadPro11Inch
Expand Down
8 changes: 8 additions & 0 deletions Sources/Identifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,14 @@ extension Identifier: CustomStringConvertible {
return "3rd Gen iPad Pro (12.9 inch, Wi-Fi+LTE)"
case (8, 8):
return "3rd Gen iPad Pro (12.9 inch, Wi-Fi+LTE, 1TB)"
case (11, 1):
return "5th Gen iPad Mini (Wi-Fi)"
case (11, 2):
return "5th Gen iPad Mini (Wi-Fi+LTE)"
case (11, 3):
return "3rd Gen iPad Air (Wi-Fi)"
case (11, 4):
return "3rd Gen iPad Air (Wi-Fi+LTE)"
default:
return "unknown"
}
Expand Down
13 changes: 13 additions & 0 deletions Tests/DeviceModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ class DeviceModelTests: XCTestCase {
let deviceModel2 = DeviceModel(identifier: Identifier("iPad7,2"))
XCTAssert(deviceModel1 == .iPadPro12_9Inch_SecondGen && deviceModel2 == .iPadPro12_9Inch_SecondGen , "DeviceModel - .iPadPro12_9Inch_SecondGen is failing")
}

func testDeviceModelIPadPro12_9Inch_ThirdGen() {
let deviceModel1 = DeviceModel(identifier: Identifier("iPad8,5"))
let deviceModel2 = DeviceModel(identifier: Identifier("iPad8,6"))
Expand All @@ -255,6 +256,18 @@ class DeviceModelTests: XCTestCase {
XCTAssert(deviceModel1 == .iPadPro12_9Inch_ThirdGen && deviceModel2 == .iPadPro12_9Inch_ThirdGen && deviceModel3 == .iPadPro12_9Inch_ThirdGen && deviceModel4 == .iPadPro12_9Inch_ThirdGen, "DeviceModel - .iPadPro12_9Inch_ThirdGen is failing")
}

func testDeviceModelIPadMini5() {
let deviceModel1 = DeviceModel(identifier: Identifier("iPad11,1"))
let deviceModel2 = DeviceModel(identifier: Identifier("iPad11,2"))
XCTAssert(deviceModel1 == .iPadMini5 && deviceModel2 == .iPadMini5 , "DeviceModel - .iPadMini5 is failing")
}

func testDeviceModelIPadAir3() {
let deviceModel1 = DeviceModel(identifier: Identifier("iPad11,3"))
let deviceModel2 = DeviceModel(identifier: Identifier("iPad11,4"))
XCTAssert(deviceModel1 == .iPadAir3 && deviceModel2 == .iPadAir3 , "DeviceModel - .iPadAir3 is failing")
}

// MARK: - iPod Device Model tests

func testDeviceModelIPodTouchFirstGen() {
Expand Down
17 changes: 17 additions & 0 deletions Tests/IdentifierTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,23 @@ class IdentifierTests: XCTestCase {


// MARK: - iPad

func testDisplayStringiPad11v4() {
XCTAssert(Identifier("iPad11,4").description == "3rd Gen iPad Air (Wi-Fi+LTE)", "iPad11,4 is failing to produce a common device model string")
}

func testDisplayStringiPad11v3() {
XCTAssert(Identifier("iPad11,3").description == "3rd Gen iPad Air (Wi-Fi)", "iPad11,3 is failing to produce a common device model string")
}

func testDisplayStringiPad11v2() {
XCTAssert(Identifier("iPad11,2").description == "5th Gen iPad Mini (Wi-Fi+LTE)", "iPad11,2 is failing to produce a common device model string")
}

func testDisplayStringiPad11v1() {
XCTAssert(Identifier("iPad11,1").description == "5th Gen iPad Mini (Wi-Fi)", "iPad11,1 is failing to produce a common device model string")
}

func testDisplayStringiPad8v8() {
XCTAssert(Identifier("iPad8,8").description == "3rd Gen iPad Pro (12.9 inch, Wi-Fi+LTE, 1TB)", "iPad8,8 is failing to produce a common device model string")
}
Expand Down

0 comments on commit b70d17e

Please sign in to comment.