From bb896cad457ac41388b77f268ca2e993af13f32b Mon Sep 17 00:00:00 2001 From: Roman Podymov Date: Fri, 27 Oct 2023 16:30:57 +0200 Subject: [PATCH] testView --- .../CommonAppleKitTests.swift | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Tests/CommonAppleKitTests/CommonAppleKitTests.swift b/Tests/CommonAppleKitTests/CommonAppleKitTests.swift index 3f9cc72..b97521c 100644 --- a/Tests/CommonAppleKitTests/CommonAppleKitTests.swift +++ b/Tests/CommonAppleKitTests/CommonAppleKitTests.swift @@ -15,6 +15,24 @@ private final class ControllerB: CAViewController { } private final class CellA: CAListViewCell { } +private final class ViewA: CAView { + override init(frame: CARect) { + super.init(frame: frame) + + addSubview(CALabel()) + addSubview(CATextField()) + #if canImport(AppKit) + layer?.backgroundColor = CAColor.red.cgColor + #elseif canImport(UIKit) + backgroundColor = CAColor.red + #endif + } + + required init?(coder: NSCoder) { + nil + } +} + final class CommonAppleKitTests: XCTestCase { func testButton() { let button = CAButton() @@ -38,6 +56,13 @@ final class CommonAppleKitTests: XCTestCase { XCTAssertEqual(viewControllers, tabBarController.viewControllers) } + func testView() { + let view = ViewA(frame: .zero) + + XCTAssertTrue(view.subviews.contains { $0 is CALabel }) + XCTAssertTrue(view.subviews.contains { $0 is CATextField }) + } + func testCollectionView() { let layout: CACollectionViewLayout = CACollectionViewFlowLayout() let collectionView = CACollectionView(frame: .zero, collectionViewLayout: layout)