-
Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathAVFoundation_Swift4.swift
84 lines (68 loc) · 2.19 KB
/
AVFoundation_Swift4.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// RUN: %empty-directory(%t)
// RUN: %target-build-swift -swift-version 4 %s -o %t/a.out
// RUN: %target-codesign %t/a.out
// RUN: %target-run %t/a.out
// REQUIRES: objc_interop
// REQUIRES: executable_test
// CoreMedia is not present on watchOS.
// UNSUPPORTED: OS=watchos
import AVFoundation
import StdlibUnittest
var AVFoundationTests = TestSuite("AVFoundation_Swift4")
let pixelFormat = kCVPixelFormatType_420YpCbCr8BiPlanarFullRange
#if os(macOS) || os(iOS)
if #available(iOS 5, *) {
AVFoundationTests.test("AVCaptureVideoDataOutput.availableVideoPixelFormatTypes") {
func f(v: AVCaptureVideoDataOutput) -> Bool {
return v.availableVideoPixelFormatTypes.contains(pixelFormat)
}
}
}
#endif
#if os(iOS)
if #available(iOS 7, *) {
AVFoundationTests.test("AVMetadataMachineReadableCodeObject.corners") {
func f(m: AVMetadataMachineReadableCodeObject) -> Bool {
if let c = m.corners.first {
return c.x == 0
}
return false
}
}
}
if #available(iOS 10, *) {
AVFoundationTests.test("AVCaptureDevice.Format.supportedColorSpaces") {
func f(df: AVCaptureDevice.Format) -> Bool {
return df.supportedColorSpaces.contains(.sRGB)
}
}
AVFoundationTests.test("AVCapturePhotoOutput.supportedFlashModes") {
func f(p: AVCapturePhotoOutput) -> Bool {
return p.supportedFlashModes.contains(.off)
}
}
AVFoundationTests.test("AVCapturePhotoOutput.availablePhotoPixelFormatTypes") {
func f(p: AVCapturePhotoOutput) -> Bool {
return p.availablePhotoPixelFormatTypes.contains(pixelFormat)
}
}
AVFoundationTests.test("AVCapturePhotoOutput.availableRawPhotoPixelFormatTypes") {
func f(p: AVCapturePhotoOutput) -> Bool {
return p.availableRawPhotoPixelFormatTypes.contains(pixelFormat)
}
}
AVFoundationTests.test("AVCapturePhotoSettings.availablePreviewPhotoPixelFormatTypes") {
func f(p: AVCapturePhotoSettings) -> Bool {
return p.availablePreviewPhotoPixelFormatTypes.contains(pixelFormat)
}
}
}
if #available(iOS 11, *) {
AVFoundationTests.test("AVCaptureSynchronizedDataCollection.makeIterator()") {
func f(c: AVCaptureSynchronizedDataCollection) {
for _ in c {}
}
}
}
#endif
runAllTests()