-
-
Notifications
You must be signed in to change notification settings - Fork 214
/
Copy pathHierarchyTests.swift
92 lines (84 loc) · 2.55 KB
/
HierarchyTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//
// HierarchyTests.swift
// Stevia
//
// Created by Naabed on 12/02/16.
// Copyright © 2016 Sacha Durand Saint Omer. All rights reserved.
//
import Testing
import UIKit
import Stevia
@Suite
@MainActor
struct HierarchyTests {
@Test
func subviews() {
let view = UIView()
let v1 = UIView()
let v2 = UIView()
view.subviews {
v1
v2
}
#expect(view.subviews.count == 2)
#expect(view.subviews.contains(v1))
#expect(view.subviews.contains(v2))
#expect(v1.translatesAutoresizingMaskIntoConstraints == false)
#expect(v2.translatesAutoresizingMaskIntoConstraints == false)
}
@Test
func tableViewCellSubviews() {
let cell = UITableViewCell()
let v1 = UIView()
let v2 = UIView()
cell.subviews {
v1
v2
}
#expect(cell.contentView.subviews.count == 2)
#expect(cell.contentView.subviews.contains(v1))
#expect(cell.contentView.subviews.contains(v2))
#expect(v1.translatesAutoresizingMaskIntoConstraints == false)
#expect(v2.translatesAutoresizingMaskIntoConstraints == false)
}
@Test
func testCollectionViewCellSubviews() {
let cell = UICollectionViewCell()
let v1 = UIView()
let v2 = UIView()
cell.subviews {
v1
v2
}
#expect(cell.contentView.subviews.count == 2)
#expect(cell.contentView.subviews.contains(v1))
#expect(cell.contentView.subviews.contains(v2))
#expect(v1.translatesAutoresizingMaskIntoConstraints == false)
#expect(v2.translatesAutoresizingMaskIntoConstraints == false)
}
@Test
func testSubviewsCanBeNested() {
let view = UIView()
let v1 = UIView()
let v2 = UIView()
let v3 = UIView()
let v4 = UIView()
view.subviews {
v1.subviews {
v3
v4
}
v2
}
#expect(view.subviews.count == 2)
#expect(view.subviews.contains(v1))
#expect(view.subviews.contains(v2))
#expect(v1.subviews.count == 2)
#expect(v1.subviews.contains(v3))
#expect(v1.subviews.contains(v4))
#expect(v1.translatesAutoresizingMaskIntoConstraints == false)
#expect(v2.translatesAutoresizingMaskIntoConstraints == false)
#expect(v3.translatesAutoresizingMaskIntoConstraints == false)
#expect(v4.translatesAutoresizingMaskIntoConstraints == false)
}
}