Skip to content

Commit

Permalink
Initial Commit 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
lawrencelomax committed Sep 10, 2015
0 parents commit 5a9f5f4
Show file tree
Hide file tree
Showing 640 changed files with 25,981 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## Build generated
build/
DerivedData

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
xcuserdata/

## Other
*.xccheckout
*.moved-aside
*.xcuserstate
*.xcscmblueprint

## Obj-C/Swift specific
*.hmap
*.ipa

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
Pods/
FBSimulatorControl.xcworkspace

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build
33 changes: 33 additions & 0 deletions CONTRIBUTING
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Contributing to FBSimulatorControl
We want to make contributing to this project as easy and transparent as
possible.

## Pull Requests
We actively welcome your pull requests.

1. Fork the repo and create your branch from `master`.
2. If you've added code that should be tested, add tests.
3. If you've changed APIs, update the documentation.
4. Ensure the test suite passes.
6. If you haven't already, complete the Contributor License Agreement ("CLA").

## Contributor License Agreement ("CLA")
In order to accept your pull request, we need you to submit a CLA. You only need
to do this once to work on any of Facebook's open source projects.

Complete your CLA here: <https://code.facebook.com/cla>

## Issues
We use GitHub issues to track public bugs. Please ensure your description is
clear and has sufficient instructions to be able to reproduce the issue.

Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe
disclosure of security bugs. In those cases, please go through the process
outlined on that page and do not file a public issue.

## Coding Style
* 2 spaces for indentation rather than tabs

## License
By contributing to FBSimulatorControl, you agree that your contributions will be licensed
under its BSD license.
2,032 changes: 2,032 additions & 0 deletions FBSimulatorControl.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E66DC04E390C419500000000"
BuildableName = "FBSimulatorControl.framework"
BlueprintName = "FBSimulatorControl"
ReferencedContainer = "container:FBSimulatorControl.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AA819DB11B9FB40D002F58CA"
BuildableName = "FBSimulatorControlTests.xctest"
BlueprintName = "FBSimulatorControlTests"
ReferencedContainer = "container:FBSimulatorControl.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E66DC04E390C419500000000"
BuildableName = "FBSimulatorControl.framework"
BlueprintName = "FBSimulatorControl"
ReferencedContainer = "container:FBSimulatorControl.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E66DC04E390C419500000000"
BuildableName = "FBSimulatorControl.framework"
BlueprintName = "FBSimulatorControl"
ReferencedContainer = "container:FBSimulatorControl.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E66DC04E390C419500000000"
BuildableName = "FBSimulatorControl.framework"
BlueprintName = "FBSimulatorControl"
ReferencedContainer = "container:FBSimulatorControl.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
27 changes: 27 additions & 0 deletions FBSimulatorControl/FBDispatchSourceNotifier.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/

#import <Foundation/Foundation.h>

#import "FBTerminationHandle.h"

/**
A class for wrapping `dispatch_source` with some conveniences
*/
@interface FBDispatchSourceNotifier : NSObject<FBTerminationHandle>

/**
Creates and returns an `FBDispatchSourceNotifier` that will call the `handler` when the provided `processIdentifier` quits
@param processIdentifier the Process Identifier of the Process to Monitor
@param handler the handler to call when the process exits
*/
+ (instancetype)processTerminationNotifierForProcessIdentifier:(NSInteger)processIdentifier handler:(void (^)(FBDispatchSourceNotifier *))handler;

@end
63 changes: 63 additions & 0 deletions FBSimulatorControl/FBDispatchSourceNotifier.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/

#import "FBDispatchSourceNotifier.h"

@interface FBDispatchSourceNotifier ()

@property (nonatomic, strong) dispatch_source_t dispatchSource;

@end

@implementation FBDispatchSourceNotifier

+ (instancetype)processTerminationNotifierForProcessIdentifier:(NSInteger)processIdentifier handler:(void (^)(FBDispatchSourceNotifier *))handler
{
dispatch_source_t dispatchSource = dispatch_source_create(
DISPATCH_SOURCE_TYPE_PROC,
(pid_t) processIdentifier,
DISPATCH_PROC_EXIT,
DISPATCH_TARGET_QUEUE_DEFAULT
);
return [[self alloc] initWithDispatchSource:dispatchSource handler:handler];
}

- (instancetype)initWithDispatchSource:(dispatch_source_t)dispatchSource handler:(void (^)(FBDispatchSourceNotifier *))handler
{
self = [super init];
if (!self) {
return nil;
}

self.dispatchSource = dispatchSource;
__weak typeof(self) weakSelf = self;
dispatch_source_set_event_handler(dispatchSource, ^(){
__strong typeof(self) strongSelf = weakSelf;
dispatch_async(dispatch_get_main_queue(), ^{
handler(strongSelf);
});
});
dispatch_resume(dispatchSource);
return self;
}

