Add PromiseKit dependency
- Added PromiseKit dependency
This commit is contained in:
BIN
Carthage/Checkouts/PromiseKit/Extensions/UIKit/UITests/Default-568h@2x.png
vendored
Normal file
BIN
Carthage/Checkouts/PromiseKit/Extensions/UIKit/UITests/Default-568h@2x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.5 KiB |
12
Carthage/Checkouts/PromiseKit/Extensions/UIKit/UITests/Entitlements.plist
vendored
Normal file
12
Carthage/Checkouts/PromiseKit/Extensions/UIKit/UITests/Entitlements.plist
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.private.tcc.allow</key>
|
||||
<array>
|
||||
<string>kTCCServiceAddressBook</string>
|
||||
<string>kTCCServiceCalendar</string>
|
||||
<string>kTCCServicePhotos</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
61
Carthage/Checkouts/PromiseKit/Extensions/UIKit/UITests/TestUIImagePickerController.swift
vendored
Normal file
61
Carthage/Checkouts/PromiseKit/Extensions/UIKit/UITests/TestUIImagePickerController.swift
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
import XCTest
|
||||
|
||||
class UIImagePickerControllerTests: XCTestCase {
|
||||
var button: XCUIElement {
|
||||
// calling this ensures that any other ViewController has dismissed
|
||||
// as a side-effect since otherwise the switch won't be found
|
||||
return XCUIApplication().tables.buttons.element
|
||||
}
|
||||
|
||||
var value: Bool {
|
||||
return button.isEnabled
|
||||
}
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
continueAfterFailure = false
|
||||
XCUIApplication().launch()
|
||||
XCTAssertFalse(value)
|
||||
}
|
||||
|
||||
#if !os(tvOS)
|
||||
// this test works locally but not on travis
|
||||
// attempting to detect Travis and early-return did not work
|
||||
func test_rejects_when_cancelled() {
|
||||
let app = XCUIApplication()
|
||||
let table = app.tables
|
||||
table.cells.staticTexts["1"].tap()
|
||||
table.cells.element(boundBy: 0).tap()
|
||||
app.navigationBars.buttons["Cancel"].tap()
|
||||
|
||||
XCTAssertTrue(value)
|
||||
}
|
||||
|
||||
// following two don't seem to work since Xcode 8.1
|
||||
// The UI-Testing infrastructure cannot “see” the image picking UI
|
||||
// And… trying to re-record by hand fails.
|
||||
|
||||
func test_fulfills_with_edited_image() {
|
||||
let app = XCUIApplication()
|
||||
app.tables.cells.staticTexts["2"].tap()
|
||||
app.tables.children(matching: .cell).element(boundBy: 1).tap()
|
||||
app.collectionViews.children(matching: .cell).element(boundBy: 0).tap()
|
||||
|
||||
// XCUITesting fails to tap this button, hence this test disabled
|
||||
app.buttons["Choose"].tap()
|
||||
|
||||
XCTAssertTrue(value)
|
||||
}
|
||||
|
||||
func test_fulfills_with_image() {
|
||||
let app = XCUIApplication()
|
||||
let tablesQuery = app.tables
|
||||
tablesQuery.staticTexts["3"].tap()
|
||||
tablesQuery.children(matching: .cell).element(boundBy: 1).tap()
|
||||
|
||||
app.collectionViews.children(matching: .cell).element(boundBy: 0).tap()
|
||||
|
||||
XCTAssertTrue(value)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
100
Carthage/Checkouts/PromiseKit/Extensions/UIKit/UITests/app.swift
vendored
Normal file
100
Carthage/Checkouts/PromiseKit/Extensions/UIKit/UITests/app.swift
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
import PromiseKit
|
||||
import PMKUIKit
|
||||
import UIKit
|
||||
|
||||
@UIApplicationMain
|
||||
class App: UITableViewController, UIApplicationDelegate {
|
||||
var window: UIWindow? = UIWindow(frame: UIScreen.main.bounds)
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]? = nil) -> Bool {
|
||||
window!.rootViewController = self
|
||||
window!.backgroundColor = UIColor.purple
|
||||
window!.makeKeyAndVisible()
|
||||
UIView.setAnimationsEnabled(false)
|
||||
return true
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
return Row.count
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
let cell = UITableViewCell()
|
||||
cell.textLabel?.text = Row(indexPath)?.description
|
||||
return cell
|
||||
}
|
||||
|
||||
let testSuceededButton = UIButton()
|
||||
|
||||
override func viewDidLoad() {
|
||||
testSuceededButton.setTitle("unused", for: .normal)
|
||||
testSuceededButton.sizeToFit()
|
||||
testSuceededButton.backgroundColor = UIColor.blue
|
||||
testSuceededButton.isEnabled = false
|
||||
|
||||
view.addSubview(testSuceededButton)
|
||||
}
|
||||
|
||||
override func viewDidLayoutSubviews() {
|
||||
testSuceededButton.center = view.center
|
||||
}
|
||||
|
||||
private func success() {
|
||||
self.testSuceededButton.isEnabled = true
|
||||
}
|
||||
|
||||
#if !os(tvOS)
|
||||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||
switch Row(indexPath)! {
|
||||
case .ImagePickerCancel:
|
||||
let p = promise(UIImagePickerController())
|
||||
p.catch(policy: .allErrors) { error in
|
||||
guard (error as! CancellableError).isCancelled else { abort() }
|
||||
self.success()
|
||||
}
|
||||
p.catch { error in
|
||||
abort()
|
||||
}
|
||||
case .ImagePickerEditImage:
|
||||
let picker = UIImagePickerController()
|
||||
picker.allowsEditing = true
|
||||
_ = promise(picker).done { _ in
|
||||
self.success()
|
||||
}
|
||||
case .ImagePickerPickImage:
|
||||
_ = promise(UIImagePickerController()).done { image in
|
||||
self.success()
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
enum Row: Int {
|
||||
case ImagePickerCancel
|
||||
case ImagePickerEditImage
|
||||
case ImagePickerPickImage
|
||||
|
||||
init?(_ indexPath: IndexPath) {
|
||||
guard let row = Row(rawValue: indexPath.row) else {
|
||||
return nil
|
||||
}
|
||||
self = row
|
||||
}
|
||||
|
||||
var indexPath: IndexPath {
|
||||
return IndexPath(row: rawValue, section: 0)
|
||||
}
|
||||
|
||||
var description: String {
|
||||
return (rawValue + 1).description
|
||||
}
|
||||
|
||||
static var count: Int {
|
||||
var x = 0
|
||||
while Row(rawValue: x) != nil {
|
||||
x += 1
|
||||
}
|
||||
return x
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user