mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Fix tests.
This commit is contained in:
parent
8063886a41
commit
6b39f73e65
3 changed files with 21 additions and 14 deletions
|
@ -59,6 +59,11 @@ public class ContactsPicker: OWSViewController, UITableViewDelegate, UITableView
|
|||
}
|
||||
|
||||
private let collation = UILocalizedIndexedCollation.current()
|
||||
public var collationForTests: UILocalizedIndexedCollation {
|
||||
get {
|
||||
return collation
|
||||
}
|
||||
}
|
||||
private let contactStore = CNContactStore()
|
||||
|
||||
// Data Source State
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
@ -12,35 +12,37 @@ import WebRTC
|
|||
class FakePeerConnectionClientDelegate: PeerConnectionClientDelegate {
|
||||
|
||||
enum ConnectionState {
|
||||
case connected, failed
|
||||
case connected, disconnected, failed
|
||||
}
|
||||
|
||||
var connectionState: ConnectionState?
|
||||
var localIceCandidates = [RTCIceCandidate]()
|
||||
var dataChannelMessages = [OWSWebRTCProtosData]()
|
||||
|
||||
internal func peerConnectionClientIceConnected(_ peerconnectionClient: PeerConnectionClient) {
|
||||
func peerConnectionClientIceConnected(_ peerconnectionClient: PeerConnectionClient) {
|
||||
connectionState = .connected
|
||||
}
|
||||
|
||||
internal func peerConnectionClientIceFailed(_ peerconnectionClient: PeerConnectionClient) {
|
||||
func peerConnectionClientIceDisconnected(_ peerconnectionClient: PeerConnectionClient) {
|
||||
connectionState = .disconnected
|
||||
}
|
||||
|
||||
func peerConnectionClientIceFailed(_ peerconnectionClient: PeerConnectionClient) {
|
||||
connectionState = .failed
|
||||
}
|
||||
|
||||
internal func peerConnectionClient(_ peerconnectionClient: PeerConnectionClient, addedLocalIceCandidate iceCandidate: RTCIceCandidate) {
|
||||
func peerConnectionClient(_ peerconnectionClient: PeerConnectionClient, addedLocalIceCandidate iceCandidate: RTCIceCandidate) {
|
||||
localIceCandidates.append(iceCandidate)
|
||||
}
|
||||
|
||||
internal func peerConnectionClient(_ peerconnectionClient: PeerConnectionClient, received dataChannelMessage: OWSWebRTCProtosData) {
|
||||
func peerConnectionClient(_ peerconnectionClient: PeerConnectionClient, received dataChannelMessage: OWSWebRTCProtosData) {
|
||||
dataChannelMessages.append(dataChannelMessage)
|
||||
}
|
||||
|
||||
internal func peerConnectionClient(_ peerconnectionClient: PeerConnectionClient, didUpdateLocal videoTrack: RTCVideoTrack?) {
|
||||
|
||||
func peerConnectionClient(_ peerconnectionClient: PeerConnectionClient, didUpdateLocal videoTrack: RTCVideoTrack?) {
|
||||
}
|
||||
|
||||
internal func peerConnectionClient(_ peerconnectionClient: PeerConnectionClient, didUpdateRemote videoTrack: RTCVideoTrack?) {
|
||||
|
||||
func peerConnectionClient(_ peerconnectionClient: PeerConnectionClient, didUpdateRemote videoTrack: RTCVideoTrack?) {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,10 +32,10 @@ final class ContactsPickerTest: XCTestCase {
|
|||
let emailOnlyContactD = CNMutableContact()
|
||||
emailOnlyContactD.emailAddresses.append(CNLabeledValue(label: nil, value: "dude@bla.com"))
|
||||
|
||||
let contactsPicker = ContactsPicker(delegate: nil)
|
||||
let contactsPicker = ContactsPicker(allowsMultipleSelection: false, subtitleCellType: .phoneNumber)
|
||||
let collatedContacts = contactsPicker.collatedContacts([emailOnlyContactB, emailOnlyContactD])
|
||||
|
||||
let sectionTitles = contactsPicker.collation.sectionTitles
|
||||
let sectionTitles = contactsPicker.collationForTests.sectionTitles
|
||||
if let bIndex = sectionTitles.index(of: "B") {
|
||||
let bSectionContacts = collatedContacts[bIndex]
|
||||
XCTAssertEqual(bSectionContacts.first, emailOnlyContactB)
|
||||
|
@ -54,10 +54,10 @@ final class ContactsPickerTest: XCTestCase {
|
|||
nameAndEmailContact.givenName = "Alice"
|
||||
nameAndEmailContact.emailAddresses.append(CNLabeledValue(label: nil, value: "nameAndEmail@bla.com"))
|
||||
|
||||
let contactsPicker = ContactsPicker(delegate: nil)
|
||||
let contactsPicker = ContactsPicker(allowsMultipleSelection: false, subtitleCellType: .phoneNumber)
|
||||
let collatedContacts = contactsPicker.collatedContacts([nameAndEmailContact])
|
||||
|
||||
let sectionTitles = contactsPicker.collation.sectionTitles
|
||||
let sectionTitles = contactsPicker.collationForTests.sectionTitles
|
||||
if let aIndex = sectionTitles.index(of: "A") {
|
||||
let aSectionContacts = collatedContacts[aIndex]
|
||||
XCTAssertEqual(aSectionContacts.first, nameAndEmailContact)
|
||||
|
|
Loading…
Reference in a new issue