- (void)terminate
{
if (self.dispatchSource) {
dispatch_source_cancel(self.dispatchSource);
self.dispatchSource = nil;
}
}

- (void)dealloc
{
[self terminate];
}

@end
117 changes: 117 additions & 0 deletions FBSimulatorControl/FBProcessLaunchConfiguration.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/

#import <Foundation/Foundation.h>

@class FBSimulator;
@class FBSimulatorApplication;
@class FBSimulatorBinary;

/**
An abstract value object for launching both agents and applications
*/
@interface FBProcessLaunchConfiguration : NSObject<NSCopying>

/**
An NSArray<NSString *> of arguments to the process.
*/
@property (nonatomic, copy, readonly) NSArray *arguments;

/**
A NSDictionary<NSString *, NSString *> of the Environment of the launched Application process.
*/
@property (nonatomic, copy, readonly) NSDictionary *environment;

/**
The file path where the stdout of the launched process should be written.
*/
@property (nonatomic, copy, readonly) NSString *stdOutPath;

/**
The file path where the stderr of the launched process should be written.
*/
@property (nonatomic, copy, readonly) NSString *stdErrPath;

@end

/**
A Value object with the information required to launch an Application.
*/
@interface FBApplicationLaunchConfiguration : FBProcessLaunchConfiguration

/**
Creates and returns a new Configuration with the provided parameters
@param application the Application to Launch.
@param arguments an NSArray<NSString *> of arguments to the process.
@param environment a NSDictionary<NSString *, NSString *> of the Environment of the launched Application process.
@returns a new Configuration Object with the arguments applied.
*/
+ (instancetype)configurationWithApplication:(FBSimulatorApplication *)application arguments:(NSArray *)arguments environment:(NSDictionary *)environment;

/**
Creates and returns a new Configuration with the provided parameters
@param application the Application to Launch.
@param arguments an NSArray<NSString *> of arguments to the process.
@param environment a NSDictionary<NSString *, NSString *> of the Environment of the launched Application process.
@param stdOutPath the file path where the stderr of the launched process should be written. May be nil.
@param stdErrPat The file path where the stderr of the launched process should be written. May be nil.
@returns a new Configuration Object with the arguments applied.
*/
+ (instancetype)configurationWithApplication:(FBSimulatorApplication *)application arguments:(NSArray *)arguments environment:(NSDictionary *)environment stdOutPath:(NSString *)stdOutPath stdErrPath:(NSString *)stdErrPath;

/**
The Application to Launch.
*/
@property (nonatomic, copy, readonly) FBSimulatorApplication *application;

@end

/**
A Value object with the information required to launch a Binary Agent.
*/
@interface FBAgentLaunchConfiguration : FBProcessLaunchConfiguration

/**
Creates and returns a new Configuration with the provided parameters
@param agentBinary the Binary Path of the agent to Launch
@param arguments an array-of-strings of arguments to the process
@param environment a Dictionary, mapping Strings to Strings of the Environment to set in the launched Application process
@returns a new Configuration Object with the arguments applied.
*/
+ (instancetype)configurationWithBinary:(FBSimulatorBinary *)agentBinary arguments:(NSArray *)arguments environment:(NSDictionary *)environment;

/**
Creates and returns a new Configuration with the provided parameters
@param agentBinary the Binary Path of the agent to Launch
@param arguments an array-of-strings of arguments to the process
@param environment a Dictionary, mapping Strings to Strings of the Environment to set in the launched Application process
@param stdOutPath the file path where the stderr of the launched process should be written. May be nil.
@param stdErrPat The file path where the stderr of the launched process should be written. May be nil.
@returns a new Configuration Object with the arguments applied.
*/
+ (instancetype)configurationWithBinary:(FBSimulatorBinary *)agentBinary arguments:(NSArray *)arguments environment:(NSDictionary *)environment stdOutPath:(NSString *)stdOutPath stdErrPath:(NSString *)stdErrPath;

/**
Creates and returns a new Configuration for launching WebDriverAgent. Assumes that a WebDriverAgent binary exists in the bundle.
@param simulator the Simulator to create the configuration for.
@returna new Agent Launch Configuration for the provided Simulator.
*/
+ (instancetype)defaultWebDriverAgentConfigurationForSimulator:(FBSimulator *)simulator;

/**
The Binary Path of the agent to Launch.
*/
@property (nonatomic, copy, readonly) FBSimulatorBinary *agentBinary;

@end
Loading

0 comments on commit 5a9f5f4

Please sign in to comment.