├── .gitignore ├── AGAsyncTestHelper.podspec ├── AGAsyncTestHelperDemo ├── AGAsyncTestHelperDemo.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── AGAsyncTestHelperDemo.xccheckout │ └── xcuserdata │ │ └── hfossli.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ ├── AGAsyncTestHelperDemo.xcscheme │ │ └── xcschememanagement.plist ├── AGAsyncTestHelperDemo │ ├── AGAppDelegate.h │ ├── AGAppDelegate.m │ ├── AGAsyncTestHelperDemo-Info.plist │ ├── AGAsyncTestHelperDemo-Prefix.pch │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── LaunchImage.launchimage │ │ │ └── Contents.json │ ├── en.lproj │ │ └── InfoPlist.strings │ └── main.m ├── AGAsyncTestHelperDemoTests │ ├── AGAsyncTestHelperDemoTests-Info.plist │ └── en.lproj │ │ └── InfoPlist.strings └── AGAsyncTestHelperSenTestTarget │ ├── AGAsyncTestHelperSenTestTarget-Info.plist │ ├── AGAsyncTestHelperSenTestTarget-Prefix.pch │ └── en.lproj │ └── InfoPlist.strings ├── LICENSE ├── README.md ├── Source └── AGAsyncTestHelper.h └── Tests ├── AGAsyncTestHelperSenTest.m └── AGAsyncTestHelperXCTTest.m /.gitignore: -------------------------------------------------------------------------------- 1 | Demo/AsyncTestWait.xcodeproj/xcuserdata/ 2 | Demo/AsyncTestWait.xcodeproj/project.xcworkspace/xcuserdata/ 3 | UserInterfaceState.xcuserstate* 4 | 5 | /Demo/AsyncTestWait.xcodeproj/xcuserdata/hfossli.xcuserdatad/xcschemes/AsyncTestWait.xcscheme 6 | -------------------------------------------------------------------------------- /AGAsyncTestHelper.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "AGAsyncTestHelper" 3 | s.version = "1.0" 4 | s.summary = "Macro for writing unit tests with asynchronous operations." 5 | s.homepage = "https://github.com/hfossli/AGAsyncTestHelper" 6 | s.license = { :type => 'MIT', :file => 'LICENSE' } 7 | s.author = { "Håvard Fossli" => "hfossli@gmail.com" } 8 | s.source = { 9 | :git => "https://github.com/hfossli/AGAsyncTestHelper.git", 10 | :tag => s.version.to_s 11 | } 12 | s.default_subspec = 'Core' 13 | 14 | s.subspec 'Core' do |ss| 15 | ss.source_files = 'Source/*.{h,m}' 16 | ss.requires_arc = false 17 | end 18 | 19 | s.subspec 'Shorthand' do |ss| 20 | ss.dependency 'AGAsyncTestHelper/Core' 21 | ss.xcconfig = { "GCC_PREPROCESSOR_DEFINITIONS" => '$(inherited) AGWW_SHORTHAND' } 22 | end 23 | 24 | end 25 | -------------------------------------------------------------------------------- /AGAsyncTestHelperDemo/AGAsyncTestHelperDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | A3FE7D6618C4B3A800E080D2 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A3FE7D6518C4B3A800E080D2 /* Foundation.framework */; }; 11 | A3FE7D6818C4B3A800E080D2 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A3FE7D6718C4B3A800E080D2 /* CoreGraphics.framework */; }; 12 | A3FE7D6A18C4B3A800E080D2 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A3FE7D6918C4B3A800E080D2 /* UIKit.framework */; }; 13 | A3FE7D7018C4B3A800E080D2 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A3FE7D6E18C4B3A800E080D2 /* InfoPlist.strings */; }; 14 | A3FE7D7218C4B3A800E080D2 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A3FE7D7118C4B3A800E080D2 /* main.m */; }; 15 | A3FE7D7618C4B3A800E080D2 /* AGAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A3FE7D7518C4B3A800E080D2 /* AGAppDelegate.m */; }; 16 | A3FE7D7818C4B3A800E080D2 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A3FE7D7718C4B3A800E080D2 /* Images.xcassets */; }; 17 | A3FE7D7F18C4B3A800E080D2 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A3FE7D7E18C4B3A800E080D2 /* XCTest.framework */; }; 18 | A3FE7D8018C4B3A800E080D2 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A3FE7D6518C4B3A800E080D2 /* Foundation.framework */; }; 19 | A3FE7D8118C4B3A800E080D2 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A3FE7D6918C4B3A800E080D2 /* UIKit.framework */; }; 20 | A3FE7D8918C4B3A800E080D2 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A3FE7D8718C4B3A800E080D2 /* InfoPlist.strings */; }; 21 | A3FE7D9A18C4B3DF00E080D2 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A3FE7D9918C4B3DF00E080D2 /* SenTestingKit.framework */; }; 22 | A3FE7D9B18C4B3DF00E080D2 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A3FE7D6518C4B3A800E080D2 /* Foundation.framework */; }; 23 | A3FE7D9C18C4B3DF00E080D2 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A3FE7D6918C4B3A800E080D2 /* UIKit.framework */; }; 24 | A3FE7DA218C4B3DF00E080D2 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A3FE7DA018C4B3DF00E080D2 /* InfoPlist.strings */; }; 25 | A3FE7DB018C4B42200E080D2 /* AGAsyncTestHelperSenTest.m in Sources */ = {isa = PBXBuildFile; fileRef = A3FE7DAE18C4B41E00E080D2 /* AGAsyncTestHelperSenTest.m */; }; 26 | A3FE7DB118C4B42400E080D2 /* AGAsyncTestHelperXCTTest.m in Sources */ = {isa = PBXBuildFile; fileRef = A3FE7DAF18C4B41E00E080D2 /* AGAsyncTestHelperXCTTest.m */; }; 27 | /* End PBXBuildFile section */ 28 | 29 | /* Begin PBXContainerItemProxy section */ 30 | A3FE7D8218C4B3A800E080D2 /* PBXContainerItemProxy */ = { 31 | isa = PBXContainerItemProxy; 32 | containerPortal = A3FE7D5A18C4B3A800E080D2 /* Project object */; 33 | proxyType = 1; 34 | remoteGlobalIDString = A3FE7D6118C4B3A800E080D2; 35 | remoteInfo = AGAsyncTestHelperDemo; 36 | }; 37 | A3FE7DA618C4B3DF00E080D2 /* PBXContainerItemProxy */ = { 38 | isa = PBXContainerItemProxy; 39 | containerPortal = A3FE7D5A18C4B3A800E080D2 /* Project object */; 40 | proxyType = 1; 41 | remoteGlobalIDString = A3FE7D6118C4B3A800E080D2; 42 | remoteInfo = AGAsyncTestHelperDemo; 43 | }; 44 | /* End PBXContainerItemProxy section */ 45 | 46 | /* Begin PBXFileReference section */ 47 | A3FE7D6218C4B3A800E080D2 /* AGAsyncTestHelperDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AGAsyncTestHelperDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 48 | A3FE7D6518C4B3A800E080D2 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 49 | A3FE7D6718C4B3A800E080D2 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 50 | A3FE7D6918C4B3A800E080D2 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 51 | A3FE7D6D18C4B3A800E080D2 /* AGAsyncTestHelperDemo-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "AGAsyncTestHelperDemo-Info.plist"; sourceTree = ""; }; 52 | A3FE7D6F18C4B3A800E080D2 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 53 | A3FE7D7118C4B3A800E080D2 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 54 | A3FE7D7318C4B3A800E080D2 /* AGAsyncTestHelperDemo-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AGAsyncTestHelperDemo-Prefix.pch"; sourceTree = ""; }; 55 | A3FE7D7418C4B3A800E080D2 /* AGAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AGAppDelegate.h; sourceTree = ""; }; 56 | A3FE7D7518C4B3A800E080D2 /* AGAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AGAppDelegate.m; sourceTree = ""; }; 57 | A3FE7D7718C4B3A800E080D2 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 58 | A3FE7D7D18C4B3A800E080D2 /* AGAsyncTestHelperXCTestTarget.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AGAsyncTestHelperXCTestTarget.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 59 | A3FE7D7E18C4B3A800E080D2 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 60 | A3FE7D8618C4B3A800E080D2 /* AGAsyncTestHelperDemoTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "AGAsyncTestHelperDemoTests-Info.plist"; sourceTree = ""; }; 61 | A3FE7D8818C4B3A800E080D2 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 62 | A3FE7D9818C4B3DF00E080D2 /* AGAsyncTestHelperSenTestTarget.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AGAsyncTestHelperSenTestTarget.octest; sourceTree = BUILT_PRODUCTS_DIR; }; 63 | A3FE7D9918C4B3DF00E080D2 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; }; 64 | A3FE7D9F18C4B3DF00E080D2 /* AGAsyncTestHelperSenTestTarget-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "AGAsyncTestHelperSenTestTarget-Info.plist"; sourceTree = ""; }; 65 | A3FE7DA118C4B3DF00E080D2 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 66 | A3FE7DA518C4B3DF00E080D2 /* AGAsyncTestHelperSenTestTarget-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AGAsyncTestHelperSenTestTarget-Prefix.pch"; sourceTree = ""; }; 67 | A3FE7DAC18C4B41500E080D2 /* AGAsyncTestHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AGAsyncTestHelper.h; sourceTree = ""; }; 68 | A3FE7DAE18C4B41E00E080D2 /* AGAsyncTestHelperSenTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AGAsyncTestHelperSenTest.m; sourceTree = ""; }; 69 | A3FE7DAF18C4B41E00E080D2 /* AGAsyncTestHelperXCTTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AGAsyncTestHelperXCTTest.m; sourceTree = ""; }; 70 | /* End PBXFileReference section */ 71 | 72 | /* Begin PBXFrameworksBuildPhase section */ 73 | A3FE7D5F18C4B3A800E080D2 /* Frameworks */ = { 74 | isa = PBXFrameworksBuildPhase; 75 | buildActionMask = 2147483647; 76 | files = ( 77 | A3FE7D6818C4B3A800E080D2 /* CoreGraphics.framework in Frameworks */, 78 | A3FE7D6A18C4B3A800E080D2 /* UIKit.framework in Frameworks */, 79 | A3FE7D6618C4B3A800E080D2 /* Foundation.framework in Frameworks */, 80 | ); 81 | runOnlyForDeploymentPostprocessing = 0; 82 | }; 83 | A3FE7D7A18C4B3A800E080D2 /* Frameworks */ = { 84 | isa = PBXFrameworksBuildPhase; 85 | buildActionMask = 2147483647; 86 | files = ( 87 | A3FE7D7F18C4B3A800E080D2 /* XCTest.framework in Frameworks */, 88 | A3FE7D8118C4B3A800E080D2 /* UIKit.framework in Frameworks */, 89 | A3FE7D8018C4B3A800E080D2 /* Foundation.framework in Frameworks */, 90 | ); 91 | runOnlyForDeploymentPostprocessing = 0; 92 | }; 93 | A3FE7D9518C4B3DF00E080D2 /* Frameworks */ = { 94 | isa = PBXFrameworksBuildPhase; 95 | buildActionMask = 2147483647; 96 | files = ( 97 | A3FE7D9A18C4B3DF00E080D2 /* SenTestingKit.framework in Frameworks */, 98 | A3FE7D9C18C4B3DF00E080D2 /* UIKit.framework in Frameworks */, 99 | A3FE7D9B18C4B3DF00E080D2 /* Foundation.framework in Frameworks */, 100 | ); 101 | runOnlyForDeploymentPostprocessing = 0; 102 | }; 103 | /* End PBXFrameworksBuildPhase section */ 104 | 105 | /* Begin PBXGroup section */ 106 | A3FE7D5918C4B3A800E080D2 = { 107 | isa = PBXGroup; 108 | children = ( 109 | A3FE7DAD18C4B41E00E080D2 /* Tests */, 110 | A3FE7DAB18C4B41500E080D2 /* Source */, 111 | A3FE7D6B18C4B3A800E080D2 /* AGAsyncTestHelperDemo */, 112 | A3FE7D8418C4B3A800E080D2 /* AGAsyncTestHelperDemoTests */, 113 | A3FE7D9D18C4B3DF00E080D2 /* AGAsyncTestHelperSenTestTarget */, 114 | A3FE7D6418C4B3A800E080D2 /* Frameworks */, 115 | A3FE7D6318C4B3A800E080D2 /* Products */, 116 | ); 117 | sourceTree = ""; 118 | }; 119 | A3FE7D6318C4B3A800E080D2 /* Products */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | A3FE7D6218C4B3A800E080D2 /* AGAsyncTestHelperDemo.app */, 123 | A3FE7D7D18C4B3A800E080D2 /* AGAsyncTestHelperXCTestTarget.xctest */, 124 | A3FE7D9818C4B3DF00E080D2 /* AGAsyncTestHelperSenTestTarget.octest */, 125 | ); 126 | name = Products; 127 | sourceTree = ""; 128 | }; 129 | A3FE7D6418C4B3A800E080D2 /* Frameworks */ = { 130 | isa = PBXGroup; 131 | children = ( 132 | A3FE7D6518C4B3A800E080D2 /* Foundation.framework */, 133 | A3FE7D6718C4B3A800E080D2 /* CoreGraphics.framework */, 134 | A3FE7D6918C4B3A800E080D2 /* UIKit.framework */, 135 | A3FE7D7E18C4B3A800E080D2 /* XCTest.framework */, 136 | A3FE7D9918C4B3DF00E080D2 /* SenTestingKit.framework */, 137 | ); 138 | name = Frameworks; 139 | sourceTree = ""; 140 | }; 141 | A3FE7D6B18C4B3A800E080D2 /* AGAsyncTestHelperDemo */ = { 142 | isa = PBXGroup; 143 | children = ( 144 | A3FE7D7418C4B3A800E080D2 /* AGAppDelegate.h */, 145 | A3FE7D7518C4B3A800E080D2 /* AGAppDelegate.m */, 146 | A3FE7D7718C4B3A800E080D2 /* Images.xcassets */, 147 | A3FE7D6C18C4B3A800E080D2 /* Supporting Files */, 148 | ); 149 | path = AGAsyncTestHelperDemo; 150 | sourceTree = ""; 151 | }; 152 | A3FE7D6C18C4B3A800E080D2 /* Supporting Files */ = { 153 | isa = PBXGroup; 154 | children = ( 155 | A3FE7D6D18C4B3A800E080D2 /* AGAsyncTestHelperDemo-Info.plist */, 156 | A3FE7D6E18C4B3A800E080D2 /* InfoPlist.strings */, 157 | A3FE7D7118C4B3A800E080D2 /* main.m */, 158 | A3FE7D7318C4B3A800E080D2 /* AGAsyncTestHelperDemo-Prefix.pch */, 159 | ); 160 | name = "Supporting Files"; 161 | sourceTree = ""; 162 | }; 163 | A3FE7D8418C4B3A800E080D2 /* AGAsyncTestHelperDemoTests */ = { 164 | isa = PBXGroup; 165 | children = ( 166 | A3FE7D8518C4B3A800E080D2 /* Supporting Files */, 167 | ); 168 | path = AGAsyncTestHelperDemoTests; 169 | sourceTree = ""; 170 | }; 171 | A3FE7D8518C4B3A800E080D2 /* Supporting Files */ = { 172 | isa = PBXGroup; 173 | children = ( 174 | A3FE7D8618C4B3A800E080D2 /* AGAsyncTestHelperDemoTests-Info.plist */, 175 | A3FE7D8718C4B3A800E080D2 /* InfoPlist.strings */, 176 | ); 177 | name = "Supporting Files"; 178 | sourceTree = ""; 179 | }; 180 | A3FE7D9D18C4B3DF00E080D2 /* AGAsyncTestHelperSenTestTarget */ = { 181 | isa = PBXGroup; 182 | children = ( 183 | A3FE7D9E18C4B3DF00E080D2 /* Supporting Files */, 184 | ); 185 | path = AGAsyncTestHelperSenTestTarget; 186 | sourceTree = ""; 187 | }; 188 | A3FE7D9E18C4B3DF00E080D2 /* Supporting Files */ = { 189 | isa = PBXGroup; 190 | children = ( 191 | A3FE7D9F18C4B3DF00E080D2 /* AGAsyncTestHelperSenTestTarget-Info.plist */, 192 | A3FE7DA018C4B3DF00E080D2 /* InfoPlist.strings */, 193 | A3FE7DA518C4B3DF00E080D2 /* AGAsyncTestHelperSenTestTarget-Prefix.pch */, 194 | ); 195 | name = "Supporting Files"; 196 | sourceTree = ""; 197 | }; 198 | A3FE7DAB18C4B41500E080D2 /* Source */ = { 199 | isa = PBXGroup; 200 | children = ( 201 | A3FE7DAC18C4B41500E080D2 /* AGAsyncTestHelper.h */, 202 | ); 203 | name = Source; 204 | path = ../Source; 205 | sourceTree = ""; 206 | }; 207 | A3FE7DAD18C4B41E00E080D2 /* Tests */ = { 208 | isa = PBXGroup; 209 | children = ( 210 | A3FE7DAE18C4B41E00E080D2 /* AGAsyncTestHelperSenTest.m */, 211 | A3FE7DAF18C4B41E00E080D2 /* AGAsyncTestHelperXCTTest.m */, 212 | ); 213 | name = Tests; 214 | path = ../Tests; 215 | sourceTree = ""; 216 | }; 217 | /* End PBXGroup section */ 218 | 219 | /* Begin PBXNativeTarget section */ 220 | A3FE7D6118C4B3A800E080D2 /* AGAsyncTestHelperDemo */ = { 221 | isa = PBXNativeTarget; 222 | buildConfigurationList = A3FE7D8E18C4B3A800E080D2 /* Build configuration list for PBXNativeTarget "AGAsyncTestHelperDemo" */; 223 | buildPhases = ( 224 | A3FE7D5E18C4B3A800E080D2 /* Sources */, 225 | A3FE7D5F18C4B3A800E080D2 /* Frameworks */, 226 | A3FE7D6018C4B3A800E080D2 /* Resources */, 227 | ); 228 | buildRules = ( 229 | ); 230 | dependencies = ( 231 | ); 232 | name = AGAsyncTestHelperDemo; 233 | productName = AGAsyncTestHelperDemo; 234 | productReference = A3FE7D6218C4B3A800E080D2 /* AGAsyncTestHelperDemo.app */; 235 | productType = "com.apple.product-type.application"; 236 | }; 237 | A3FE7D7C18C4B3A800E080D2 /* AGAsyncTestHelperXCTestTarget */ = { 238 | isa = PBXNativeTarget; 239 | buildConfigurationList = A3FE7D9118C4B3A800E080D2 /* Build configuration list for PBXNativeTarget "AGAsyncTestHelperXCTestTarget" */; 240 | buildPhases = ( 241 | A3FE7D7918C4B3A800E080D2 /* Sources */, 242 | A3FE7D7A18C4B3A800E080D2 /* Frameworks */, 243 | A3FE7D7B18C4B3A800E080D2 /* Resources */, 244 | ); 245 | buildRules = ( 246 | ); 247 | dependencies = ( 248 | A3FE7D8318C4B3A800E080D2 /* PBXTargetDependency */, 249 | ); 250 | name = AGAsyncTestHelperXCTestTarget; 251 | productName = AGAsyncTestHelperDemoTests; 252 | productReference = A3FE7D7D18C4B3A800E080D2 /* AGAsyncTestHelperXCTestTarget.xctest */; 253 | productType = "com.apple.product-type.bundle.unit-test"; 254 | }; 255 | A3FE7D9718C4B3DF00E080D2 /* AGAsyncTestHelperSenTestTarget */ = { 256 | isa = PBXNativeTarget; 257 | buildConfigurationList = A3FE7DA818C4B3DF00E080D2 /* Build configuration list for PBXNativeTarget "AGAsyncTestHelperSenTestTarget" */; 258 | buildPhases = ( 259 | A3FE7D9418C4B3DF00E080D2 /* Sources */, 260 | A3FE7D9518C4B3DF00E080D2 /* Frameworks */, 261 | A3FE7D9618C4B3DF00E080D2 /* Resources */, 262 | ); 263 | buildRules = ( 264 | ); 265 | dependencies = ( 266 | A3FE7DA718C4B3DF00E080D2 /* PBXTargetDependency */, 267 | ); 268 | name = AGAsyncTestHelperSenTestTarget; 269 | productName = AGAsyncTestHelperSenTestTarget; 270 | productReference = A3FE7D9818C4B3DF00E080D2 /* AGAsyncTestHelperSenTestTarget.octest */; 271 | productType = "com.apple.product-type.bundle"; 272 | }; 273 | /* End PBXNativeTarget section */ 274 | 275 | /* Begin PBXProject section */ 276 | A3FE7D5A18C4B3A800E080D2 /* Project object */ = { 277 | isa = PBXProject; 278 | attributes = { 279 | CLASSPREFIX = AG; 280 | LastUpgradeCheck = 0500; 281 | ORGANIZATIONNAME = "Agens AS"; 282 | TargetAttributes = { 283 | A3FE7D7C18C4B3A800E080D2 = { 284 | TestTargetID = A3FE7D6118C4B3A800E080D2; 285 | }; 286 | A3FE7D9718C4B3DF00E080D2 = { 287 | TestTargetID = A3FE7D6118C4B3A800E080D2; 288 | }; 289 | }; 290 | }; 291 | buildConfigurationList = A3FE7D5D18C4B3A800E080D2 /* Build configuration list for PBXProject "AGAsyncTestHelperDemo" */; 292 | compatibilityVersion = "Xcode 3.2"; 293 | developmentRegion = English; 294 | hasScannedForEncodings = 0; 295 | knownRegions = ( 296 | en, 297 | ); 298 | mainGroup = A3FE7D5918C4B3A800E080D2; 299 | productRefGroup = A3FE7D6318C4B3A800E080D2 /* Products */; 300 | projectDirPath = ""; 301 | projectRoot = ""; 302 | targets = ( 303 | A3FE7D6118C4B3A800E080D2 /* AGAsyncTestHelperDemo */, 304 | A3FE7D7C18C4B3A800E080D2 /* AGAsyncTestHelperXCTestTarget */, 305 | A3FE7D9718C4B3DF00E080D2 /* AGAsyncTestHelperSenTestTarget */, 306 | ); 307 | }; 308 | /* End PBXProject section */ 309 | 310 | /* Begin PBXResourcesBuildPhase section */ 311 | A3FE7D6018C4B3A800E080D2 /* Resources */ = { 312 | isa = PBXResourcesBuildPhase; 313 | buildActionMask = 2147483647; 314 | files = ( 315 | A3FE7D7018C4B3A800E080D2 /* InfoPlist.strings in Resources */, 316 | A3FE7D7818C4B3A800E080D2 /* Images.xcassets in Resources */, 317 | ); 318 | runOnlyForDeploymentPostprocessing = 0; 319 | }; 320 | A3FE7D7B18C4B3A800E080D2 /* Resources */ = { 321 | isa = PBXResourcesBuildPhase; 322 | buildActionMask = 2147483647; 323 | files = ( 324 | A3FE7D8918C4B3A800E080D2 /* InfoPlist.strings in Resources */, 325 | ); 326 | runOnlyForDeploymentPostprocessing = 0; 327 | }; 328 | A3FE7D9618C4B3DF00E080D2 /* Resources */ = { 329 | isa = PBXResourcesBuildPhase; 330 | buildActionMask = 2147483647; 331 | files = ( 332 | A3FE7DA218C4B3DF00E080D2 /* InfoPlist.strings in Resources */, 333 | ); 334 | runOnlyForDeploymentPostprocessing = 0; 335 | }; 336 | /* End PBXResourcesBuildPhase section */ 337 | 338 | /* Begin PBXSourcesBuildPhase section */ 339 | A3FE7D5E18C4B3A800E080D2 /* Sources */ = { 340 | isa = PBXSourcesBuildPhase; 341 | buildActionMask = 2147483647; 342 | files = ( 343 | A3FE7D7618C4B3A800E080D2 /* AGAppDelegate.m in Sources */, 344 | A3FE7D7218C4B3A800E080D2 /* main.m in Sources */, 345 | ); 346 | runOnlyForDeploymentPostprocessing = 0; 347 | }; 348 | A3FE7D7918C4B3A800E080D2 /* Sources */ = { 349 | isa = PBXSourcesBuildPhase; 350 | buildActionMask = 2147483647; 351 | files = ( 352 | A3FE7DB118C4B42400E080D2 /* AGAsyncTestHelperXCTTest.m in Sources */, 353 | ); 354 | runOnlyForDeploymentPostprocessing = 0; 355 | }; 356 | A3FE7D9418C4B3DF00E080D2 /* Sources */ = { 357 | isa = PBXSourcesBuildPhase; 358 | buildActionMask = 2147483647; 359 | files = ( 360 | A3FE7DB018C4B42200E080D2 /* AGAsyncTestHelperSenTest.m in Sources */, 361 | ); 362 | runOnlyForDeploymentPostprocessing = 0; 363 | }; 364 | /* End PBXSourcesBuildPhase section */ 365 | 366 | /* Begin PBXTargetDependency section */ 367 | A3FE7D8318C4B3A800E080D2 /* PBXTargetDependency */ = { 368 | isa = PBXTargetDependency; 369 | target = A3FE7D6118C4B3A800E080D2 /* AGAsyncTestHelperDemo */; 370 | targetProxy = A3FE7D8218C4B3A800E080D2 /* PBXContainerItemProxy */; 371 | }; 372 | A3FE7DA718C4B3DF00E080D2 /* PBXTargetDependency */ = { 373 | isa = PBXTargetDependency; 374 | target = A3FE7D6118C4B3A800E080D2 /* AGAsyncTestHelperDemo */; 375 | targetProxy = A3FE7DA618C4B3DF00E080D2 /* PBXContainerItemProxy */; 376 | }; 377 | /* End PBXTargetDependency section */ 378 | 379 | /* Begin PBXVariantGroup section */ 380 | A3FE7D6E18C4B3A800E080D2 /* InfoPlist.strings */ = { 381 | isa = PBXVariantGroup; 382 | children = ( 383 | A3FE7D6F18C4B3A800E080D2 /* en */, 384 | ); 385 | name = InfoPlist.strings; 386 | sourceTree = ""; 387 | }; 388 | A3FE7D8718C4B3A800E080D2 /* InfoPlist.strings */ = { 389 | isa = PBXVariantGroup; 390 | children = ( 391 | A3FE7D8818C4B3A800E080D2 /* en */, 392 | ); 393 | name = InfoPlist.strings; 394 | sourceTree = ""; 395 | }; 396 | A3FE7DA018C4B3DF00E080D2 /* InfoPlist.strings */ = { 397 | isa = PBXVariantGroup; 398 | children = ( 399 | A3FE7DA118C4B3DF00E080D2 /* en */, 400 | ); 401 | name = InfoPlist.strings; 402 | sourceTree = ""; 403 | }; 404 | /* End PBXVariantGroup section */ 405 | 406 | /* Begin XCBuildConfiguration section */ 407 | A3FE7D8C18C4B3A800E080D2 /* Debug */ = { 408 | isa = XCBuildConfiguration; 409 | buildSettings = { 410 | ALWAYS_SEARCH_USER_PATHS = NO; 411 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 412 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 413 | CLANG_CXX_LIBRARY = "libc++"; 414 | CLANG_ENABLE_MODULES = YES; 415 | CLANG_ENABLE_OBJC_ARC = YES; 416 | CLANG_WARN_BOOL_CONVERSION = YES; 417 | CLANG_WARN_CONSTANT_CONVERSION = YES; 418 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 419 | CLANG_WARN_EMPTY_BODY = YES; 420 | CLANG_WARN_ENUM_CONVERSION = YES; 421 | CLANG_WARN_INT_CONVERSION = YES; 422 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 423 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 424 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 425 | COPY_PHASE_STRIP = NO; 426 | GCC_C_LANGUAGE_STANDARD = gnu99; 427 | GCC_DYNAMIC_NO_PIC = NO; 428 | GCC_OPTIMIZATION_LEVEL = 0; 429 | GCC_PREPROCESSOR_DEFINITIONS = ( 430 | "DEBUG=1", 431 | "$(inherited)", 432 | ); 433 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 434 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 435 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 436 | GCC_WARN_UNDECLARED_SELECTOR = YES; 437 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 438 | GCC_WARN_UNUSED_FUNCTION = YES; 439 | GCC_WARN_UNUSED_VARIABLE = YES; 440 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 441 | ONLY_ACTIVE_ARCH = YES; 442 | SDKROOT = iphoneos; 443 | TARGETED_DEVICE_FAMILY = "1,2"; 444 | }; 445 | name = Debug; 446 | }; 447 | A3FE7D8D18C4B3A800E080D2 /* Release */ = { 448 | isa = XCBuildConfiguration; 449 | buildSettings = { 450 | ALWAYS_SEARCH_USER_PATHS = NO; 451 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 452 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 453 | CLANG_CXX_LIBRARY = "libc++"; 454 | CLANG_ENABLE_MODULES = YES; 455 | CLANG_ENABLE_OBJC_ARC = YES; 456 | CLANG_WARN_BOOL_CONVERSION = YES; 457 | CLANG_WARN_CONSTANT_CONVERSION = YES; 458 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 459 | CLANG_WARN_EMPTY_BODY = YES; 460 | CLANG_WARN_ENUM_CONVERSION = YES; 461 | CLANG_WARN_INT_CONVERSION = YES; 462 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 463 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 464 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 465 | COPY_PHASE_STRIP = YES; 466 | ENABLE_NS_ASSERTIONS = NO; 467 | GCC_C_LANGUAGE_STANDARD = gnu99; 468 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 469 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 470 | GCC_WARN_UNDECLARED_SELECTOR = YES; 471 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 472 | GCC_WARN_UNUSED_FUNCTION = YES; 473 | GCC_WARN_UNUSED_VARIABLE = YES; 474 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 475 | SDKROOT = iphoneos; 476 | TARGETED_DEVICE_FAMILY = "1,2"; 477 | VALIDATE_PRODUCT = YES; 478 | }; 479 | name = Release; 480 | }; 481 | A3FE7D8F18C4B3A800E080D2 /* Debug */ = { 482 | isa = XCBuildConfiguration; 483 | buildSettings = { 484 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 485 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 486 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 487 | GCC_PREFIX_HEADER = "AGAsyncTestHelperDemo/AGAsyncTestHelperDemo-Prefix.pch"; 488 | INFOPLIST_FILE = "AGAsyncTestHelperDemo/AGAsyncTestHelperDemo-Info.plist"; 489 | PRODUCT_NAME = "$(TARGET_NAME)"; 490 | WRAPPER_EXTENSION = app; 491 | }; 492 | name = Debug; 493 | }; 494 | A3FE7D9018C4B3A800E080D2 /* Release */ = { 495 | isa = XCBuildConfiguration; 496 | buildSettings = { 497 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 498 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 499 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 500 | GCC_PREFIX_HEADER = "AGAsyncTestHelperDemo/AGAsyncTestHelperDemo-Prefix.pch"; 501 | INFOPLIST_FILE = "AGAsyncTestHelperDemo/AGAsyncTestHelperDemo-Info.plist"; 502 | PRODUCT_NAME = "$(TARGET_NAME)"; 503 | WRAPPER_EXTENSION = app; 504 | }; 505 | name = Release; 506 | }; 507 | A3FE7D9218C4B3A800E080D2 /* Debug */ = { 508 | isa = XCBuildConfiguration; 509 | buildSettings = { 510 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 511 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/AGAsyncTestHelperDemo.app/AGAsyncTestHelperDemo"; 512 | FRAMEWORK_SEARCH_PATHS = ( 513 | "$(SDKROOT)/Developer/Library/Frameworks", 514 | "$(inherited)", 515 | "$(DEVELOPER_FRAMEWORKS_DIR)", 516 | ); 517 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 518 | GCC_PREFIX_HEADER = "AGAsyncTestHelperDemo/AGAsyncTestHelperDemo-Prefix.pch"; 519 | GCC_PREPROCESSOR_DEFINITIONS = ( 520 | "DEBUG=1", 521 | "$(inherited)", 522 | ); 523 | INFOPLIST_FILE = "AGAsyncTestHelperDemoTests/AGAsyncTestHelperDemoTests-Info.plist"; 524 | PRODUCT_NAME = "$(TARGET_NAME)"; 525 | TEST_HOST = "$(BUNDLE_LOADER)"; 526 | WRAPPER_EXTENSION = xctest; 527 | }; 528 | name = Debug; 529 | }; 530 | A3FE7D9318C4B3A800E080D2 /* Release */ = { 531 | isa = XCBuildConfiguration; 532 | buildSettings = { 533 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 534 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/AGAsyncTestHelperDemo.app/AGAsyncTestHelperDemo"; 535 | FRAMEWORK_SEARCH_PATHS = ( 536 | "$(SDKROOT)/Developer/Library/Frameworks", 537 | "$(inherited)", 538 | "$(DEVELOPER_FRAMEWORKS_DIR)", 539 | ); 540 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 541 | GCC_PREFIX_HEADER = "AGAsyncTestHelperDemo/AGAsyncTestHelperDemo-Prefix.pch"; 542 | INFOPLIST_FILE = "AGAsyncTestHelperDemoTests/AGAsyncTestHelperDemoTests-Info.plist"; 543 | PRODUCT_NAME = "$(TARGET_NAME)"; 544 | TEST_HOST = "$(BUNDLE_LOADER)"; 545 | WRAPPER_EXTENSION = xctest; 546 | }; 547 | name = Release; 548 | }; 549 | A3FE7DA918C4B3DF00E080D2 /* Debug */ = { 550 | isa = XCBuildConfiguration; 551 | buildSettings = { 552 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 553 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/AGAsyncTestHelperDemo.app/AGAsyncTestHelperDemo"; 554 | FRAMEWORK_SEARCH_PATHS = ( 555 | "$(SDKROOT)/Developer/Library/Frameworks", 556 | "$(inherited)", 557 | "$(DEVELOPER_FRAMEWORKS_DIR)", 558 | ); 559 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 560 | GCC_PREFIX_HEADER = "AGAsyncTestHelperSenTestTarget/AGAsyncTestHelperSenTestTarget-Prefix.pch"; 561 | GCC_PREPROCESSOR_DEFINITIONS = ( 562 | "DEBUG=1", 563 | "$(inherited)", 564 | ); 565 | INFOPLIST_FILE = "AGAsyncTestHelperSenTestTarget/AGAsyncTestHelperSenTestTarget-Info.plist"; 566 | PRODUCT_NAME = "$(TARGET_NAME)"; 567 | TEST_HOST = "$(BUNDLE_LOADER)"; 568 | WRAPPER_EXTENSION = octest; 569 | }; 570 | name = Debug; 571 | }; 572 | A3FE7DAA18C4B3DF00E080D2 /* Release */ = { 573 | isa = XCBuildConfiguration; 574 | buildSettings = { 575 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 576 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/AGAsyncTestHelperDemo.app/AGAsyncTestHelperDemo"; 577 | FRAMEWORK_SEARCH_PATHS = ( 578 | "$(SDKROOT)/Developer/Library/Frameworks", 579 | "$(inherited)", 580 | "$(DEVELOPER_FRAMEWORKS_DIR)", 581 | ); 582 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 583 | GCC_PREFIX_HEADER = "AGAsyncTestHelperSenTestTarget/AGAsyncTestHelperSenTestTarget-Prefix.pch"; 584 | INFOPLIST_FILE = "AGAsyncTestHelperSenTestTarget/AGAsyncTestHelperSenTestTarget-Info.plist"; 585 | PRODUCT_NAME = "$(TARGET_NAME)"; 586 | TEST_HOST = "$(BUNDLE_LOADER)"; 587 | WRAPPER_EXTENSION = octest; 588 | }; 589 | name = Release; 590 | }; 591 | /* End XCBuildConfiguration section */ 592 | 593 | /* Begin XCConfigurationList section */ 594 | A3FE7D5D18C4B3A800E080D2 /* Build configuration list for PBXProject "AGAsyncTestHelperDemo" */ = { 595 | isa = XCConfigurationList; 596 | buildConfigurations = ( 597 | A3FE7D8C18C4B3A800E080D2 /* Debug */, 598 | A3FE7D8D18C4B3A800E080D2 /* Release */, 599 | ); 600 | defaultConfigurationIsVisible = 0; 601 | defaultConfigurationName = Release; 602 | }; 603 | A3FE7D8E18C4B3A800E080D2 /* Build configuration list for PBXNativeTarget "AGAsyncTestHelperDemo" */ = { 604 | isa = XCConfigurationList; 605 | buildConfigurations = ( 606 | A3FE7D8F18C4B3A800E080D2 /* Debug */, 607 | A3FE7D9018C4B3A800E080D2 /* Release */, 608 | ); 609 | defaultConfigurationIsVisible = 0; 610 | defaultConfigurationName = Release; 611 | }; 612 | A3FE7D9118C4B3A800E080D2 /* Build configuration list for PBXNativeTarget "AGAsyncTestHelperXCTestTarget" */ = { 613 | isa = XCConfigurationList; 614 | buildConfigurations = ( 615 | A3FE7D9218C4B3A800E080D2 /* Debug */, 616 | A3FE7D9318C4B3A800E080D2 /* Release */, 617 | ); 618 | defaultConfigurationIsVisible = 0; 619 | defaultConfigurationName = Release; 620 | }; 621 | A3FE7DA818C4B3DF00E080D2 /* Build configuration list for PBXNativeTarget "AGAsyncTestHelperSenTestTarget" */ = { 622 | isa = XCConfigurationList; 623 | buildConfigurations = ( 624 | A3FE7DA918C4B3DF00E080D2 /* Debug */, 625 | A3FE7DAA18C4B3DF00E080D2 /* Release */, 626 | ); 627 | defaultConfigurationIsVisible = 0; 628 | defaultConfigurationName = Release; 629 | }; 630 | /* End XCConfigurationList section */ 631 | }; 632 | rootObject = A3FE7D5A18C4B3A800E080D2 /* Project object */; 633 | } 634 | -------------------------------------------------------------------------------- /AGAsyncTestHelperDemo/AGAsyncTestHelperDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /AGAsyncTestHelperDemo/AGAsyncTestHelperDemo.xcodeproj/project.xcworkspace/xcshareddata/AGAsyncTestHelperDemo.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | C5E44A92-C7EF-4610-8CE5-7B54DB47EB5B 9 | IDESourceControlProjectName 10 | AGAsyncTestHelperDemo 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 1D46435B-C797-4239-A800-CD091831D47D 14 | ssh://github.com/hfossli/AGSAsyncTestHelper.git 15 | 16 | IDESourceControlProjectPath 17 | Demo2/AGAsyncTestHelperDemo/AGAsyncTestHelperDemo.xcodeproj/project.xcworkspace 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 1D46435B-C797-4239-A800-CD091831D47D 21 | ../../../.. 22 | 23 | IDESourceControlProjectURL 24 | ssh://github.com/hfossli/AGSAsyncTestHelper.git 25 | IDESourceControlProjectVersion 26 | 110 27 | IDESourceControlProjectWCCIdentifier 28 | 1D46435B-C797-4239-A800-CD091831D47D 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 1D46435B-C797-4239-A800-CD091831D47D 36 | IDESourceControlWCCName 37 | AGSAsyncTestHelper 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /AGAsyncTestHelperDemo/AGAsyncTestHelperDemo.xcodeproj/xcuserdata/hfossli.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /AGAsyncTestHelperDemo/AGAsyncTestHelperDemo.xcodeproj/xcuserdata/hfossli.xcuserdatad/xcschemes/AGAsyncTestHelperDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 71 | 72 | 78 | 79 | 80 | 81 | 82 | 83 | 89 | 90 | 96 | 97 | 98 | 99 | 101 | 102 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /AGAsyncTestHelperDemo/AGAsyncTestHelperDemo.xcodeproj/xcuserdata/hfossli.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | AGAsyncTestHelperDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | A3FE7D6118C4B3A800E080D2 16 | 17 | primary 18 | 19 | 20 | A3FE7D7C18C4B3A800E080D2 21 | 22 | primary 23 | 24 | 25 | A3FE7D9718C4B3DF00E080D2 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /AGAsyncTestHelperDemo/AGAsyncTestHelperDemo/AGAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AGAppDelegate.h 3 | // AGAsyncTestHelperDemo 4 | // 5 | // Created by Håvard Fossli on 03.03.14. 6 | // Copyright (c) 2014 Agens AS. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AGAppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /AGAsyncTestHelperDemo/AGAsyncTestHelperDemo/AGAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AGAppDelegate.m 3 | // AGAsyncTestHelperDemo 4 | // 5 | // Created by Håvard Fossli on 03.03.14. 6 | // Copyright (c) 2014 Agens AS. All rights reserved. 7 | // 8 | 9 | #import "AGAppDelegate.h" 10 | 11 | @implementation AGAppDelegate 12 | 13 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 14 | { 15 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 16 | // Override point for customization after application launch. 17 | self.window.backgroundColor = [UIColor whiteColor]; 18 | [self.window makeKeyAndVisible]; 19 | return YES; 20 | } 21 | 22 | - (void)applicationWillResignActive:(UIApplication *)application 23 | { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application 29 | { 30 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 31 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 32 | } 33 | 34 | - (void)applicationWillEnterForeground:(UIApplication *)application 35 | { 36 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 37 | } 38 | 39 | - (void)applicationDidBecomeActive:(UIApplication *)application 40 | { 41 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 42 | } 43 | 44 | - (void)applicationWillTerminate:(UIApplication *)application 45 | { 46 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /AGAsyncTestHelperDemo/AGAsyncTestHelperDemo/AGAsyncTestHelperDemo-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | no.agens.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /AGAsyncTestHelperDemo/AGAsyncTestHelperDemo/AGAsyncTestHelperDemo-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_3_0 10 | #warning "This project uses features only available in iOS SDK 3.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | #import 15 | #import 16 | #endif 17 | -------------------------------------------------------------------------------- /AGAsyncTestHelperDemo/AGAsyncTestHelperDemo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "ipad", 20 | "size" : "29x29", 21 | "scale" : "1x" 22 | }, 23 | { 24 | "idiom" : "ipad", 25 | "size" : "29x29", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "ipad", 30 | "size" : "40x40", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "40x40", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "76x76", 41 | "scale" : "1x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "76x76", 46 | "scale" : "2x" 47 | } 48 | ], 49 | "info" : { 50 | "version" : 1, 51 | "author" : "xcode" 52 | } 53 | } -------------------------------------------------------------------------------- /AGAsyncTestHelperDemo/AGAsyncTestHelperDemo/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "orientation" : "portrait", 20 | "idiom" : "ipad", 21 | "extent" : "full-screen", 22 | "minimum-system-version" : "7.0", 23 | "scale" : "1x" 24 | }, 25 | { 26 | "orientation" : "landscape", 27 | "idiom" : "ipad", 28 | "extent" : "full-screen", 29 | "minimum-system-version" : "7.0", 30 | "scale" : "1x" 31 | }, 32 | { 33 | "orientation" : "portrait", 34 | "idiom" : "ipad", 35 | "extent" : "full-screen", 36 | "minimum-system-version" : "7.0", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "orientation" : "landscape", 41 | "idiom" : "ipad", 42 | "extent" : "full-screen", 43 | "minimum-system-version" : "7.0", 44 | "scale" : "2x" 45 | } 46 | ], 47 | "info" : { 48 | "version" : 1, 49 | "author" : "xcode" 50 | } 51 | } -------------------------------------------------------------------------------- /AGAsyncTestHelperDemo/AGAsyncTestHelperDemo/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /AGAsyncTestHelperDemo/AGAsyncTestHelperDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // AGAsyncTestHelperDemo 4 | // 5 | // Created by Håvard Fossli on 03.03.14. 6 | // Copyright (c) 2014 Agens AS. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "AGAppDelegate.h" 12 | 13 | int main(int argc, char * argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AGAppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /AGAsyncTestHelperDemo/AGAsyncTestHelperDemoTests/AGAsyncTestHelperDemoTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | no.agens.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /AGAsyncTestHelperDemo/AGAsyncTestHelperDemoTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /AGAsyncTestHelperDemo/AGAsyncTestHelperSenTestTarget/AGAsyncTestHelperSenTestTarget-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | no.agens.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /AGAsyncTestHelperDemo/AGAsyncTestHelperSenTestTarget/AGAsyncTestHelperSenTestTarget-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #ifdef __OBJC__ 8 | #import 9 | #import 10 | #endif 11 | -------------------------------------------------------------------------------- /AGAsyncTestHelperDemo/AGAsyncTestHelperSenTestTarget/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Author: Håvard Fossli 3 | 4 | Copyright (c) 2013 Agens AS (http://agens.no/) 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AGAsyncTestHelper 2 | 3 | C Macro for writing unit tests with asynchronous operations on iOS. Supports both SenTestingKit and XCTest. 4 | 5 | ### No further support 6 | 7 | This repo will not be developed or supported any further. You may continue to use it, but we recommend switching to [expecta](https://github.com/specta/expecta) instead. 8 | 9 | 10 | ### Install 11 | 12 | `pod 'AGAsyncTestHelper'` or `pod 'AGAsyncTestHelper/Shorthand'` with cocoapods. The latter one lets you write `WAIT_WHILE()` instead of `AGWW_WAIT_WHILE()`. 13 | 14 | 15 | #### Manual installation 16 | 17 | Copy the files found in `Source` over to your project. 18 | 19 | If you want to have shorthand enabled (`WAIT_WHILE()` instead of `AGWW_WAIT_WHILE()`) you can either create a *User Defined Build Setting* within Xcode named `AGWW_SHORTHAND` OR write `#define AGWW_SHORTHAND` some clever place in your testsuite. 20 | 21 | 22 | ### Overview 23 | 24 | The macro will evaluate the expression (the first parameter) until expression is not longer true **or** the time limit is reached. 25 | 26 | These macros will generate `XCTFail()` or `STFail()` if time limit is reached. 27 | 28 | WAIT_WHILE(, limit_in_seconds, ...) 29 | WAIT_WHILE_EQUALS(, , limit_in_seconds, ...) 30 | WAIT_WHILE_EQUALS_WITH_ACCURACY(, , accuracy, limit_in_seconds, ...) 31 | WAIT_WHILE_NOT_EQUALS(, , limit_in_seconds, ...) 32 | STALL_RUNLOPP_WHILE(, limit_in_seconds) 33 | 34 | 35 | 36 | 37 | 38 | ### Example: Wait for block callback 39 | 40 | ``` 41 | - (void)testAsyncBlockCallback 42 | { 43 | __block BOOL jobDone = NO; 44 | 45 | [Manager doSomeOperationOnDone:^(id data) { 46 | jobDone = YES; 47 | }]; 48 | 49 | WAIT_WHILE(!jobDone, 2.0); 50 | } 51 | ``` 52 | 53 | `WAIT_WHILE()` will stall current runloop while `!jobDone` is `TRUE` and throw an `XCTFail()` if exceeding time limit (2.0 seconds) 54 | 55 | 56 | 57 | 58 | 59 | ### Example: Wait for delegate callback 60 | 61 | ``` 62 | - (void)testAsyncDelegateCallback 63 | { 64 | Manager *manager = [Manager new]; 65 | manager.delegate = self; 66 | [manager doSomeOperation]; 67 | 68 | WAIT_WHILE(!self.jobDone, 2.0); 69 | } 70 | 71 | - (void)someOperationIsDoneInManager:(Manager *)manager 72 | { 73 | self.jobDone = YES; 74 | } 75 | ``` 76 | `WAIT_WHILE()` will stall current runloop while `!self.jobDone` is `TRUE` and throw an `XCTFail()` or `STFail()` if exceeding time limit (2.0 seconds) 77 | 78 | 79 | 80 | 81 | 82 | 83 | ### Example: Wait for @selector callback 84 | 85 | ``` 86 | - (void)testAsyncSelectorCallback 87 | { 88 | [Manager doSomeOperationOnDoneTellTarget:self selector:@selector(someOperationIsDone)]; 89 | 90 | WAIT_WHILE(!self.jobDone, 2.0); 91 | } 92 | 93 | - (void)someOperationIsDone 94 | { 95 | self.jobDone = YES; 96 | } 97 | ``` 98 | 99 | `WAIT_WHILE()` will stall current runloop while `!self.jobDone` is `TRUE` and throw an `XCTFail()` or `STFail()` if exceeding time limit (2.0 seconds) 100 | 101 | 102 | 103 | 104 | 105 | 106 | ### Example: Multiple values will eventually be right 107 | 108 | ``` 109 | - (void)testMultipleWillEventuallyBeRight 110 | { 111 | UIImage *image = ...; 112 | [[ImageManager shared] saveImage:image]; 113 | 114 | BOOL (^cacheIsPurged) = ^{ 115 | UIImage *cachedMemoryImage = [[ImageManager shared] imageFromMemoryCacheForKey:@"IMAGE_KEY"]; 116 | UIImage *cachedDiskImage = [[ImageManager shared] imageFromDiskCacheForKey:@"IMAGE_KEY"]; 117 | return cachedMemoryImage || cachedDiskImage; 118 | }; 119 | 120 | [[ImageManager shared] purgeCacheAsync]; 121 | 122 | WAIT_WHILE(!cacheIsPurged(), 5.0, @"Failed to clean up image cache!"); 123 | } 124 | ``` 125 | `WAIT_WHILE()` will stall current runloop while `!cacheIsPurged()` is `TRUE` and throw an `XCTFail()` or `STFail()` if exceeding time limit (5.0 seconds) 126 | 127 | 128 | 129 | 130 | ### Under the hood 131 | 132 | A simplified version of how the macro works could look like this 133 | 134 | ``` 135 | __block BOOL done = NO; 136 | doSomethingAsynchronouslyWithBlock(^{ 137 | done = YES; 138 | }); 139 | 140 | while(!done) { 141 | [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; 142 | } 143 | ``` 144 | 145 | Effectively stalling the runloop until `done` is true. This does not block the main thread so you are still able to have callbacks on the main thread. 146 | 147 | 148 | 149 | 150 | 151 | ### Advantages 152 | 153 | - Minimum code 154 | - Error thrown *in the test*. Since it is based on macro's the exception will not be thrown in some 3rd party implementation file further down the stack 155 | - Small library 156 | - Works perfectly with SenTestingKit and XCTest (could easily support more) 157 | - No known bugs or issues 158 | 159 | 160 | 161 | 162 | ### Alternatives 163 | 164 | You've got several alternatives like 165 | 166 | - [SenAsyncTestCase](https://github.com/akisute/SenAsyncTestCase) 167 | - [AssertEventually](https://gist.github.com/lukeredpath/506353/) 168 | - [Kiwi](https://github.com/allending/Kiwi/wiki/Asynchronous-Testing) 169 | - [SenTestCase+SRTAdditions](https://github.com/square/SocketRocket/blob/master/SRWebSocketTests/SenTestCase+SRTAdditions.h) 170 | - [SenTestingKitAsync](https://github.com/nxtbgthng/SenTestingKitAsync) 171 | 172 | If you've got other alternatives which should be listed here please let me know. 173 | 174 | There is also a great thread on stack overflow http://stackoverflow.com/questions/4114083/ios-tests-specs-tdd-bdd-and-integration-acceptance-testing 175 | 176 | 177 | 178 | 179 | 180 | ### Extensive description 181 | 182 | This library or bundle enables you to do async test operations with asynchronous callbacks in your SenTestCase or XCTestCase. Works with GCD (Grand Central Dispatch), blocks, NSOperation and regular delegate callbacks. 183 | 184 | [![Agens | Digital craftsmanship](http://static.agens.no/images/agens_logo_w_slogan_avenir_small.png)](http://agens.no/) 185 | -------------------------------------------------------------------------------- /Source/AGAsyncTestHelper.h: -------------------------------------------------------------------------------- 1 | // 2 | // Author: Håvard Fossli 3 | // 4 | // Copyright (c) 2013 Agens AS (http://agens.no/) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | 25 | 26 | /** 27 | * @param whileTrue Can be anything 28 | * @param seconds NSTimeInterval 29 | */ 30 | #define AGWW_STALL_RUNLOOP_WHILE(whileTrue, limitInSeconds)\ 31 | ({\ 32 | NSDate *giveUpDate = [NSDate dateWithTimeIntervalSinceNow:limitInSeconds];\ 33 | while ((whileTrue) && [giveUpDate timeIntervalSinceNow] > 0)\ 34 | {\ 35 | NSDate *loopIntervalDate = [NSDate dateWithTimeIntervalSinceNow:0.01];\ 36 | [[NSRunLoop currentRunLoop] runUntilDate:loopIntervalDate];\ 37 | }\ 38 | }) 39 | #ifdef AGWW_SHORTHAND 40 | # define STALL_RUNLOOP_WHILE(whileTrue, limitInSeconds) AGWW_STALL_RUNLOOP_WHILE(whileTrue, limitInSeconds) 41 | #endif 42 | 43 | /** 44 | * @param whileTrue Can be anything 45 | * @param seconds NSTimeInterval 46 | * @param ... Description format string (optional) 47 | */ 48 | #define AGWW_WAIT_WHILE(whileTrue, seconds, ...)\ 49 | ({\ 50 | NSTimeInterval castedLimit = seconds;\ 51 | NSString *conditionString = [NSString stringWithFormat:@"(%s) should NOT be true after async operation completed", #whileTrue];\ 52 | AGWW_STALL_RUNLOOP_WHILE(whileTrue, castedLimit);\ 53 | if(whileTrue)\ 54 | {\ 55 | NSString *description = [NSString stringWithFormat:@"" __VA_ARGS__]; \ 56 | NSString *failString = _agww_makeFailString(conditionString, castedLimit, description, ##__VA_ARGS__);\ 57 | _AGWW_FAIL(@"%@", failString);\ 58 | }\ 59 | }) 60 | #ifdef AGWW_SHORTHAND 61 | # define WAIT_WHILE(whileTrue, seconds, ...) AGWW_WAIT_WHILE(whileTrue, seconds, ##__VA_ARGS__) 62 | #endif 63 | 64 | /** 65 | * @param value1 Primitive value 66 | * @param value2 Other primitive value (must be same type as 'value1') 67 | * @param seconds NSTimeInterval 68 | * @param ... Description format string (optional) 69 | */ 70 | #define AGWW_WAIT_WHILE_EQUALS(value1, value2, limitInSeconds, ...)\ 71 | ({\ 72 | _AGWW_ASSERT_SAME_TYPE(value1, value2);\ 73 | NSTimeInterval castedLimit = limitInSeconds;\ 74 | \ 75 | AGWW_STALL_RUNLOOP_WHILE(value1 == value2, castedLimit);\ 76 | if(value1 == value2)\ 77 | {\ 78 | NSString *description = [NSString stringWithFormat:@"" __VA_ARGS__]; \ 79 | NSString *conditionString = _AGWW_VALUE_EQUALITY_FAIL_STRING(value1, @"should not be equal to", value2, 0);\ 80 | NSString *failString = _agww_makeFailString(conditionString, castedLimit, description, ##__VA_ARGS__);\ 81 | _AGWW_FAIL(@"%@", failString);\ 82 | }\ 83 | }) 84 | #ifdef AGWW_SHORTHAND 85 | # define WAIT_WHILE_EQUALS(value1, value2, limitInSeconds, ...) AGWW_WAIT_WHILE_EQUALS(value1, value2, limitInSeconds, ##__VA_ARGS__) 86 | #endif 87 | 88 | /** 89 | * @param value1 Primitive value 90 | * @param value2 Other primitive value (must be same type as 'value1') 91 | * @param accuracy Primitive value 92 | * @param seconds NSTimeInterval 93 | * @param ... Description format string (optional) 94 | */ 95 | #define AGWW_WAIT_WHILE_EQUALS_WITH_ACCURACY(value1, value2, accuracy, limitInSeconds, ...)\ 96 | ({\ 97 | _AGWW_ASSERT_SAME_TYPE(value1, value2);\ 98 | _AGWW_ASSERT_SAME_TYPE(value1, accuracy);\ 99 | NSTimeInterval castedLimit = limitInSeconds;\ 100 | \ 101 | AGWW_STALL_RUNLOOP_WHILE(_AGWW_ABSOLUTE_DIFFERENCE(value1, value2) < accuracy, castedLimit);\ 102 | if(_AGWW_ABSOLUTE_DIFFERENCE(value1, value2) < accuracy)\ 103 | {\ 104 | NSString *description = [NSString stringWithFormat:@"" __VA_ARGS__]; \ 105 | NSString *conditionString = _AGWW_VALUE_EQUALITY_FAIL_STRING(value1, @"should be equal to", value2, accuracy);\ 106 | NSString *failString = _agww_makeFailString(conditionString, castedLimit, description, ##__VA_ARGS__);\ 107 | _AGWW_FAIL(@"%@", failString);\ 108 | }\ 109 | }) 110 | #ifdef AGWW_SHORTHAND 111 | # define WAIT_WHILE_EQUALS_WITH_ACCURACY(value1, value2, accuracy, limitInSeconds, ...) AGWW_WAIT_WHILE_EQUALS_WITH_ACCURACY(value1, value2, accuracy, limitInSeconds, ##__VA_ARGS__) 112 | #endif 113 | 114 | /** 115 | * @param value1 Primitive value 116 | * @param value2 Other primitive value (must be same type as 'value1') 117 | * @param seconds NSTimeInterval 118 | * @param ... Description format string (optional) 119 | */ 120 | #define AGWW_WAIT_WHILE_NOT_EQUALS(value1, value2, limitInSeconds, ...)\ 121 | ({\ 122 | _AGWW_ASSERT_SAME_TYPE(value1, value2);\ 123 | NSTimeInterval castedLimit = limitInSeconds;\ 124 | \ 125 | AGWW_STALL_RUNLOOP_WHILE(value1 != value2, castedLimit);\ 126 | if(value1 != value2)\ 127 | {\ 128 | NSString *description = [NSString stringWithFormat:@"" __VA_ARGS__]; \ 129 | NSString *conditionString = _AGWW_VALUE_EQUALITY_FAIL_STRING(value1, @"should not be equal to", value2, 0);\ 130 | NSString *failString = _agww_makeFailString(conditionString, castedLimit, description, ##__VA_ARGS__);\ 131 | _AGWW_FAIL(@"%@", failString);\ 132 | }\ 133 | }) 134 | #ifdef AGWW_SHORTHAND 135 | # define WAIT_WHILE_NOT_EQUALS(value1, value2, limitInSeconds, ...) AGWW_WAIT_WHILE_NOT_EQUALS(value1, value2, limitInSeconds, ##__VA_ARGS__) 136 | #endif 137 | 138 | 139 | 140 | /** 141 | * @param value1 Primitive value 142 | * @param value2 Other primitive value (must be same type as 'value1') 143 | * @param accuracy Primitive value 144 | * @param seconds NSTimeInterval 145 | * @param ... Description format string (optional) 146 | */ 147 | #define AGWW_WAIT_WHILE_NOT_EQUALS_WITH_ACCURACY(value1, value2, accuracy, limitInSeconds, ...)\ 148 | ({\ 149 | _AGWW_ASSERT_SAME_TYPE(value1, value2);\ 150 | _AGWW_ASSERT_SAME_TYPE(value1, accuracy);\ 151 | NSTimeInterval castedLimit = limitInSeconds;\ 152 | \ 153 | AGWW_STALL_RUNLOOP_WHILE(_AGWW_ABSOLUTE_DIFFERENCE(value1, value2) > accuracy, castedLimit);\ 154 | if(_AGWW_ABSOLUTE_DIFFERENCE(value1, value2) > accuracy)\ 155 | {\ 156 | NSString *description = [NSString stringWithFormat:@"" __VA_ARGS__]; \ 157 | NSString *conditionString = _AGWW_VALUE_EQUALITY_FAIL_STRING(value1, @"should be equal to", value2, accuracy);\ 158 | NSString *failString = _agww_makeFailString(conditionString, castedLimit, description, ##__VA_ARGS__);\ 159 | _AGWW_FAIL(@"%@", failString);\ 160 | }\ 161 | }) 162 | #ifdef AGWW_SHORTHAND 163 | # define WAIT_WHILE_EQUALS_WITH_ACCURACY(value1, value2, accuracy, limitInSeconds, ...) AGWW_WAIT_WHILE_EQUALS_WITH_ACCURACY(value1, value2, accuracy, limitInSeconds, ##__VA_ARGS__) 164 | #endif 165 | 166 | #if defined( XCTFail ) 167 | # define _AGWW_FAIL(...) XCTFail(__VA_ARGS__); 168 | #elif defined( STFail ) 169 | # define _AGWW_FAIL(...) STFail(__VA_ARGS__); 170 | #else 171 | # error "Missing import of either SenTestingKit or XCTest. Please check that your testclass which is importing AGAsyncTestHelper.h is actually importing the desired test framework." 172 | #endif 173 | 174 | #define _AGWW_IS_DIFFERENT_TYPE(a1, a2) strcmp(@encode(__typeof__(a1)), @encode(__typeof__(a2))) != 0 175 | 176 | #define _AGWW_ASSERT_SAME_TYPE(a1, a2) {\ 177 | if(_AGWW_IS_DIFFERENT_TYPE(a1, a2)) {\ 178 | _AGWW_FAIL(@"Type mismatch: %s is not same type as %s", #a1, #a2);\ 179 | }\ 180 | } 181 | 182 | #if __has_feature(objc_arc) 183 | # define _AGWW_RETAIN(xx) xx 184 | # define _AGWW_RELEASE(xx) xx 185 | # define _AGWW_AUTORELEASE(xx) xx 186 | #else 187 | # define _AGWW_RETAIN(xx) [xx retain] 188 | # define _AGWW_RELEASE(xx) [xx release] 189 | # define _AGWW_AUTORELEASE(xx) [xx autorelease] 190 | #endif 191 | 192 | // TODO: should be replaced with 193 | // https://github.com/JensAyton/JAValueToString 194 | 195 | #define _AGWW_PRIMITIVE_AS_STRING(value) \ 196 | ({\ 197 | const char *valueType = @encode(__typeof__(value));\ 198 | NSString *format = [NSString stringWithFormat:@"%s", _agww_printFormatTypeForObjCType(valueType)];\ 199 | NSString *valueAsString = [NSString stringWithFormat:format, value];\ 200 | valueAsString;\ 201 | }) 202 | 203 | #define _AGWW_VALUE_EQUALITY_FAIL_STRING(value1, glue, value2, accuracy) \ 204 | ({\ 205 | NSString *stringValue1 = _AGWW_PRIMITIVE_AS_STRING(value1);\ 206 | NSString *stringValue2 = _AGWW_PRIMITIVE_AS_STRING(value2);\ 207 | \ 208 | NSString *reason;\ 209 | if (accuracy) {\ 210 | reason = [NSString stringWithFormat:@"'%s' (%@) %@ '%s' (%@)", #value1, stringValue1, glue, #value2, stringValue2];\ 211 | } else {\ 212 | NSString *stringAccuracy = _AGWW_PRIMITIVE_AS_STRING(accuracy);\ 213 | reason = [NSString stringWithFormat:@"'%s' (%@) %@ '%s' (%@) +/-'%@'", #value1, stringValue1, glue, #value2, stringValue2, stringAccuracy];\ 214 | }\ 215 | reason;\ 216 | }) 217 | 218 | #define _AGWW_ABSOLUTE_DIFFERENCE(left,right) (MAX(left,right)-MIN(left,right)) 219 | 220 | static NSString * _agww_makeFailString(NSString *conditionString, NSTimeInterval seconds, NSString *description, ...) { 221 | va_list args; 222 | va_start(args, description); 223 | 224 | NSString *outputFormat = [NSString stringWithFormat:@"Async test didn't complete within %.2f seconds. %@. %@", (NSTimeInterval) seconds, conditionString, description]; 225 | NSString *outputString = _AGWW_AUTORELEASE([[NSString alloc] initWithFormat:outputFormat arguments:args]); 226 | va_end(args); 227 | 228 | return outputString; 229 | } 230 | 231 | static const char * _agww_printFormatTypeForObjCType(const char *type) 232 | { 233 | if(strcmp(type, @encode(BOOL)) == 0) 234 | return "%i"; 235 | else if(strcmp(type, @encode(int)) == 0) 236 | return "%i"; 237 | else if(strcmp(type, @encode(unsigned int)) == 0) 238 | return "%u"; 239 | else if(strcmp(type, @encode(long)) == 0) 240 | return "%li"; 241 | else if(strcmp(type, @encode(unsigned long)) == 0) 242 | return "%lu"; 243 | else if(strcmp(type, @encode(long long)) == 0) 244 | return "%lli"; 245 | else if(strcmp(type, @encode(unsigned long long)) == 0) 246 | return "%llu"; 247 | else if(strcmp(type, @encode(float)) == 0) 248 | return "%f"; 249 | else if(strcmp(type, @encode(double)) == 0) 250 | return "%d"; 251 | else 252 | return "%i"; 253 | } 254 | -------------------------------------------------------------------------------- /Tests/AGAsyncTestHelperSenTest.m: -------------------------------------------------------------------------------- 1 | // 2 | // Author: Håvard Fossli 3 | // 4 | // Copyright (c) 2013 Agens AS (http://agens.no/) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #import 25 | 26 | #define AGWW_SHORTHAND 27 | 28 | #import "AGAsyncTestHelper.h" 29 | 30 | @interface AGAsyncTestHelperSenTest : SenTestCase { 31 | @private 32 | BOOL asyncOperationCompleted; 33 | } 34 | 35 | @end 36 | 37 | @implementation AGAsyncTestHelperSenTest 38 | 39 | #pragma mark - Construct and destruct 40 | 41 | - (void)setUp 42 | { 43 | asyncOperationCompleted = NO; 44 | [super setUp]; 45 | } 46 | 47 | - (void)tearDown 48 | { 49 | [super tearDown]; 50 | } 51 | 52 | #pragma mark - Tests 53 | 54 | - (void)testAGWW_STALL_RUNLOOP_WHILE 55 | { 56 | __block BOOL value = NO; 57 | 58 | double delayInSeconds = 0.1; 59 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); 60 | dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(void){ 61 | value = TRUE; 62 | }); 63 | 64 | AGWW_STALL_RUNLOOP_WHILE(!value, (NSTimeInterval)1.0); 65 | STAssertTrue(value, nil); 66 | } 67 | 68 | - (void)testWAIT_WHILE_withCorrectValueAfterDelay 69 | { 70 | __block BOOL shouldWait = YES; 71 | __block BOOL didWait = FALSE; 72 | 73 | double delayInSeconds = 0.1; 74 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); 75 | dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(void){ 76 | shouldWait = NO; 77 | didWait = TRUE; 78 | }); 79 | 80 | AGWW_WAIT_WHILE(shouldWait, (NSTimeInterval)1.0); 81 | STAssertTrue(didWait, nil); 82 | } 83 | 84 | - (void)testWAIT_WHILE_withCorrectInitialValue 85 | { 86 | __block BOOL shouldWait = NO; 87 | __block BOOL didWait = FALSE; 88 | 89 | double delayInSeconds = 0.1; 90 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); 91 | dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(void){ 92 | didWait = TRUE; 93 | }); 94 | 95 | AGWW_WAIT_WHILE(shouldWait, (NSTimeInterval)1.0); 96 | STAssertFalse(didWait, nil); 97 | } 98 | 99 | - (void)testWAIT_WHILE_withDescription 100 | { 101 | __block BOOL shouldWaitFurther = YES; 102 | __block BOOL didWait = FALSE; 103 | 104 | double delayInSeconds = 0.1; 105 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); 106 | dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(void){ 107 | shouldWaitFurther = NO; 108 | didWait = TRUE; 109 | }); 110 | 111 | AGWW_WAIT_WHILE(shouldWaitFurther, (NSTimeInterval)1.0, @"Test description %i", 12345); 112 | STAssertTrue(didWait, nil); 113 | } 114 | 115 | - (void)testWAIT_WHILE_EQUALS 116 | { 117 | __block CGFloat value = 2.0; 118 | __block BOOL didWait = FALSE; 119 | 120 | double delayInSeconds = 0.1; 121 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); 122 | dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(void){ 123 | value = 1; 124 | didWait = TRUE; 125 | }); 126 | 127 | AGWW_WAIT_WHILE_EQUALS(value, 2.0, (NSTimeInterval)1.0); 128 | STAssertTrue(didWait, nil); 129 | } 130 | 131 | - (void)testWAIT_WHILE_EQUALS_withDescription 132 | { 133 | __block CGFloat value = 2.0; 134 | __block BOOL didWait = FALSE; 135 | 136 | double delayInSeconds = 0.1; 137 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); 138 | dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(void){ 139 | value = 1; 140 | didWait = TRUE; 141 | }); 142 | 143 | AGWW_WAIT_WHILE_EQUALS(value, 2.0, (NSTimeInterval)1.0, @"Test description %i", 12345); 144 | STAssertTrue(didWait, nil); 145 | } 146 | 147 | - (CGFloat)testValue 148 | { 149 | return 2.0; 150 | } 151 | 152 | - (void)testWAIT_WHILE_EQUALS_WITH_ACCURACY 153 | { 154 | __block CGFloat value1 = 2.0005f; 155 | __block BOOL didWait = FALSE; 156 | 157 | double delayInSeconds = 0.1; 158 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); 159 | dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(void){ 160 | value1 = 1; 161 | didWait = TRUE; 162 | }); 163 | 164 | AGWW_WAIT_WHILE_EQUALS_WITH_ACCURACY(value1, [self testValue], (CGFloat)0.001, (NSTimeInterval)1.0); 165 | STAssertTrue(didWait, nil); 166 | } 167 | 168 | - (void)testWAIT_WHILE_EQUALS_WITH_ACCURACY_withDescription 169 | { 170 | __block CGFloat value1 = 2.0; 171 | __block BOOL didWait = FALSE; 172 | 173 | double delayInSeconds = 0.1; 174 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); 175 | dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(void){ 176 | value1 = 1; 177 | didWait = TRUE; 178 | }); 179 | 180 | AGWW_WAIT_WHILE_EQUALS_WITH_ACCURACY(value1, 2.0, (CGFloat)0.001, (NSTimeInterval)1.0, @"Test description %i", 12345); 181 | STAssertTrue(didWait, nil); 182 | } 183 | 184 | - (void)testWAIT_WHILE_NOT_EQUALS 185 | { 186 | __block CGFloat value1 = 1.0; 187 | __block BOOL didWait = FALSE; 188 | 189 | double delayInSeconds = 0.1; 190 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); 191 | dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(void){ 192 | value1 = 2.0; 193 | didWait = TRUE; 194 | }); 195 | 196 | AGWW_WAIT_WHILE_NOT_EQUALS(value1, 2.0, (NSTimeInterval)1.0); 197 | STAssertTrue(didWait, nil); 198 | } 199 | 200 | - (void)testWAIT_WHILE_NOT_EQUALS_withDescription 201 | { 202 | __block CGFloat value1 = 1.0; 203 | __block BOOL didWait = FALSE; 204 | 205 | double delayInSeconds = 0.1; 206 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); 207 | dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(void){ 208 | value1 = 2.0; 209 | didWait = TRUE; 210 | }); 211 | 212 | AGWW_WAIT_WHILE_NOT_EQUALS(value1, 2.0, (NSTimeInterval)1.0, @"Test description %i", 12345); 213 | STAssertTrue(didWait, nil); 214 | } 215 | 216 | - (void)testWAIT_WHILE_NOT_EQUALS_WITH_ACCURACY 217 | { 218 | CGFloat targetValue = 1.0; 219 | CGFloat accuracy = 0.5; 220 | CGFloat increment = 0.05; 221 | NSUInteger numberOfIterations = 20; 222 | __block CGFloat value = 0.0; 223 | __block BOOL didWait = FALSE; 224 | 225 | dispatch_apply(numberOfIterations, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(size_t i) { 226 | value += increment; 227 | didWait = TRUE; 228 | }); 229 | 230 | AGWW_WAIT_WHILE_NOT_EQUALS_WITH_ACCURACY(value, targetValue, accuracy, (NSTimeInterval)1.0); 231 | STAssertTrue(didWait, nil); 232 | } 233 | 234 | - (void)testShortNames 235 | { 236 | BOOL wait = NO; 237 | NSTimeInterval maxWaitDuration = 0.2; 238 | WAIT_WHILE(wait, maxWaitDuration); 239 | WAIT_WHILE_EQUALS(1, 3, maxWaitDuration); 240 | WAIT_WHILE_EQUALS_WITH_ACCURACY(0.2, 0.3, 0.01, maxWaitDuration); 241 | WAIT_WHILE_NOT_EQUALS(1, 1, maxWaitDuration); 242 | } 243 | 244 | @end 245 | -------------------------------------------------------------------------------- /Tests/AGAsyncTestHelperXCTTest.m: -------------------------------------------------------------------------------- 1 | // 2 | // Author: Håvard Fossli 3 | // 4 | // Copyright (c) 2013 Agens AS (http://agens.no/) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #import 25 | 26 | #define AGWW_SHORTHAND 27 | 28 | #import "AGAsyncTestHelper.h" 29 | 30 | @interface AGAsyncTestHelperXCTTest : XCTestCase { 31 | @private 32 | BOOL asyncOperationCompleted; 33 | } 34 | 35 | @end 36 | 37 | @implementation AGAsyncTestHelperXCTTest 38 | 39 | #pragma mark - Construct and destruct 40 | 41 | - (void)setUp 42 | { 43 | asyncOperationCompleted = NO; 44 | [super setUp]; 45 | } 46 | 47 | - (void)tearDown 48 | { 49 | [super tearDown]; 50 | } 51 | 52 | #pragma mark - Tests 53 | 54 | 55 | - (void)test_AGWW_ASSERT_SAME_TYPE 56 | { 57 | XCTAssertTrue(_AGWW_IS_DIFFERENT_TYPE(2, 2.0f)); 58 | XCTAssertTrue(_AGWW_IS_DIFFERENT_TYPE(2.0, 2.0f)); 59 | XCTAssertFalse(_AGWW_IS_DIFFERENT_TYPE((double)2.0, (double)2.0f)); 60 | XCTAssertFalse(_AGWW_IS_DIFFERENT_TYPE((int)2.0, (int)2.0f)); 61 | } 62 | 63 | - (void)testAGWW_STALL_RUNLOOP_WHILE 64 | { 65 | __block BOOL value = NO; 66 | 67 | double delayInSeconds = 0.1; 68 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); 69 | dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(void){ 70 | value = TRUE; 71 | }); 72 | 73 | AGWW_STALL_RUNLOOP_WHILE(!value, (NSTimeInterval)1.0); 74 | 75 | XCTAssertTrue(value); 76 | } 77 | 78 | - (void)testAGWW_CREATE_FAIL_STRING 79 | { 80 | float value = 2.0; 81 | float equalTo = 3.0; 82 | NSString *conditionFormat = [NSString stringWithFormat:@"%s should NOT be equal to %s", "%.2f", "%.1f"]; 83 | NSString *conditionString = [NSString stringWithFormat:conditionFormat, value, equalTo]; 84 | 85 | { 86 | NSString *string = _agww_makeFailString(conditionString, 10.0, @"Testdescription with param %f and another %i", 99.0, 1000); 87 | XCTAssertEqualObjects(string, @"Async test didn't complete within 10.00 seconds. 2.00 should NOT be equal to 3.0. Testdescription with param 99.000000 and another 1000"); 88 | } 89 | { 90 | NSString *string = _agww_makeFailString(conditionString, 7.0, @"Testdescription without params"); 91 | XCTAssertEqualObjects(string, @"Async test didn't complete within 7.00 seconds. 2.00 should NOT be equal to 3.0. Testdescription without params"); 92 | } 93 | } 94 | 95 | - (void)testWAIT_WHILE_withCorrectValueAfterDelay 96 | { 97 | __block BOOL shouldWait = YES; 98 | __block BOOL didWait = FALSE; 99 | 100 | double delayInSeconds = 0.1; 101 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); 102 | dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(void){ 103 | shouldWait = NO; 104 | didWait = TRUE; 105 | }); 106 | 107 | AGWW_WAIT_WHILE(shouldWait, (NSTimeInterval)1.0); 108 | XCTAssertTrue(didWait); 109 | } 110 | 111 | - (void)testWAIT_WHILE_withCorrectInitialValue 112 | { 113 | __block BOOL shouldWait = NO; 114 | __block BOOL didWait = FALSE; 115 | 116 | double delayInSeconds = 0.1; 117 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); 118 | dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(void){ 119 | didWait = TRUE; 120 | }); 121 | 122 | AGWW_WAIT_WHILE(shouldWait, (NSTimeInterval)1.0); 123 | XCTAssertFalse(didWait); 124 | } 125 | 126 | - (void)testWAIT_WHILE_withDescription 127 | { 128 | __block BOOL shouldWaitFurther = YES; 129 | __block BOOL didWait = FALSE; 130 | 131 | double delayInSeconds = 0.1; 132 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); 133 | dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(void){ 134 | shouldWaitFurther = NO; 135 | didWait = TRUE; 136 | }); 137 | 138 | AGWW_WAIT_WHILE(shouldWaitFurther, (NSTimeInterval)1.0, @"Test description %i", 12345); 139 | XCTAssertTrue(didWait); 140 | } 141 | 142 | - (void)testWAIT_WHILE_EQUALS 143 | { 144 | __block double value = 2.0; 145 | __block BOOL didWait = FALSE; 146 | 147 | double delayInSeconds = 0.1; 148 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); 149 | dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(void){ 150 | value = 1; 151 | didWait = TRUE; 152 | }); 153 | 154 | AGWW_WAIT_WHILE_EQUALS(value, (double)2.0, (NSTimeInterval)1.0); 155 | XCTAssertTrue(didWait); 156 | } 157 | 158 | - (void)testWAIT_WHILE_EQUALS_withDescription 159 | { 160 | __block double value = 2.0; 161 | __block BOOL didWait = FALSE; 162 | 163 | double delayInSeconds = 0.1; 164 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); 165 | dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(void){ 166 | value = 1; 167 | didWait = TRUE; 168 | }); 169 | 170 | AGWW_WAIT_WHILE_EQUALS(value, (double)2.0, (NSTimeInterval)1.0, @"Test description %i", 12345); 171 | XCTAssertTrue(didWait); 172 | } 173 | 174 | - (double)testValue 175 | { 176 | return 2.0; 177 | } 178 | 179 | - (void)testWAIT_WHILE_EQUALS_WITH_ACCURACY 180 | { 181 | __block double value1 = 2.0005; 182 | __block BOOL didWait = FALSE; 183 | 184 | double delayInSeconds = 0.1; 185 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); 186 | dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(void){ 187 | value1 = 1; 188 | didWait = TRUE; 189 | }); 190 | 191 | AGWW_WAIT_WHILE_EQUALS_WITH_ACCURACY(value1, [self testValue], (double)0.001, (NSTimeInterval)1.0); 192 | XCTAssertTrue(didWait); 193 | } 194 | 195 | - (void)testWAIT_WHILE_EQUALS_WITH_ACCURACY_withDescription 196 | { 197 | __block double value1 = 2.0; 198 | __block BOOL didWait = FALSE; 199 | 200 | double delayInSeconds = 0.1; 201 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); 202 | dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(void){ 203 | value1 = 1; 204 | didWait = TRUE; 205 | }); 206 | 207 | AGWW_WAIT_WHILE_EQUALS_WITH_ACCURACY(value1, 2.0, (double)0.001, (NSTimeInterval)1.0, @"Test description %i", 12345); 208 | XCTAssertTrue(didWait); 209 | } 210 | 211 | - (void)testWAIT_WHILE_NOT_EQUALS 212 | { 213 | __block double value1 = 1.0; 214 | __block BOOL didWait = FALSE; 215 | 216 | double delayInSeconds = 0.1; 217 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); 218 | dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(void){ 219 | value1 = 2.0; 220 | didWait = TRUE; 221 | }); 222 | 223 | AGWW_WAIT_WHILE_NOT_EQUALS(value1, 2.0, (NSTimeInterval)1.0); 224 | XCTAssertTrue(didWait); 225 | } 226 | 227 | - (void)testWAIT_WHILE_NOT_EQUALS_withDescription 228 | { 229 | __block double value1 = 1.0; 230 | __block BOOL didWait = FALSE; 231 | 232 | double delayInSeconds = 0.1; 233 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); 234 | dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(void){ 235 | value1 = 2.0; 236 | didWait = TRUE; 237 | }); 238 | 239 | AGWW_WAIT_WHILE_NOT_EQUALS(value1, 2.0, (NSTimeInterval)1.0, @"Test description %i", 12345); 240 | XCTAssertTrue(didWait); 241 | } 242 | 243 | - (void)testWAIT_WHILE_NOT_EQUALS_WITH_ACCURACY 244 | { 245 | double targetValue = 1.0; 246 | double accuracy = 0.5; 247 | double increment = 0.05; 248 | NSUInteger numberOfIterations = 20; 249 | __block double value = 0.0; 250 | __block BOOL didWait = FALSE; 251 | 252 | dispatch_apply(numberOfIterations, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(size_t i) { 253 | value += increment; 254 | didWait = TRUE; 255 | }); 256 | 257 | AGWW_WAIT_WHILE_NOT_EQUALS_WITH_ACCURACY(value, targetValue, accuracy, (NSTimeInterval)1.0); 258 | XCTAssertTrue(didWait); 259 | } 260 | 261 | - (void)testShortNames 262 | { 263 | BOOL wait = NO; 264 | NSTimeInterval maxWaitDuration = 0.2; 265 | WAIT_WHILE(wait, maxWaitDuration); 266 | WAIT_WHILE_EQUALS(1, 3, maxWaitDuration); 267 | WAIT_WHILE_EQUALS_WITH_ACCURACY(0.2, 0.3, 0.01, maxWaitDuration); 268 | WAIT_WHILE_NOT_EQUALS(1, 1, maxWaitDuration); 269 | } 270 | 271 | @end 272 | --------------------------------------------------------------------------------