Skip to content

Commit bff515d

Browse files
authored
Merge pull request #12 from SiliconLabs/release2.7.1
Branch release2.7.1 merge into master gitHub branch
2 parents 533df99 + 3c8d0a3 commit bff515d

29 files changed

+254
-253
lines changed

BlueGeckoTests/ViewModels/ESLDemo/Model/Commands/SILESLCommandConnectTestSpec.swift

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,34 @@ class SILESLCommandConnectTestSpec: QuickSpec {
2020
var sut: SILESLCommandConnect!
2121

2222
override func spec() {
23-
describe("connect bt_addr") {
24-
it("should prepare data for public address") {
23+
describe("raw data") {
24+
it("should prepare connect from raw data") {
2525
let btAddress = "8c:f6:81:b8:82:b2"
26-
self.address = SILAddress.btAddress(SILBluetoothAddress(address: btAddress, addressType: .public))
27-
self.sut = SILESLCommandConnect(address: self.address)
28-
2926
let dataToSend = "connect \(btAddress)".bytes
3027

28+
self.sut = SILESLCommandConnect(qrData: dataToSend)
29+
3130
expect(self.sut.dataToSend).to(equal(dataToSend))
3231
}
33-
34-
it("should prepare data for public address with passcode") {
32+
}
33+
34+
describe("connect bt_addr") {
35+
it("should prepare data for public address") {
3536
let btAddress = "8c:f6:81:b8:82:b2"
36-
let passcode = "1234"
3737
self.address = SILAddress.btAddress(SILBluetoothAddress(address: btAddress, addressType: .public))
38-
self.sut = SILESLCommandConnect(address: self.address, passcode: passcode)
38+
self.sut = SILESLCommandConnect(address: self.address)
3939

40-
let dataToSend = "connect \(btAddress) \(passcode)".bytes
40+
let dataToSend = "connect \(btAddress)".bytes
4141

4242
expect(self.sut.dataToSend).to(equal(dataToSend))
4343
}
4444

45-
it("should prepare data for static address with passcode") {
45+
it("should prepare data for static address") {
4646
let btAddress = "X"
47-
let passcode = "1234"
4847
self.address = SILAddress.btAddress(SILBluetoothAddress(address: btAddress, addressType: .static))
49-
self.sut = SILESLCommandConnect(address: self.address, passcode: passcode)
48+
self.sut = SILESLCommandConnect(address: self.address)
5049

51-
let dataToSend = "connect \(btAddress) static \(passcode)".bytes
50+
let dataToSend = "connect \(btAddress) static".bytes
5251

5352
expect(self.sut.dataToSend).to(equal(dataToSend))
5453
}
@@ -65,11 +64,10 @@ class SILESLCommandConnectTestSpec: QuickSpec {
6564

6665
it("should prepare data for rand_nonres address") {
6766
let btAddress = "XXX"
68-
let passcode = "4321"
6967
self.address = SILAddress.btAddress(SILBluetoothAddress(address: btAddress, addressType: .rand_nonres))
70-
self.sut = SILESLCommandConnect(address: self.address, passcode: passcode)
68+
self.sut = SILESLCommandConnect(address: self.address)
7169

72-
let dataToSend = "connect \(btAddress) rand_nonres \(passcode)".bytes
70+
let dataToSend = "connect \(btAddress) rand_nonres".bytes
7371

7472
expect(self.sut.dataToSend).to(equal(dataToSend))
7573
}
@@ -85,17 +83,6 @@ class SILESLCommandConnectTestSpec: QuickSpec {
8583

8684
expect(self.sut.dataToSend).to(equal(dataToSend))
8785
}
88-
89-
it("should prepare data for esl_id with passcode") {
90-
let eslId = 55
91-
let passcode = "56789"
92-
self.address = SILAddress.eslId(SILESLIdAddress.unicast(id: 55))
93-
self.sut = SILESLCommandConnect(address: self.address, passcode: passcode)
94-
95-
let dataToSend = "connect \(eslId) \(passcode)".bytes
96-
97-
expect(self.sut.dataToSend).to(equal(dataToSend))
98-
}
9986
}
10087
}
10188
}

BlueGeckoTests/ViewModels/ESLDemo/Model/Processes/SILESLProvisioningTagTestSpec.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class SILESLProvisioningTagTestSpec: QuickSpec {
3030
self.sut = SILESLProvisioningTag(peripheral: self.peripheralMock,
3131
peripheralReferences: self.peripheralReferencesMock,
3232
commandRunnerFactory: self.commandRunnerFactoryMock,
33-
address: .init(address: "", addressType: .public))
33+
qrData: [UInt8]())
3434
}
3535

3636
afterEach {
@@ -39,11 +39,10 @@ class SILESLProvisioningTagTestSpec: QuickSpec {
3939

4040
describe("perform(timeout:)") {
4141
it("should call function and return success") {
42-
let btAddress = SILBluetoothAddress(address: "", addressType: .public)
43-
let connectCommandMock = mock(SILESLCommandConnect.self).initialize(address: .btAddress(btAddress), passcode: "1234")
42+
let connectCommandMock = mock(SILESLCommandConnect.self).initialize(qrData: [UInt8]())
4443
let connect = mock(SILESLCommandConnectRunner.self).initialize(peripheral: self.peripheralMock, peripheralReferences: self.peripheralReferencesMock, command: connectCommandMock)
4544

46-
given(self.commandRunnerFactoryMock.createCommandConnectRunner(peripheral: self.peripheralMock, peripheralReferences: any(), address: any(), passcode: any())).willReturn(connect)
45+
given(self.commandRunnerFactoryMock.createCommandConnectRunner(peripheral: self.peripheralMock, peripheralReferences: any(), qrData: any(), address: nil)).willReturn(connect)
4746

4847
let publishRelay: PublishRelay<Result<Bool, SILESLCommandGenericError>> = PublishRelay()
4948
given(connect.commandResult).willReturn(publishRelay)
@@ -62,11 +61,10 @@ class SILESLProvisioningTagTestSpec: QuickSpec {
6261
}
6362

6463
it("should call function and return error") {
65-
let btAddress = SILBluetoothAddress(address: "", addressType: .public)
66-
let connectCommandMock = mock(SILESLCommandConnect.self).initialize(address: .btAddress(btAddress), passcode: "1234")
64+
let connectCommandMock = mock(SILESLCommandConnect.self).initialize(qrData: [UInt8]())
6765
let connect = mock(SILESLCommandConnectRunner.self).initialize(peripheral: self.peripheralMock, peripheralReferences: self.peripheralReferencesMock, command: connectCommandMock)
6866

69-
given(self.commandRunnerFactoryMock.createCommandConnectRunner(peripheral: self.peripheralMock, peripheralReferences: any(), address: any(), passcode: any())).willReturn(connect)
67+
given(self.commandRunnerFactoryMock.createCommandConnectRunner(peripheral: self.peripheralMock, peripheralReferences: any(), qrData: any(), address: nil)).willReturn(connect)
7068

7169
let publishRelay: PublishRelay<Result<Bool, SILESLCommandGenericError>> = PublishRelay()
7270
given(connect.commandResult).willReturn(publishRelay)

BlueGeckoTests/ViewModels/ESLDemo/Model/Runners/SILESLCommandConnectRunnerTestSpec.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ class SILESLCommandConnectRunnerTestSpec: QuickSpec {
2828
override func spec() {
2929
beforeEach {
3030
self.address = .eslId(.broadcast)
31-
self.commandMock = mock(SILESLCommandConnect.self).initialize(address: self.address, passcode: nil)
31+
self.commandMock = mock(SILESLCommandConnect.self).initialize(address: self.address)
3232
let defaultMock = SILESLPeripheralMockFactory().getDefault()
33-
given(self.commandMock.getFullCommand()).willReturn("")
33+
given(self.commandMock.getDataToSend()).willReturn([UInt8]())
3434
self.eslDemoServiceMock = defaultMock.eslDemoServiceMock
3535
self.eslControlPointMock = defaultMock.eslControlPointMock
3636
self.peripheralMock = defaultMock.peripheralMock

BlueGeckoTests/ViewModels/ESLDemo/Model/SILESLCommandRunnerFactoryTestSpec.swift

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ class SILESLCommandRunnerFactoryTestSpec: QuickSpec {
3434
let provisioning = self.sut.createCommandProvisioning(peripheral: self.peripheralMock,
3535
peripheralReferences: self.peripheralReferencesMock,
3636
commandRunnerFactory: self.sut,
37-
address: SILBluetoothAddress(address: "", addressType: .public),
38-
passcode: "12345")
37+
qrData: [UInt8]())
3938

4039
expect(provisioning.isKind(of: SILESLProvisioningTag.self)).to(beTrue())
4140
}
@@ -56,11 +55,18 @@ class SILESLCommandRunnerFactoryTestSpec: QuickSpec {
5655
}
5756

5857
describe("createCommandConnectRunner") {
59-
it("should create proper object") {
58+
it("should create proper object with address") {
59+
let connectRunner = self.sut.createCommandConnectRunner(peripheral: self.peripheralMock,
60+
peripheralReferences: self.peripheralReferencesMock,
61+
address: self.addressMock)
62+
63+
expect(connectRunner.isKind(of: SILESLCommandConnectRunner.self)).to(beTrue())
64+
}
65+
66+
it("should create proper object with qrCode") {
6067
let connectRunner = self.sut.createCommandConnectRunner(peripheral: self.peripheralMock,
6168
peripheralReferences: self.peripheralReferencesMock,
62-
address: self.addressMock,
63-
passcode: "12345")
69+
qrData: [UInt8]())
6470

6571
expect(connectRunner.isKind(of: SILESLCommandConnectRunner.self)).to(beTrue())
6672
}

BlueGeckoTests/ViewModels/ESLDemo/QRScannerViewModelTestSpec.swift

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -26,66 +26,39 @@ class QRScannerViewModelTestSpec: QuickSpec {
2626
describe("readQR - correct") {
2727
it("should read correct two words") {
2828
let address = "00:01:02:03:04:05"
29-
let qrData = self.sut.readQR(metadata: "connect \(address)")
29+
let full = "connect \(address)"
30+
let qrData = self.sut.readQR(metadata: full)
3031

3132
expect(qrData).notTo(beNil())
3233
expect(qrData?.bluetoothAddress.addressType).to(equal(.public))
3334
expect(qrData?.bluetoothAddress.address).to(equal(address))
34-
expect(qrData?.passcode).to(beNil())
35+
expect(qrData?.rawData).to(equal(full.bytes))
3536
}
3637

37-
it("should read correct three words") {
38+
it("should read correct with more characters") {
3839
let address = "00:01:02:03:04:05"
39-
let qrData = self.sut.readQR(metadata: "connect \(address) static")
40+
let full = "abc dconnect \(address) static"
41+
let qrData = self.sut.readQR(metadata: full)
4042

4143
expect(qrData).notTo(beNil())
42-
expect(qrData?.bluetoothAddress.addressType).to(equal(.static))
43-
expect(qrData?.bluetoothAddress.address).to(equal(address))
44-
expect(qrData?.passcode).to(beNil())
45-
}
46-
47-
it("should read correct four words") {
48-
let address = "00:01:02:03:04:05"
49-
let passcode = "1234"
50-
let qrData = self.sut.readQR(metadata: "connect \(address) rand_nonres \(passcode)")
51-
52-
expect(qrData).notTo(beNil())
53-
expect(qrData?.bluetoothAddress.addressType).to(equal(.rand_nonres))
44+
expect(qrData?.bluetoothAddress.addressType).to(equal(.public))
5445
expect(qrData?.bluetoothAddress.address).to(equal(address))
55-
expect(qrData?.passcode).to(equal(passcode))
46+
expect(qrData?.rawData).to(equal(full.bytes))
5647
}
5748
}
5849

5950
describe("readQR - incorrect") {
60-
it("return nil - words.count = 1") {
61-
let qrData = self.sut.readQR(metadata: "connect")
62-
63-
expect(qrData).to(beNil())
64-
}
65-
66-
it("return nil - words.count = 5") {
51+
it("return nil - missing btAddress") {
6752
let qrData = self.sut.readQR(metadata: "connect a b c d")
6853

6954
expect(qrData).to(beNil())
7055
}
7156

72-
it("return nil - words[0] != connect") {
73-
let qrData = self.sut.readQR(metadata: "connected 11:12:13:14:15:16")
74-
75-
expect(qrData).to(beNil())
76-
}
77-
78-
it("return nil - words[1].isValid = false") {
57+
it("return nil - btAddress wrong") {
7958
let qrData = self.sut.readQR(metadata: "connect 100:12:13:14:15:16")
8059

8160
expect(qrData).to(beNil())
8261
}
83-
84-
it("return nil - words[2] invalid type") {
85-
let qrData = self.sut.readQR(metadata: "connect 11:12:13:14:15:16 nonpublic")
86-
87-
expect(qrData).to(beNil())
88-
}
8962
}
9063
}
9164
}

BlueGeckoTests/ViewModels/ESLDemo/SILESLDemoViewModelTestSpec.swift

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,12 @@ class SILESLDemoViewModelTestSpec: QuickSpec {
143143

144144
describe("provisionTag") {
145145
it("should call perform on runner and finish with success") {
146-
let btAddress = SILBluetoothAddress(address: "", addressType: .public)
147146
let provisionCommandMock = mock(SILESLProvisioningTag.self).initialize(peripheral: self.peripheralMock,
148147
peripheralReferences: self.peripheralReferencesMock,
149148
commandRunnerFactory: self.commandRunnerFactoryMock,
150-
address: btAddress,
151-
passcode: nil)
149+
qrData: [UInt8]())
152150

153-
given(self.commandRunnerFactoryMock.createCommandProvisioning(peripheral: self.peripheralMock, peripheralReferences: any(), commandRunnerFactory: self.commandRunnerFactoryMock, address: any(), passcode: any())).willReturn(provisionCommandMock)
151+
given(self.commandRunnerFactoryMock.createCommandProvisioning(peripheral: self.peripheralMock, peripheralReferences: any(), commandRunnerFactory: self.commandRunnerFactoryMock, qrData: any())).willReturn(provisionCommandMock)
154152

155153
let publishRelay: PublishRelay<Result<SILESLDemoViewModelState, SILESLCommandGenericError>> = PublishRelay()
156154
given(provisionCommandMock.commandResult).willReturn(publishRelay)
@@ -160,22 +158,20 @@ class SILESLDemoViewModelTestSpec: QuickSpec {
160158
expectedState = commandState
161159
}).disposed(by: self.disposeBag)
162160

163-
self.sut.provisionTag(with: btAddress, passcode: "1234")
161+
self.sut.provisionTag(with: [UInt8]())
164162
publishRelay.accept(.success(.provisioningInProgressConfig))
165163

166164
verify(provisionCommandMock.perform(timeout: 10.0)).wasCalled(1)
167165
expect(expectedState == .provisioningInProgressConfig).to(beTrue())
168166
}
169167

170168
it("should call perform on runner and finish with failure") {
171-
let btAddress = SILBluetoothAddress(address: "", addressType: .public)
172169
let provisionCommandMock = mock(SILESLProvisioningTag.self).initialize(peripheral: self.peripheralMock,
173170
peripheralReferences: self.peripheralReferencesMock,
174171
commandRunnerFactory: self.commandRunnerFactoryMock,
175-
address: btAddress,
176-
passcode: nil)
172+
qrData: [UInt8]())
177173

178-
given(self.commandRunnerFactoryMock.createCommandProvisioning(peripheral: self.peripheralMock, peripheralReferences: any(), commandRunnerFactory: self.commandRunnerFactoryMock, address: any(), passcode: any())).willReturn(provisionCommandMock)
174+
given(self.commandRunnerFactoryMock.createCommandProvisioning(peripheral: self.peripheralMock, peripheralReferences: any(), commandRunnerFactory: self.commandRunnerFactoryMock, qrData: any())).willReturn(provisionCommandMock)
179175

180176
let publishRelay: PublishRelay<Result<SILESLDemoViewModelState, SILESLCommandGenericError>> = PublishRelay()
181177
given(provisionCommandMock.commandResult).willReturn(publishRelay)
@@ -185,7 +181,7 @@ class SILESLDemoViewModelTestSpec: QuickSpec {
185181
expectedState = commandState
186182
}).disposed(by: self.disposeBag)
187183

188-
self.sut.provisionTag(with: btAddress, passcode: "1234")
184+
self.sut.provisionTag(with: [UInt8]())
189185
publishRelay.accept(.failure(.timeout))
190186

191187
verify(provisionCommandMock.perform(timeout: 10.0)).wasCalled(1)

Podfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def shared_pods
2424
pod 'AEXML'
2525
pod 'RxSwift', '~> 6.2.0'
2626
pod 'RxCocoa', '~> 6.2.0'
27+
pod 'Introspect'
2728
end
2829

2930
def test_pods

Podfile.lock

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ PODS:
1111
- Crashlytics (3.12.0):
1212
- Fabric (~> 1.9.0)
1313
- Fabric (1.9.0)
14+
- Introspect (0.1.4)
1415
- IP-UIKit-Wisdom (0.0.10)
1516
- KVOController (1.2.0)
1617
- MockingbirdFramework (0.20.0)
@@ -43,6 +44,7 @@ DEPENDENCIES:
4344
- Charts (~> 4.1.0)
4445
- Crashlytics (~> 3.12.0)
4546
- Fabric (~> 1.9.0)
47+
- Introspect
4648
- IP-UIKit-Wisdom (~> 0.0.10)
4749
- KVOController (~> 1.2.0)
4850
- MockingbirdFramework (~> 0.20)
@@ -68,6 +70,7 @@ SPEC REPOS:
6870
- Charts
6971
- Crashlytics
7072
- Fabric
73+
- Introspect
7174
- IP-UIKit-Wisdom
7275
- KVOController
7376
- MockingbirdFramework
@@ -99,9 +102,10 @@ SPEC CHECKSUMS:
99102
ActionSheetPicker-3.0: 2f5e3fde6b3205a7318f9338e4ec0f373ce7e75c
100103
AEXML: 1e255ecc6597212f97a7454a69ebd3ede64ac1cf
101104
ChameleonFramework: d21a3cc247abfe5e37609a283a8238b03575cf64
102-
Charts: 354f86803d11d9c35de280587fef50d1af063978
105+
Charts: ce0768268078eee0336f122c3c4ca248e4e204c5
103106
Crashlytics: a33af323773f73904037dc2e684cd2f0d29f4fe2
104107
Fabric: 09ef2d9b99b104702bede1acaf469fb8f20a9146
108+
Introspect: b62c4dd2063072327c21d618ef2bedc3c87bc366
105109
IP-UIKit-Wisdom: b395a065344071b33659e5f6b918043a97c48a44
106110
KVOController: d72ace34afea42468329623b3379ab3cd1d286b6
107111
MockingbirdFramework: 54e35fbbb47b806c1a1fae2cf3ef99f6eceb55e5
@@ -121,6 +125,6 @@ SPEC CHECKSUMS:
121125
WYPopoverController: a9db25ac2841a686acdc0f3a99bdb21545db32f4
122126
XMLDictionary: fa07b6ff422b3a91d47a5de9bc82e3fc04fbd167
123127

124-
PODFILE CHECKSUM: 2a7bf762833c9e5113333b740d5adcf2e3da73dc
128+
PODFILE CHECKSUM: ccf13e60e9ab41471864f78e72f744756afc259a
125129

126-
COCOAPODS: 1.10.0
130+
COCOAPODS: 1.12.1

0 commit comments

Comments
 (0)