Skip to content

Commit

Permalink
Fixed UISwitch playback.
Browse files Browse the repository at this point in the history
Playback now begins at currently selected command.
Double-tapping will play individual command.
Ignore filenames starting with "."


git-svn-id: https://svn.gorillalogic.com/svn/fonemonkey4/trunk@74 72bb13d0-f000-403e-beb8-1553beae081e
  • Loading branch information
sstern committed Jan 31, 2011
1 parent 3380c1d commit e3e5610
Show file tree
Hide file tree
Showing 8 changed files with 214 additions and 11 deletions.
2 changes: 1 addition & 1 deletion FMBuildStampDefines.h
@@ -1,2 +1,2 @@
#define FM_BUILD_STAMP @"BUILD 110119.1020"
#define FM_BUILD_STAMP @"BUILD 110130.1954"
#define FM_VERSION @"4.0.d"
31 changes: 31 additions & 0 deletions FMEventViewCell.h
@@ -0,0 +1,31 @@
/* This file is part of FoneMonkey.
FoneMonkey is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
FoneMonkey is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FoneMonkey. If not, see <http://www.gnu.org/licenses/>. */


//
// FMEventViewCell.h
// FoneMonkey
//
// Created by Stuart Stern on 1/30/11.
// Copyright 2011 Gorilla Logic, Inc. All rights reserved.
//
#import <Foundation/Foundation.h>


@interface FMEventViewCell : UITableViewCell {
NSInteger commandNumber;
}
@property NSInteger commandNumber;
@end
38 changes: 38 additions & 0 deletions FMEventViewCell.m
@@ -0,0 +1,38 @@
/* This file is part of FoneMonkey.
FoneMonkey is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
FoneMonkey is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FoneMonkey. If not, see <http://www.gnu.org/licenses/>. */


//
// FMEventViewCell.m
// FoneMonkey
//
// Created by Stuart Stern on 1/30/11.
// Copyright 2011 Gorilla Logic, Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "FoneMonkey.h"
#import "FMEventViewCell.h"


@implementation FMEventViewCell
@synthesize commandNumber;
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
if ([(UITouch*)[touches anyObject] tapCount] > 1 ){
[[FoneMonkey sharedMonkey] playFrom:commandNumber numberOfCommands:1];
}
[super touchesEnded:touches withEvent:event];
}
@end
1 change: 1 addition & 0 deletions FMUtils.m
Expand Up @@ -283,6 +283,7 @@ + (void) shake {
//[[UIApplication sharedApplication] sendEvent:m]; // Works in simulator but not on device
[[[UIApplication sharedApplication] keyWindow] motionBegan:UIEventSubtypeMotionShake withEvent:m];
[[[UIApplication sharedApplication] keyWindow] motionEnded:UIEventSubtypeMotionShake withEvent:m];
[m release];
}

