Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #41 unable to integrate test target #92

Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions RZBluetooth.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
Pod::Spec.new do |s|
s.name = "RZBluetooth"
s.version = "1.2.1"
s.version = "1.2.2"
s.summary = "A Core Bluetooth helper library to simplify the development and testing of Core Bluetooth applications."

s.description = <<-DESC
Expand Down Expand Up @@ -35,12 +35,4 @@ RZBluetooth is a Core Bluetooth helper with 3 primary goals:
mock.private_header_files = "RZMockBluetooth/**/*+Private.h"
end

s.subspec "Test" do |test|
test.dependency "RZBluetooth/Mock"
test.frameworks = "XCTest"
test.source_files = "RZBluetoothTests/RZBTestDefines.h",
"RZBluetoothTests/RZBSimulatedTestCase.{h,m}",
"RZBluetoothTests/Helpers/NSRunLoop+RZBWaitFor.{h,m}"
test.public_header_files = "RZBluetoothTests/RZBSimulatedTestCase.h", "RZBluetoothTests/RZBTestDefines.h"
end
end
149 changes: 134 additions & 15 deletions RZBluetooth.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

18 changes: 2 additions & 16 deletions RZBluetooth.xcodeproj/xcshareddata/xcschemes/RZBluetooth.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,14 @@
ReferencedContainer = "container:RZBluetooth.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AB45C4A31B6BF70B00CC0166"
BuildableName = "RZBluetoothTests.xctest"
BlueprintName = "RZBluetoothTests"
ReferencedContainer = "container:RZBluetooth.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
codeCoverageEnabled = "YES"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand Down
30 changes: 30 additions & 0 deletions RZBluetoothTest.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
Pod::Spec.new do |s|
s.name = "RZBluetoothTest"
s.version = "1.2.2"
s.summary = "A Core Bluetooth helper library to simplify the development and testing of Core Bluetooth applications."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The summary should state that this pod is specifically so simplify testing bluetooth with XCTest and RZBluetooth mocks.


s.description = <<-DESC
RZBluetooth is a Core Bluetooth helper with 3 primary goals:

- Simplify the delegate callbacks and encourage best practices
- Provide a pattern for Profile level APIs, with support for public profiles
- Simplify and encourage testing - including unit tests, automated integration tests, and manual tests.
DESC

s.homepage = "http://github.com/Raizlabs/RZBluetooth"
s.license = { :type => "MIT", :file => "LICENSE" }
s.author = { "Brian King" => "[email protected]" }
s.osx.deployment_target = "10.10"
s.ios.deployment_target = "8.0"
s.source = { :git => "https://github.com/Raizlabs/RZBluetooth.git", :tag => s.version }
s.requires_arc = true

s.dependency "RZBluetooth/Mock"
s.frameworks = "XCTest"
s.source_files = "RZBluetoothTests/RZBTestDefines.h",
"RZBluetoothTests/RZBSimulatedTestCase.{h,m}",
"RZBluetoothTests/Helpers/NSRunLoop+RZBWaitFor.{h,m}"
s.public_header_files = "RZBluetoothTests/RZBSimulatedTestCase.h", "RZBluetoothTests/RZBTestDefines.h"

end
4 changes: 0 additions & 4 deletions RZBluetoothTests/RZBPeripheralManagerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
//

#import "RZBSimulatedTestCase.h"
#import "RZBPeripheral+RZBBattery.h"
#import "RZBSimulatedDevice+RZBBatteryLevel.h"
#import "CBUUID+RZBPublic.h"
#import "XCTestCase+Helpers.h"

@interface RZBPeripheralManagerTests : RZBSimulatedTestCase

Expand Down
4 changes: 0 additions & 4 deletions RZBluetoothTests/RZBProfileBatteryTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
//

#import "RZBSimulatedTestCase.h"
#import "RZBPeripheral+RZBBattery.h"
#import "RZBSimulatedDevice+RZBBatteryLevel.h"
#import "CBUUID+RZBPublic.h"
#import "RZBLog.h"

@interface RZBProfileBatteryTests : RZBSimulatedTestCase

