Skip to content

Commit

Permalink
Disables app when running tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Guido Marucci Blas committed Mar 11, 2015
1 parent 9d753c7 commit 6f3dbb2
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
Expand Up @@ -25,7 +25,7 @@
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldUseLaunchSchemeArgsEnv = "NO"
buildConfiguration = "Debug">
<Testables>
<TestableReference
Expand All @@ -48,6 +48,13 @@
ReferencedContainer = "container:WLXBluetoothDevice.xcodeproj">
</BuildableReference>
</MacroExpansion>
<EnvironmentVariables>
<EnvironmentVariable
key = "TEST"
value = "YES"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
Expand All @@ -58,7 +65,8 @@
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6003F589195388D20070C39A"
Expand All @@ -76,7 +84,8 @@
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6003F589195388D20070C39A"
Expand Down
4 changes: 2 additions & 2 deletions Example/WLXBluetoothDevice/Base.lproj/Main_iPhone.storyboard
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6250" systemVersion="13F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="eQ8-Jx-xM4">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6751" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="eQ8-Jx-xM4">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6244"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6736"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
</dependencies>
<scenes>
Expand Down
7 changes: 6 additions & 1 deletion Example/WLXBluetoothDevice/WLXApplication.m
Expand Up @@ -21,12 +21,17 @@ + (instancetype)sharedInstance {

- (instancetype)init {
self = [super init];
if (self) {
if (self && ![self isTestMode]) {
_bluetoothDeviceManager = [WLXBluetoothDeviceManager deviceManager];
id repository = [[WLXBluetoothDeviceUserDefaultsRepository alloc] initWithUserDefaults:[NSUserDefaults standardUserDefaults]];
_bluetoothDeviceRegistry = [_bluetoothDeviceManager deviceRegistryWithRepository:repository];
}
return self;
}

- (BOOL)isTestMode {
NSDictionary* environment = [[NSProcessInfo processInfo] environment];
return [environment objectForKey:@"TEST"] != nil;
}

@end
15 changes: 15 additions & 0 deletions Example/WLXBluetoothDevice/WLXConnectViewController.m
Expand Up @@ -32,6 +32,9 @@ @interface WLXConnectViewController ()<WLXDiscoverViewControllerDelegate, WLXCon
@implementation WLXConnectViewController

- (void)viewDidLoad {
if ([self isTestMode]) {
return;
}
self.notificationCenter = [NSNotificationCenter defaultCenter];
self.deviceManager = [WLXApplication sharedInstance].bluetoothDeviceManager;
self.deviceRegistry = [WLXApplication sharedInstance].bluetoothDeviceRegistry;
Expand All @@ -43,11 +46,17 @@ - (void)viewDidLoad {
}

- (void)viewWillAppear:(BOOL)animated {
if ([self isTestMode]) {
return;
}
[self reloadUI];
[self registerNotificationHandlers];
}

- (void)viewWillDisappear:(BOOL)animated {
if ([self isTestMode]) {
return;
}
[self unregisterNotificationHandlers];
}

Expand Down Expand Up @@ -249,4 +258,10 @@ - (void)showServiceDiscoveryErrorAlert:(NSError *)error {
otherButtonTitles:nil] show];
}

- (BOOL)isTestMode {
NSDictionary* environment = [[NSProcessInfo processInfo] environment];
return [environment objectForKey:@"TEST"] != nil;
}


@end

0 comments on commit 6f3dbb2

Please sign in to comment.