@onekeyfe/react-native-native-list 6.7.0-alpha.475 → 6.8.0-10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +312 -379
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +15 -6
- package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +3 -87
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaPlaceholderView.kt +244 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaTileRenderer.kt +32 -11
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +60 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +3 -6
- package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +5 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +75 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +25 -19
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListDescriptionTouchPolicyTest.kt +153 -0
- package/docs/ROW_TEMPLATES.md +12 -12
- package/docs/SPEC.md +226 -110
- package/docs/STYLE_SPEC.md +7 -0
- package/ios/NativeListActivityDetailsView.swift +13 -5
- package/ios/NativeListIdentityRenderer.swift +6 -94
- package/ios/NativeListMediaPlaceholderView.swift +189 -0
- package/ios/NativeListMediaTileRenderer.swift +13 -13
- package/ios/NativeListResolvedText.swift +15 -4
- package/ios/NativeListTextLabel.swift +106 -0
- package/ios/RNCNativeListView.swift +129 -32
- package/ios/tests/NativeListActivityPresentationTests.swift +270 -0
- package/ios/tests/NativeListIdentityTitleIconLayoutTests.swift +0 -95
- package/ios/tests/NativeListLifecycleTests.swift +369 -40
- package/ios/tests/NativeListMediaVisibilityTests.swift +16 -7
- package/lib/module/NativeList.js +17 -4
- package/lib/module/NativeList.web.js +3 -1
- package/lib/module/models.js +0 -2
- package/lib/module/validation.js +54 -71
- package/lib/module/web/NativeListGeneratedIcons.js +1 -0
- package/lib/module/web/NativeListWebEngine.js +13 -11
- package/lib/module/web/templates/ActivityRowRenderer.js +29 -23
- package/lib/module/web/templates/DataRowRenderer.js +54 -1
- package/lib/module/web/templates/IdentityRowRenderer.js +3 -92
- package/lib/module/web/templates/MediaTileRowRenderer.js +84 -15
- package/lib/typescript/src/models.d.ts +19 -22
- package/package.json +1 -1
- package/scripts/generate-icons.test.mjs +1 -0
- package/scripts/native-list-icons.json +1 -1
- package/src/NativeList.tsx +25 -4
- package/src/NativeList.web.tsx +1 -1
- package/src/models.ts +18 -23
- package/src/validation.ts +89 -113
- package/src/web/NativeListGeneratedIcons.ts +1 -0
- package/src/web/NativeListWebEngine.ts +16 -11
- package/src/web/templates/ActivityRowRenderer.ts +42 -32
- package/src/web/templates/DataRowRenderer.ts +76 -1
- package/src/web/templates/IdentityRowRenderer.ts +3 -141
- package/src/web/templates/MediaTileRowRenderer.ts +90 -15
- package/android/src/main/java/com/onekey/nativelist/NativeListTitleSegmentLayout.kt +0 -49
- package/android/src/main/java/com/onekey/nativelist/NativeListTitleSegmentsView.kt +0 -105
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListTitleSegmentLayoutTest.kt +0 -80
- package/ios/NativeListTitleSegmentLayout.swift +0 -45
- package/ios/NativeListTitleSegmentsLabel.swift +0 -80
|
@@ -78,99 +78,4 @@ final class NativeListIdentityTitleIconLayoutTests: XCTestCase {
|
|
|
78
78
|
XCTAssertGreaterThan(badgeFrame.minX, iconFrame.maxX)
|
|
79
79
|
XCTAssertLessThanOrEqual(badgeFrame.maxX, cell.bounds.width)
|
|
80
80
|
}
|
|
81
|
-
|
|
82
|
-
// An address book row: a plain title after the 16pt `titleLeadingIcon`. A
|
|
83
|
-
// long name truncates after the glyph instead of squeezing it to nothing.
|
|
84
|
-
func testLongPlainTitleTruncatesAfterTheLeadingIcon() throws {
|
|
85
|
-
let cell = NativeListIdentityCell(frame: CGRect(x: 0, y: 0, width: 320, height: 60))
|
|
86
|
-
let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 320, height: 200))
|
|
87
|
-
window.addSubview(cell)
|
|
88
|
-
let leadingIcon = try child(cell, "titleLeadingIconView", as: UIImageView.self)
|
|
89
|
-
let titleLabel = try child(cell, "titleLabel", as: UILabel.self)
|
|
90
|
-
let item = try NativeListItem(data: [
|
|
91
|
-
"key": "book", "type": "identity",
|
|
92
|
-
"title": "A very long address book name that cannot possibly fit on one line",
|
|
93
|
-
"height": 60,
|
|
94
|
-
"leading": ["kind": "token", "fallbackIcon": ["name": "CryptoCoinOutline"]],
|
|
95
|
-
"titleLeadingIcon": ["name": "BookOpenOutline"],
|
|
96
|
-
"subtitle": "0x1234...abcd",
|
|
97
|
-
])
|
|
98
|
-
cell.bind(item: item, theme: nil, layout: "linear", selected: false,
|
|
99
|
-
checkboxState: { _, _, fallback in fallback }, fonts: NativeListFontFamilies())
|
|
100
|
-
cell.layoutIfNeeded()
|
|
101
|
-
|
|
102
|
-
let iconFrame = leadingIcon.convert(leadingIcon.bounds, to: cell)
|
|
103
|
-
let labelFrame = titleLabel.convert(titleLabel.bounds, to: cell)
|
|
104
|
-
XCTAssertFalse(leadingIcon.isHidden)
|
|
105
|
-
XCTAssertEqual(leadingIcon.bounds.width, 16, accuracy: 0.5,
|
|
106
|
-
"the leading glyph keeps its 16pt width")
|
|
107
|
-
XCTAssertEqual(labelFrame.minX, iconFrame.maxX + 6, accuracy: 1,
|
|
108
|
-
"the title follows the glyph with the 6pt gap")
|
|
109
|
-
XCTAssertLessThan(titleLabel.bounds.width, titleLabel.intrinsicContentSize.width,
|
|
110
|
-
"the title truncates instead of the glyph")
|
|
111
|
-
XCTAssertLessThanOrEqual(labelFrame.maxX, cell.bounds.width)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// A wallet sidebar row keeps the plain title even when a production row
|
|
115
|
-
// carries runs and a leading glyph, also after the cell drew both for a
|
|
116
|
-
// recipient row.
|
|
117
|
-
func testWalletSidebarRowIgnoresTitleRunsAndLeadingIcon() throws {
|
|
118
|
-
let cell = NativeListIdentityCell(frame: CGRect(x: 0, y: 0, width: 320, height: 68))
|
|
119
|
-
let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 320, height: 200))
|
|
120
|
-
window.addSubview(cell)
|
|
121
|
-
let titleLabel = try child(cell, "titleLabel", as: UILabel.self)
|
|
122
|
-
let runs = try child(cell, "titleSegmentsLabel", as: UIView.self)
|
|
123
|
-
let leadingIcon = try child(cell, "titleLeadingIconView", as: UIImageView.self)
|
|
124
|
-
let decorations: [String: Any] = [
|
|
125
|
-
"titleSegments": [
|
|
126
|
-
["text": "Main", "shrink": true],
|
|
127
|
-
["text": " / ", "tone": "secondary"],
|
|
128
|
-
["text": "Account 1"],
|
|
129
|
-
],
|
|
130
|
-
"titleLeadingIcon": ["name": "BookOpenOutline"],
|
|
131
|
-
]
|
|
132
|
-
func bind(_ data: [String: Any]) throws {
|
|
133
|
-
var row: [String: Any] = [
|
|
134
|
-
"key": "wallet", "type": "identity", "title": "Main / Account 1", "height": 68,
|
|
135
|
-
]
|
|
136
|
-
data.forEach { row[$0.key] = $0.value }
|
|
137
|
-
cell.bind(item: try NativeListItem(data: row), theme: nil, layout: "linear",
|
|
138
|
-
selected: false, checkboxState: { _, _, fallback in fallback },
|
|
139
|
-
fonts: NativeListFontFamilies())
|
|
140
|
-
cell.layoutIfNeeded()
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
try bind(decorations)
|
|
144
|
-
XCTAssertFalse(runs.isHidden)
|
|
145
|
-
XCTAssertFalse(leadingIcon.isHidden)
|
|
146
|
-
|
|
147
|
-
try bind(decorations.merging(["presentation": "walletSidebar"]) { $1 })
|
|
148
|
-
XCTAssertTrue(runs.isHidden, "wallet sidebar rows draw no runs")
|
|
149
|
-
XCTAssertTrue(leadingIcon.isHidden, "wallet sidebar rows draw no leading glyph")
|
|
150
|
-
XCTAssertFalse(titleLabel.isHidden)
|
|
151
|
-
XCTAssertEqual(titleLabel.text, "Main / Account 1")
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// `titleMatch` keeps the plain highlighted title on screen, so an
|
|
155
|
-
// auto-height row is measured for that title and its `titleLines`, not for
|
|
156
|
-
// one line of runs.
|
|
157
|
-
func testHighlightedTitleIsMeasuredWithItsOwnLines() throws {
|
|
158
|
-
func height(_ data: [String: Any]) throws -> CGFloat {
|
|
159
|
-
var row: [String: Any] = [
|
|
160
|
-
"key": "match", "type": "identity", "contentHeight": "auto",
|
|
161
|
-
"title": "A very long recipient name that needs a second line to show",
|
|
162
|
-
"titleLines": 2, "titleMatch": [["start": 0, "end": 6]],
|
|
163
|
-
"subtitle": "0x1234...abcd",
|
|
164
|
-
]
|
|
165
|
-
data.forEach { row[$0.key] = $0.value }
|
|
166
|
-
return try XCTUnwrap(NativeListIdentityCell.measure(
|
|
167
|
-
try NativeListItem(data: row), width: 240, theme: nil, layout: "linear",
|
|
168
|
-
fonts: NativeListFontFamilies()))
|
|
169
|
-
}
|
|
170
|
-
let runs: [[String: Any]] = [["text": "A very long", "shrink": true], ["text": " recipient"]]
|
|
171
|
-
|
|
172
|
-
let plain = try height([:])
|
|
173
|
-
XCTAssertEqual(try height(["titleSegments": runs]), plain, accuracy: 0.5)
|
|
174
|
-
XCTAssertGreaterThan(plain, try height(["titleLines": 1]))
|
|
175
|
-
}
|
|
176
81
|
}
|
|
@@ -1,9 +1,97 @@
|
|
|
1
|
+
import ObjectiveC
|
|
1
2
|
import UIKit
|
|
2
3
|
import XCTest
|
|
3
4
|
@testable import NativeListModule
|
|
4
5
|
|
|
5
6
|
@MainActor
|
|
6
7
|
final class NativeListLifecycleTests: XCTestCase {
|
|
8
|
+
func testFilteredSnapshotSuppliesCellsDuringOutgoingUIKitLayout() throws {
|
|
9
|
+
let view = NativeListView(frame: CGRect(x: 0, y: 0, width: 390, height: 697))
|
|
10
|
+
let window = UIWindow(frame: view.frame)
|
|
11
|
+
let controller = UIViewController()
|
|
12
|
+
window.rootViewController = controller
|
|
13
|
+
window.makeKeyAndVisible()
|
|
14
|
+
controller.view.addSubview(view)
|
|
15
|
+
defer {
|
|
16
|
+
view.dispose()
|
|
17
|
+
window.isHidden = true
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let collection = try XCTUnwrap(view.subviews.compactMap { $0 as? UICollectionView }.first)
|
|
21
|
+
let dataSource = try XCTUnwrap(collection.dataSource as? UICollectionViewDiffableDataSource<Int, String>)
|
|
22
|
+
collection.isPrefetchingEnabled = false
|
|
23
|
+
collection.contentInsetAdjustmentBehavior = .never
|
|
24
|
+
collection.contentInset = UIEdgeInsets(top: 190, left: 0, bottom: 449, right: 0)
|
|
25
|
+
func snapshot(_ indices: Range<Int>) throws -> String {
|
|
26
|
+
let rows: [[String: Any]] = indices.map { index in
|
|
27
|
+
["key": "account-\(index)", "type": "identity", "title": "Account \(index)",
|
|
28
|
+
"testID": "recipient-\(index)", "height": 64,
|
|
29
|
+
"leading": ["kind": "icon", "name": "Circle"]]
|
|
30
|
+
}
|
|
31
|
+
let value: [String: Any] = ["schemaVersion": 1, "generation": 1,
|
|
32
|
+
"layout": ["kind": "linear"], "rows": rows]
|
|
33
|
+
return String(decoding: try JSONSerialization.data(withJSONObject: value), as: UTF8.self)
|
|
34
|
+
}
|
|
35
|
+
view.applySnapshotJson(try snapshot(0..<18))
|
|
36
|
+
view.layoutIfNeeded()
|
|
37
|
+
let initialOffset = CGPoint(x: 0, y: -190)
|
|
38
|
+
collection.contentOffset = initialOffset
|
|
39
|
+
collection.layoutIfNeeded()
|
|
40
|
+
XCTAssertEqual(dataSource.snapshot().numberOfItems, 18)
|
|
41
|
+
let outgoingIndexPath = IndexPath(item: 8, section: 0)
|
|
42
|
+
let outgoingFrame = try XCTUnwrap(collection.layoutAttributesForItem(at: outgoingIndexPath)).frame
|
|
43
|
+
XCTAssertFalse(collection.bounds.intersects(outgoingFrame))
|
|
44
|
+
XCTAssertNil(collection.cellForItem(at: outgoingIndexPath))
|
|
45
|
+
|
|
46
|
+
// Force a real UIKit layout at the invalidation inside applySnapshotJson,
|
|
47
|
+
// while UIKit still owns the old snapshot. Scope the hook to this layout.
|
|
48
|
+
let layout = collection.collectionViewLayout
|
|
49
|
+
let layoutClass: AnyClass = type(of: layout)
|
|
50
|
+
let selector = NSSelectorFromString("invalidateLayout")
|
|
51
|
+
let method = try XCTUnwrap(class_getInstanceMethod(layoutClass, selector))
|
|
52
|
+
let encoding = try XCTUnwrap(method_getTypeEncoding(method))
|
|
53
|
+
let original = method_getImplementation(method)
|
|
54
|
+
let callOriginal = unsafeBitCast(original, to: (@convention(c) (AnyObject, Selector) -> Void).self)
|
|
55
|
+
var didLayoutOutgoingSnapshot = false
|
|
56
|
+
let invalidate: @convention(block) (UICollectionViewLayout) -> Void = { current in
|
|
57
|
+
callOriginal(current, selector)
|
|
58
|
+
guard current === layout, !didLayoutOutgoingSnapshot,
|
|
59
|
+
dataSource.snapshot().numberOfItems == 18 else { return }
|
|
60
|
+
didLayoutOutgoingSnapshot = true
|
|
61
|
+
let size = view.collectionView(collection, layout: current, sizeForItemAt: outgoingIndexPath)
|
|
62
|
+
XCTAssertEqual(size.height, 64, "UIKit still needs the outgoing row’s geometry")
|
|
63
|
+
XCTAssertNil(collection.cellForItem(at: outgoingIndexPath))
|
|
64
|
+
collection.contentOffset.y = outgoingFrame.midY - collection.bounds.height / 2
|
|
65
|
+
collection.setNeedsLayout()
|
|
66
|
+
collection.layoutIfNeeded()
|
|
67
|
+
XCTAssertTrue(collection.bounds.intersects(outgoingFrame))
|
|
68
|
+
guard let outgoingCell = collection.cellForItem(at: outgoingIndexPath) else {
|
|
69
|
+
XCTFail("UIKit must request the previously offscreen outgoing cell")
|
|
70
|
+
return
|
|
71
|
+
}
|
|
72
|
+
XCTAssertEqual(outgoingCell.reuseIdentifier,
|
|
73
|
+
NativeListRendererRegistry.reuseIdentifier(for: .identity))
|
|
74
|
+
XCTAssertFalse(outgoingCell.isUserInteractionEnabled)
|
|
75
|
+
XCTAssertTrue(outgoingCell.accessibilityElementsHidden)
|
|
76
|
+
XCTAssertFalse(view.collectionView(collection, shouldSelectItemAt: outgoingIndexPath))
|
|
77
|
+
}
|
|
78
|
+
let replacement = imp_implementationWithBlock(invalidate)
|
|
79
|
+
class_replaceMethod(layoutClass, selector, replacement, encoding)
|
|
80
|
+
defer {
|
|
81
|
+
class_replaceMethod(layoutClass, selector, original, encoding)
|
|
82
|
+
imp_removeBlock(replacement)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
view.applySnapshotJson(try snapshot(12..<15))
|
|
86
|
+
collection.contentOffset = initialOffset
|
|
87
|
+
collection.layoutIfNeeded()
|
|
88
|
+
XCTAssertTrue(didLayoutOutgoingSnapshot)
|
|
89
|
+
XCTAssertEqual(dataSource.snapshot().itemIdentifiers, ["account-12", "account-13", "account-14"])
|
|
90
|
+
let first = try XCTUnwrap(collection.cellForItem(at: IndexPath(item: 0, section: 0)))
|
|
91
|
+
XCTAssertFalse(first.isHidden)
|
|
92
|
+
XCTAssertEqual(first.accessibilityIdentifier, "recipient-12")
|
|
93
|
+
}
|
|
94
|
+
|
|
7
95
|
func testCanonicalNullPatchRemovesStoredOptionalFields() throws {
|
|
8
96
|
let view = NativeListView(frame: CGRect(x: 0, y: 0, width: 320, height: 480))
|
|
9
97
|
let row: [String: Any] = ["key": "token", "type": "identity", "title": "Token",
|
|
@@ -135,11 +223,17 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
135
223
|
window.rootViewController = controller
|
|
136
224
|
controller.view.addSubview(view)
|
|
137
225
|
window.isHidden = false
|
|
138
|
-
defer { window.isHidden = true }
|
|
139
226
|
window.layoutIfNeeded()
|
|
140
227
|
view.layoutIfNeeded()
|
|
141
228
|
drainMainQueue()
|
|
142
229
|
let list = try XCTUnwrap(view.subviews.compactMap { $0 as? UICollectionView }.first)
|
|
230
|
+
defer {
|
|
231
|
+
list.setContentOffset(list.contentOffset, animated: false)
|
|
232
|
+
view.dispose()
|
|
233
|
+
view.removeFromSuperview()
|
|
234
|
+
window.isHidden = true
|
|
235
|
+
window.rootViewController = nil
|
|
236
|
+
}
|
|
143
237
|
XCTAssertNotNil(view.window)
|
|
144
238
|
XCTAssertGreaterThan(list.contentSize.height - list.bounds.height +
|
|
145
239
|
list.adjustedContentInset.top + list.adjustedContentInset.bottom, 800)
|
|
@@ -1047,6 +1141,68 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
1047
1141
|
XCTAssertTrue(second.isHidden)
|
|
1048
1142
|
}
|
|
1049
1143
|
|
|
1144
|
+
func testFixedFooterSharesRetiringRowKeyDuringStructuralTransition() throws {
|
|
1145
|
+
try requireStructuralAnimation()
|
|
1146
|
+
let footerData: [String: Any] = [
|
|
1147
|
+
"key": "a", "type": "action", "title": "Continue", "actionKey": "continue",
|
|
1148
|
+
]
|
|
1149
|
+
func snapshot(_ keys: [String], animate: Bool) throws -> String {
|
|
1150
|
+
let rows: [[String: Any]] = keys.map {
|
|
1151
|
+
["key": $0, "type": "action", "title": $0, "actionKey": "row-\($0)"]
|
|
1152
|
+
}
|
|
1153
|
+
var value: [String: Any] = ["schemaVersion": 1, "generation": animate ? 2 : 1,
|
|
1154
|
+
"layout": ["kind": "linear"], "rows": rows, "fixedFooter": footerData]
|
|
1155
|
+
if animate { value["structuralTransition"] = ["id": "remove-a", "durationMs": 800] }
|
|
1156
|
+
return String(decoding: try JSONSerialization.data(withJSONObject: value), as: UTF8.self)
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 320, height: 480))
|
|
1160
|
+
let controller = UIViewController()
|
|
1161
|
+
window.rootViewController = controller
|
|
1162
|
+
let view = NativeListView(frame: window.bounds)
|
|
1163
|
+
controller.view.addSubview(view)
|
|
1164
|
+
window.isHidden = false
|
|
1165
|
+
defer {
|
|
1166
|
+
view.dispose()
|
|
1167
|
+
window.isHidden = true
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
let collection = try XCTUnwrap(view.subviews.compactMap { $0 as? UICollectionView }.first)
|
|
1171
|
+
let dataSource = try XCTUnwrap(collection.dataSource as? UICollectionViewDiffableDataSource<Int, String>)
|
|
1172
|
+
var actions: [String] = []
|
|
1173
|
+
view.onRowAction = { payload in
|
|
1174
|
+
if let action = (try? JSONSerialization.jsonObject(with: Data(payload.utf8))) as? [String: Any],
|
|
1175
|
+
let key = action["actionKey"] as? String { actions.append(key) }
|
|
1176
|
+
}
|
|
1177
|
+
view.applySnapshotJson(try snapshot(["a", "b", "c"], animate: false))
|
|
1178
|
+
view.layoutIfNeeded()
|
|
1179
|
+
collection.layoutIfNeeded()
|
|
1180
|
+
let outgoingIndex = IndexPath(item: 0, section: 0)
|
|
1181
|
+
let outgoing = try XCTUnwrap(collection.cellForItem(at: outgoingIndex) as? NativeListRowHost)
|
|
1182
|
+
let outgoingAction = try XCTUnwrap(outgoing.onAction)
|
|
1183
|
+
|
|
1184
|
+
view.applySnapshotJson(try snapshot(["b", "c"], animate: true))
|
|
1185
|
+
XCTAssertEqual(dataSource.itemIdentifier(for: outgoingIndex), "a")
|
|
1186
|
+
XCTAssertFalse(view.collectionView(collection, shouldSelectItemAt: outgoingIndex))
|
|
1187
|
+
view.collectionView(collection, didSelectItemAt: outgoingIndex)
|
|
1188
|
+
// Child renderers can emit a different key than the enclosing collection row.
|
|
1189
|
+
let child = try NativeListItem(data: ["key": "child", "type": "action", "title": "Child"])
|
|
1190
|
+
outgoingAction(child, "child-press", nil, outgoing.rowActionOrigin())
|
|
1191
|
+
XCTAssertTrue(actions.isEmpty)
|
|
1192
|
+
|
|
1193
|
+
let footer = try XCTUnwrap(footerCell(in: view))
|
|
1194
|
+
XCTAssertEqual(footer.accessibilityLabel, "Continue")
|
|
1195
|
+
XCTAssertEqual(footer.alpha, 1)
|
|
1196
|
+
XCTAssertTrue(footer.isUserInteractionEnabled)
|
|
1197
|
+
XCTAssertFalse(footer.accessibilityElementsHidden)
|
|
1198
|
+
// Dispatch the gesture's target directly in this hostless XCTest.
|
|
1199
|
+
let footerPress = NSSelectorFromString("footerPressed")
|
|
1200
|
+
XCTAssertTrue(view.responds(to: footerPress))
|
|
1201
|
+
_ = view.perform(footerPress)
|
|
1202
|
+
footer.onAction?(try NativeListItem(data: footerData), "footer-accessory", nil, footer.rowActionOrigin())
|
|
1203
|
+
XCTAssertEqual(actions, ["continue", "footer-accessory"])
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1050
1206
|
func testFontResolversMeasureBindResetAndKeepIndependentInstances() throws {
|
|
1051
1207
|
let first = NativeListFontFamilies(names: ["regular": "Courier", "bold": "Courier-Bold"])
|
|
1052
1208
|
let second = NativeListFontFamilies(names: ["regular": "Georgia", "bold": "Georgia-Bold"])
|
|
@@ -1228,7 +1384,9 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
1228
1384
|
list.layoutIfNeeded()
|
|
1229
1385
|
let header = try XCTUnwrap(slots[0].superview)
|
|
1230
1386
|
XCTAssertTrue(header.clipsToBounds)
|
|
1231
|
-
XCTAssertEqual(header.bounds.height,
|
|
1387
|
+
XCTAssertEqual(header.bounds.height, 44, "The mounted Fabric header reserves its first-frame height")
|
|
1388
|
+
let firstRow = try XCTUnwrap(list.layoutAttributesForItem(at: IndexPath(item: 0, section: 0)))
|
|
1389
|
+
XCTAssertEqual(firstRow.frame.minY, 44, accuracy: 0.5)
|
|
1232
1390
|
|
|
1233
1391
|
view.setContainerSlotHeightsJson("[44,44,60,0]")
|
|
1234
1392
|
view.layoutIfNeeded()
|
|
@@ -1245,6 +1403,143 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
1245
1403
|
XCTAssertNil(slots[2].superview)
|
|
1246
1404
|
}
|
|
1247
1405
|
|
|
1406
|
+
func testPendingHeaderReservesMountedGeometryInEitherPropertyOrder() throws {
|
|
1407
|
+
for pendingBeforeMount in [true, false] {
|
|
1408
|
+
let view = NativeListView(frame: CGRect(x: 0, y: 0, width: 320, height: 708))
|
|
1409
|
+
view.applySnapshotJson(try scrollingSnapshot(count: 3))
|
|
1410
|
+
let header = UIView(frame: CGRect(x: 16, y: 0, width: 288, height: 44.2))
|
|
1411
|
+
if pendingBeforeMount { view.setContainerSlotHeightsJson("[null,0,0,0,0,0]") }
|
|
1412
|
+
view.mountContainerSlot(header, atIndex: 0)
|
|
1413
|
+
if !pendingBeforeMount { view.setContainerSlotHeightsJson("[null,0,0,0,0,0]") }
|
|
1414
|
+
view.layoutIfNeeded()
|
|
1415
|
+
let list = try XCTUnwrap(view.subviews.compactMap { $0 as? UICollectionView }.first)
|
|
1416
|
+
list.layoutIfNeeded()
|
|
1417
|
+
let host = try XCTUnwrap(header.superview)
|
|
1418
|
+
XCTAssertTrue(host.clipsToBounds)
|
|
1419
|
+
XCTAssertEqual(host.bounds.height, 45, accuracy: 0.5)
|
|
1420
|
+
let firstRow = try XCTUnwrap(list.layoutAttributesForItem(at: IndexPath(item: 0, section: 0)))
|
|
1421
|
+
XCTAssertEqual(firstRow.frame.minY, 45, accuracy: 0.5)
|
|
1422
|
+
|
|
1423
|
+
view.setContainerSlotHeightsJson("[null,0,18,0,0,0]")
|
|
1424
|
+
view.layoutIfNeeded()
|
|
1425
|
+
list.layoutIfNeeded()
|
|
1426
|
+
XCTAssertEqual(host.bounds.height, 45, accuracy: 0.5)
|
|
1427
|
+
XCTAssertEqual(list.layoutAttributesForItem(
|
|
1428
|
+
at: IndexPath(item: 0, section: 0))?.frame.minY, 45)
|
|
1429
|
+
|
|
1430
|
+
view.setContainerSlotHeightsJson("[18,0,0,0,0,0]")
|
|
1431
|
+
view.layoutIfNeeded()
|
|
1432
|
+
list.layoutIfNeeded()
|
|
1433
|
+
XCTAssertEqual(host.bounds.height, 18, accuracy: 0.5)
|
|
1434
|
+
XCTAssertEqual(list.collectionViewLayout.layoutAttributesForItem(
|
|
1435
|
+
at: IndexPath(item: 0, section: 0))?.frame.minY, 18)
|
|
1436
|
+
view.setContainerSlotHeightsJson("[0,0,0,0,0,0]")
|
|
1437
|
+
view.layoutIfNeeded()
|
|
1438
|
+
list.layoutIfNeeded()
|
|
1439
|
+
XCTAssertEqual(host.bounds.height, 0)
|
|
1440
|
+
XCTAssertEqual(list.collectionViewLayout.layoutAttributesForItem(
|
|
1441
|
+
at: IndexPath(item: 0, section: 0))?.frame.minY, 0)
|
|
1442
|
+
view.dispose()
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
func testNumericHeaderHeightIsAuthoritativeBeforeRootMounts() throws {
|
|
1447
|
+
for height in [0, 24] {
|
|
1448
|
+
let view = NativeListView(frame: CGRect(x: 0, y: 0, width: 320, height: 708))
|
|
1449
|
+
view.setContainerSlotHeightsJson("[\(height),0,0,0]")
|
|
1450
|
+
view.applySnapshotJson(try scrollingSnapshot(count: 3))
|
|
1451
|
+
let header = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 44))
|
|
1452
|
+
view.mountContainerSlot(header, atIndex: 0)
|
|
1453
|
+
view.layoutIfNeeded()
|
|
1454
|
+
let list = try XCTUnwrap(view.subviews.compactMap { $0 as? UICollectionView }.first)
|
|
1455
|
+
list.layoutIfNeeded()
|
|
1456
|
+
XCTAssertEqual(header.superview?.bounds.height, CGFloat(height))
|
|
1457
|
+
XCTAssertEqual(list.layoutAttributesForItem(
|
|
1458
|
+
at: IndexPath(item: 0, section: 0))?.frame.minY, CGFloat(height))
|
|
1459
|
+
view.dispose()
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
func testPendingHeaderDoesNotInheritAnUnmountedRootsHeight() throws {
|
|
1464
|
+
let view = NativeListView(frame: CGRect(x: 0, y: 0, width: 320, height: 708))
|
|
1465
|
+
view.applySnapshotJson(try scrollingSnapshot(count: 3))
|
|
1466
|
+
view.setContainerSlotHeightsJson("[null,0,0,0,0,0]")
|
|
1467
|
+
let first = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 44))
|
|
1468
|
+
view.mountContainerSlot(first, atIndex: 0)
|
|
1469
|
+
XCTAssertEqual(first.superview?.bounds.height, 44)
|
|
1470
|
+
view.unmountContainerSlot(first)
|
|
1471
|
+
let empty = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 0))
|
|
1472
|
+
view.mountContainerSlot(empty, atIndex: 0)
|
|
1473
|
+
XCTAssertEqual(empty.superview?.bounds.height, 0)
|
|
1474
|
+
view.unmountContainerSlot(empty)
|
|
1475
|
+
let replacement = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 27))
|
|
1476
|
+
view.mountContainerSlot(replacement, atIndex: 0)
|
|
1477
|
+
XCTAssertEqual(replacement.superview?.bounds.height, 27)
|
|
1478
|
+
view.setContainerSlotHeightsJson("[0,0,0,0,0,0]")
|
|
1479
|
+
view.unmountContainerSlot(replacement)
|
|
1480
|
+
let authoritativeZero = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 60))
|
|
1481
|
+
view.mountContainerSlot(authoritativeZero, atIndex: 0)
|
|
1482
|
+
XCTAssertEqual(authoritativeZero.superview?.bounds.height, 0)
|
|
1483
|
+
view.dispose()
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
func testPendingHeaderOnlyAcceptsNullAtTheHeaderSlot() throws {
|
|
1487
|
+
let view = NativeListView(frame: CGRect(x: 0, y: 0, width: 320, height: 708))
|
|
1488
|
+
view.setContainerSlotHeightsJson("[24,0,0,0,0,0]")
|
|
1489
|
+
let header = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 44))
|
|
1490
|
+
view.mountContainerSlot(header, atIndex: 0)
|
|
1491
|
+
for invalid in ["[null,null,0,0,0,0]", "[\"invalid\",0,0,0,0,0]",
|
|
1492
|
+
"[null,0,0,0,-1,0]", "[null,0,0,0,0,null]"] {
|
|
1493
|
+
view.setContainerSlotHeightsJson(invalid)
|
|
1494
|
+
XCTAssertEqual(header.superview?.bounds.height, 24)
|
|
1495
|
+
}
|
|
1496
|
+
view.dispose()
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
func testFirstUsableBoundsNotifiesPagerBeforeSlotLayout() throws {
|
|
1500
|
+
let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 390, height: 844))
|
|
1501
|
+
let root = UIViewController()
|
|
1502
|
+
window.rootViewController = root
|
|
1503
|
+
window.isHidden = false
|
|
1504
|
+
let view = NativeListView(frame: .zero)
|
|
1505
|
+
root.view.addSubview(view)
|
|
1506
|
+
defer {
|
|
1507
|
+
view.dispose()
|
|
1508
|
+
view.removeFromSuperview()
|
|
1509
|
+
window.rootViewController = nil
|
|
1510
|
+
window.isHidden = true
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
let header = UIView(frame: CGRect(x: 0, y: 0, width: 390, height: 65))
|
|
1514
|
+
view.mountContainerSlot(header, atIndex: 0)
|
|
1515
|
+
view.setContainerSlotHeightsJson("[65,0,0,0,0,0]")
|
|
1516
|
+
view.applySnapshotJson(try scrollingSnapshot(count: 6))
|
|
1517
|
+
|
|
1518
|
+
let list = try XCTUnwrap(view.subviews.compactMap { $0 as? UICollectionView }.first)
|
|
1519
|
+
let owner = NSObject()
|
|
1520
|
+
var readyCount = 0
|
|
1521
|
+
let observer = NotificationCenter.default.addObserver(
|
|
1522
|
+
forName: Notification.Name("OneKeyNativeScrollViewDidBecomeReady"),
|
|
1523
|
+
object: list,
|
|
1524
|
+
queue: nil
|
|
1525
|
+
) { _ in
|
|
1526
|
+
readyCount += 1
|
|
1527
|
+
view.setPagerStickyHeight(52, forOwner: owner)
|
|
1528
|
+
list.contentInset = UIEdgeInsets(top: 345, left: 0, bottom: 0, right: 0)
|
|
1529
|
+
list.setContentOffset(CGPoint(x: 0, y: -345), animated: false)
|
|
1530
|
+
}
|
|
1531
|
+
defer { NotificationCenter.default.removeObserver(observer) }
|
|
1532
|
+
|
|
1533
|
+
view.frame = CGRect(x: 0, y: 0, width: 390, height: 697)
|
|
1534
|
+
view.layoutIfNeeded()
|
|
1535
|
+
|
|
1536
|
+
let host = try XCTUnwrap(header.superview)
|
|
1537
|
+
XCTAssertEqual(readyCount, 1)
|
|
1538
|
+
XCTAssertEqual(list.contentInset.top, 345, accuracy: 0.01)
|
|
1539
|
+
XCTAssertEqual(list.contentOffset.y, -345, accuracy: 0.01)
|
|
1540
|
+
XCTAssertNil(host.layer.mask)
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1248
1543
|
func testSidecarCentersRowsWhenConfiguredBeforeFirstWidth() throws {
|
|
1249
1544
|
try assertHomeSidecarGeometry(sidecarBeforeFirstLayout: true)
|
|
1250
1545
|
}
|
|
@@ -1481,7 +1776,7 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
1481
1776
|
view.layoutIfNeeded()
|
|
1482
1777
|
list.layoutIfNeeded()
|
|
1483
1778
|
} completion: { _ in finished.fulfill() }
|
|
1484
|
-
wait(for: [finished], timeout:
|
|
1779
|
+
wait(for: [finished], timeout: 5)
|
|
1485
1780
|
try check(phase, count: count, width: 700)
|
|
1486
1781
|
waitForStructuralFrames(0.1)
|
|
1487
1782
|
try check("\(phase) stable", count: count, width: 700)
|
|
@@ -1538,9 +1833,12 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
1538
1833
|
XCTAssertEqual(list.contentOffset.y, testCase.offset, accuracy: 1, testCase.name)
|
|
1539
1834
|
|
|
1540
1835
|
view.applySnapshotJson(try structuralRowsSnapshot(count: 25, transitionID: testCase.name))
|
|
1541
|
-
let
|
|
1542
|
-
|
|
1543
|
-
|
|
1836
|
+
let settleDeadline = Date().addingTimeInterval(5)
|
|
1837
|
+
while Mirror(reflecting: view).descendant("structuralDisplayLink") as? CADisplayLink != nil,
|
|
1838
|
+
Date() < settleDeadline {
|
|
1839
|
+
RunLoop.main.run(until: Date().addingTimeInterval(0.01))
|
|
1840
|
+
}
|
|
1841
|
+
waitForStructuralFrames(0.05)
|
|
1544
1842
|
list.layoutIfNeeded()
|
|
1545
1843
|
XCTAssertEqual(list.adjustedContentInset, explicitInset, testCase.name)
|
|
1546
1844
|
XCTAssertEqual(list.contentSize.height, testCase.height, accuracy: 1, testCase.name)
|
|
@@ -1662,17 +1960,20 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
1662
1960
|
list.contentOffset.y = 900
|
|
1663
1961
|
list.layoutIfNeeded()
|
|
1664
1962
|
|
|
1963
|
+
let flow = try XCTUnwrap(list.collectionViewLayout as? NativeListFlowLayout)
|
|
1665
1964
|
view.applySnapshotJson(try structuralRowsSnapshot(count: 30, generation: 2,
|
|
1666
|
-
transitionID: "expand-first", durationMs:
|
|
1667
|
-
|
|
1965
|
+
transitionID: "expand-first", durationMs: 1200))
|
|
1966
|
+
let expandDeadline = Date().addingTimeInterval(3)
|
|
1967
|
+
while (flow.tailClip?.endY ?? 0) <= 1505 && Date() < expandDeadline {
|
|
1968
|
+
RunLoop.main.run(until: Date().addingTimeInterval(0.01))
|
|
1969
|
+
}
|
|
1668
1970
|
list.contentOffset.y = 1100
|
|
1669
1971
|
list.layoutIfNeeded()
|
|
1670
1972
|
view.applySnapshotJson(try structuralRowsSnapshot(count: 25, generation: 3,
|
|
1671
|
-
transitionID: "collapse-middle", durationMs:
|
|
1973
|
+
transitionID: "collapse-middle", durationMs: 2400))
|
|
1672
1974
|
waitForStructuralFrames(0.08)
|
|
1673
1975
|
list.layoutIfNeeded()
|
|
1674
1976
|
let source = try XCTUnwrap(list.dataSource as? UICollectionViewDiffableDataSource<Int, String>)
|
|
1675
|
-
let flow = try XCTUnwrap(list.collectionViewLayout as? NativeListFlowLayout)
|
|
1676
1977
|
let clip = try XCTUnwrap(flow.tailClip)
|
|
1677
1978
|
let retiring = try XCTUnwrap(list.cellForItem(at: IndexPath(item: 25, section: 0)) as? NativeListRowHost)
|
|
1678
1979
|
XCTAssertGreaterThan(clip.endY, 1500)
|
|
@@ -1990,7 +2291,7 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
1990
2291
|
view.applySnapshotJson(try structuralRowsSnapshot(count: 6, generation: 5,
|
|
1991
2292
|
transitionID: "collapse-latest", durationMs: 400,
|
|
1992
2293
|
disclosureExpanded: false))
|
|
1993
|
-
wait(for: [latestSettled], timeout:
|
|
2294
|
+
wait(for: [latestSettled], timeout: 5)
|
|
1994
2295
|
XCTAssertEqual(settlements.map(\.0), ["same-rows", "collapse-latest"])
|
|
1995
2296
|
XCTAssertEqual(settlements.last?.1, "completed")
|
|
1996
2297
|
XCTAssertEqual(settlements.last?.2, false)
|
|
@@ -2182,13 +2483,13 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
2182
2483
|
defer { growthProbe.invalidate() }
|
|
2183
2484
|
view.applySnapshotJson(try structuralRowsSnapshot(count: 50, generation: 2,
|
|
2184
2485
|
transitionID: "grow", durationMs: 800, disclosureExpanded: true))
|
|
2185
|
-
wait(for: [growthPhase], timeout:
|
|
2486
|
+
wait(for: [growthPhase], timeout: 5)
|
|
2186
2487
|
guard growthObserved else {
|
|
2187
2488
|
XCTFail("No partial disclosure growth frame observed: \(growthLast)")
|
|
2188
2489
|
return
|
|
2189
2490
|
}
|
|
2190
2491
|
growthProbe.invalidate()
|
|
2191
|
-
wait(for: [growSettled], timeout:
|
|
2492
|
+
wait(for: [growSettled], timeout: 5)
|
|
2192
2493
|
XCTAssertEqual(contentHost.bounds.height, 140, accuracy: 1)
|
|
2193
2494
|
XCTAssertNil(contentHost.layer.mask)
|
|
2194
2495
|
XCTAssertTrue(contentHost.isUserInteractionEnabled)
|
|
@@ -2227,7 +2528,7 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
2227
2528
|
defer { collapseProbe.invalidate() }
|
|
2228
2529
|
view.applySnapshotJson(try structuralRowsSnapshot(count: 6, generation: 3,
|
|
2229
2530
|
transitionID: "drag", durationMs: 800, disclosureExpanded: false))
|
|
2230
|
-
wait(for: [collapsePhase], timeout:
|
|
2531
|
+
wait(for: [collapsePhase], timeout: 5)
|
|
2231
2532
|
guard collapseObserved else {
|
|
2232
2533
|
XCTFail("No partial disclosure collapse frame observed: \(collapseLast)")
|
|
2233
2534
|
return
|
|
@@ -2559,8 +2860,10 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
2559
2860
|
view.setContainerSlotHeightsJson("[0,0,60,0]")
|
|
2560
2861
|
let list = try XCTUnwrap(view.subviews.compactMap { $0 as? UICollectionView }.first)
|
|
2561
2862
|
list.contentInsetAdjustmentBehavior = .never
|
|
2562
|
-
|
|
2563
|
-
|
|
2863
|
+
// Six retained rows plus 129 retiring rows still exceed the 128-host limit
|
|
2864
|
+
// inside three viewports, without materializing hundreds of 1-point cells.
|
|
2865
|
+
view.applySnapshotJson(try structuralRowsSnapshot(count: 135, generation: 1,
|
|
2866
|
+
uniformHeight: 10))
|
|
2564
2867
|
view.layoutIfNeeded()
|
|
2565
2868
|
list.layoutIfNeeded()
|
|
2566
2869
|
drainMainQueue()
|
|
@@ -2573,7 +2876,7 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
2573
2876
|
}
|
|
2574
2877
|
defer { NotificationCenter.default.removeObserver(observer) }
|
|
2575
2878
|
view.applySnapshotJson(try structuralRowsSnapshot(count: 6, generation: 2,
|
|
2576
|
-
transitionID: "tail-host-limit", durationMs: 400, uniformHeight:
|
|
2879
|
+
transitionID: "tail-host-limit", durationMs: 400, uniformHeight: 10))
|
|
2577
2880
|
list.layoutIfNeeded()
|
|
2578
2881
|
let source = try XCTUnwrap(list.dataSource as? UICollectionViewDiffableDataSource<Int, String>)
|
|
2579
2882
|
let flow = try XCTUnwrap(list.collectionViewLayout as? NativeListFlowLayout)
|
|
@@ -2610,22 +2913,41 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
2610
2913
|
list.layoutIfNeeded()
|
|
2611
2914
|
view.applySnapshotJson(try structuralRowsSnapshot(count: 50, generation: 2,
|
|
2612
2915
|
transitionID: "tail-6-to-50", durationMs: 400))
|
|
2613
|
-
waitForStructuralFrames(0.16)
|
|
2614
2916
|
list.layoutIfNeeded()
|
|
2615
2917
|
let source = try XCTUnwrap(list.dataSource as? UICollectionViewDiffableDataSource<Int, String>)
|
|
2616
2918
|
let flow = try XCTUnwrap(list.collectionViewLayout as? NativeListFlowLayout)
|
|
2617
2919
|
XCTAssertEqual(source.snapshot().itemIdentifiers, (0..<50).map { "row-\($0)" })
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2920
|
+
var checkedActiveTail = false
|
|
2921
|
+
func checkActiveTail() {
|
|
2922
|
+
guard let clip = flow.tailClip else { return }
|
|
2923
|
+
checkedActiveTail = true
|
|
2924
|
+
list.layoutIfNeeded()
|
|
2925
|
+
XCTAssertGreaterThanOrEqual(clip.endY, 360)
|
|
2926
|
+
XCTAssertLessThanOrEqual(clip.endY, 3000)
|
|
2927
|
+
let suffixCells = list.visibleCells.filter {
|
|
2928
|
+
(list.indexPath(for: $0)?.item ?? -1) >= 6
|
|
2929
|
+
}
|
|
2930
|
+
if clip.endY > list.contentOffset.y + 60 {
|
|
2931
|
+
XCTAssertFalse(suffixCells.isEmpty)
|
|
2932
|
+
}
|
|
2933
|
+
XCTAssertTrue(suffixCells.allSatisfy {
|
|
2934
|
+
!$0.isUserInteractionEnabled && $0.accessibilityElementsHidden
|
|
2935
|
+
})
|
|
2936
|
+
XCTAssertEqual(list.contentOffset.y, 1000, accuracy: 1)
|
|
2937
|
+
}
|
|
2938
|
+
// Inspect actual active frames instead of assuming a delayed callback lands
|
|
2939
|
+
// inside a 400 ms animation on a busy CI runner.
|
|
2940
|
+
checkActiveTail()
|
|
2941
|
+
let probe = Timer(timeInterval: 1.0 / 60, repeats: true) { _ in checkActiveTail() }
|
|
2942
|
+
RunLoop.main.add(probe, forMode: .common)
|
|
2943
|
+
defer { probe.invalidate() }
|
|
2944
|
+
let finished = XCTNSPredicateExpectation(predicate: NSPredicate { _, _ in
|
|
2945
|
+
flow.tailClip == nil &&
|
|
2946
|
+
Mirror(reflecting: view).descendant("structuralDisplayLink") as? CADisplayLink == nil
|
|
2947
|
+
}, object: nil)
|
|
2948
|
+
wait(for: [finished], timeout: 5)
|
|
2949
|
+
probe.invalidate()
|
|
2950
|
+
XCTAssertTrue(checkedActiveTail)
|
|
2629
2951
|
list.layoutIfNeeded()
|
|
2630
2952
|
XCTAssertEqual(source.snapshot().itemIdentifiers, (0..<50).map { "row-\($0)" })
|
|
2631
2953
|
XCTAssertEqual(list.contentSize.height, 3060, accuracy: 1)
|
|
@@ -2715,8 +3037,8 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
2715
3037
|
drainMainQueue()
|
|
2716
3038
|
list.contentOffset.y = 300
|
|
2717
3039
|
list.layoutIfNeeded()
|
|
2718
|
-
view.applySnapshotJson(try structuralRowsSnapshot(count:
|
|
2719
|
-
transitionID: "interrupt-boundary", durationMs:
|
|
3040
|
+
view.applySnapshotJson(try structuralRowsSnapshot(count: 15, generation: 2,
|
|
3041
|
+
transitionID: "interrupt-boundary", durationMs: 2400))
|
|
2720
3042
|
let footerBottomBeforeResize = footer.convert(.zero, to: list).y + 60
|
|
2721
3043
|
view.setContainerSlotHeightsJson("[0,0,80,2200]")
|
|
2722
3044
|
XCTAssertEqual(footer.convert(.zero, to: list).y + 80,
|
|
@@ -2730,7 +3052,7 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
2730
3052
|
XCTAssertFalse(footerHost.point(inside: CGPoint(x: 10, y: hiddenTop / 2), with: nil))
|
|
2731
3053
|
XCTAssertTrue(footerHost.point(inside: CGPoint(x: 10, y: hiddenTop + 1), with: nil))
|
|
2732
3054
|
var boundaryCell: NativeListRowHost?
|
|
2733
|
-
let deadline = Date().addingTimeInterval(
|
|
3055
|
+
let deadline = Date().addingTimeInterval(3)
|
|
2734
3056
|
while boundaryCell == nil && Date() < deadline {
|
|
2735
3057
|
if let clip = flow.tailClip {
|
|
2736
3058
|
for case let cell as NativeListRowHost in list.visibleCells {
|
|
@@ -3012,9 +3334,13 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
3012
3334
|
}
|
|
3013
3335
|
|
|
3014
3336
|
private func waitForStructuralFrames(_ seconds: TimeInterval) {
|
|
3015
|
-
let
|
|
3016
|
-
|
|
3017
|
-
|
|
3337
|
+
let deadline = Date().addingTimeInterval(seconds)
|
|
3338
|
+
while Date() < deadline {
|
|
3339
|
+
RunLoop.main.run(until: Date().addingTimeInterval(0.01))
|
|
3340
|
+
}
|
|
3341
|
+
for _ in 0..<4 {
|
|
3342
|
+
RunLoop.main.run(until: Date().addingTimeInterval(0.02))
|
|
3343
|
+
}
|
|
3018
3344
|
}
|
|
3019
3345
|
|
|
3020
3346
|
private func labels(in view: UIView) -> [UILabel] {
|
|
@@ -3183,14 +3509,17 @@ final class NativeListLifecycleTests: XCTestCase {
|
|
|
3183
3509
|
}
|
|
3184
3510
|
|
|
3185
3511
|
private func drainMainQueue() {
|
|
3186
|
-
|
|
3187
|
-
DispatchQueue.main.async {
|
|
3188
|
-
|
|
3512
|
+
var drained = false
|
|
3513
|
+
DispatchQueue.main.async { drained = true }
|
|
3514
|
+
let deadline = Date().addingTimeInterval(5)
|
|
3515
|
+
while !drained && Date() < deadline {
|
|
3516
|
+
RunLoop.main.run(until: Date().addingTimeInterval(0.01))
|
|
3517
|
+
}
|
|
3189
3518
|
}
|
|
3190
3519
|
|
|
3191
3520
|
private func footerCell(in view: NativeListView) -> NativeListRowHost? {
|
|
3192
|
-
view.subviews.lazy.compactMap { container in
|
|
3193
|
-
container.subviews.
|
|
3521
|
+
view.subviews.lazy.filter { !($0 is UICollectionView) }.compactMap { container in
|
|
3522
|
+
container.subviews.first { $0 is NativeListRowHost } as? NativeListRowHost
|
|
3194
3523
|
}.first
|
|
3195
3524
|
}
|
|
3196
3525
|
}
|