Migrated to Travis Matrix

This commit is contained in:
Kevin Harwood 2015-10-13 10:43:52 -05:00
parent 824f7c570a
commit e0815dacfa
14 changed files with 622 additions and 148 deletions

1
.gitignore vendored
View File

@ -18,4 +18,3 @@ DerivedData
.idea/
Tests/Pods
Tests/Podfile.lock
Tests/AFNetworking Tests.xcodeproj/xcshareddata/xcschemes/

View File

@ -1,8 +1,36 @@
language: objective-c
osx_image: xcode7
sudo: false
env:
global:
- LC_CTYPE=en_US.UTF-8
- LANG=en_US.UTF-8
matrix:
- DESTINATION="OS=9.0,name=iPhone 6 Plus" TEST_SCHEME="iOS Tests" EXAMPLE_SCHEME="AFNetworking iOS Example" SDK=iphonesimulator9.0 RUN_TESTS="YES" BUILD_EXAMPLE="YES" POD_LINT="NO"
- DESTINATION="OS=8.1,name=iPhone 4S" TEST_SCHEME="iOS Tests" EXAMPLE_SCHEME="AFNetworking iOS Example" SDK=iphonesimulator9.0 RUN_TESTS="YES" BUILD_EXAMPLE="NO" POD_LINT="YES"
- DESTINATION="OS=8.2,name=iPhone 5" TEST_SCHEME="iOS Tests" EXAMPLE_SCHEME="AFNetworking iOS Example" SDK=iphonesimulator9.0 RUN_TESTS="YES" BUILD_EXAMPLE="NO" POD_LINT="NO"
- DESTINATION="OS=8.3,name=iPhone 5S" TEST_SCHEME="iOS Tests" EXAMPLE_SCHEME="AFNetworking iOS Example" SDK=iphonesimulator9.0 RUN_TESTS="YES" BUILD_EXAMPLE="NO" POD_LINT="NO"
- DESTINATION="OS=8.4,name=iPhone 6" TEST_SCHEME="iOS Tests" EXAMPLE_SCHEME="AFNetworking iOS Example" SDK=iphonesimulator9.0 RUN_TESTS="YES" BUILD_EXAMPLE="NO" POD_LINT="NO"
# TESTS ARE CURRENTLY DISABLED FOR MAC OS X DUE TO THIS ISSUE: https://github.com/travis-ci/travis-ci/issues/4904
- DESTINATION="arch=x86_64" TEST_SCHEME="OS X Tests" SDK=macosx10.11 EXAMPLE_SCHEME="AFNetworking Example" RUN_TESTS="NO" BUILD_EXAMPLE="YES" POD_LINT="NO"
before_install:
- gem install cocoapods --no-rdoc --no-ri --no-document --quiet
- gem install xcpretty --no-rdoc --no-ri --no-document --quiet
- cd Tests && pod install && cd $TRAVIS_BUILD_DIR
script: rake test
- gem install cocoapods --no-rdoc --no-ri --no-document --quiet
- gem install xcpretty --no-rdoc --no-ri --no-document --quiet
- cd Tests && pod install && cd $TRAVIS_BUILD_DIR
script:
- set -o pipefail
- xcodebuild -version
- xcodebuild -showsdks
- if [ $RUN_TESTS == "YES" ]; then
xcodebuild -workspace AFNetworking.xcworkspace -scheme "$TEST_SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Debug ONLY_ACTIVE_ARCH=NO test | xcpretty -c;
xcodebuild -workspace AFNetworking.xcworkspace -scheme "$TEST_SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Release ONLY_ACTIVE_ARCH=NO test | xcpretty -c;
fi
- if [ $BUILD_EXAMPLE == "YES" ]; then
xcodebuild -workspace AFNetworking.xcworkspace -scheme "$EXAMPLE_SCHEME" -destination "$DESTINATION"
-configuration Debug ONLY_ACTIVE_ARCH=NO build | xcpretty -c;
xcodebuild -workspace AFNetworking.xcworkspace -scheme "$EXAMPLE_SCHEME" -destination "$DESTINATION"
-configuration Release ONLY_ACTIVE_ARCH=NO build | xcpretty -c;
fi
- if [ $POD_LINT == "YES" ]; then
pod lib lint --quick;
fi

