Skip to content

Commit

Permalink
SimonStewart: Getting the iphone driver to compile again
Browse files Browse the repository at this point in the history
r13286
  • Loading branch information
shs96c committed Aug 8, 2011
1 parent 92799a3 commit 3da107a
Show file tree
Hide file tree
Showing 4 changed files with 4,290 additions and 2,298 deletions.
1 change: 0 additions & 1 deletion iphone/iWebDriver.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,6 @@
isa = PBXProject;
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "iWebDriver" */;
compatibilityVersion = "Xcode 3.1";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
English,
Expand Down
2 changes: 1 addition & 1 deletion iphone/src/objc/HTTPVirtualDirectory+ExecuteScript.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
// http://code.google.com/p/selenium/wiki/JsonWireProtocol
//
// Returns the script result; throws an exception if it fails.
-(id) executeAtom:(const char* const)atom
-(id) executeAtom:(const char* const[])atom
withArgs:(NSArray*) arguments;

// Executes a JavaScript function in the |UIViewController|. Each script
Expand Down
23 changes: 19 additions & 4 deletions iphone/src/objc/HTTPVirtualDirectory+ExecuteScript.mm
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,14 @@ -(NSDictionary*) waitForData {

@implementation HTTPVirtualDirectory (ExecuteScript)

-(id) executeAtom:(const char* const)atom
-(id) executeAtom:(const char* const[])atom
withArgs:(NSArray*) args {
return [self executeJsFunction:[NSString stringWithUTF8String:atom]
std::string compiled("");
for (size_t i = 0; atom[i] != NULL; i++) {
compiled.append(atom[i]);
}

return [self executeJsFunction:[NSString stringWithCString:compiled.c_str() encoding:NSUTF8StringEncoding]
withArgs:args];
}

Expand All @@ -136,8 +141,13 @@ -(id) verifyResult:(NSDictionary*)resultDict {

-(id) executeScript:(NSString*)script
withArgs:(NSArray*)args {
std::string compiled("");
for (size_t i = 0; webdriver::atoms::EXECUTE_SCRIPT[i] != NULL; i++) {
compiled.append(webdriver::atoms::EXECUTE_SCRIPT[i]);
}

NSString* result = [[self viewController] jsEval:@"(%@)(%@,%@,true)",
[NSString stringWithUTF8String:webdriver::atoms::EXECUTE_SCRIPT],
[NSString stringWithCString:compiled.c_str() encoding:NSUTF8StringEncoding],
script,
[args JSONRepresentation]];
NSLog(@"Got result: %@", result);
Expand Down Expand Up @@ -165,8 +175,13 @@ -(id) executeAsyncJsFunction:(NSString*)script
[SimpleObserver simpleObserverForAction:@"webdriver:executeAsyncScript"
andSender:[self viewController]];

std::string compiled("");
for (size_t i = 0; webdriver::atoms::EXECUTE_ASYNC_SCRIPT[i] != NULL; i++) {
compiled.append(webdriver::atoms::EXECUTE_ASYNC_SCRIPT[i]);
}

[[self viewController] jsEval:@"(%@)(function(){%@\n},%@,%@)",
[NSString stringWithUTF8String:webdriver::atoms::EXECUTE_ASYNC_SCRIPT],
[NSString stringWithCString:compiled.c_str() encoding:NSUTF8StringEncoding],
script,
[args JSONRepresentation],
[NSNumber numberWithDouble:timeout * 1000]];
Expand Down
Loading

0 comments on commit 3da107a

Please sign in to comment.