Expand Down
1 change: 0 additions & 1 deletion RZBluetoothTests/RZBProfileDeviceInfoTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//

#import "RZBSimulatedTestCase.h"
#import "RZBDeviceInfo.h"

@interface RZBProfileDeviceInfoTests : RZBSimulatedTestCase
@property (strong, nonatomic) RZBDeviceInfo *deviceInfo;
Expand Down
17 changes: 3 additions & 14 deletions RZBluetoothTests/RZBSimulatedTestCase.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// RZBProfileTestCase.h
// RZBSimulatedTestCase.h
// RZBluetooth
//
// Created by Brian King on 8/4/15.
Expand All @@ -8,19 +8,8 @@

@import XCTest;

#import "RZBCentralManager.h"
#import "RZBPeripheral.h"
#import "RZBScanInfo.h"

#import "RZBMockCentralManager.h"
#import "RZBMockPeripheralManager.h"

#import "RZBSimulatedDevice.h"
#import "RZBSimulatedCentral.h"
#import "RZBSimulatedConnection.h"
#import "RZBSimulatedCallback.h"

#import "NSError+RZBMock.h"
#import "RZBluetooth/RZBluetooth.h"
#import "RZBluetooth/RZMockBluetooth.h"

/**
* The RZBSimulatedTestCase is a convience class to assist testing bluetooth code.
Expand Down
5 changes: 2 additions & 3 deletions RZBluetoothTests/RZBSimulatedTestCase.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
//

#import "RZBTestDefines.h"
#import "RZMockBluetooth.h"
#import "RZBluetooth/RZMockBluetooth.h"
#import "RZBSimulatedTestCase.h"
#import "NSRunLoop+RZBWaitFor.h"
#import "RZBCentralManager+Private.h"
#import "RZBLog.h"
#import "RZBluetooth/RZBCentralManager+Private.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's been a while... Why do we need the private header? Ideally we wouldn't, but if we can safely remove it we should.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it exposes the RZBCommandDispatch *dispatch property which is used in waitForQueueFlush and required for RZBAssertCommandCount().


@implementation RZBSimulatedTestCase

Expand Down
3 changes: 0 additions & 3 deletions RZBluetoothTests/RZBSimulatedTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
//

#import "RZBSimulatedTestCase.h"
#import "RZBPeripheral+RZBBattery.h"
#import "RZBSimulatedDevice+RZBBatteryLevel.h"
#import "CBUUID+RZBPublic.h"

@interface RZBSimulatedTests : RZBSimulatedTestCase <RZBPeripheralConnectionDelegate>

Expand Down
4 changes: 0 additions & 4 deletions RZBluetoothTests/RZBUserInteractionTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
//

#import "RZBSimulatedTestCase.h"
#import "RZBPeripheral+RZBBattery.h"
#import "RZBUserInteraction.h"
#import "RZBSimulatedDevice+RZBBatteryLevel.h"
#import "RZBErrors.h"
#import "RZBTestDefines.h"

static const NSTimeInterval DelayCausingTimeout = 1.0;
Expand Down
4 changes: 1 addition & 3 deletions RZBluetoothTests/RZBluetoothTests-Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@
// Use this file to import your target's public headers that you would like to expose to Swift.
//

#import "RZBluetooth.h"
#import "RZMockBluetooth.h"
#import "RZBSimulatedTestCase.h"
#import "RZBSimulatedTestCase.h"
2 changes: 2 additions & 0 deletions RZMockBluetooth/RZMockBluetooth.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@
#import "RZBSimulatedConnection.h"
#import "RZBSimulatedCallback.h"
#import "NSError+RZBMock.h"

#import "RZBSimulatedDevice+RZBBatteryLevel.h"
5 changes: 5 additions & 0 deletions RZMockBluetooth/Simulation/RZBSimulatedCallback.m
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ - (void)cancel
{
@synchronized(self) {
for (dispatch_source_t timer in self.timers) {
// In Xcode 9+, you can not cancel an inactive / suspended timer.
// So if the callback is paused, resume it before canceling
if (self.paused) {
dispatch_resume(timer);
}
dispatch_cancel(timer);
}
[self.timers removeAllObjects];
Expand Down