diff --git a/Rx.xcodeproj/project.pbxproj b/Rx.xcodeproj/project.pbxproj index 30321e36..af93104a 100644 --- a/Rx.xcodeproj/project.pbxproj +++ b/Rx.xcodeproj/project.pbxproj @@ -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 = ""; }; 842A5A281C357F7D003568D5 /* NSTextStorage+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSTextStorage+Rx.swift"; sourceTree = ""; }; + 8476A01F1C3D5D580040BA22 /* UIImagePickerController+RxTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIImagePickerController+RxTests.swift"; sourceTree = ""; }; 8479BC441C3ACDA400FB8B54 /* RxImagePickerDelegateProxy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RxImagePickerDelegateProxy.swift; sourceTree = ""; }; 8479BC4A1C3ACED100FB8B54 /* UIImagePickerController+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIImagePickerController+Rx.swift"; sourceTree = ""; }; 84C225A21C33F00B008724EC /* RxTextStorageDelegateProxy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RxTextStorageDelegateProxy.swift; sourceTree = ""; }; @@ -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 */, diff --git a/Tests/RxCocoaTests/UIImagePickerController+RxTests.swift b/Tests/RxCocoaTests/UIImagePickerController+RxTests.swift new file mode 100644 index 00000000..a8387ecf --- /dev/null +++ b/Tests/RxCocoaTests/UIImagePickerController+RxTests.swift @@ -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