From be2f1644a2d7712bbfe987c497b20d406f92a518 Mon Sep 17 00:00:00 2001 From: Roman Podymov Date: Sun, 3 Mar 2024 13:34:10 +0100 Subject: [PATCH] isSecureTextEntry --- Sources/CommonAppleKit/CATextField.swift | 10 ++++++++++ Tests/CommonAppleKitTests/CommonAppleKitTests.swift | 11 +++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Sources/CommonAppleKit/CATextField.swift b/Sources/CommonAppleKit/CATextField.swift index a06663f..b213855 100644 --- a/Sources/CommonAppleKit/CATextField.swift +++ b/Sources/CommonAppleKit/CATextField.swift @@ -79,6 +79,16 @@ public class CATextField: CATextFieldBaseClass { public required init?(coder: NSCoder) { super.init(coder: coder) } + + public var isSecureTextEntry: Bool { + get { + true + } + + set { + + } + } } public extension CATextFieldBaseClass { diff --git a/Tests/CommonAppleKitTests/CommonAppleKitTests.swift b/Tests/CommonAppleKitTests/CommonAppleKitTests.swift index 698b88b..2f1ef6a 100644 --- a/Tests/CommonAppleKitTests/CommonAppleKitTests.swift +++ b/Tests/CommonAppleKitTests/CommonAppleKitTests.swift @@ -41,7 +41,9 @@ private final class ViewA: CAView { label.alignment = .center addSubview(label) addSubview(CATextField()) - addSubview(CASecureTextField()) + let secureTextField = CASecureTextField() + secureTextField.isSecureTextEntry = true + addSubview(secureTextField) #if canImport(AppKit) layer?.backgroundColor = CAColor.red.cgColor #elseif canImport(UIKit) @@ -109,7 +111,12 @@ final class CommonAppleKitTests: XCTestCase { return false }) XCTAssertTrue(view.subviews.contains { $0 is CATextField }) - XCTAssertTrue(view.subviews.contains { $0 is CASecureTextField }) + XCTAssertTrue(view.subviews.contains { + guard let secureTextField = $0 as? CASecureTextField else { + return false + } + return secureTextField.isSecureTextEntry + }) } func testCollectionView() {