How to use _qck_testMethodSelectors method of var class

Best Quick code snippet using var._qck_testMethodSelectors

VideoTransformationComposerAspectFillTests.swift

Source:VideoTransformationComposerAspectFillTests.swift Github

copy

Full Screen

...45 XCTAssertGreaterThanOrEqual(resultOffsetX, 0)46 XCTAssertGreaterThanOrEqual(resultOffsetY, 0)47 }48 49 override class func _qck_testMethodSelectors() -> [_QuickSelectorWrapper] {50 51 //generate parameters52 53 let sizes = [50, 100, 200]54 var testsParameters: [(originalSize: CGSize, targetSize: CGSize)] = []55 var originalSizes: [CGSize] = []56 var targetSizes: [CGSize] = []57 58 for width in sizes {59 for height in sizes {60 originalSizes.append(CGSize(width: width, height: height))61 targetSizes.append(CGSize(width: width, height: height))62 }63 }64 65 for originalSize in originalSizes {66 for targetSize in targetSizes {67 testsParameters.append((originalSize: originalSize, targetSize: targetSize))68 }69 }70 71 return testsParameters.map { parameter in72 /// first we wrap our test method in block that takes TestCase instance73 let block: @convention(block) (Self) -> Void = { $0.methodToTestWithParameters(originalSize: parameter.originalSize, targetSize: parameter.targetSize) }74 /// with help of ObjC runtime we add new test method to class75 let implementation = imp_implementationWithBlock(block)76 let selectorName = "test_\(parameter)"77 let selector = NSSelectorFromString(selectorName)78 class_addMethod(self, selector, implementation, "v@:")79 /// and return wrapped selector on new created method80 return _QuickSelectorWrapper(selector: selector)81 }82 }83}84class VideoTransformationComposerAspectFillOnlyCropTests: ParametrizedTestCase {85 func methodToTestWithParameters(originalSize: CGSize, crop: Crop) {86 87 //only crop, no additional resize to fill occur88 let targetWidth = (originalSize.width * (1.0 - (crop.left + crop.right) / 100.0)).rounded()89 let targetHeight = (originalSize.height * (1.0 - (crop.top + crop.bottom) / 100.0)).rounded()90 91 let targetSize = CGSize(width: targetWidth,92 height: targetHeight)93 94 let resizeContentMode = ResizeContentMode.aspectFill(targetSize)95 96 let transformationComposer = VideoTransformationComposer(originalSize: originalSize,97 cropPerCent: crop,98 resizeContentMode: resizeContentMode)99 100 101 let transformationParameters = transformationComposer.transformationParameters102 103 let inputWidth = originalSize.width104 let inputHeight = originalSize.height105 106 let resultOffsetX = transformationParameters.crop.x107 let resultOffsetY = transformationParameters.crop.y108 109 let resultRemainedWidth = inputWidth - resultOffsetX - (targetSize.width / transformationParameters.scale.x)110 let resultRemainedHeight = inputHeight - resultOffsetY - (targetSize.height / transformationParameters.scale.y)111 112 XCTAssertLessThanOrEqual(abs(resultOffsetX - (crop.left * originalSize.width / 100.0)).rounded(), 1)113 XCTAssertLessThanOrEqual(abs(resultOffsetY - (crop.top * originalSize.height / 100.0)).rounded(), 1)114 XCTAssertLessThanOrEqual(abs(resultRemainedWidth - (crop.right * originalSize.width / 100.0)).rounded(), 1)115 XCTAssertLessThanOrEqual(abs(resultRemainedHeight - (crop.bottom * originalSize.height / 100.0)).rounded(), 1)116 117 XCTAssertEqual(transformationParameters.targetSize, targetSize)118 }119 120 override class func _qck_testMethodSelectors() -> [_QuickSelectorWrapper] {121 122 //generate parameters123 124 let sizes: [CGFloat] = [50, 100, 200]125 let cropAmounts: [CGFloat] = [5, 0]126 127 var testsParameters: [(originalSize: CGSize, crop: Crop)] = []128 var originalSizes: [CGSize] = []129 130 var crops: [Crop] = []131 132 for width in sizes {133 for height in sizes {134 originalSizes.append(CGSize(width: width, height: height))135 }136 }137 138 for top in cropAmounts {139 for bottom in cropAmounts {140 for left in cropAmounts {141 for right in cropAmounts {142 let crop = Crop(top: top, left: left, bottom: bottom, right: right)143 crops.append(crop)144 }145 }146 }147 }148 149 for originalSize in originalSizes {150 for crop in crops {151 testsParameters.append((originalSize: originalSize, crop: crop))152 }153 }154 155 return testsParameters.map { parameter in156 /// first we wrap our test method in block that takes TestCase instance157 let block: @convention(block) (Self) -> Void = { $0.methodToTestWithParameters(originalSize: parameter.originalSize, crop: parameter.crop) }158 /// with help of ObjC runtime we add new test method to class159 let implementation = imp_implementationWithBlock(block)160 161 let selectorName = "test_\(parameter)"162 let selector = NSSelectorFromString(selectorName)163 class_addMethod(self, selector, implementation, "v@:")164 /// and return wrapped selector on new created method165 return _QuickSelectorWrapper(selector: selector)166 }167 }168}169class VideoTransformationComposerAspectFillResizeWithCropTests: ParametrizedTestCase {170 func methodToTestWithParameters(originalSize: CGSize, targetSize: CGSize, crop: Crop) {171 //step1 - perform crop only transformation172 173 let cropTargetWidth = (originalSize.width * (1.0 - (crop.left + crop.right) / 100.0)).rounded()174 let cropTargetHeight = (originalSize.height * (1.0 - (crop.top + crop.bottom) / 100.0)).rounded()175 176 let cropTargetSize = CGSize(width: cropTargetWidth,177 height: cropTargetHeight)178 179 let cropResizeContentMode = ResizeContentMode.aspectFill(cropTargetSize)180 181 let cropTransformationComposer = VideoTransformationComposer(originalSize: originalSize,182 cropPerCent: crop,183 resizeContentMode: cropResizeContentMode)184 185 let cropTransformationParameters = cropTransformationComposer.transformationParameters186 187 let originalSizeInputWidthToCrop = originalSize.width188 let originalSizeInputHeightToCrop = originalSize.height189 190 let cropResultOffsetX = cropTransformationParameters.crop.x191 let cropResultOffsetY = cropTransformationParameters.crop.y192 193 let cropResultRemainedWidth = originalSizeInputWidthToCrop - cropResultOffsetX - (cropTargetSize.width / cropTransformationParameters.scale.x)194 let cropResultRemainedHeight = originalSizeInputHeightToCrop - cropResultOffsetY - (cropTargetSize.height / cropTransformationParameters.scale.y)195 196 197 XCTAssertLessThanOrEqual(abs(cropResultOffsetX - (crop.left * originalSize.width / 100.0)).rounded(), 1)198 XCTAssertLessThanOrEqual(abs(cropResultOffsetY - (crop.top * originalSize.height / 100.0)).rounded(), 1)199 XCTAssertLessThanOrEqual(abs(cropResultRemainedWidth - (crop.right * originalSize.width / 100.0)).rounded(), 1)200 XCTAssertLessThanOrEqual(abs(cropResultRemainedHeight - (crop.bottom * originalSize.height / 100.0)).rounded(), 1)201 202 XCTAssertEqual(cropTransformationParameters.targetSize, cropTargetSize)203 204 205 206 //step2 - resize cropped result207 208 let croppedResultResizeContentMode = ResizeContentMode.aspectFill(targetSize)209 210 let croppedResultTransformationComposer = VideoTransformationComposer(originalSize: cropTargetSize,211 cropPerCent: Crop.zero,212 resizeContentMode: croppedResultResizeContentMode)213 214 let croppedResultTransformationParameters = croppedResultTransformationComposer.transformationParameters215 216 let inputWidth = cropTargetSize.width217 let inputHeight = cropTargetSize.height218 219 let croppedResultOffsetX = croppedResultTransformationParameters.crop.x220 let croppedResultOffsetY = croppedResultTransformationParameters.crop.y221 222 let croppedResultRemainedWidth = inputWidth - croppedResultOffsetX - (targetSize.width / croppedResultTransformationParameters.scale.x)223 let croppedResultRemainedHeight = inputHeight - croppedResultOffsetY - (targetSize.height / croppedResultTransformationParameters.scale.y)224 225 226 227 XCTAssertEqual(croppedResultTransformationParameters.targetSize, targetSize)228 229 //at least any of cropX, cropY should be zero, because aspect fill resize should be centered230 XCTAssertEqual((croppedResultOffsetX + croppedResultRemainedWidth) * (croppedResultOffsetY + croppedResultRemainedHeight), 0)231 232 233 //step3 - perform crop and resize at once234 235 let resizeContentMode = ResizeContentMode.aspectFill(targetSize)236 237 let transformationComposer = VideoTransformationComposer(originalSize: originalSize,238 cropPerCent: crop,239 resizeContentMode: resizeContentMode)240 241 let transformationParameters = transformationComposer.transformationParameters242 243 let originalSizeInputWidth = originalSize.width244 let originalSizeInputHeight = originalSize.height245 246 let resultOffsetX = transformationParameters.crop.x247 let resultOffsetY = transformationParameters.crop.y248 249 let resultRemainedWidth = originalSizeInputWidth - resultOffsetX - (targetSize.width / transformationParameters.scale.x)250 let resultRemainedHeight = originalSizeInputHeight - resultOffsetY - (targetSize.height / transformationParameters.scale.y)251 252 XCTAssertEqual(transformationParameters.targetSize, targetSize)253 254 //compare step1 + step2 with step3255 XCTAssertLessThanOrEqual(abs(resultOffsetX - (cropResultOffsetX + croppedResultOffsetX)), 1)256 XCTAssertLessThanOrEqual(abs(resultOffsetY - (cropResultOffsetY + croppedResultOffsetY)), 1)257 XCTAssertLessThanOrEqual(abs(resultRemainedWidth - (croppedResultRemainedWidth + cropResultRemainedWidth)).rounded(),1)258 XCTAssertLessThanOrEqual(abs(resultRemainedHeight - (croppedResultRemainedHeight + cropResultRemainedHeight)).rounded(), 1)259 }260 261 override class func _qck_testMethodSelectors() -> [_QuickSelectorWrapper] {262 263 //generate parameters264 265 let sizes: [CGFloat] = [50, 100, 200]266 let cropAmounts: [CGFloat] = [5, 0]267 268 var testsParameters: [(originalSize: CGSize, targetSize: CGSize, crop: Crop)] = []269 var originalSizes: [CGSize] = []270 var targetSizes: [CGSize] = []271 var crops: [Crop] = []272 273 for width in sizes {274 for height in sizes {275 originalSizes.append(CGSize(width: width, height: height))...

Full Screen

Full Screen

VideoTransformationComposerAspectFitTests.swift

Source:VideoTransformationComposerAspectFitTests.swift Github

copy

Full Screen

...43 XCTAssertLessThanOrEqual(resultOffsetX, 0)44 XCTAssertLessThanOrEqual(resultOffsetY, 0)45 }46 47 override class func _qck_testMethodSelectors() -> [_QuickSelectorWrapper] {48 49 //generate parameters50 51 let sizes = [50, 100, 200]52 var testsParameters: [(originalSize: CGSize, targetSize: CGSize)] = []53 var originalSizes: [CGSize] = []54 var targetSizes: [CGSize] = []55 56 for width in sizes {57 for height in sizes {58 originalSizes.append(CGSize(width: width, height: height))59 targetSizes.append(CGSize(width: width, height: height))60 }61 }62 63 for originalSize in originalSizes {64 for targetSize in targetSizes {65 testsParameters.append((originalSize: originalSize, targetSize: targetSize))66 }67 }68 69 return testsParameters.map { parameter in70 /// first we wrap our test method in block that takes TestCase instance71 let block: @convention(block) (Self) -> Void = { $0.methodToTestWithParameters(originalSize: parameter.originalSize, targetSize: parameter.targetSize) }72 /// with help of ObjC runtime we add new test method to class73 let implementation = imp_implementationWithBlock(block)74 let selectorName = "test_\(parameter)"75 let selector = NSSelectorFromString(selectorName)76 class_addMethod(self, selector, implementation, "v@:")77 /// and return wrapped selector on new created method78 return _QuickSelectorWrapper(selector: selector)79 }80 }81}82class VideoTransformationComposerAspectFitOnlyCropTests: ParametrizedTestCase {83 func methodToTestWithParameters(originalSize: CGSize, crop: Crop) {84 85 //only crop, no additional resize to fit occur86 let targetWidth = (originalSize.width * (1.0 - (crop.left + crop.right) / 100.0)).rounded()87 let targetHeight = (originalSize.height * (1.0 - (crop.top + crop.bottom) / 100.0)).rounded()88 89 let targetSize = CGSize(width: targetWidth,90 height: targetHeight)91 92 let resizeContentMode = ResizeContentMode.aspectFit(targetSize)93 94 let transformationComposer = VideoTransformationComposer(originalSize: originalSize,95 cropPerCent: crop,96 resizeContentMode: resizeContentMode)97 98 99 let transformationParameters = transformationComposer.transformationParameters100 101 let inputWidth = originalSize.width102 let inputHeight = originalSize.height103 104 let resultOffsetX = transformationParameters.crop.x105 let resultOffsetY = transformationParameters.crop.y106 107 let resultRemainedWidth = inputWidth - resultOffsetX - (targetSize.width / transformationParameters.scale.x)108 let resultRemainedHeight = inputHeight - resultOffsetY - (targetSize.height / transformationParameters.scale.y)109 110 XCTAssertLessThanOrEqual(abs(resultOffsetX - (crop.left * originalSize.width / 100.0)).rounded(), 1)111 XCTAssertLessThanOrEqual(abs(resultOffsetY - (crop.top * originalSize.height / 100.0)).rounded(), 1)112 XCTAssertLessThanOrEqual(abs(resultRemainedWidth - (crop.right * originalSize.width / 100.0)).rounded(), 1)113 XCTAssertLessThanOrEqual(abs(resultRemainedHeight - (crop.bottom * originalSize.height / 100.0)).rounded(), 1)114 115 XCTAssertEqual(transformationParameters.targetSize, targetSize)116 }117 118 override class func _qck_testMethodSelectors() -> [_QuickSelectorWrapper] {119 120 //generate parameters121 122 let sizes: [CGFloat] = [50, 100, 200]123 let cropAmounts: [CGFloat] = [5, 0]124 125 var testsParameters: [(originalSize: CGSize, crop: Crop)] = []126 var originalSizes: [CGSize] = []127 128 var crops: [Crop] = []129 130 for width in sizes {131 for height in sizes {132 originalSizes.append(CGSize(width: width, height: height))133 }134 }135 136 for top in cropAmounts {137 for bottom in cropAmounts {138 for left in cropAmounts {139 for right in cropAmounts {140 let crop = Crop(top: top, left: left, bottom: bottom, right: right)141 crops.append(crop)142 }143 }144 }145 }146 147 for originalSize in originalSizes {148 for crop in crops {149 testsParameters.append((originalSize: originalSize, crop: crop))150 }151 }152 153 return testsParameters.map { parameter in154 /// first we wrap our test method in block that takes TestCase instance155 let block: @convention(block) (Self) -> Void = { $0.methodToTestWithParameters(originalSize: parameter.originalSize, crop: parameter.crop) }156 /// with help of ObjC runtime we add new test method to class157 let implementation = imp_implementationWithBlock(block)158 159 let selectorName = "test_\(parameter)"160 let selector = NSSelectorFromString(selectorName)161 class_addMethod(self, selector, implementation, "v@:")162 /// and return wrapped selector on new created method163 return _QuickSelectorWrapper(selector: selector)164 }165 }166}167class VideoTransformationComposerAspectFitResizeWithCropTests: ParametrizedTestCase {168 func methodToTestWithParameters(originalSize: CGSize, targetSize: CGSize, crop: Crop) {169 //step1 - perform crop only transformation170 171 let cropTargetWidth = (originalSize.width * (1.0 - (crop.left + crop.right) / 100.0)).rounded()172 let cropTargetHeight = (originalSize.height * (1.0 - (crop.top + crop.bottom) / 100.0)).rounded()173 174 let cropTargetSize = CGSize(width: cropTargetWidth,175 height: cropTargetHeight)176 177 let cropResizeContentMode = ResizeContentMode.aspectFill(cropTargetSize)178 179 let cropTransformationComposer = VideoTransformationComposer(originalSize: originalSize,180 cropPerCent: crop,181 resizeContentMode: cropResizeContentMode)182 183 let cropTransformationParameters = cropTransformationComposer.transformationParameters184 185 let originalSizeInputWidthToCrop = originalSize.width186 let originalSizeInputHeightToCrop = originalSize.height187 188 let cropResultOffsetX = cropTransformationParameters.crop.x189 let cropResultOffsetY = cropTransformationParameters.crop.y190 191 let cropResultRemainedWidth = originalSizeInputWidthToCrop - cropResultOffsetX - (cropTargetSize.width / cropTransformationParameters.scale.x)192 let cropResultRemainedHeight = originalSizeInputHeightToCrop - cropResultOffsetY - (cropTargetSize.height / cropTransformationParameters.scale.y)193 194 195 XCTAssertLessThanOrEqual(abs(cropResultOffsetX - (crop.left * originalSize.width / 100.0)).rounded(), 1)196 XCTAssertLessThanOrEqual(abs(cropResultOffsetY - (crop.top * originalSize.height / 100.0)).rounded(), 1)197 XCTAssertLessThanOrEqual(abs(cropResultRemainedWidth - (crop.right * originalSize.width / 100.0)).rounded(), 1)198 XCTAssertLessThanOrEqual(abs(cropResultRemainedHeight - (crop.bottom * originalSize.height / 100.0)).rounded(), 1)199 200 XCTAssertEqual(cropTransformationParameters.targetSize, cropTargetSize)201 202 203 204 //step2 - resize cropped result205 206 let croppedResultResizeContentMode = ResizeContentMode.aspectFill(targetSize)207 208 let croppedResultTransformationComposer = VideoTransformationComposer(originalSize: cropTargetSize,209 cropPerCent: Crop.zero,210 resizeContentMode: croppedResultResizeContentMode)211 212 let croppedResultTransformationParameters = croppedResultTransformationComposer.transformationParameters213 214 let inputWidth = cropTargetSize.width215 let inputHeight = cropTargetSize.height216 217 let croppedResultOffsetX = croppedResultTransformationParameters.crop.x218 let croppedResultOffsetY = croppedResultTransformationParameters.crop.y219 220 let croppedResultRemainedWidth = inputWidth - croppedResultOffsetX - (targetSize.width / croppedResultTransformationParameters.scale.x)221 let croppedResultRemainedHeight = inputHeight - croppedResultOffsetY - (targetSize.height / croppedResultTransformationParameters.scale.y)222 223 224 225 XCTAssertEqual(croppedResultTransformationParameters.targetSize, targetSize)226 227 //at least any of cropX, cropY should be zero, because aspect fill resize should be centered228 XCTAssertEqual((croppedResultOffsetX + croppedResultRemainedWidth) * (croppedResultOffsetY + croppedResultRemainedHeight), 0)229 230 231 //step3 - perform crop and resize at once232 233 let resizeContentMode = ResizeContentMode.aspectFill(targetSize)234 235 let transformationComposer = VideoTransformationComposer(originalSize: originalSize,236 cropPerCent: crop,237 resizeContentMode: resizeContentMode)238 239 let transformationParameters = transformationComposer.transformationParameters240 241 let originalSizeInputWidth = originalSize.width242 let originalSizeInputHeight = originalSize.height243 244 let resultOffsetX = transformationParameters.crop.x245 let resultOffsetY = transformationParameters.crop.y246 247 let resultRemainedWidth = originalSizeInputWidth - resultOffsetX - (targetSize.width / transformationParameters.scale.x)248 let resultRemainedHeight = originalSizeInputHeight - resultOffsetY - (targetSize.height / transformationParameters.scale.y)249 250 XCTAssertEqual(transformationParameters.targetSize, targetSize)251 252 //compare step1 + step2 with step3253 XCTAssertLessThanOrEqual(abs(resultOffsetX - (cropResultOffsetX + croppedResultOffsetX)), 1)254 XCTAssertLessThanOrEqual(abs(resultOffsetY - (cropResultOffsetY + croppedResultOffsetY)), 1)255 XCTAssertLessThanOrEqual(abs(resultRemainedWidth - (croppedResultRemainedWidth + cropResultRemainedWidth)).rounded(),1)256 XCTAssertLessThanOrEqual(abs(resultRemainedHeight - (croppedResultRemainedHeight + cropResultRemainedHeight)).rounded(), 1)257 }258 259 override class func _qck_testMethodSelectors() -> [_QuickSelectorWrapper] {260 261 //generate parameters262 263 let sizes: [CGFloat] = [50, 100, 200]264 let cropAmounts: [CGFloat] = [5, 0]265 266 var testsParameters: [(originalSize: CGSize, targetSize: CGSize, crop: Crop)] = []267 var originalSizes: [CGSize] = []268 var targetSizes: [CGSize] = []269 var crops: [Crop] = []270 271 for width in sizes {272 for height in sizes {273 originalSizes.append(CGSize(width: width, height: height))...

Full Screen

Full Screen

QuickSpec.swift

Source:QuickSpec.swift Github

copy

Full Screen

...45 // as listing spec classes in `LinuxMain.swift` on Linux.46 _ = allTests47 return super.defaultTestSuite()48 }49 override open class func _qck_testMethodSelectors() -> [_QuickSelectorWrapper] {50 let examples = World.sharedWorld.examples(self)51 var selectorNames = Set<String>()52 return examples.map { example in53 let selector = addInstanceMethod(for: example, classSelectorNames: &selectorNames)54 return _QuickSelectorWrapper(selector: selector)55 }56 }57 private static func addInstanceMethod(for example: Example, classSelectorNames selectorNames : inout Set<String>) -> Selector {58 let block: @convention(block) (QuickSpec) -> Void = { _ in59 example.run()60 }61 let implementation = imp_implementationWithBlock(block as Any)62 let originalName = example.name63 var selectorName = originalName...

Full Screen

Full Screen

_qck_testMethodSelectors

Using AI Code Generation

copy

Full Screen

1import XCTest2class MyTests: XCTestCase {3 func testSomething() {4 let selectors = _qck_testMethodSelectors(MyTests.self)5 print("selectors = \(selectors)")6 }7}8import XCTest9class MyTests: XCTestCase {10 class func testSomething() {11 let selectors = _qck_testMethodSelectors(MyTests.self)12 print("selectors = \(selectors)")13 }14}15import XCTest16class MyTests: XCTestCase {17 class func testSomething() {18 let selectors = _qck_testMethodSelectors(MyTests.self)19 print("selectors = \(selectors)")20 }21}22import XCTest23class MyTests: XCTestCase {24 class func testSomething() {25 let selectors = _qck_testMethodSelectors(MyTests.self)26 print("selectors = \(selectors)")27 }28}29import XCTest30class MyTests: XCTestCase {31 class func testSomething() {32 let selectors = _qck_testMethodSelectors(MyTests.self)33 print("selectors = \(selectors)")34 }35}36import XCTest37class MyTests: XCTestCase {38 class func testSomething() {39 let selectors = _qck_testMethodSelectors(MyTests.self)40 print("selectors = \(selectors)")41 }42}43import XCTest44class MyTests: XCTestCase {45 class func testSomething() {46 let selectors = _qck_testMethodSelectors(MyTests.self)47 print("selectors = \(selectors)")48 }49}50import XCTest51class MyTests: XCTestCase {52 class func testSomething() {53 let selectors = _qck_testMethodSelectors(MyTests.self)54 print("selectors = \(selectors)")55 }56}

Full Screen

Full Screen

_qck_testMethodSelectors

Using AI Code Generation

copy

Full Screen

1 func test() {2 let b = a._qck_testMethodSelectors()3 print(b)4 }5}6class Test: XCTestCase {7 func test() {8 let b = a._qck_testMethodSelectors()9 print(b)10 }11}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Quick automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful