Skip to content

Commit

Permalink
Merge pull request #215 from linkedin/video_upload
Browse files Browse the repository at this point in the history
Add capabilities to add video/image to simulator
  • Loading branch information
oliverhu committed Nov 2, 2017
2 parents 6faa025 + 5939b6c commit 09e48ee
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 5 deletions.
7 changes: 7 additions & 0 deletions Bluepill-cli/BPInstanceTests/BPTestHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,11 @@

// Return the derivedDataPath
+ (NSString *)derivedDataPath;

// Return path to the sample video file.
+ (NSString *)sampleVideoPath;

// Return the sample photo path.
+ (NSString *)samplePhotoPath;

@end
8 changes: 8 additions & 0 deletions Bluepill-cli/BPInstanceTests/BPTestHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ + (NSString *)sampleAppUITestBundlePath {
return [[self sampleAppUITestRunnerPath] stringByAppendingString:@"/PlugIns/BPSampleAppUITests.xctest"];
}

+ (NSString *)sampleVideoPath {
return [[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"demo.mov"];
}

+ (NSString *)samplePhotoPath {
return [[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"image.png"];
}

+ (NSString *)bpExecutablePath {
return [[[[NSBundle bundleForClass:[self class]] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"bp"];
}
Expand Down
1 change: 1 addition & 0 deletions Bluepill-cli/BPInstanceTests/BluepillTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ - (void)setUp {
self.config.plainOutput = NO;
self.config.jsonOutput = NO;
self.config.headlessMode = YES;
self.config.videoPaths = @[[BPTestHelper sampleVideoPath]];
self.config.junitOutput = NO;
self.config.testRunnerAppPath = nil;
self.config.testing_CrashAppOnLaunch = NO;
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 21 additions & 1 deletion Bluepill-cli/Bluepill-cli.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
BA4BCFD11DC4888800592FA4 /* hanging_tests.xml in Resources */ = {isa = PBXBuildFile; fileRef = BA4BCFD01DC4888800592FA4 /* hanging_tests.xml */; };
BA53B16C1E30931E00FCED71 /* BPConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = BA53B16B1E30931E00FCED71 /* BPConstants.m */; };
BA53B1701E30A0F100FCED71 /* BPConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = BA53B16B1E30931E00FCED71 /* BPConstants.m */; };
BA6E53021FA8F9FD00D80675 /* demo.mov in Resources */ = {isa = PBXBuildFile; fileRef = BA6E53011FA8F9F100D80675 /* demo.mov */; };
BA6E53061FA8FA2500D80675 /* image.png in Resources */ = {isa = PBXBuildFile; fileRef = BA6E53051FA8FA2000D80675 /* image.png */; };
BA944BD01D76A39A00A4BDA3 /* Bluepill.m in Sources */ = {isa = PBXBuildFile; fileRef = BA944BCF1D76A39A00A4BDA3 /* Bluepill.m */; };
BA9C2DE01DD84A72007CB967 /* fatal_tests.xml in Resources */ = {isa = PBXBuildFile; fileRef = BA9C2DDF1DD84A72007CB967 /* fatal_tests.xml */; };
BAB24F711DB5DBED00867756 /* SimulatorHelperTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BAB24F701DB5DBED00867756 /* SimulatorHelperTests.m */; };
Expand Down Expand Up @@ -180,6 +182,8 @@
BA4BCFD01DC4888800592FA4 /* hanging_tests.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = hanging_tests.xml; sourceTree = "<group>"; };
BA53B16A1E30931E00FCED71 /* BPConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BPConstants.h; sourceTree = "<group>"; };
BA53B16B1E30931E00FCED71 /* BPConstants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BPConstants.m; sourceTree = "<group>"; };
BA6E53011FA8F9F100D80675 /* demo.mov */ = {isa = PBXFileReference; lastKnownFileType = video.quicktime; path = demo.mov; sourceTree = "<group>"; };
BA6E53051FA8FA2000D80675 /* image.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = image.png; sourceTree = "<group>"; };
BA944BCE1D76A39A00A4BDA3 /* Bluepill.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bluepill.h; sourceTree = "<group>"; };
BA944BCF1D76A39A00A4BDA3 /* Bluepill.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bluepill.m; sourceTree = "<group>"; };
BA954F571D6D1AB3007D011D /* CDStructures.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CDStructures.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -393,6 +397,8 @@
BA180A0A1DBB011200D7D130 /* Resource Files */ = {
isa = PBXGroup;
children = (
BA6E53011FA8F9F100D80675 /* demo.mov */,
BA6E53051FA8FA2000D80675 /* image.png */,
C4FAC2941E5E67ED00ACC5D9 /* testConfig-busted.json */,
7AA4C2281E4A797E00FAA39E /* multiple_reports_for_one_error.log */,
7A4FB8E71DFB66980073F268 /* error_only_crash.log */,
Expand Down Expand Up @@ -649,7 +655,7 @@
7A79017A1D5CB679004D4325 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0810;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = LinkedIn;
TargetAttributes = {
7A7901811D5CB679004D4325 = {
Expand Down Expand Up @@ -686,6 +692,8 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
BA6E53061FA8FA2500D80675 /* image.png in Resources */,
BA6E53021FA8F9FD00D80675 /* demo.mov in Resources */,
C4FAC2951E5E67ED00ACC5D9 /* testConfig-busted.json in Resources */,
BA180A141DBB088100D7D130 /* testScheme.xcscheme in Resources */,
BA0C554D1DDAE241009E1377 /* failure_retry_report.xml in Resources */,
Expand Down Expand Up @@ -796,15 +804,21 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
Expand Down Expand Up @@ -845,15 +859,21 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
Expand Down
31 changes: 29 additions & 2 deletions Bluepill-cli/Bluepill-cli/Simulator/BPSimulator.m
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ - (SimDevice *)findDeviceWithConfig:(BPConfiguration *)config andDeviceID:(NSUUI
}

- (NSRunningApplication *)findSimGUIApp {
NSString * cmd = [NSString stringWithFormat:@"ps -A | grep 'Simulator\\.app'"];
NSString * output = [[BPUtils runShell:cmd] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSString *cmd = [NSString stringWithFormat:@"ps -A | grep 'Simulator\\.app'"];
NSString *output = [[BPUtils runShell:cmd] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSArray *fields = [output componentsSeparatedByString: @" "];
if ([fields count] > 0) {
NSString *pidStr = [fields objectAtIndex:0];
Expand All @@ -170,7 +170,34 @@ - (NSRunningApplication *)findSimGUIApp {
return nil;
}

- (void)addVideosToSimulator {
for (NSString *urlString in self.config.videoPaths) {
NSURL *videoUrl = [NSURL URLWithString:urlString];
NSError *error;
BOOL uploadResult = [self.device addVideo:videoUrl error:&error];
if (!uploadResult) {
[BPUtils printInfo:ERROR withString:[NSString stringWithFormat:@"Failed to upload video at path: %@, error message: %@", urlString, [error description]]];
}
}
}

- (void)addPhotosToSimulator {
for (NSString *urlString in self.config.imagePaths) {
NSURL *photoUrl = [NSURL URLWithString:urlString];
NSError *error;
BOOL uploadResult = [self.device addPhoto:photoUrl error:&error];
if (!uploadResult) {
[BPUtils printInfo:ERROR withString:[NSString stringWithFormat:@"Failed to upload photo at path: %@, error message: %@", urlString, [error description]]];
}
}
}

- (BOOL)installApplicationAndReturnError:(NSError *__autoreleasing *)error {
// Add photos and videos to the simulator.
[self addPhotosToSimulator];
[self addVideosToSimulator];

// Install the app
NSString *hostBundleId = [SimulatorHelper bundleIdForPath:self.config.appBundlePath];
NSString *hostBundlePath = self.config.appBundlePath;

Expand Down
14 changes: 13 additions & 1 deletion Bluepill-runner/Bluepill.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@
BAEF4B2C1DAC539400E68294 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0810;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = LinkedIn;
TargetAttributes = {
BA1809DF1DBA8FB100D7D130 = {
Expand Down Expand Up @@ -426,15 +426,21 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
Expand Down Expand Up @@ -475,15 +481,21 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
Expand Down
3 changes: 3 additions & 0 deletions Source/Shared/BPConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ typedef NS_ENUM(NSInteger, BPProgram) {
@property (nonatomic, strong) NSArray<NSString *> *commandLineArguments; // command line arguments for the app
@property (nonatomic, strong) NSDictionary<NSString *, NSString *> *environmentVariables;

// Media Assets
@property (nonatomic, strong) NSArray<NSString *> *videoPaths; // The videos to be pushed into each simulator.
@property (nonatomic, strong) NSArray<NSString *> *imagePaths; // The images to be pushed into each simulator.

// These fields are for testing.
@property (nonatomic) BOOL testing_CrashAppOnLaunch;
Expand Down
4 changes: 4 additions & 0 deletions Source/Shared/BPConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ typedef NS_OPTIONS(NSUInteger, BPOptionType) {
"Do not create a simulator but reuse the one with the UDID given. (BP INTERNAL USE ONLY). "},
{'D', "delete-simulator", BP_SLAVE, NO, NO, required_argument, NULL, BP_VALUE, "deleteSimUDID",
"The device UUID of simulator to delete. Using this option enables a DELETE-ONLY-MODE. (BP INTERNAL USE ONLY). "},
{'V', "video-paths", BP_MASTER | BP_SLAVE, NO, NO, required_argument, NULL, BP_LIST | BP_PATH, "videoPaths",
"Paths to the videos to be uploaded."},
{'I', "image-paths", BP_MASTER | BP_SLAVE, NO, NO, required_argument, NULL, BP_LIST | BP_PATH, "imagePaths",
"Paths to the images to be uploaded."},

// options with no argument
{'H', "headless", BP_MASTER | BP_SLAVE, NO, NO, no_argument, "Off", BP_VALUE | BP_BOOL , "headlessMode",
Expand Down
2 changes: 1 addition & 1 deletion scripts/bluepill.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ bluepill_build_sample_app()
-workspace Bluepill.xcworkspace \
-scheme BPSampleApp \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 7,OS=11.0' \
-destination 'platform=iOS Simulator,name=iPhone 7,OS=11.0.1' \
-derivedDataPath "build/" 2>&1 | tee result.txt | $XCPRETTY

test $? == 0 || {
Expand Down

0 comments on commit 09e48ee

Please sign in to comment.