Fix tests.

This commit is contained in:
Matthew Chen 2018-05-25 12:51:49 -04:00
parent 8063886a41
commit 6b39f73e65
3 changed files with 21 additions and 14 deletions

View file

@ -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

View file

@ -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?) {
}
}

View file

@ -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)