From d8cd6fce2e4a429f231bb7e9f616b6bd8043557c Mon Sep 17 00:00:00 2001 From: Olivier Halligon Date: Sat, 31 Oct 2015 21:50:50 +0100 Subject: [PATCH] Enabling NSURLSession & AFNetworking tests for tvOS - Enable NSURLSession and AFNetworking-based tests for the tvOS target - Disable tests not compatible with tvOS (because of deprecated methods used in those tests) --- OHHTTPStubs/Podfile | 12 ++++++++---- .../UnitTests/Test Suites/AFNetworkingTests.m | 5 ++++- .../Test Suites/NSURLConnectionDelegateTests.m | 6 ++++++ .../UnitTests/Test Suites/NSURLConnectionTests.m | 6 ++++++ .../UnitTests/Test Suites/NSURLSessionTests.m | 5 +++-- OHHTTPStubs/UnitTests/Test Suites/NilValuesTests.m | 6 ++++++ OHHTTPStubs/UnitTests/Test Suites/TimingTests.m | 5 +++++ 7 files changed, 38 insertions(+), 7 deletions(-) diff --git a/OHHTTPStubs/Podfile b/OHHTTPStubs/Podfile index a93f21ef..9a0f333f 100644 --- a/OHHTTPStubs/Podfile +++ b/OHHTTPStubs/Podfile @@ -3,22 +3,26 @@ source 'https://github.com/CocoaPods/Specs.git' xcodeproj 'OHHTTPStubs.xcodeproj' inhibit_all_warnings! +def pod_afnetworking + pod 'AFNetworking', :git => 'https://github.com/AFNetworking/AFNetworking.git', :branch => '3_0_0_branch' +end + target 'OHHTTPStubs iOS Lib Tests' do platform :ios, '7.0' - pod 'AFNetworking', :git => 'https://github.com/AFNetworking/AFNetworking.git', :branch => '3_0_0_branch' + pod_afnetworking end target 'OHHTTPStubs iOS Fmk Tests' do platform :ios, '8.0' - pod 'AFNetworking', :git => 'https://github.com/AFNetworking/AFNetworking.git', :branch => '3_0_0_branch' + pod_afnetworking end target 'OHHTTPStubs Mac Tests' do platform :osx, '10.9' - pod 'AFNetworking', :git => 'https://github.com/AFNetworking/AFNetworking.git', :branch => '3_0_0_branch' + pod_afnetworking end target 'OHHTTPStubs tvOS Fmk Tests' do platform :tvos, '9.0' - pod 'AFNetworking', :git => 'https://github.com/AFNetworking/AFNetworking.git', :branch => '3_0_0_branch' + pod_afnetworking end diff --git a/OHHTTPStubs/UnitTests/Test Suites/AFNetworkingTests.m b/OHHTTPStubs/UnitTests/Test Suites/AFNetworkingTests.m index 700272a2..8363f694 100644 --- a/OHHTTPStubs/UnitTests/Test Suites/AFNetworkingTests.m +++ b/OHHTTPStubs/UnitTests/Test Suites/AFNetworkingTests.m @@ -23,6 +23,7 @@ ***********************************************************************************/ #import +#import #if OHHTTPSTUBS_USE_STATIC_LIBRARY #import "OHHTTPStubs.h" @@ -170,7 +171,9 @@ -(void)test_AFHTTPRequestOperation_redirect // Compile this only if SDK version (…MAX_ALLOWED) is iOS7+/10.9+ because NSURLSession is a class only known starting these SDKs // (this code won't compile if we use an eariler SDKs, like when building with Xcode4) #if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) \ -|| (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) + || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) \ + || (defined(__TV_OS_VERSION_MIN_REQUIRED) || defined(__WATCH_OS_VERSION_MIN_REQUIRED)) + #import "AFHTTPSessionManager.h" diff --git a/OHHTTPStubs/UnitTests/Test Suites/NSURLConnectionDelegateTests.m b/OHHTTPStubs/UnitTests/Test Suites/NSURLConnectionDelegateTests.m index 3fa370db..90046781 100644 --- a/OHHTTPStubs/UnitTests/Test Suites/NSURLConnectionDelegateTests.m +++ b/OHHTTPStubs/UnitTests/Test Suites/NSURLConnectionDelegateTests.m @@ -22,6 +22,10 @@ * ***********************************************************************************/ +#import +// tvOS & WatchOS deprecate use of NSURLConnection but these tests are based on it +#if (!defined(__TV_OS_VERSION_MIN_REQUIRED) && !defined(__WATCH_OS_VERSION_MIN_REQUIRED)) + #import #if OHHTTPSTUBS_USE_STATIC_LIBRARY @@ -397,3 +401,5 @@ - (void)test_NSURLConnection_redirected } @end + +#endif diff --git a/OHHTTPStubs/UnitTests/Test Suites/NSURLConnectionTests.m b/OHHTTPStubs/UnitTests/Test Suites/NSURLConnectionTests.m index 842591d6..7e2baf98 100644 --- a/OHHTTPStubs/UnitTests/Test Suites/NSURLConnectionTests.m +++ b/OHHTTPStubs/UnitTests/Test Suites/NSURLConnectionTests.m @@ -22,6 +22,10 @@ * ***********************************************************************************/ +#import +// tvOS & WatchOS deprecate use of NSURLConnection but these tests are based on it +#if (!defined(__TV_OS_VERSION_MIN_REQUIRED) && !defined(__WATCH_OS_VERSION_MIN_REQUIRED)) + #import #if OHHTTPSTUBS_USE_STATIC_LIBRARY @@ -190,3 +194,5 @@ -(void)test_NSURLConnection_sendMultipleAsyncronousRequests_parallelQueue @end + +#endif diff --git a/OHHTTPStubs/UnitTests/Test Suites/NSURLSessionTests.m b/OHHTTPStubs/UnitTests/Test Suites/NSURLSessionTests.m index b274ba86..a4cb91f4 100644 --- a/OHHTTPStubs/UnitTests/Test Suites/NSURLSessionTests.m +++ b/OHHTTPStubs/UnitTests/Test Suites/NSURLSessionTests.m @@ -22,11 +22,12 @@ * ***********************************************************************************/ - +#import // Compile this only if SDK version (…MAX_ALLOWED) is iOS7+/10.9+ because NSURLSession is a class only known starting these SDKs // (this code won't compile if we use an eariler SDKs, like when building with Xcode4) #if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) \ - || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) + || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) \ + || (defined(__TV_OS_VERSION_MIN_REQUIRED) || defined(__WATCH_OS_VERSION_MIN_REQUIRED)) #import diff --git a/OHHTTPStubs/UnitTests/Test Suites/NilValuesTests.m b/OHHTTPStubs/UnitTests/Test Suites/NilValuesTests.m index d3cc8d08..534f36a0 100644 --- a/OHHTTPStubs/UnitTests/Test Suites/NilValuesTests.m +++ b/OHHTTPStubs/UnitTests/Test Suites/NilValuesTests.m @@ -22,6 +22,10 @@ * ***********************************************************************************/ +#import +// tvOS & WatchOS deprecate use of NSURLConnection but these tests are based on it +#if (!defined(__TV_OS_VERSION_MIN_REQUIRED) && !defined(__WATCH_OS_VERSION_MIN_REQUIRED)) + #import #if OHHTTPSTUBS_USE_STATIC_LIBRARY @@ -272,3 +276,5 @@ - (void)test_NilURLAndCookieHandlingDisabled } @end + +#endif diff --git a/OHHTTPStubs/UnitTests/Test Suites/TimingTests.m b/OHHTTPStubs/UnitTests/Test Suites/TimingTests.m index aa1dc0c0..4133874e 100644 --- a/OHHTTPStubs/UnitTests/Test Suites/TimingTests.m +++ b/OHHTTPStubs/UnitTests/Test Suites/TimingTests.m @@ -22,6 +22,9 @@ * ***********************************************************************************/ +#import +// tvOS & WatchOS deprecate use of NSURLConnection but these tests are based on it +#if (!defined(__TV_OS_VERSION_MIN_REQUIRED) && !defined(__WATCH_OS_VERSION_MIN_REQUIRED)) #import @@ -165,3 +168,5 @@ -(void)test_VeryLongData_RequestTime1_ResponseTime0 } @end + +#endif