Skip to content
This repository has been archived by the owner on May 3, 2023. It is now read-only.

Commit

Permalink
Update to OCMock 3.6 (TextureGroup#1829)
Browse files Browse the repository at this point in the history
- The issues in TextureGroup#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.
- 5c42bb4 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.
  • Loading branch information
Greg Bolsinga authored and piotrdebosz committed Mar 1, 2021
1 parent 48cd52c commit 70b4e8e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B35061D91B010EDF0018CF92"
BuildableName = "AsyncDisplayKit.framework"
BlueprintName = "AsyncDisplayKit"
ReferencedContainer = "container:AsyncDisplayKit.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -38,23 +47,15 @@
ReferencedContainer = "container:AsyncDisplayKit.xcodeproj">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "ASCALayerTests">
</Test>
<Test
Identifier = "ASTextNodePerformanceTests">
</Test>
</SkippedTests>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B35061D91B010EDF0018CF92"
BuildableName = "AsyncDisplayKit.framework"
BlueprintName = "AsyncDisplayKit"
ReferencedContainer = "container:AsyncDisplayKit.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand Down Expand Up @@ -82,8 +83,6 @@
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'

target :'AsyncDisplayKitTests' do
pod 'OCMock', '=3.4.1' # 3.4.2 currently has issues.
pod 'OCMock', '~>3.6'
pod 'FBSnapshotTestCase/Core', '~> 2.1'
pod 'JGMethodSwizzler', :git => 'https://github.com/JonasGessner/JGMethodSwizzler', :branch => 'master'
end
8 changes: 4 additions & 4 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
11 changes: 6 additions & 5 deletions Tests/ASCollectionViewTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ - (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibB
// 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;
Expand Down Expand Up @@ -636,14 +635,14 @@ - (void)testThatDisappearingSupplementariesWithLayerBackedNodesDontFailAssert
- (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];
Expand All @@ -658,10 +657,12 @@ - (void)testThatNodeCalculatedSizesAreUpdatedBeforeFirstPrepareLayoutAfterRotati
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];
}

/**
Expand Down

0 comments on commit 70b4e8e

Please sign in to comment.