Added tests for UIImagePickerController+Rx
This commit is contained in:
parent
d665aaff61
commit
a25cdd598c
|
|
@ -14,6 +14,9 @@
|
|||
842A5A2C1C357F92003568D5 /* NSTextStorage+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 842A5A281C357F7D003568D5 /* NSTextStorage+Rx.swift */; };
|
||||
842A5A2D1C357F93003568D5 /* NSTextStorage+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 842A5A281C357F7D003568D5 /* NSTextStorage+Rx.swift */; };
|
||||
842A5A2E1C357F94003568D5 /* NSTextStorage+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 842A5A281C357F7D003568D5 /* NSTextStorage+Rx.swift */; };
|
||||
8476A0211C3D5DC60040BA22 /* UIImagePickerController+RxTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8476A01F1C3D5D580040BA22 /* UIImagePickerController+RxTests.swift */; };
|
||||
8476A0221C3D5DC60040BA22 /* UIImagePickerController+RxTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8476A01F1C3D5D580040BA22 /* UIImagePickerController+RxTests.swift */; };
|
||||
8476A0231C3D5DC80040BA22 /* UIImagePickerController+RxTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8476A01F1C3D5D580040BA22 /* UIImagePickerController+RxTests.swift */; };
|
||||
8479BC461C3ACDF100FB8B54 /* RxImagePickerDelegateProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8479BC441C3ACDA400FB8B54 /* RxImagePickerDelegateProxy.swift */; };
|
||||
8479BC481C3ACDF700FB8B54 /* RxImagePickerDelegateProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8479BC441C3ACDA400FB8B54 /* RxImagePickerDelegateProxy.swift */; };
|
||||
8479BC491C3ACDFD00FB8B54 /* RxImagePickerDelegateProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8479BC441C3ACDA400FB8B54 /* RxImagePickerDelegateProxy.swift */; };
|
||||
|
|
@ -1299,6 +1302,7 @@
|
|||
/* Begin PBXFileReference section */
|
||||
79E9DE881C3417FD009970AF /* DispatchQueueSchedulerQOS.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DispatchQueueSchedulerQOS.swift; sourceTree = "<group>"; };
|
||||
842A5A281C357F7D003568D5 /* NSTextStorage+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSTextStorage+Rx.swift"; sourceTree = "<group>"; };
|
||||
8476A01F1C3D5D580040BA22 /* UIImagePickerController+RxTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIImagePickerController+RxTests.swift"; sourceTree = "<group>"; };
|
||||
8479BC441C3ACDA400FB8B54 /* RxImagePickerDelegateProxy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RxImagePickerDelegateProxy.swift; sourceTree = "<group>"; };
|
||||
8479BC4A1C3ACED100FB8B54 /* UIImagePickerController+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIImagePickerController+Rx.swift"; sourceTree = "<group>"; };
|
||||
84C225A21C33F00B008724EC /* RxTextStorageDelegateProxy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RxTextStorageDelegateProxy.swift; sourceTree = "<group>"; };
|
||||
|
|
@ -2146,6 +2150,7 @@
|
|||
isa = PBXGroup;
|
||||
children = (
|
||||
C83508D91C38706D0027C24C /* CLLocationManager+RxTests.swift */,
|
||||
8476A01F1C3D5D580040BA22 /* UIImagePickerController+RxTests.swift */,
|
||||
C83508DA1C38706D0027C24C /* Control+RxTests+Cocoa.swift */,
|
||||
C83508DB1C38706D0027C24C /* Control+RxTests+UIKit.swift */,
|
||||
C83508DC1C38706D0027C24C /* Control+RxTests.swift */,
|
||||
|
|
@ -3354,6 +3359,7 @@
|
|||
C83509411C38706E0027C24C /* BackgroundThreadPrimitiveHotObservable.swift in Sources */,
|
||||
C83509581C38706E0027C24C /* Observable+MultipleTest+CombineLatest.swift in Sources */,
|
||||
C83509651C38706E0027C24C /* VirtualSchedulerTest.swift in Sources */,
|
||||
8476A0211C3D5DC60040BA22 /* UIImagePickerController+RxTests.swift in Sources */,
|
||||
C83509361C38706E0027C24C /* NSLayoutConstraint+RxTests.swift in Sources */,
|
||||
C835095E1C38706E0027C24C /* Observable+StandardSequenceOperatorsTest.swift in Sources */,
|
||||
C83509691C38706E0027C24C /* Recorded+Timeless.swift in Sources */,
|
||||
|
|
@ -3423,6 +3429,7 @@
|
|||
C83509C21C3875220027C24C /* Driver+Test.swift in Sources */,
|
||||
C83509FE1C38755D0027C24C /* Observable+CreationTest.swift in Sources */,
|
||||
C83509FC1C38755D0027C24C /* Observable+BlockingTest.swift in Sources */,
|
||||
8476A0221C3D5DC60040BA22 /* UIImagePickerController+RxTests.swift in Sources */,
|
||||
C8350A161C38756A0027C24C /* QueueTests.swift in Sources */,
|
||||
C83509C51C3875220027C24C /* NSNotificationCenterTests.swift in Sources */,
|
||||
C83509FF1C38755D0027C24C /* Observable+MultipleTest+CombineLatest.swift in Sources */,
|
||||
|
|
@ -3492,6 +3499,7 @@
|
|||
C8350A061C38755E0027C24C /* HistoricalSchedulerTest.swift in Sources */,
|
||||
C83509D11C38752E0027C24C /* RuntimeStateSnapshot.swift in Sources */,
|
||||
C83509B31C3875010027C24C /* CLLocationManager+RxTests.swift in Sources */,
|
||||
8476A0231C3D5DC80040BA22 /* UIImagePickerController+RxTests.swift in Sources */,
|
||||
C8350A221C38756B0027C24C /* VariableTest.swift in Sources */,
|
||||
C83509D21C3875380027C24C /* RXObjCRuntime+Testing.m in Sources */,
|
||||
C83509CC1C3875230027C24C /* NSLayoutConstraint+RxTests.swift in Sources */,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,74 @@
|
|||
//
|
||||
// UIImagePickerController+RxTests.swift
|
||||
// Rx
|
||||
//
|
||||
// Created by Segii Shulga on 1/6/16.
|
||||
// Copyright © 2016 Krunoslav Zaher. All rights reserved.
|
||||
//
|
||||
|
||||
|
||||
|
||||
#if os(iOS)
|
||||
|
||||
import Foundation
|
||||
import RxSwift
|
||||
import RxCocoa
|
||||
import XCTest
|
||||
import UIKit
|
||||
|
||||
class UIImagePickerControllerTests: RxTest {
|
||||
|
||||
}
|
||||
|
||||
extension UIImagePickerControllerTests {
|
||||
|
||||
func testDidFinishPickingMediaWithInfo() {
|
||||
var completed = false
|
||||
var info:[String:AnyObject]?
|
||||
|
||||
let pickedInfo = [UIImagePickerControllerOriginalImage : UIImage()]
|
||||
|
||||
autoreleasepool {
|
||||
let imagePickerController = UIImagePickerController()
|
||||
|
||||
_ = imagePickerController.rx_didFinishPickingMediaWithInfo
|
||||
.subscribe(onNext: { (i) -> Void in
|
||||
info = i
|
||||
}, onCompleted: {
|
||||
completed = true
|
||||
})
|
||||
|
||||
imagePickerController.delegate!
|
||||
.imagePickerController!(imagePickerController,didFinishPickingMediaWithInfo:pickedInfo)
|
||||
|
||||
|
||||
}
|
||||
|
||||
XCTAssertTrue(info?[UIImagePickerControllerOriginalImage] === pickedInfo[UIImagePickerControllerOriginalImage])
|
||||
XCTAssertTrue(completed)
|
||||
}
|
||||
|
||||
func testDidCancel() {
|
||||
var completed = false
|
||||
var canceled = false
|
||||
|
||||
autoreleasepool {
|
||||
|
||||
let imagePickerController = UIImagePickerController()
|
||||
|
||||
_ = imagePickerController.rx_didCancel
|
||||
.subscribe(onNext: { (i) -> Void in
|
||||
canceled = true
|
||||
}, onCompleted: {
|
||||
completed = true
|
||||
})
|
||||
imagePickerController.delegate!.imagePickerControllerDidCancel!(imagePickerController)
|
||||
|
||||
}
|
||||
XCTAssertTrue(canceled)
|
||||
XCTAssertTrue(completed)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
Reference in New Issue