mirror of
https://github.com/joncardasis/ChromaColorPicker.git
synced 2024-09-11 06:35:41 +03:00
Added more tests to brightness slider
This commit is contained in:
parent
16b9f6aa6c
commit
7191d098d0
@ -93,6 +93,20 @@ class ChromaBrightnessSliderTests: XCTestCase {
|
|||||||
XCTAssertEqual(subject.handle.layer.shadowOpacity, 0)
|
XCTAssertEqual(subject.handle.layer.shadowOpacity, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testHandleIsRepositionedAccordingToCurrentValueOnLayout() {
|
||||||
|
// Given
|
||||||
|
let subject = ChromaBrightnessSlider(frame: CGRect(x: 0, y: 0, width: 300, height: 30))
|
||||||
|
//subject.layoutIfNeeded()
|
||||||
|
let expectedPosition = subject.center
|
||||||
|
|
||||||
|
// When
|
||||||
|
subject.currentValue = 0.5
|
||||||
|
subject.layoutIfNeeded()
|
||||||
|
|
||||||
|
// Then
|
||||||
|
XCTAssertEqual(subject.handle.center, expectedPosition)
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Convenience Functions
|
// MARK: - Convenience Functions
|
||||||
|
|
||||||
func testConnectCallsConnectFunctionOfColorPicker() {
|
func testConnectCallsConnectFunctionOfColorPicker() {
|
||||||
@ -231,7 +245,23 @@ class ChromaBrightnessSliderTests: XCTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testEndTrackingSendsTouchUpInsideAction() {
|
func testEndTrackingSendsTouchUpInsideAction() {
|
||||||
|
// Given
|
||||||
|
let subject = ChromaBrightnessSlider(frame: CGRect(x: 0, y: 0, width: 300, height: 30))
|
||||||
|
subject.layoutIfNeeded()
|
||||||
|
let fakeTouch = FakeUITouch(locationInParent: CGPoint(x: 0, y: 0))
|
||||||
|
let eventReceiver = FakeEventReceiver(listensFor: .touchUpInside)
|
||||||
|
subject.addTarget(eventReceiver, action: #selector(FakeEventReceiver.catchEvent(_:)), for: .touchUpInside)
|
||||||
|
|
||||||
|
var eventDidTrigger = false
|
||||||
|
eventReceiver.eventCaught = {
|
||||||
|
eventDidTrigger = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// When
|
||||||
|
let _ = subject.endTracking(fakeTouch, with: nil)
|
||||||
|
|
||||||
|
// Then
|
||||||
|
XCTAssertTrue(eventDidTrigger)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user