-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #567 from zenangst/improve/click-interactions-on-m…
…acos Improve handling mouse clicks on macOS
- Loading branch information
Showing
8 changed files
with
135 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
github "krzyzanowskim/CryptoSwift" "0.6.7" | ||
github "ReactiveX/RxSwift" "3.2.0" | ||
github "ReactiveX/RxSwift" "3.3.1" | ||
github "hyperoslo/Cache" "2.2.2" | ||
github "krzyzanowskim/CryptoSwift" "0.6.8" | ||
github "zenangst/Tailor" "2.0.2" | ||
github "hyperoslo/Cache" "2.2.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
@testable import Spots | ||
import XCTest | ||
|
||
class MockTableView: NSTableView { | ||
|
||
var rowClicked: Int = -1 | ||
|
||
override var clickedRow: Int { | ||
|
||
if rowView(atRow: rowClicked, makeIfNecessary: false) != nil { | ||
return rowClicked | ||
} else { | ||
return -1 | ||
} | ||
} | ||
} | ||
|
||
class MockComponentDelegate: NSObject, ComponentDelegate { | ||
|
||
var invocation: Int = 0 | ||
|
||
func component(_ component: Component, itemSelected item: Item) { | ||
invocation += 1 | ||
} | ||
} | ||
|
||
class TestMouseClick: XCTestCase { | ||
|
||
func testMouseClick() { | ||
let mockTableView = MockTableView() | ||
let mockDelegate = MockComponentDelegate() | ||
let interaction = Interaction(mouseClick: .single) | ||
let model = ComponentModel(kind: .list, interaction: interaction, items: [ | ||
Item(title: "foo") | ||
] | ||
) | ||
let component = Component(model: model, userInterface: mockTableView) | ||
component.setup(with: CGSize(width: 100, height: 100)) | ||
|
||
component.delegate = mockDelegate | ||
|
||
guard let tableView = component.tableView as? MockTableView else { | ||
XCTFail("Unable to resolve table view.") | ||
return | ||
} | ||
|
||
tableView.rowClicked = 0 | ||
|
||
/// Expect that the component delegate will be called once. | ||
component.singleMouseClick(nil) | ||
XCTAssertEqual(mockDelegate.invocation, 1) | ||
|
||
/// Expect that the invocation count is still one after double clicking. | ||
component.doubleMouseClick(nil) | ||
XCTAssertEqual(mockDelegate.invocation, 1) | ||
|
||
/// Expect that the invocation is unchanged when the configuration is set | ||
/// to only accept double clicks. | ||
component.model.interaction.mouseClick = .double | ||
component.singleMouseClick(nil) | ||
XCTAssertEqual(mockDelegate.invocation, 1) | ||
|
||
/// Expect that invocation is two because it is inline with the configuration. | ||
component.doubleMouseClick(nil) | ||
XCTAssertEqual(mockDelegate.invocation, 2) | ||
} | ||
|
||
} |