Skip to content

Commit

Permalink
LukeIS: updating the CocoaHTTPServer for iOS to the latest and greate…
Browse files Browse the repository at this point in the history
…st. Ignoring one Click Scrolling Test for iphone that is failing.

Fixes Issue 1396.
Fixes Issue 2747.
Fixes Issue 2869.
Fixes Issue 2431.

r15285
  • Loading branch information
lukeis committed Dec 28, 2011
1 parent aa5d31e commit 1fc36b7
Show file tree
Hide file tree
Showing 27 changed files with 323 additions and 961 deletions.
299 changes: 237 additions & 62 deletions iphone/iWebDriver.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// iWebDriver
//
// Copyright 2009 Google Inc.
// Copyright 2011 Software Freedom Convervancy.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -18,18 +19,18 @@

#import <Foundation/Foundation.h>
#import "HTTPResource.h"
#import "HTTPResponse.h"
#import "HTTPRedirectResponse.h"

// An HTTPResource which always responds with a particular response.
@interface HTTPStaticResource : NSObject<HTTPResource> {
id<HTTPResponse,NSObject> response;
HTTPRedirectResponse* response;
}

@property(nonatomic, retain) id<HTTPResponse,NSObject> response;
@property(nonatomic, retain) HTTPRedirectResponse* response;

- (id)initWithResponse:(id<HTTPResponse,NSObject>)theResponse;
- (id)initWithResponse:(HTTPRedirectResponse*)theResponse;

+ (HTTPStaticResource *)resourceWithResponse:(id<HTTPResponse,NSObject>)theResponse;
+ (HTTPStaticResource *)resourceWithResponse:(HTTPRedirectResponse*)theResponse;

+ (HTTPStaticResource *)redirectWithURL:(NSString *)url;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// iWebDriver
//
// Copyright 2009 Google Inc.
// Copyright 2011 Software Freedom Convervancy.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -23,7 +24,7 @@ @implementation HTTPStaticResource

@synthesize response;

- (id)initWithResponse:(id<HTTPResponse,NSObject>)theResponse
- (id)initWithResponse:(HTTPRedirectResponse*)theResponse
{
if (![super init])
return nil;
Expand All @@ -40,18 +41,20 @@ - (void)dealloc
[super dealloc];
}

+ (HTTPStaticResource *)resourceWithResponse:(id<HTTPResponse,NSObject>)theResponse
+ (HTTPStaticResource *)resourceWithResponse:(HTTPRedirectResponse*)theResponse
{
return [[[self alloc] initWithResponse:theResponse] autorelease];
}

+ (HTTPStaticResource *)redirectWithURL:(NSString *)url
{
return [self resourceWithResponse:[HTTPRedirectResponse redirectToURL:url]];
return [self resourceWithResponse:
[[HTTPRedirectResponse alloc] initWithPath:url]
];
}

// Get the HTTP response to this request
- (id<HTTPResponse,NSObject>)httpResponseForQuery:(NSString *)query
- (HTTPRedirectResponse*)httpResponseForQuery:(NSString *)query
method:(NSString *)method
withData:(NSData *)theData
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// iWebDriver
//
// Copyright 2009 Google Inc.
// Copyright 2011 Software Freedom Convervancy.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -35,7 +36,7 @@

// The index of the vdir. This will be returnd on .../vdir/ and .../vdir
// You can make this a redirect to index.html or something if you want.
@property (nonatomic, retain) id<HTTPResource> index;
@property (nonatomic, retain) NSObject* index;

// Do we redirect /foo/self to /foo/self/ or just return index?
@property (nonatomic) BOOL redirectBaseToIndex;
Expand All @@ -46,7 +47,7 @@
// Set a virtual file in the VirtualDirectory. The resource is retained.
// If resource is nil, this method removes the named resource from the
// VirtualDirectory.
- (void)setResource:(id<HTTPResource>)resource withName:(NSString *)name;
- (void)setResource:(NSObject*)resource withName:(NSString *)name;

// Remove a resource from the VirtualDirectory.
- (void)removeResourceWithName:(NSString *)name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// iWebDriver
//
// Copyright 2009 Google Inc.
// Copyright 2011 Software Freedom Convervancy.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -46,7 +47,7 @@ + (HTTPVirtualDirectory *)virtualDirectory
return [[[self alloc] init] autorelease];
}

- (void)setResource:(id<HTTPResource>)resource withName:(NSString *)name
- (void)setResource:(NSObject*)resource withName:(NSString *)name
{
[contents setValue:resource forKey:name];
}
Expand Down
3 changes: 2 additions & 1 deletion iphone/src/objc/Database.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2010 WebDriver committers
Copyright 2010 Google Inc.
Copyright 2011 Software Freedom Convervancy.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -16,7 +17,7 @@
*/

