From 8d6c4e67cd02a7111b7b1dc3265af9c5ee480f63 Mon Sep 17 00:00:00 2001 From: Greg Bolsinga Date: Thu, 21 May 2020 19:52:05 -0700 Subject: [PATCH] Update to OCMock 3.6 (#1829) - The issues in #1038 are not explained. - In `ASCollectionViewTests` do not mock every `collectionViewLayout`, only do it for the test that requires it. In addition, call `-stopMocking` when done. OCMock 3.6 found this code using stuff after it should have been. - 5c42bb4e2f2424f09097a461ffbaa53cc3e21695 says the layer tests are not typically run, but they are in the project. That diff refers to ASUIViewTests being skipped, but those tests do not exist. So I've just disabled them in this diff. It is not clear how they ever worked. --- .../xcschemes/AsyncDisplayKit.xcscheme | 25 +++++++++---------- Podfile | 2 +- Podfile.lock | 8 +++--- Tests/ASCollectionViewTests.mm | 11 ++++---- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/AsyncDisplayKit.xcodeproj/xcshareddata/xcschemes/AsyncDisplayKit.xcscheme b/AsyncDisplayKit.xcodeproj/xcshareddata/xcschemes/AsyncDisplayKit.xcscheme index f06fd13c..4cfa046b 100644 --- a/AsyncDisplayKit.xcodeproj/xcshareddata/xcschemes/AsyncDisplayKit.xcscheme +++ b/AsyncDisplayKit.xcodeproj/xcshareddata/xcschemes/AsyncDisplayKit.xcscheme @@ -27,6 +27,15 @@ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES"> + + + + @@ -38,23 +47,15 @@ ReferencedContainer = "container:AsyncDisplayKit.xcodeproj"> + + - - - - - - - - 3.6' pod 'FBSnapshotTestCase/Core', '~> 2.1' pod 'JGMethodSwizzler', :git => 'https://github.com/JonasGessner/JGMethodSwizzler', :branch => 'master' end diff --git a/Podfile.lock b/Podfile.lock index ce77f9d7..77af0503 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,12 +1,12 @@ PODS: - FBSnapshotTestCase/Core (2.1.4) - JGMethodSwizzler (2.0.1) - - OCMock (3.4.1) + - OCMock (3.6) DEPENDENCIES: - FBSnapshotTestCase/Core (~> 2.1) - JGMethodSwizzler (from `https://github.com/JonasGessner/JGMethodSwizzler`, branch `master`) - - OCMock (= 3.4.1) + - OCMock (~> 3.6) SPEC REPOS: https://github.com/CocoaPods/Specs.git: @@ -26,8 +26,8 @@ CHECKOUT OPTIONS: SPEC CHECKSUMS: FBSnapshotTestCase: 094f9f314decbabe373b87cc339bea235a63e07a JGMethodSwizzler: 7328146117fffa8a4038c42eb7cd3d4c75006f97 - OCMock: 2cd0716969bab32a2283ff3a46fd26a8c8b4c5e3 + OCMock: 5ea90566be239f179ba766fd9fbae5885040b992 -PODFILE CHECKSUM: 345a6700f5fdec438ef5553e1eebf62653862733 +PODFILE CHECKSUM: 7e86f0142d0db2230d763087056ba6d9eb2afd54 COCOAPODS: 1.9.1 diff --git a/Tests/ASCollectionViewTests.mm b/Tests/ASCollectionViewTests.mm index 2c748d1f..65dc1bd6 100644 --- a/Tests/ASCollectionViewTests.mm +++ b/Tests/ASCollectionViewTests.mm @@ -147,8 +147,7 @@ // Populate these immediately so that they're not unexpectedly nil during tests. self.asyncDelegate = [[ASCollectionViewTestDelegate alloc] initWithNumberOfSections:10 numberOfItemsInSection:10]; id realLayout = [UICollectionViewFlowLayout new]; - id mockLayout = [OCMockObject partialMockForObject:realLayout]; - self.collectionNode = [[ASCollectionNode alloc] initWithFrame:self.view.bounds collectionViewLayout:mockLayout]; + self.collectionNode = [[ASCollectionNode alloc] initWithFrame:self.view.bounds collectionViewLayout:realLayout]; self.collectionView = self.collectionNode.view; self.collectionView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; self.collectionNode.dataSource = self.asyncDelegate; @@ -636,14 +635,14 @@ - (void)testThatNodeCalculatedSizesAreUpdatedBeforeFirstPrepareLayoutAfterRotation { updateValidationTestPrologue - id layout = cv.collectionViewLayout; + id collectionViewLayoutMock = OCMPartialMock(cv.collectionViewLayout); CGSize initialItemSize = [cv nodeForItemAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]].calculatedSize; CGSize initialCVSize = cv.bounds.size; // Capture the node size before first call to prepareLayout after frame change. __block CGSize itemSizeAtFirstLayout = CGSizeZero; __block CGSize boundsSizeAtFirstLayout = CGSizeZero; - [[[[layout expect] andDo:^(NSInvocation *) { + [[[[collectionViewLayoutMock expect] andDo:^(NSInvocation *) { itemSizeAtFirstLayout = [cv nodeForItemAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]].calculatedSize; boundsSizeAtFirstLayout = [cv bounds].size; }] andForwardToRealObject] prepareLayout]; @@ -658,10 +657,12 @@ XCTAssertNotEqualObjects(NSStringFromCGSize(initialCVSize), NSStringFromCGSize(boundsSizeAtFirstLayout)); XCTAssertEqualObjects(NSStringFromCGSize(itemSizeAtFirstLayout), NSStringFromCGSize(finalItemSize)); XCTAssertEqualObjects(NSStringFromCGSize(boundsSizeAtFirstLayout), NSStringFromCGSize(finalCVSize)); - [layout verify]; + [collectionViewLayoutMock verify]; // Teardown [[UIDevice currentDevice] setValue:@(oldDeviceOrientation) forKey:@"orientation"]; + + [collectionViewLayoutMock stopMocking]; } /**