Skip to content

Commit 56b74a9

Browse files
committed
Fix date
1 parent f530df6 commit 56b74a9

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

source/_posts/2019-04-02-testing the camera on the simulator.markdown renamed to source/_posts/2019-04-08-testing the camera on the simulator.markdown

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
layout: post
33
author: rafa
44
title: "Testing the camera on the simulator"
5-
date: 2019-04-02 22:36:49 +0200
5+
date: 2019-04-08 22:36:49 +0200
66
comments: false
77
categories:
88
---
@@ -35,17 +35,17 @@ final class Camera: NSObject {
3535
private let session: AVCaptureSession
3636
private let metadataOutput: AVCaptureMetadataOutput
3737
private weak var delegate: CameraOutputDelegate?
38-
38+
3939
public init(
4040
session: AVCaptureSession = AVCaptureSession(),
4141
metadataOutput: AVCaptureMetadataOutput = AVCaptureMetadataOutput(),
4242
delegate: CameraOutputDelegate?
4343
) {
4444
self.session = session
4545
self.metadataOutput = metadataOutput
46-
46+
4747
super.init()
48-
48+
4949
self.metadataOutput.setMetadataObjectsDelegate(self, queue: .main)
5050
}
5151
}
@@ -61,7 +61,7 @@ extension Camera: AVCaptureMetadataOutputObjectsDelegate {
6161
delegate?.qrCode(failed: .invalidMetadata)
6262
return
6363
}
64-
64+
6565
delegate?.qrCode(read: code)
6666
}
6767
}
@@ -77,7 +77,7 @@ final class CameraOutputSpy: CameraOutputDelegate {
7777
var qrCodePassed: String?
7878
var qrCodeFailedCalled: Bool?
7979
var qrCodeErrorPassed: CameraError?
80-
80+
8181
func qrCode(read code: String) {
8282
qrCodeReadCalled = true
8383
qrCodePassed = code
@@ -114,20 +114,20 @@ I'm not going to lay down the nitty-gritty details about how it works, but the m
114114
```swift
115115
struct Swizzler {
116116
private let `class`: AnyClass
117-
117+
118118
init(_ class: AnyClass) {
119119
self.`class` = `class`
120120
}
121-
121+
122122
func injectNSObjectInit(into selector: Selector) {
123123
let original = [
124124
class_getInstanceMethod(`class`, selector)
125125
].compactMap { $0 }
126-
126+
127127
let swizzled = [
128128
class_getInstanceMethod(`class`, #selector(NSObject.init))
129129
].compactMap { $0 }
130-
130+
131131
zip(original, swizzled)
132132
.forEach {
133133
method_setImplementation($0.0, method_getImplementation($0.1))
@@ -168,7 +168,7 @@ final class FakeMachineReadableCodeObject: AVMetadataMachineReadableCodeObject {
168168

169169
// 2
170170
static func createFake(code: String, type: AVMetadataObject.ObjectType) -> FakeMachineReadableCodeObject? {
171-
// 3
171+
// 3
172172
Swizzler(self).injectNSObjectInit(into: #selector(FakeMachineReadableCodeObject.init(fake:)))
173173
return fake(fake: code, type: type)
174174
}
@@ -207,4 +207,4 @@ XCTAssertNil(delegate.qrCodeErrorPassed)
207207

208208
As you can see, you can also check if your [`sut`](https://en.wikipedia.org/wiki/System_under_test) handles just QR code.
209209

210-
P.S: You can use this technique along side with other collaborators, like `AVCaptureDevice`, `AVCaptureInput` and `AVCaptureOutput`.
210+
You can use this technique along side with other collaborators, like `AVCaptureDevice`, `AVCaptureInput` and `AVCaptureOutput`.

0 commit comments

Comments
 (0)