#import <Foundation/Foundation.h>
#import <HTTPVirtualDirectory.h>
#import "HTTPVirtualDirectory.h"
#import <sqlite3.h>

@interface Database : HTTPVirtualDirectory {
Expand Down
3 changes: 2 additions & 1 deletion iphone/src/objc/HTTPJSONResponse.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// iWebDriver
//
// Copyright 2009 Google Inc.
// Copyright 2011 Software Freedom Convervancy.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -17,7 +18,7 @@
// limitations under the License.

#import <Foundation/Foundation.h>
#import "HTTPResponse.h"
#import "HTTPDataResponse.h"

// |HTTPJSONResponse| wraps |HTTPDataResponse| for JSON data. It is used to
// return JSON from an HTTP method.
Expand Down
5 changes: 3 additions & 2 deletions iphone/src/objc/HTTPJSONResponse.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// iWebDriver
//
// Copyright 2009 Google Inc.
// Copyright 2011 Software Freedom Convervancy.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -41,8 +42,8 @@ + (HTTPJSONResponse *)responseWithObject:(id)object {
return [[[self alloc] initWithObject:object] autorelease];
}

- (NSString *)contentType {
return @"application/json; charset=UTF-8";
- (NSDictionary *)httpHeaders {
return [NSDictionary dictionaryWithObject:@"application/json; charset=UTF-8" forKey:@"Content-Type"];
}

@end
3 changes: 2 additions & 1 deletion iphone/src/objc/HTTPPNGResponse.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// iWebDriver
//
// Copyright 2009 Google Inc.
// Copyright 2011 Software Freedom Convervancy.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -17,7 +18,7 @@
// limitations under the License.

#import <Foundation/Foundation.h>
#import "HTTPResponse.h"
#import "HTTPDataResponse.h"

// |HTTPPNGResponse| wraps |HTTPDataResponse| for image data. It is used to
// return a PNG from an HTTP method.
Expand Down
3 changes: 2 additions & 1 deletion iphone/src/objc/HTTPResponse+Utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// iWebDriver
//
// Copyright 2009 Google Inc.
// Copyright 2011 Software Freedom Convervancy.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -17,7 +18,7 @@
// limitations under the License.

#import <Foundation/Foundation.h>
#import "HTTPResponse.h"
#import "HTTPDataResponse.h"

// The |Utility| category adds some convenience methods to HTTPDataResponse
// allowing |HTTPDataResponse|s to be created from strings.
Expand Down
8 changes: 4 additions & 4 deletions iphone/src/objc/HTTPServerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// iWebDriver
//
// Copyright 2009 Google Inc.
// Copyright 2011 Software Freedom Convervancy.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -17,7 +18,7 @@
// limitations under the License.

#import "HTTPServerController.h"
#import "WebDriverHTTPServer.h"
#import "HTTPServer.h"
#import "WebDriverHTTPConnection.h"
#import "RESTServiceMapping.h"
#import "WebDriverPreferences.h"
Expand Down Expand Up @@ -85,11 +86,10 @@ -(id) init {
UInt16 portNumber = [[WebDriverPreferences sharedInstance] serverPortNumber];
NSString* grid = [[WebDriverPreferences sharedInstance] gridLocation];

server_ = [[WebDriverHTTPServer alloc] init];
server_ = [[HTTPServer alloc] init];

[server_ setType:@"_http._tcp."];
[server_ setPort:portNumber];
[server_ setDelegate:self];
[server_ setConnectionClass:[WebDriverHTTPConnection class]];

NSError *error;
Expand Down Expand Up @@ -215,7 +215,7 @@ +(HTTPServerController*) sharedInstance {
return singleton;
}

- (NSObject<HTTPResponse> *)httpResponseForRequest:(CFHTTPMessageRef)request {
- (NSObject<HTTPResponse> *)httpResponseForRequest:(HTTPMessage*)request {
return [serviceMapping_ httpResponseForRequest:request];
}

Expand Down
4 changes: 3 additions & 1 deletion iphone/src/objc/RESTServiceMapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// iWebDriver
//
// Copyright 2009 Google Inc.
// Copyright 2011 Software Freedom Convervancy.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -19,6 +20,7 @@
#import <Foundation/Foundation.h>
#import <CFNetwork/CFNetwork.h>
#import "HTTPResponse.h"
#import "HTTPMessage.h"

@class HTTPVirtualDirectory;

Expand All @@ -36,6 +38,6 @@
- (id) initWithIpAddress:(NSString *)ipAddress
port:(int)port;

- (NSObject<HTTPResponse> *)httpResponseForRequest:(CFHTTPMessageRef)request;
- (NSObject<HTTPResponse> *)httpResponseForRequest:(HTTPMessage*)request;

@end
Loading

0 comments on commit 1fc36b7

Please sign in to comment.