View File

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F8129BFA1591061B009BFE23"
BuildableName = "AFNetworking Example.app"
BlueprintName = "AFNetworking Example"
ReferencedContainer = "container:AFNetworking OS X Example.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F8129BFA1591061B009BFE23"
BuildableName = "AFNetworking Example.app"
BlueprintName = "AFNetworking Example"
ReferencedContainer = "container:AFNetworking OS X Example.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F8129BFA1591061B009BFE23"
BuildableName = "AFNetworking Example.app"
BlueprintName = "AFNetworking Example"
ReferencedContainer = "container:AFNetworking OS X Example.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F8129BFA1591061B009BFE23"
BuildableName = "AFNetworking Example.app"
BlueprintName = "AFNetworking Example"
ReferencedContainer = "container:AFNetworking OS X Example.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -1218,6 +1218,7 @@
29900D261B6FB14000DE5662 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
29900D291B6FB14000DE5662 /* Build configuration list for PBXNativeTarget "AFNetworking watchOS" */ = {
isa = XCConfigurationList;
@ -1226,6 +1227,7 @@
29900D241B6FB14000DE5662 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
EBE11F591B62EDD200753127 /* Build configuration list for PBXNativeTarget "Today Extension" */ = {
isa = XCConfigurationList;

View File

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F8E4695F1395739C00DB05C8"
BuildableName = "AFNetworking iOS Example.app"
BlueprintName = "AFNetworking iOS Example"
ReferencedContainer = "container:AFNetworking iOS Example.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F8E4695F1395739C00DB05C8"
BuildableName = "AFNetworking iOS Example.app"
BlueprintName = "AFNetworking iOS Example"
ReferencedContainer = "container:AFNetworking iOS Example.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F8E4695F1395739C00DB05C8"
BuildableName = "AFNetworking iOS Example.app"
BlueprintName = "AFNetworking iOS Example"
ReferencedContainer = "container:AFNetworking iOS Example.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F8E4695F1395739C00DB05C8"
BuildableName = "AFNetworking iOS Example.app"
BlueprintName = "AFNetworking iOS Example"
ReferencedContainer = "container:AFNetworking iOS Example.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,141 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "29900D051B6FB14000DE5662"
BuildableName = "AFNetworking watchOS.app"
BlueprintName = "AFNetworking watchOS"
ReferencedContainer = "container:AFNetworking iOS Example.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F8E4695F1395739C00DB05C8"
BuildableName = "AFNetworking iOS Example.app"
BlueprintName = "AFNetworking iOS Example"
ReferencedContainer = "container:AFNetworking iOS Example.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "29900D111B6FB14000DE5662"
BuildableName = "AFNetworking watchOS Extension.appex"
BlueprintName = "AFNetworking watchOS Extension"
ReferencedContainer = "container:AFNetworking iOS Example.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "29900D051B6FB14000DE5662"
BuildableName = "AFNetworking watchOS.app"
BlueprintName = "AFNetworking watchOS"
ReferencedContainer = "container:AFNetworking iOS Example.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.carousel"
RemotePath = "/AFNetworking iOS Example">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "29900D051B6FB14000DE5662"
BuildableName = "AFNetworking watchOS.app"
BlueprintName = "AFNetworking watchOS"
ReferencedContainer = "container:AFNetworking iOS Example.xcodeproj">
</BuildableReference>
</RemoteRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "29900D051B6FB14000DE5662"
BuildableName = "AFNetworking watchOS.app"
BlueprintName = "AFNetworking watchOS"
ReferencedContainer = "container:AFNetworking iOS Example.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.carousel"
RemotePath = "/AFNetworking iOS Example">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "29900D051B6FB14000DE5662"
BuildableName = "AFNetworking watchOS.app"
BlueprintName = "AFNetworking watchOS"
ReferencedContainer = "container:AFNetworking iOS Example.xcodeproj">
</BuildableReference>
</RemoteRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "29900D051B6FB14000DE5662"
BuildableName = "AFNetworking watchOS.app"
BlueprintName = "AFNetworking watchOS"
ReferencedContainer = "container:AFNetworking iOS Example.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
wasCreatedForAppExtension = "YES"
version = "2.0">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "EBE11F471B62EDD200753127"
BuildableName = "Today Extension.appex"
BlueprintName = "Today Extension"
ReferencedContainer = "container:AFNetworking iOS Example.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F8E4695F1395739C00DB05C8"
BuildableName = "AFNetworking iOS Example.app"
BlueprintName = "AFNetworking iOS Example"
ReferencedContainer = "container:AFNetworking iOS Example.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "EBE11F471B62EDD200753127"
BuildableName = "Today Extension.appex"
BlueprintName = "Today Extension"
ReferencedContainer = "container:AFNetworking iOS Example.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES"
launchAutomaticallySubstyle = "2">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F8E4695F1395739C00DB05C8"
BuildableName = "AFNetworking iOS Example.app"
BlueprintName = "AFNetworking iOS Example"
ReferencedContainer = "container:AFNetworking iOS Example.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES"
launchAutomaticallySubstyle = "2">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F8E4695F1395739C00DB05C8"
BuildableName = "AFNetworking iOS Example.app"
BlueprintName = "AFNetworking iOS Example"
ReferencedContainer = "container:AFNetworking iOS Example.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>1.0.0</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>

View File

@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>1.0.0</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>

View File

@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>1.0.0</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionMainStoryboard</key>

View File

@ -1,89 +0,0 @@
include FileUtils::Verbose
namespace :test do
task :prepare do
mkdir_p "Tests/AFNetworking Tests.xcodeproj/xcshareddata/xcschemes"
cp Dir.glob('Tests/Schemes/*.xcscheme'), "Tests/AFNetworking Tests.xcodeproj/xcshareddata/xcschemes/"
end
desc "Run the AFNetworking Tests for iOS"
task :ios => :prepare do
simulators = get_ios_simulators
destinations = Array.new
simulators.each {|version, available_simulators|
destinations.push("platform=iOS Simulator,OS=#{available_simulators[:runtime]},name=#{available_simulators[:device_names][0]}")
puts "Will run tests for iOS Simulator on iOS #{available_simulators[:runtime]} using #{available_simulators[:device_names][0]}"
}
run_tests('iOS Tests', 'iphonesimulator', destinations)
tests_failed('iOS') unless $?.success?
end
desc "Run the AFNetworking Tests for Mac OS X"
task :osx => :prepare do
run_tests('OS X Tests', 'macosx', ['platform=OS X,arch=x86_64'])
tests_failed('OSX') unless $?.success?
end
end
desc "Run the AFNetworking Tests for iOS & Mac OS X"
task :test do
Rake::Task['test:ios'].invoke
Rake::Task['test:osx'].invoke if is_mavericks_or_above
end
task :default => 'test'
private
def run_tests(scheme, sdk, destinations)
destinations = destinations.map! { |destination| "-destination \'#{destination}\'" }.join(' ')
sh("xcodebuild -workspace AFNetworking.xcworkspace -scheme '#{scheme}' -sdk '#{sdk}' #{destinations} -configuration Release clean test | xcpretty -c ; exit ${PIPESTATUS[0]}") rescue nil
end
def is_mavericks_or_above
osx_version = `sw_vers -productVersion`.chomp
Gem::Version.new(osx_version) >= Gem::Version.new('10.9')
end
def tests_failed(platform)
puts red("#{platform} unit tests failed")
exit $?.exitstatus
end
def red(string)
"\033[0;31m! #{string}"
end
def get_ios_simulators
device_section_regex = /== Devices ==(.*?)(?=(?===)|\z)/m
runtime_section_regex = /== Runtimes ==(.*?)(?=(?===)|\z)/m
runtime_version_regex = /iOS (.*) \((.*) - .*?\) (\(.*\))/
xcrun_output = `xcrun simctl list`
puts "Available iOS Simulators: \n#{xcrun_output}"
simulators = Hash.new
runtimes_section = xcrun_output.scan(runtime_section_regex)[0]
runtimes_section[0].scan(runtime_version_regex) {|result|
if result[2] !~ /unavailable/
simulators[result[0]] = Hash.new
simulators[result[0]][:runtime] = result[1]
end
}
device_section = xcrun_output.scan(device_section_regex)[0]
version_regex = /-- iOS (.*?) --(.*?)(?=(?=-- .*? --)|\z)/m
simulator_name_regex = /(.*) \([A-F0-9-]*\) \(.*\)/
device_section[0].scan(version_regex) {|result|
if simulators.has_key?(result[0])
simulators[result[0]][:device_names] = Array.new
result[1].scan(simulator_name_regex) { |device_name_result|
device_name = device_name_result[0].strip
simulators[result[0]][:device_names].push(device_name)
}
end
}
return simulators
end

View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2902D28B17DF4E2900C81C5A"
BuildableName = "OS X Tests.xctest"
BlueprintName = "OS X Tests"
ReferencedContainer = "container:AFNetworking Tests.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2902D27717DF4E1100C81C5A"
BuildableName = "iOS Tests.xctest"
BlueprintName = "iOS Tests"
ReferencedContainer = "container:AFNetworking Tests.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -22,12 +22,11 @@
#import "AFTestCase.h"
#import "AFNetworkActivityIndicatorManager.h"
#import "AFHTTPRequestOperation.h"
#import "AFHTTPSessionManager.h"
@interface AFNetworkActivityManagerTests : AFTestCase
@property (nonatomic, strong) AFNetworkActivityIndicatorManager *networkActivityIndicatorManager;
@property (nonatomic, assign) BOOL isNetworkActivityIndicatorVisible;
@property (nonatomic, strong) id mockApplication;
@property (nonatomic, strong) AFHTTPSessionManager *sessionManager;
@end
#pragma mark -
@ -37,71 +36,63 @@
- (void)setUp {
[super setUp];
self.sessionManager = [[AFHTTPSessionManager alloc] initWithBaseURL:self.baseURL sessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
self.networkActivityIndicatorManager = [[AFNetworkActivityIndicatorManager alloc] init];
self.networkActivityIndicatorManager.enabled = YES;
self.mockApplication = [OCMockObject mockForClass:[UIApplication class]];
[[[self.mockApplication stub] andReturn:self.mockApplication] sharedApplication];
[[[self.mockApplication stub] andDo:^(NSInvocation *invocation) {
[invocation setReturnValue:(void *)&_isNetworkActivityIndicatorVisible];
}] isNetworkActivityIndicatorVisible];
[[[self.mockApplication stub] andDo:^(NSInvocation *invocation) {
[invocation getArgument:&_isNetworkActivityIndicatorVisible atIndex:2];
}] setNetworkActivityIndicatorVisible:YES];
}
- (void)tearDown {
[super tearDown];
[self.mockApplication stopMocking];
self.mockApplication = nil;
self.networkActivityIndicatorManager = nil;
[self.sessionManager invalidateSessionCancelingTasks:YES];
}
#pragma mark -
- (void)testThatNetworkActivityIndicatorTurnsOffIndicatorWhenRequestSucceeds {
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/get" relativeToURL:self.baseURL]];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
expect([self.mockApplication isNetworkActivityIndicatorVisible]).will.beFalsy();
} failure:nil];
XCTestExpectation *requestCompleteExpectation = [self expectationWithDescription:@"Request should succeed"];
[self.sessionManager
GET:@"/delay/1"
parameters:nil
success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) {
[requestCompleteExpectation fulfill];
}
failure:nil];
[self expectationForPredicate:[NSPredicate predicateWithFormat:@"isNetworkActivityIndicatorVisible == YES"]
evaluatedWithObject:self.networkActivityIndicatorManager
handler:nil];
[self waitForExpectationsWithTimeout:10.0 handler:nil];
[operation start];
expect([self.mockApplication isNetworkActivityIndicatorVisible]).will.beTruthy();
[self expectationForPredicate:[NSPredicate predicateWithFormat:@"isNetworkActivityIndicatorVisible == NO"]
evaluatedWithObject:self.networkActivityIndicatorManager
handler:nil];
[self waitForExpectationsWithTimeout:5.0 handler:nil];
}
- (void)testThatNetworkActivityIndicatorTurnsOffIndicatorWhenRequestFails {
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/status/500" relativeToURL:self.baseURL]];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[operation setCompletionBlockWithSuccess:nil failure:^(AFHTTPRequestOperation *operation, NSError *error) {
expect([self.mockApplication isNetworkActivityIndicatorVisible]).will.beFalsy();
}];
XCTestExpectation *requestCompleteExpectation = [self expectationWithDescription:@"Request should succeed"];
[self.sessionManager
GET:@"/status/500"
parameters:nil
success:nil
failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
[requestCompleteExpectation fulfill];
}];
[operation start];
[self
keyValueObservingExpectationForObject:self.networkActivityIndicatorManager
keyPath:@"isNetworkActivityIndicatorVisible"
handler:^BOOL(AFNetworkActivityIndicatorManager * observedObject, NSDictionary * _Nonnull change) {
return observedObject.isNetworkActivityIndicatorVisible;
}];
[self waitForExpectationsWithTimeout:5.0 handler:nil];
expect([self.mockApplication isNetworkActivityIndicatorVisible]).will.beTruthy();
}
- (void)testThatNetworkActivityIsUnchangedWhenManagerIsDisabled {
self.networkActivityIndicatorManager.enabled = NO;
__block BOOL didChangeNetworkActivityIndicatorVisible = NO;
[[[self.mockApplication stub] andDo:^(NSInvocation *invocation) {
didChangeNetworkActivityIndicatorVisible = YES;
}] setNetworkActivityIndicatorVisible:YES];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/get" relativeToURL:self.baseURL]];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[operation setCompletionBlockWithSuccess:nil failure:nil];
[operation start];
expect(didChangeNetworkActivityIndicatorVisible).will.beFalsy();
[self expectationForPredicate:[NSPredicate predicateWithFormat:@"isNetworkActivityIndicatorVisible == NO"]
evaluatedWithObject:self.networkActivityIndicatorManager
handler:nil];
[self waitForExpectationsWithTimeout:5.0 handler:nil];
}
@end