Skip to content

Commit

Permalink
Conditionally #import "AFHTTPSessionManager.h" so that we can still b…
Browse files Browse the repository at this point in the history
…uild with Xcode4 & SDK 6.0
  • Loading branch information
AliSoftware committed Oct 6, 2013
1 parent 6895883 commit 93a41fc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
11 changes: 9 additions & 2 deletions OHHTTPStubs/UnitTests/Test Suites/AFNetworkingTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,18 @@


#import "AsyncSenTestCase.h"
#import "AFHTTPRequestOperation.h"
#import "AFHTTPSessionManager.h"
#import "OHHTTPStubs.h"
#import "OHHTTPStubsResponse+JSON.h"

#import "AFHTTPRequestOperation.h"

// Note: because AFNetworking conditionally compiles AFHTTPSessionManager only when the deployment target
// is iOS 7+, these tests will only be run when the tests are built for deployment on iOS 7+.
// Otherwise, compilation will fail.
#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000)
#import "AFHTTPSessionManager.h"
#endif

@interface AFNetworkingTests : AsyncSenTestCase @end

@implementation AFNetworkingTests
Expand Down
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,19 @@ When building the `OHHTTPStubsResponse` object, you can specify a response time
If you specify a negative value for the responseTime parameter, instead of being interpreted as a time in seconds, it will be interpreted as a download speed in KBytes/s. In that case, the response time will be computed using the size of the response's data to simulate the indicated download speed.

The `OHHTTPStubsResponse` header defines some constants for standard download speeds:
* `OHHTTPStubsDownloadSpeedGPRS` : 56 kbps (7 KB/s)
* `OHHTTPStubsDownloadSpeedEDGE` : 128 kbps (16 KB/s)
* `OHHTTPStubsDownloadSpeed3G` : 3200 kbps (400 KB/s)
* `OHHTTPStubsDownloadSpeed3GPlus` : 7200 kbps (900 KB/s)
* `OHHTTPStubsDownloadSpeedWifi` : 12000 kbps (1500 KB/s)

```
OHHTTPStubsDownloadSpeedGPRS = -7 = 7 KB/s = 56 kbps
OHHTTPStubsDownloadSpeedEDGE = -16 = 16 KB/s = 128 kbps
OHHTTPStubsDownloadSpeed3G = -400 = 400 KB/s = 3200 kbps
OHHTTPStubsDownloadSpeed3GPlus = -900 = 900 KB/s = 7200 kbps
OHHTTPStubsDownloadSpeedWifi = -1500 = 1500 KB/s = 12000 kbps
```

Example:

return [[OHHTTPStubsResponse responseWithData:nil statusCode:400 headers:nil] responseTime:OHHTTPStubsDownloadSpeed3G];
return [[OHHTTPStubsResponse responseWithData:nil statusCode:400 headers:nil]
responseTime:OHHTTPStubsDownloadSpeed3G];



Expand Down Expand Up @@ -180,7 +184,7 @@ You can then list all the installed stubs using `[OHHTTPStubs allStubs]`, which
You can also setup a block to execute each time a request has been stubbed, using `onStubActivation:` method, typically to log the stub being used for each request:

[OHHTTPStubs onStubActivation:^(NSURLRequest *request, id<OHHTTPStubsDescriptor> stub) {
NSLog(@"%@ stubbed %@", request.URL, stub.name);
NSLog(@"%@ stubbed by %@", request.URL, stub.name);
}];

### OHHTTPStubs and NSURLSession
Expand Down

0 comments on commit 93a41fc

Please sign in to comment.