From 42180fb1363c2311242f02038eddbbd0a2e32f7d Mon Sep 17 00:00:00 2001 From: Vincent Neo <23420208+vincentneo@users.noreply.github.com> Date: Tue, 26 Mar 2019 15:06:16 +0800 Subject: [PATCH 1/2] Add new iPads Added iPad Mini 5 and iPad Air 3 --- Sources/DeviceModel.swift | 7 +++++-- Sources/Identifier.swift | 8 ++++++++ Tests/DeviceModelTests.swift | 13 +++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Sources/DeviceModel.swift b/Sources/DeviceModel.swift index beeee8e..37e229d 100644 --- a/Sources/DeviceModel.swift +++ b/Sources/DeviceModel.swift @@ -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 @@ -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 @@ -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 diff --git a/Sources/Identifier.swift b/Sources/Identifier.swift index fc6bcab..81f4097 100644 --- a/Sources/Identifier.swift +++ b/Sources/Identifier.swift @@ -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" } diff --git a/Tests/DeviceModelTests.swift b/Tests/DeviceModelTests.swift index 68d54d2..0553be2 100644 --- a/Tests/DeviceModelTests.swift +++ b/Tests/DeviceModelTests.swift @@ -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")) @@ -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() { From f5179868dcd374b310002b54784d857ed2d45759 Mon Sep 17 00:00:00 2001 From: Vincent Neo <23420208+vincentneo@users.noreply.github.com> Date: Tue, 26 Mar 2019 15:15:31 +0800 Subject: [PATCH 2/2] add identifer tests --- Tests/IdentifierTests.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Tests/IdentifierTests.swift b/Tests/IdentifierTests.swift index db0415a..121242b 100644 --- a/Tests/IdentifierTests.swift +++ b/Tests/IdentifierTests.swift @@ -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") }