+ (void) rotate:(UIInterfaceOrientation)orientation {
Expand Down
34 changes: 31 additions & 3 deletions FoneMonkey.m
Expand Up @@ -288,6 +288,20 @@ - (void) play:(BOOL)waitUntilDone {
return;
}

- (void) playFrom:(NSUInteger)index {
state = FMStatePlaying;
NSThread* thread = [[NSThread alloc] initWithTarget:self selector:@selector(runCommandsStartingFrom:) object:[NSNumber numberWithInteger:index]];
[thread start];

}

- (void) playFrom:(NSUInteger)index numberOfCommands:(NSUInteger)count{
state = FMStatePlaying;
NSThread* thread = [[NSThread alloc] initWithTarget:self selector:@selector(runCommandRange:) object:[NSArray arrayWithObjects:[NSNumber numberWithInteger:index],[NSNumber numberWithInteger:count],nil]];
[thread start];

}

- (NSString*) playAndWait {
state = FMStatePlaying;
[_console performSelectorOnMainThread:@selector(hideConsoleAndThen:) withObject:nil waitUntilDone:YES];
Expand Down Expand Up @@ -382,14 +396,25 @@ - (void) loadCommands:(NSArray*) cmds {
}
}


- (void) runCommands {
[self runCommandsStartingFrom:0 numberOfCommands:[commands count]];
}

- (void) runCommandsStartingFrom:(NSNumber*)start {
[self runCommandsStartingFrom:[start intValue] numberOfCommands:([commands count] - [start intValue])];
}

- (void) runCommandRange:(NSArray*)array {
[self runCommandsStartingFrom:[[array objectAtIndex:0] intValue] numberOfCommands:[[array objectAtIndex:1] intValue]];
}

- (void) runCommandsStartingFrom:(NSInteger)start numberOfCommands:(NSInteger)count{
// We're a thread
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

BOOL failure = NO;
int i;
for (i = 0; i < [commands count]; i++) {
for (i = start; i < start + count; i++) {
FMCommandEvent* nextCommandToRun = [self commandAt:i];
nextCommandToRun.lastResult = nil;
if (failure) {
Expand Down Expand Up @@ -524,6 +549,9 @@ - (NSArray*) scripts {
NSString* scriptsLocation = [FMUtils scriptsLocation];
for (int i=0; i<[paths count]; i++) {
NSString* path = [paths objectAtIndex:i];
if ([path hasPrefix:@"."]) {
continue;
}
NSString* fullPath = [scriptsLocation stringByAppendingPathComponent:path];
if ([fileManager fileExistsAtPath:fullPath isDirectory:&isDirectory]) {
if (!isDirectory) {
Expand Down Expand Up @@ -699,7 +727,7 @@ - (BOOL) assureUIAutomationScriptSupport {
NSError* error;
NSString* s = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error];
if (!s) {
NSLog(@"Unable to create objective-c file: Unable to read FoneMonkey.js resource: %@", [error description]);
NSLog(@"Unable to create uiautomation file: Unable to read FoneMonkey.js resource: %@", [error description]);
return false;
}
NSLog(@"writing FoneMonkey.js to file %@", supportScriptFile);
Expand Down
99 changes: 96 additions & 3 deletions FoneMonkey.xcodeproj/project.pbxproj
Expand Up @@ -7,6 +7,17 @@
objects = {

/* Begin PBXAggregateTarget section */
151F3C1F12F215E00067A732 /* Clean Dist */ = {
isa = PBXAggregateTarget;
buildConfigurationList = 151F3C2912F216200067A732 /* Build configuration list for PBXAggregateTarget "Clean Dist" */;
buildPhases = (
151F3C1E12F215E00067A732 /* ShellScript */,
);
dependencies = (
);
name = "Clean Dist";
productName = "Clean Dist";
};
D34D972C1223200C001D0B47 /* Distribution */ = {
isa = PBXAggregateTarget;
buildConfigurationList = D34D972F1223202C001D0B47 /* Build configuration list for PBXAggregateTarget "Distribution" */;
Expand All @@ -21,6 +32,8 @@
D34D974C122321CA001D0B47 /* Build Zip File */,
);
dependencies = (
151F3C2612F216020067A732 /* PBXTargetDependency */,
151F3C2412F215FD0067A732 /* PBXTargetDependency */,
);
name = Distribution;
productName = Distribution;
Expand All @@ -39,7 +52,8 @@
/* End PBXAggregateTarget section */

/* Begin PBXBuildFile section */
1536BAE712CC3A4C0012874A /* FoneMonkey.js in Sources */ = {isa = PBXBuildFile; fileRef = 1536BAE612CC3A4C0012874A /* FoneMonkey.js */; };
151F3EB812F623770067A732 /* FMEventViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 151F3EB612F623770067A732 /* FMEventViewCell.h */; };
151F3EB912F623770067A732 /* FMEventViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 151F3EB712F623770067A732 /* FMEventViewCell.m */; };
1546322E12DACE9800BAE9B2 /* UISwitch+FMReady.h in Headers */ = {isa = PBXBuildFile; fileRef = 1546322C12DACE9800BAE9B2 /* UISwitch+FMReady.h */; };
1546322F12DACE9800BAE9B2 /* UISwitch+FMReady.m in Sources */ = {isa = PBXBuildFile; fileRef = 1546322D12DACE9800BAE9B2 /* UISwitch+FMReady.m */; };
15492567128A4FC60050B2EA /* UIPickerView+FMReady.h in Headers */ = {isa = PBXBuildFile; fileRef = 15492565128A4FC60050B2EA /* UIPickerView+FMReady.h */; };
Expand Down Expand Up @@ -144,6 +158,23 @@
D3B91517123033C4003C5BB0 /* UITabBarButtonLabelProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = D3B91516123033C4003C5BB0 /* UITabBarButtonLabelProxy.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
151F3C2312F215FD0067A732 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */;
proxyType = 1;
remoteGlobalIDString = 151F3C1F12F215E00067A732 /* Clean Dist */;
remoteInfo = "Clean Dist";
};
151F3C2512F216020067A732 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */;
proxyType = 1;
remoteGlobalIDString = D34D973012232031001D0B47 /* Clean */;
remoteInfo = Clean;
};
/* End PBXContainerItemProxy section */

/* Begin PBXCopyFilesBuildPhase section */
15AC429E1289059E00A18460 /* Copy Readme */ = {
isa = PBXCopyFilesBuildPhase;
Expand Down Expand Up @@ -239,6 +270,8 @@

/* Begin PBXFileReference section */
1511032612C406AA00246792 /* FMRotate.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = FMRotate.png; path = images/FMRotate.png; sourceTree = "<group>"; };
151F3EB612F623770067A732 /* FMEventViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMEventViewCell.h; sourceTree = "<group>"; };
151F3EB712F623770067A732 /* FMEventViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMEventViewCell.m; sourceTree = "<group>"; };
1536BAE612CC3A4C0012874A /* FoneMonkey.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = FoneMonkey.js; sourceTree = "<group>"; };
1546322C12DACE9800BAE9B2 /* UISwitch+FMReady.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UISwitch+FMReady.h"; sourceTree = "<group>"; };
1546322D12DACE9800BAE9B2 /* UISwitch+FMReady.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UISwitch+FMReady.m"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -450,6 +483,8 @@
D34D960B12230DFD001D0B47 /* FMSaveScriptDialog.h */,
D34D960C12230DFD001D0B47 /* FMSaveScriptDialog.m */,
8D1107310486CEB800E47090 /* FoneMonkey-Info.plist */,
151F3EB612F623770067A732 /* FMEventViewCell.h */,
151F3EB712F623770067A732 /* FMEventViewCell.m */,
);
name = Shared;
sourceTree = "<group>";
Expand Down Expand Up @@ -677,6 +712,7 @@
1558766912885C0A003541C0 /* UITableViewCellContentViewProxy.h in Headers */,
15492567128A4FC60050B2EA /* UIPickerView+FMReady.h in Headers */,
1546322E12DACE9800BAE9B2 /* UISwitch+FMReady.h in Headers */,
151F3EB812F623770067A732 /* FMEventViewCell.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -752,11 +788,25 @@
D34D975212232255001D0B47 /* FoneMonkeyOCUnit */,
D34D972C1223200C001D0B47 /* Distribution */,
D34D973012232031001D0B47 /* Clean */,
151F3C1F12F215E00067A732 /* Clean Dist */,
);
};
/* End PBXProject section */

/* Begin PBXShellScriptBuildPhase section */
151F3C1E12F215E00067A732 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "echo \"************ Prepare ****************\"\nrm -rf ${PROJECT_DIR}/Dist\nmkdir -p ${PROJECT_DIR}/Dist/FoneMonkey/lib\nmkdir -p ${PROJECT_DIR}/Dist/FoneMonkey/docs\nmkdir -p ${PROJECT_DIR}/Dist/FoneMonkey/include\nmkdir -p ${PROJECT_DIR}/Dist/FoneMonkey/resources\n";
};
D30FA7811223303D00796ABE /* Build Library */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -795,7 +845,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "echo \"************ Clean *************\"\nrm -rf ${CONFIGURATION_TEMP_DIR}";
shellScript = "echo \"************ Clean *************\"\nrm -rf ${CONFIGURATION_TEMP_DIR}\n";
};
D34D97381223208E001D0B47 /* Prepare Dist Dir */ = {
isa = PBXShellScriptBuildPhase;
Expand Down Expand Up @@ -883,8 +933,8 @@
D3B91517123033C4003C5BB0 /* UITabBarButtonLabelProxy.m in Sources */,
1558766A12885C0A003541C0 /* UITableViewCellContentViewProxy.m in Sources */,
15492568128A4FC60050B2EA /* UIPickerView+FMReady.m in Sources */,
1536BAE712CC3A4C0012874A /* FoneMonkey.js in Sources */,
1546322F12DACE9800BAE9B2 /* UISwitch+FMReady.m in Sources */,
151F3EB912F623770067A732 /* FMEventViewCell.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -898,7 +948,41 @@
};
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
151F3C2412F215FD0067A732 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 151F3C1F12F215E00067A732 /* Clean Dist */;
targetProxy = 151F3C2312F215FD0067A732 /* PBXContainerItemProxy */;
};
151F3C2612F216020067A732 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = D34D973012232031001D0B47 /* Clean */;
targetProxy = 151F3C2512F216020067A732 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */

/* Begin XCBuildConfiguration section */
151F3C2112F215E00067A732 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
PRODUCT_NAME = "Clean Dist";
};
name = Debug;
};
151F3C2212F215E00067A732 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_ENABLE_FIX_AND_CONTINUE = NO;
PRODUCT_NAME = "Clean Dist";
ZERO_LINK = NO;
};
name = Release;
};
C01FCF4F08A954540054247B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
Expand Down Expand Up @@ -1046,6 +1130,15 @@
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
151F3C2912F216200067A732 /* Build configuration list for PBXAggregateTarget "Clean Dist" */ = {
isa = XCConfigurationList;
buildConfigurations = (
151F3C2112F215E00067A732 /* Debug */,
151F3C2212F215E00067A732 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
C01FCF4E08A954540054247B /* Build configuration list for PBXProject "FoneMonkey" */ = {
isa = XCConfigurationList;
buildConfigurations = (
Expand Down
7 changes: 6 additions & 1 deletion UISwitch+FMReady.m
Expand Up @@ -27,14 +27,19 @@
#import "FMCommandEvent.h"

@implementation UISwitch (FMReady)
- (void) playbackMonkeyEvent:(id)event {
// toggles
[self setOn:!self.on animated:YES];
}

+ (NSString*) uiAutomationCommand:(FMCommandEvent*)command {

if ([command.command isEqualToString:FMCommandSwitch]) {
return [NSString stringWithFormat:@"FoneMonkey.toggleSwitch(\"%@\"); // UIASwitch",
[FMUtils stringByJsEscapingQuotesAndNewlines:command.monkeyID]];
}

return [super uiAutomationCommand];
return [super uiAutomationCommand:command];

}
@end

0 comments on commit e3e5610

Please sign in to comment.