Skip to content

Commit da9455c

Browse files
committed
[Test] minor cleanup
1 parent 0489ad4 commit da9455c

6 files changed

Lines changed: 14 additions & 13 deletions

File tree

ComposeUI/Sources/ComposeUI/CrossPlatform/ScrollView/ScrollViewType.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,4 +241,11 @@ public extension ScrollViewType {
241241
var canScrollToBottom: Bool {
242242
contentOffset().y < maxOffsetY
243243
}
244+
245+
#if canImport(UIKit)
246+
/// Stops any ongoing scroll deceleration, freezing the scroll view at its current position.
247+
func stopDecelerating() {
248+
setContentOffset(contentOffset(), animated: false)
249+
}
250+
#endif
244251
}

ComposeUI/Tests/ComposeUITests/Animations/CALayer+DisableActionsTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class CALayer_DisableActionsTests: XCTestCase {
7777
window.layer.addSublayer(layer)
7878

7979
// wait for the layer to have a presentation layer
80-
wait(timeout: 0.05)
80+
expect(layer.presentation()).toEventuallyNot(beNil())
8181

8282
// without delegate
8383
do {
@@ -108,7 +108,7 @@ class CALayer_DisableActionsTests: XCTestCase {
108108
window.layer.addSublayer(layer)
109109

110110
// wait for the layer to have a presentation layer
111-
wait(timeout: 0.05)
111+
expect(layer.presentation()).toEventuallyNot(beNil())
112112

113113
// with delegate - should trigger assertion when called from background thread
114114
do {

ComposeUI/Tests/ComposeUITests/ComposeNodes/LayoutCacheNodeTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class LayoutCacheNodeTests: XCTestCase {
6464
expect(state.layoutCount) == 2
6565

6666
expect(state.renderCount) == 0
67-
_ = cachedNode.renderableItems(in: CGRect(0, 0, 100, 100))
67+
_ = cachedNode.renderableItems(in: CGRect(x: 0, y: 0, width: 100, height: 100))
6868
expect(state.renderCount) == 1
6969
}
7070
}

ComposeUI/Tests/ComposeUITests/ComposeNodes/ModifierNodeTests.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -275,14 +275,8 @@ class ModifierNodeTests: XCTestCase {
275275
contentView.frame = CGRect(x: 0, y: 0, width: 100, height: 50)
276276
contentView.refresh(animated: true)
277277

278-
// Layer should eventually have full opacity after transition
279-
let expectation = expectation(description: "opacity transition")
280-
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
281-
expect(layer?.opacity) == 1.0
282-
expectation.fulfill()
283-
}
284-
285-
wait(for: [expectation], timeout: 1)
278+
// layer should eventually have full opacity after transition
279+
expect(layer?.opacity).toEventually(beEqual(to: 1.0))
286280
}
287281
}
288282

ComposeUI/Tests/ComposeUITests/ComposeView/ComposeView+RefreshTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class ComposeView_RefreshTests: XCTestCase {
112112
isAnimated = nil
113113

114114
// wait for next run loop iteration
115-
wait(timeout: 0.01)
115+
wait(timeout: 1e-3)
116116

117117
// then: expect the refresh is performed
118118
expect(DynamicLookup(view).property("pendingRefresh")) == nil

ComposeUI/Tests/ComposeUITests/ComposeView/TestNode.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct TestNode: ComposeNode {
4646

4747
var id: ComposeNodeId = .custom("test", isFixed: false)
4848

49-
var size: CGSize = .zero
49+
var size: CGSize = CGSize(width: 0, height: 0)
5050

5151
mutating func layout(containerSize: CGSize, context: ComposeNodeLayoutContext) -> ComposeNodeSizing {
5252
state.layoutCount += 1

0 commit comments

Comments
 (0)