-
Couldn't load subscription status.
- Fork 39
Scroll indicators update - positioning correction, support for both indicators at the same time #229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Scroll indicators update - positioning correction, support for both indicators at the same time #229
Changes from all commits
a699f9c
61cf77b
7c048e8
c1330a0
8324590
9f1538c
d4d833e
bb7abba
6ce8af6
15a32c5
ebb41cd
19611b4
5f3149e
e11665c
696b5ec
4a0d458
9df9578
4b165b7
54afeee
4b2ed66
a09c179
f26136c
9042ce9
f3acd87
59bfdfd
e5d8f8f
9a0f804
68edcf5
e03b6d0
59b1d9d
810f0ef
a8efa15
7f4d5a7
0137095
eaf1e88
2c77d5c
c43e4d9
b13e05d
3158be6
ff215e1
7086a9d
df2624b
3a24ba3
b9b6df4
5ec8cf7
975f308
e2e62d0
fd3218f
63c89f4
497b07c
d94bead
399d18e
faa63de
646b7d2
be7e9cf
8060600
7b9e543
6af7c80
19c16fd
08ff58e
f24db7e
66938cf
91ec3cd
d1a2e74
d19f0af
75553c8
147831f
df0b435
6cc4e28
bc35223
b5dcd2a
c39799b
ead7c57
1649892
2c1a237
ab05997
b22318a
7ac4e70
60d850f
65c5f0c
0e44547
fd14007
2039d6d
b2e2c46
6379d21
fa4b095
abc824c
b3e59f0
17e0f0a
658a4a2
7298827
7d39faa
8c57422
cc0452b
8a81fe4
ac1f2ec
36e63e4
6a899ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,6 +47,42 @@ class UIScrollViewTests: XCTestCase { | |
| XCTAssertEqual(scrollView.contentInset, arbitraryContentInset) | ||
| } | ||
|
|
||
| func testIndicatorsPositionInHierarchyWhenAddingSubviews() { | ||
| // subviews[0] is the back-most view, higher indexes are higher in layer hierarchy | ||
| // we want scroll indicators to always remain on top of 'normal' subviews | ||
| // and we want newer 'normal' subviews to be above older ones | ||
|
|
||
| // XXX: iOS does not allow explicit access to scroll indicators via subviews. | ||
| // We should remove that, too - but for now it's the easy way to go and helpful in testing | ||
|
|
||
| let mockView = UIView() | ||
| scrollView.addSubview(mockView) | ||
|
|
||
| XCTAssertGreaterThan( | ||
| scrollView.subviews.index(of: scrollView.horizontalScrollIndicator)!, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These tests look seriously amazing now. Great work @janek! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's too nice! thanks a lot!! |
||
| scrollView.subviews.index(of: mockView)! | ||
| ) | ||
|
|
||
| XCTAssertGreaterThan( | ||
| scrollView.subviews.index(of: scrollView.verticalScrollIndicator)!, | ||
| scrollView.subviews.index(of: mockView)! | ||
| ) | ||
| } | ||
|
|
||
| func testIndicatorsPositionInHierarchyWhenInsertingSubviewsAtAHighPosition() { | ||
| // If we try to insert at a position occupied by or above indicators, | ||
| // the inserted view should 'slide down' and assume the highest position below indicators | ||
|
|
||
| let mockViews = [UIView(), UIView(), UIView()] | ||
| for view in mockViews { scrollView.addSubview(view) } | ||
|
|
||
| let insertedMockView = UIView() | ||
| scrollView.insertSubview(insertedMockView, at: mockViews.count + 2) | ||
|
|
||
| XCTAssertEqual(scrollView.subviews.index(of: insertedMockView), mockViews.count) | ||
| } | ||
|
|
||
|
|
||
| func testScrollIndicatorsVisibility() { | ||
| //TODO: update to match iOS behaviour: | ||
| //1. frame is always there, alpha changes from 0 to 1 | ||
|
|
@@ -98,10 +134,6 @@ class UIScrollViewTests: XCTestCase { | |
|
|
||
| // TODO: test final position. [blocked by setting contentOffset programatically - test behaviour in iOS] | ||
|
|
||
| func testIfScrollIndicatorsAreAccurate() { | ||
| // TODO: how? | ||
| } | ||
|
|
||
| func testIfScrollViewBouncesBackAferPullIfNeeded() { | ||
| // TODO: test setting inset and bouncing after it's implented in ScrollView | ||
| } | ||
|
|
@@ -158,11 +190,11 @@ class UIScrollViewTests: XCTestCase { | |
| wait(for: [beginDraggingExpectation, didScrollExpectation, didEndDraggingExpectation], timeout: 1.0) | ||
| } | ||
|
|
||
| func mockTouch(toPoint: CGPoint, inScrollView scrollView: UIScrollView) { | ||
| func mockTouch(toPoint point: CGPoint, inScrollView scrollView: UIScrollView) { | ||
| let mockTouch = UITouch(touchId: 0, at: CGPoint(x: 0, y: 0), timestamp: 0) | ||
|
|
||
| scrollView.panGestureRecognizer.touchesBegan([mockTouch], with: UIEvent()) | ||
| mockTouch.updateAbsoluteLocation(CGPoint(x: 100, y: 100)) | ||
| mockTouch.updateAbsoluteLocation(point) | ||
| scrollView.panGestureRecognizer.touchesMoved([mockTouch], with: UIEvent()) | ||
| scrollView.panGestureRecognizer.touchesEnded([mockTouch], with: UIEvent()) | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.