diff --git a/AsyncDisplayKit.xcodeproj/project.pbxproj b/AsyncDisplayKit.xcodeproj/project.pbxproj index 1e5c0ecd..07599b3e 100644 --- a/AsyncDisplayKit.xcodeproj/project.pbxproj +++ b/AsyncDisplayKit.xcodeproj/project.pbxproj @@ -356,6 +356,8 @@ CC8B05D61D73836400F54286 /* ASPerformanceTestContext.m in Sources */ = {isa = PBXBuildFile; fileRef = CC8B05D51D73836400F54286 /* ASPerformanceTestContext.m */; }; CC8B05D81D73979700F54286 /* ASTextNodePerformanceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CC8B05D71D73979700F54286 /* ASTextNodePerformanceTests.m */; }; CC90E1F41E383C0400FED591 /* AsyncDisplayKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B35061DA1B010EDF0018CF92 /* AsyncDisplayKit.framework */; }; + CC9E98311EFA23D6009D37C5 /* ASDiffingSectionController.h in Headers */ = {isa = PBXBuildFile; fileRef = CC9E982F1EFA23D6009D37C5 /* ASDiffingSectionController.h */; settings = {ATTRIBUTES = (Public, ); }; }; + CC9E98321EFA23D6009D37C5 /* ASDiffingSectionController.m in Sources */ = {isa = PBXBuildFile; fileRef = CC9E98301EFA23D6009D37C5 /* ASDiffingSectionController.m */; }; CCA221D31D6FA7EF00AF6A0F /* ASViewControllerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CCA221D21D6FA7EF00AF6A0F /* ASViewControllerTests.m */; }; CCA282B41E9EA7310037E8B7 /* ASTipsController.h in Headers */ = {isa = PBXBuildFile; fileRef = CCA282B21E9EA7310037E8B7 /* ASTipsController.h */; }; CCA282B51E9EA7310037E8B7 /* ASTipsController.m in Sources */ = {isa = PBXBuildFile; fileRef = CCA282B31E9EA7310037E8B7 /* ASTipsController.m */; }; @@ -822,6 +824,8 @@ CC8B05D41D73836400F54286 /* ASPerformanceTestContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASPerformanceTestContext.h; sourceTree = ""; }; CC8B05D51D73836400F54286 /* ASPerformanceTestContext.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASPerformanceTestContext.m; sourceTree = ""; }; CC8B05D71D73979700F54286 /* ASTextNodePerformanceTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASTextNodePerformanceTests.m; sourceTree = ""; }; + CC9E982F1EFA23D6009D37C5 /* ASDiffingSectionController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASDiffingSectionController.h; sourceTree = ""; }; + CC9E98301EFA23D6009D37C5 /* ASDiffingSectionController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASDiffingSectionController.m; sourceTree = ""; }; CCA221D21D6FA7EF00AF6A0F /* ASViewControllerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASViewControllerTests.m; sourceTree = ""; }; CCA282B21E9EA7310037E8B7 /* ASTipsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASTipsController.h; sourceTree = ""; }; CCA282B31E9EA7310037E8B7 /* ASTipsController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASTipsController.m; sourceTree = ""; }; @@ -1584,6 +1588,8 @@ CCE04B1D1E313E99006AEBBB /* Collection Data Adapter */ = { isa = PBXGroup; children = ( + CC9E982F1EFA23D6009D37C5 /* ASDiffingSectionController.h */, + CC9E98301EFA23D6009D37C5 /* ASDiffingSectionController.m */, CCE04B1E1E313EA7006AEBBB /* ASSectionController.h */, CCE04B2B1E314A32006AEBBB /* ASSupplementaryNodeSource.h */, CCF92DCE1E315FC50019E9C6 /* IGListKit Support */, @@ -1666,6 +1672,7 @@ 696F01EC1DD2AF450049FBD5 /* ASEventLog.h in Headers */, 690C35641E055C7B00069B91 /* ASDimensionInternal.h in Headers */, 3917EBD41E9C2FC400D04A01 /* _ASCollectionReusableView.h in Headers */, + CC9E98311EFA23D6009D37C5 /* ASDiffingSectionController.h in Headers */, 690C356B1E05680300069B91 /* ASDimensionDeprecated.h in Headers */, 683489281D70DE3400327501 /* ASDisplayNode+Deprecated.h in Headers */, 698371DB1E4379CD00437585 /* ASNodeController+Beta.h in Headers */, @@ -2157,6 +2164,7 @@ 254C6B861BF94F8A003EC431 /* ASTextKitContext.mm in Sources */, DBDB83971C6E879900D0098C /* ASPagerFlowLayout.m in Sources */, E5B078001E69F4EB00C24B5B /* ASElementMap.m in Sources */, + CC9E98321EFA23D6009D37C5 /* ASDiffingSectionController.m in Sources */, 9C8898BC1C738BA800D6B02E /* ASTextKitFontSizeAdjuster.mm in Sources */, 690ED59B1E36D118000627C0 /* ASImageNode+tvOS.m in Sources */, CCCCCCD81EC3EF060087FE10 /* ASTextInput.m in Sources */, diff --git a/Source/ASCollectionNode.h b/Source/ASCollectionNode.h index 22f4ae60..c7a3313a 100644 --- a/Source/ASCollectionNode.h +++ b/Source/ASCollectionNode.h @@ -21,11 +21,16 @@ #import #import #import +#import @protocol ASCollectionViewLayoutFacilitatorProtocol; @protocol ASCollectionDelegate; @protocol ASCollectionDataSource; +@protocol ASCollectionModernDataSource; @class ASCollectionView; +#if AS_DIFFING +@protocol IGListDiffable; +#endif NS_ASSUME_NONNULL_BEGIN @@ -83,6 +88,11 @@ NS_ASSUME_NONNULL_BEGIN */ @property (weak, nonatomic) id dataSource; +/** + * :todoc: + */ +@property (weak, nonatomic) id modernDataSource; + /** * The number of screens left to scroll before the delegate -collectionNode:beginBatchFetchingWithContext: is called. * @@ -477,6 +487,17 @@ NS_ASSUME_NONNULL_BEGIN */ - (nullable id)contextForSection:(NSInteger)section AS_WARN_UNUSED_RESULT; +#if AS_DIFFING + +/** + * Inform the collection node that the return value of `sectionViewModelsForCollectionNode:` has changed. + * + * The infra will requery the section view models and perform a diff. + */ +- (void)invalidateSections; + +#endif + @end @interface ASCollectionNode (Deprecated) @@ -493,6 +514,31 @@ NS_ASSUME_NONNULL_BEGIN @end +#if AS_DIFFING +@protocol IGListDiffable; + +/** + * A replacement for ASCollectionDataSource based on automatic diffing of view models. + */ +@protocol ASCollectionModernDataSource + +/** + * Asks the data source for the new array of section view models for the data source. + * + * It is strongly recommended for section view models to be immutable. + * When the return value of this method changes, call `-invalidateSections`. + */ +- (NSArray> *)sectionViewModelsForCollectionNode:(ASCollectionNode *)collectionNode; + +/** + * Asks the data source for a controller for the given section view model. + */ +- (id)collectionNode:(ASCollectionNode *)collectionNode controllerForSection:(id)sectionViewModel; + +@end + +#endif + /** * This is a node-based UICollectionViewDataSource. */ diff --git a/Source/ASDiffingSectionController.h b/Source/ASDiffingSectionController.h new file mode 100644 index 00000000..c4dcc21b --- /dev/null +++ b/Source/ASDiffingSectionController.h @@ -0,0 +1,75 @@ +// +// ASDiffingSectionController.h +// AsyncDisplayKit +// +// Created by Adlai Holler on 6/20/17. +// Copyright © 2017 Facebook. All rights reserved. +// + +#import +#import +#import + +#if AS_DIFFING + +NS_ASSUME_NONNULL_BEGIN + +@interface ASDiffingSectionController : NSObject + +/** + * This property is automatically set by the infrastructure when a diff is performed + * and the section view model is updated. + * + * Subclasses may override the setter for this property, but not the getter. + */ +@property (atomic, nullable) id viewModel; + +/** + * The array of view models currently displayed by this section controller as items. + * + * This property is set by the infrastructure after each item-level diff. + * + * Subclasses should not override this property. + */ +@property (atomic, nullable, readonly) NSArray *itemViewModels; + +#pragma mark - Public API + +/** + * Invalidate the items for this section controller. Performs a diff against the current set of items. + * + * Akin to a series of [UICollectionView insert/delete/reload/moveItemsAtIndexPaths:] calls. + * + * This method is automatically called when the view model is updated. + * + * Calls to this method will join the current `performBatchUpdates:` if any. + * + * Subclasses should not override this method. + */ +- (void)invalidateItems; + +/** + * Invalidates the section including all items and supplementaries. Akin to [UICollectionView reloadSections:]. + * + * Calls to this method will join the current `performBatchUpdates:` if any. + * + * Subclasses should not override this method. + */ +- (void)invalidateSection; + +#pragma mark - API for the Infra + +/** + * Asks the section controller to generate and return an array of item view models for the section. + * + * You should not call this method directly. + * + * Subclasses must override this method. + */ +- (NSArray> *)generateItemViewModels; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/Source/ASDiffingSectionController.m b/Source/ASDiffingSectionController.m new file mode 100644 index 00000000..dc419379 --- /dev/null +++ b/Source/ASDiffingSectionController.m @@ -0,0 +1,17 @@ +// +// ASDiffingSectionController.m +// AsyncDisplayKit +// +// Created by Adlai Holler on 6/20/17. +// Copyright © 2017 Facebook. All rights reserved. +// + +#import "ASDiffingSectionController.h" + +#if AS_DIFFING + +@implementation ASDiffingSectionController + +@end + +#endif diff --git a/Source/ASSectionController.h b/Source/ASSectionController.h index b418ee96..6cd470c9 100644 --- a/Source/ASSectionController.h +++ b/Source/ASSectionController.h @@ -18,6 +18,9 @@ #import #import #import +#if AS_DIFFING +#import +#endif NS_ASSUME_NONNULL_BEGIN diff --git a/Source/AsyncDisplayKit.h b/Source/AsyncDisplayKit.h index 6d949b5a..57e93fab 100644 --- a/Source/AsyncDisplayKit.h +++ b/Source/AsyncDisplayKit.h @@ -44,6 +44,7 @@ #import #import #import +#import #import #import diff --git a/Source/Base/ASAvailability.h b/Source/Base/ASAvailability.h index bb2defe2..62a04e57 100644 --- a/Source/Base/ASAvailability.h +++ b/Source/Base/ASAvailability.h @@ -43,6 +43,7 @@ #define AS_PIN_REMOTE_IMAGE __has_include() #define AS_IG_LIST_KIT __has_include() +#define AS_DIFFING __has_include() /** * For IGListKit versions < 3.0, you have to use IGListCollectionView. diff --git a/SubspecWorkspaces/ASDKDiffing/ASDKDiffing.xcodeproj/project.pbxproj b/SubspecWorkspaces/ASDKDiffing/ASDKDiffing.xcodeproj/project.pbxproj new file mode 100644 index 00000000..3e362451 --- /dev/null +++ b/SubspecWorkspaces/ASDKDiffing/ASDKDiffing.xcodeproj/project.pbxproj @@ -0,0 +1,585 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 5C2B0D08AE353B01DD8AFB44 /* libPods-ASDKDiffingTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D351EEAC3F60D3F2B4C6A1E5 /* libPods-ASDKDiffingTests.a */; }; + CC9E981A1EF9F46A009D37C5 /* ASDKDiffingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CC9E98191EF9F46A009D37C5 /* ASDKDiffingTests.m */; }; + CC9E98281EF9F6A4009D37C5 /* ASDisplayNode+OCMock.m in Sources */ = {isa = PBXBuildFile; fileRef = CC9E98201EF9F6A4009D37C5 /* ASDisplayNode+OCMock.m */; }; + CC9E98291EF9F6A4009D37C5 /* ASTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = CC9E98221EF9F6A4009D37C5 /* ASTestCase.m */; }; + CC9E982A1EF9F6A4009D37C5 /* NSInvocation+ASTestHelpers.m in Sources */ = {isa = PBXBuildFile; fileRef = CC9E98251EF9F6A4009D37C5 /* NSInvocation+ASTestHelpers.m */; }; + CC9E982B1EF9F6A4009D37C5 /* OCMockObject+ASAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = CC9E98271EF9F6A4009D37C5 /* OCMockObject+ASAdditions.m */; }; + CC9E982E1EFA0532009D37C5 /* ASDKDiffingFixtures.m in Sources */ = {isa = PBXBuildFile; fileRef = CC9E982D1EFA0532009D37C5 /* ASDKDiffingFixtures.m */; }; + CC9E983B1EFA267E009D37C5 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = CC9E983A1EFA267E009D37C5 /* main.m */; }; + CC9E983E1EFA267E009D37C5 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = CC9E983D1EFA267E009D37C5 /* AppDelegate.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + CC9E984E1EFA2683009D37C5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = CC9E980C1EF9F44F009D37C5 /* Project object */; + proxyType = 1; + remoteGlobalIDString = CC9E98361EFA267E009D37C5; + remoteInfo = DiffingTestHost; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 0C82DB0B426A86BE680F06B8 /* Pods-ASDKDiffingTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ASDKDiffingTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ASDKDiffingTests/Pods-ASDKDiffingTests.debug.xcconfig"; sourceTree = ""; }; + 92E6E53B4239101982E9E8A6 /* Pods-ASDKDiffingTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ASDKDiffingTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-ASDKDiffingTests/Pods-ASDKDiffingTests.release.xcconfig"; sourceTree = ""; }; + CC9E98161EF9F46A009D37C5 /* ASDKDiffingTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ASDKDiffingTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + CC9E98191EF9F46A009D37C5 /* ASDKDiffingTests.m */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = sourcecode.c.objc; path = ASDKDiffingTests.m; sourceTree = ""; tabWidth = 2; usesTabs = 0; }; + CC9E981B1EF9F46A009D37C5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + CC9E98201EF9F6A4009D37C5 /* ASDisplayNode+OCMock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "ASDisplayNode+OCMock.m"; sourceTree = ""; }; + CC9E98211EF9F6A4009D37C5 /* ASTestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASTestCase.h; sourceTree = ""; }; + CC9E98221EF9F6A4009D37C5 /* ASTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASTestCase.m; sourceTree = ""; }; + CC9E98231EF9F6A4009D37C5 /* ASXCTExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASXCTExtensions.h; sourceTree = ""; }; + CC9E98241EF9F6A4009D37C5 /* NSInvocation+ASTestHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSInvocation+ASTestHelpers.h"; sourceTree = ""; }; + CC9E98251EF9F6A4009D37C5 /* NSInvocation+ASTestHelpers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSInvocation+ASTestHelpers.m"; sourceTree = ""; }; + CC9E98261EF9F6A4009D37C5 /* OCMockObject+ASAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "OCMockObject+ASAdditions.h"; sourceTree = ""; }; + CC9E98271EF9F6A4009D37C5 /* OCMockObject+ASAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "OCMockObject+ASAdditions.m"; sourceTree = ""; }; + CC9E982C1EFA0532009D37C5 /* ASDKDiffingFixtures.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASDKDiffingFixtures.h; sourceTree = ""; }; + CC9E982D1EFA0532009D37C5 /* ASDKDiffingFixtures.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASDKDiffingFixtures.m; sourceTree = ""; }; + CC9E98371EFA267E009D37C5 /* DiffingTestHost.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DiffingTestHost.app; sourceTree = BUILT_PRODUCTS_DIR; }; + CC9E983A1EFA267E009D37C5 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + CC9E983C1EFA267E009D37C5 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + CC9E983D1EFA267E009D37C5 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + CC9E984A1EFA267E009D37C5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + D351EEAC3F60D3F2B4C6A1E5 /* libPods-ASDKDiffingTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ASDKDiffingTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + CC9E98131EF9F46A009D37C5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 5C2B0D08AE353B01DD8AFB44 /* libPods-ASDKDiffingTests.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + CC9E98341EFA267E009D37C5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 02A24BFB52264A6AAFC80F7B /* Frameworks */ = { + isa = PBXGroup; + children = ( + D351EEAC3F60D3F2B4C6A1E5 /* libPods-ASDKDiffingTests.a */, + ); + name = Frameworks; + sourceTree = ""; + }; + BCE64E0F48130D23C90FA79C /* Pods */ = { + isa = PBXGroup; + children = ( + 0C82DB0B426A86BE680F06B8 /* Pods-ASDKDiffingTests.debug.xcconfig */, + 92E6E53B4239101982E9E8A6 /* Pods-ASDKDiffingTests.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; + CC9E980B1EF9F44F009D37C5 = { + isa = PBXGroup; + children = ( + CC9E98181EF9F46A009D37C5 /* ASDKDiffingTests */, + CC9E98381EFA267E009D37C5 /* DiffingTestHost */, + CC9E98171EF9F46A009D37C5 /* Products */, + BCE64E0F48130D23C90FA79C /* Pods */, + 02A24BFB52264A6AAFC80F7B /* Frameworks */, + ); + indentWidth = 2; + sourceTree = ""; + tabWidth = 2; + usesTabs = 0; + }; + CC9E98171EF9F46A009D37C5 /* Products */ = { + isa = PBXGroup; + children = ( + CC9E98161EF9F46A009D37C5 /* ASDKDiffingTests.xctest */, + CC9E98371EFA267E009D37C5 /* DiffingTestHost.app */, + ); + name = Products; + sourceTree = ""; + }; + CC9E98181EF9F46A009D37C5 /* ASDKDiffingTests */ = { + isa = PBXGroup; + children = ( + CC9E981F1EF9F6A4009D37C5 /* Common */, + CC9E982C1EFA0532009D37C5 /* ASDKDiffingFixtures.h */, + CC9E982D1EFA0532009D37C5 /* ASDKDiffingFixtures.m */, + CC9E98191EF9F46A009D37C5 /* ASDKDiffingTests.m */, + CC9E981B1EF9F46A009D37C5 /* Info.plist */, + ); + path = ASDKDiffingTests; + sourceTree = ""; + }; + CC9E981F1EF9F6A4009D37C5 /* Common */ = { + isa = PBXGroup; + children = ( + CC9E98201EF9F6A4009D37C5 /* ASDisplayNode+OCMock.m */, + CC9E98211EF9F6A4009D37C5 /* ASTestCase.h */, + CC9E98221EF9F6A4009D37C5 /* ASTestCase.m */, + CC9E98231EF9F6A4009D37C5 /* ASXCTExtensions.h */, + CC9E98241EF9F6A4009D37C5 /* NSInvocation+ASTestHelpers.h */, + CC9E98251EF9F6A4009D37C5 /* NSInvocation+ASTestHelpers.m */, + CC9E98261EF9F6A4009D37C5 /* OCMockObject+ASAdditions.h */, + CC9E98271EF9F6A4009D37C5 /* OCMockObject+ASAdditions.m */, + ); + name = Common; + path = ../../../Tests/Common; + sourceTree = ""; + }; + CC9E98381EFA267E009D37C5 /* DiffingTestHost */ = { + isa = PBXGroup; + children = ( + CC9E983C1EFA267E009D37C5 /* AppDelegate.h */, + CC9E983D1EFA267E009D37C5 /* AppDelegate.m */, + CC9E984A1EFA267E009D37C5 /* Info.plist */, + CC9E98391EFA267E009D37C5 /* Supporting Files */, + ); + path = DiffingTestHost; + sourceTree = ""; + }; + CC9E98391EFA267E009D37C5 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + CC9E983A1EFA267E009D37C5 /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + CC9E98151EF9F46A009D37C5 /* ASDKDiffingTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = CC9E981C1EF9F46A009D37C5 /* Build configuration list for PBXNativeTarget "ASDKDiffingTests" */; + buildPhases = ( + 8F2972FB3CBA30856D1BE3D3 /* [CP] Check Pods Manifest.lock */, + CC9E98121EF9F46A009D37C5 /* Sources */, + CC9E98131EF9F46A009D37C5 /* Frameworks */, + CC9E98141EF9F46A009D37C5 /* Resources */, + 2B07374431E476290B0BAD46 /* [CP] Embed Pods Frameworks */, + 546706FC16C480BF4944D658 /* [CP] Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + CC9E984F1EFA2683009D37C5 /* PBXTargetDependency */, + ); + name = ASDKDiffingTests; + productName = ASDKDiffingTests; + productReference = CC9E98161EF9F46A009D37C5 /* ASDKDiffingTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + CC9E98361EFA267E009D37C5 /* DiffingTestHost */ = { + isa = PBXNativeTarget; + buildConfigurationList = CC9E984B1EFA267E009D37C5 /* Build configuration list for PBXNativeTarget "DiffingTestHost" */; + buildPhases = ( + CC9E98331EFA267E009D37C5 /* Sources */, + CC9E98341EFA267E009D37C5 /* Frameworks */, + CC9E98351EFA267E009D37C5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = DiffingTestHost; + productName = DiffingTestHost; + productReference = CC9E98371EFA267E009D37C5 /* DiffingTestHost.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + CC9E980C1EF9F44F009D37C5 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0830; + TargetAttributes = { + CC9E98151EF9F46A009D37C5 = { + CreatedOnToolsVersion = 8.3.3; + ProvisioningStyle = Automatic; + TestTargetID = CC9E98361EFA267E009D37C5; + }; + CC9E98361EFA267E009D37C5 = { + CreatedOnToolsVersion = 8.3.3; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = CC9E980F1EF9F44F009D37C5 /* Build configuration list for PBXProject "ASDKDiffing" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = CC9E980B1EF9F44F009D37C5; + productRefGroup = CC9E98171EF9F46A009D37C5 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + CC9E98151EF9F46A009D37C5 /* ASDKDiffingTests */, + CC9E98361EFA267E009D37C5 /* DiffingTestHost */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + CC9E98141EF9F46A009D37C5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + CC9E98351EFA267E009D37C5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 2B07374431E476290B0BAD46 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ASDKDiffingTests/Pods-ASDKDiffingTests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 546706FC16C480BF4944D658 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ASDKDiffingTests/Pods-ASDKDiffingTests-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + 8F2972FB3CBA30856D1BE3D3 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + CC9E98121EF9F46A009D37C5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + CC9E982A1EF9F6A4009D37C5 /* NSInvocation+ASTestHelpers.m in Sources */, + CC9E98281EF9F6A4009D37C5 /* ASDisplayNode+OCMock.m in Sources */, + CC9E982B1EF9F6A4009D37C5 /* OCMockObject+ASAdditions.m in Sources */, + CC9E981A1EF9F46A009D37C5 /* ASDKDiffingTests.m in Sources */, + CC9E982E1EFA0532009D37C5 /* ASDKDiffingFixtures.m in Sources */, + CC9E98291EF9F6A4009D37C5 /* ASTestCase.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + CC9E98331EFA267E009D37C5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + CC9E983E1EFA267E009D37C5 /* AppDelegate.m in Sources */, + CC9E983B1EFA267E009D37C5 /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + CC9E984F1EFA2683009D37C5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = CC9E98361EFA267E009D37C5 /* DiffingTestHost */; + targetProxy = CC9E984E1EFA2683009D37C5 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + CC9E98101EF9F44F009D37C5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + }; + name = Debug; + }; + CC9E98111EF9F44F009D37C5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + }; + name = Release; + }; + CC9E981D1EF9F46A009D37C5 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 0C82DB0B426A86BE680F06B8 /* Pods-ASDKDiffingTests.debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + INFOPLIST_FILE = ASDKDiffingTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 10.3; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + PRODUCT_BUNDLE_IDENTIFIER = org.TextureGroup.ASDKDiffingTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DiffingTestHost.app/DiffingTestHost"; + }; + name = Debug; + }; + CC9E981E1EF9F46A009D37C5 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 92E6E53B4239101982E9E8A6 /* Pods-ASDKDiffingTests.release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + INFOPLIST_FILE = ASDKDiffingTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 10.3; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_BUNDLE_IDENTIFIER = org.TextureGroup.ASDKDiffingTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DiffingTestHost.app/DiffingTestHost"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + CC9E984C1EFA267E009D37C5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + INFOPLIST_FILE = DiffingTestHost/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 10.3; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + PRODUCT_BUNDLE_IDENTIFIER = org.TextureGroup.DiffingTestHost; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + }; + name = Debug; + }; + CC9E984D1EFA267E009D37C5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + INFOPLIST_FILE = DiffingTestHost/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 10.3; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_BUNDLE_IDENTIFIER = org.TextureGroup.DiffingTestHost; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + CC9E980F1EF9F44F009D37C5 /* Build configuration list for PBXProject "ASDKDiffing" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + CC9E98101EF9F44F009D37C5 /* Debug */, + CC9E98111EF9F44F009D37C5 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + CC9E981C1EF9F46A009D37C5 /* Build configuration list for PBXNativeTarget "ASDKDiffingTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + CC9E981D1EF9F46A009D37C5 /* Debug */, + CC9E981E1EF9F46A009D37C5 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + CC9E984B1EFA267E009D37C5 /* Build configuration list for PBXNativeTarget "DiffingTestHost" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + CC9E984C1EFA267E009D37C5 /* Debug */, + CC9E984D1EFA267E009D37C5 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = CC9E980C1EF9F44F009D37C5 /* Project object */; +} diff --git a/SubspecWorkspaces/ASDKDiffing/ASDKDiffing.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/SubspecWorkspaces/ASDKDiffing/ASDKDiffing.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..08c52e53 --- /dev/null +++ b/SubspecWorkspaces/ASDKDiffing/ASDKDiffing.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/SubspecWorkspaces/ASDKDiffing/ASDKDiffing.xcworkspace/contents.xcworkspacedata b/SubspecWorkspaces/ASDKDiffing/ASDKDiffing.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..9bc31382 --- /dev/null +++ b/SubspecWorkspaces/ASDKDiffing/ASDKDiffing.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/SubspecWorkspaces/ASDKDiffing/ASDKDiffingTests/ASDKDiffingFixtures.h b/SubspecWorkspaces/ASDKDiffing/ASDKDiffingTests/ASDKDiffingFixtures.h new file mode 100644 index 00000000..2d094b1d --- /dev/null +++ b/SubspecWorkspaces/ASDKDiffing/ASDKDiffingTests/ASDKDiffingFixtures.h @@ -0,0 +1,41 @@ +// +// ASDKDiffingFixtures.h +// ASDKDiffing +// +// Created by Adlai Holler on 6/20/17. +// +// + +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface ASTViewModel : NSObject +@property (nonatomic, readonly) NSInteger identifier; // Globally unique. +@property (nonatomic, readonly) NSInteger contents; // Globally unique. Auto-increments. +@property (nonatomic, nullable, copy) NSString *debugName; // Helpful. Copied when updating. +// Returns a new view model with the next `contents` value. +- (instancetype)viewModelByUpdating; + ++ (void)reset; + +@end + +@interface ASTItem : ASTViewModel +@end + +@interface ASTSection : ASTViewModel + +@end + +@interface ASTSectionCtrl : ASDiffingSectionController + +@end + +@interface ASTItemNode : ASCellNode + +@end + +NS_ASSUME_NONNULL_END diff --git a/SubspecWorkspaces/ASDKDiffing/ASDKDiffingTests/ASDKDiffingFixtures.m b/SubspecWorkspaces/ASDKDiffing/ASDKDiffingTests/ASDKDiffingFixtures.m new file mode 100644 index 00000000..b7670b7c --- /dev/null +++ b/SubspecWorkspaces/ASDKDiffing/ASDKDiffingTests/ASDKDiffingFixtures.m @@ -0,0 +1,136 @@ +// +// ASDKDiffingFixtures.m +// ASDKDiffing +// +// Created by Adlai Holler on 6/20/17. +// +// + +#import "ASDKDiffingFixtures.h" +#import +#import + +atomic_uint g_identifier; +atomic_uint g_val; + +void ASTReset() { + atomic_store(&g_identifier, 0); + atomic_store(&g_val, 0); +} + +NSInteger ASTNextIdentifier() { + return atomic_fetch_add(&g_identifier, 1); +} + +NSInteger ASTNextContents() { + return atomic_fetch_add(&g_val, 1); +} + +id ASTWithDebugNamesTable(id (NS_NOESCAPE ^block)(NSMapTable *table)) { + static NSMapTable *table; + static NSLock *lock; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + table = [NSMapTable strongToStrongObjectsMapTable]; + lock = [NSLock new]; + }); + + [lock lock]; + id result = block(table); + [lock unlock]; + return result; +} + +@implementation ASTViewModel + +- (instancetype)init +{ + if (self = [super init]) { + _identifier = ASTNextIdentifier(); + _contents = ASTNextContents(); + } + return self; +} + +- (instancetype)viewModelByUpdating +{ + ASTViewModel *vm = [[self class] alloc]; // No init. We control the values manually. + vm->_identifier = _identifier; + vm->_contents = ASTNextContents(); + return vm; +} + +- (NSString *)debugDescription +{ + return ASObjectDescriptionMake(self, [self propertiesForDebugDescription]); +} + +- (void)setDebugName:(NSString *)debugName +{ + ASTWithDebugNamesTable(^id(NSMapTable *table) { + [table setObject:[debugName copy] forKey:@(self.identifier)]; + return nil; + }); +} + +- (NSString *)debugName +{ + return ASTWithDebugNamesTable(^id(NSMapTable *table) { + return [table objectForKey:@(self.identifier)]; + }); +} + +- (NSMutableArray *)propertiesForDebugDescription +{ + __auto_type array = [NSMutableArray array]; + NSString *name = self.debugName; + if (name.length > 0) { + [array addObject:@{ @"name": name }]; + } else { + [array addObject:@{ @"id": @(self.identifier) }]; + } + [array addObject:@{ @"contents": @(self.contents) }]; + return array; +} + ++ (void)reset +{ + ASTReset(); +} + +#pragma mark - IGListDiffable + +- (BOOL)isEqualToDiffableObject:(id)object +{ + ASTViewModel *vm = (ASTViewModel *)object; + NSParameterAssert([(id)object class] == [self class]); + NSParameterAssert(vm.identifier == self.identifier); + return vm.contents == self.contents; +} + +- (id)diffIdentifier +{ + return @(self.identifier); +} + +@end + +@implementation ASTSection +@end + +@implementation ASTItem +@end + +@implementation ASTSectionCtrl + +- (ASCellNodeBlock)nodeBlockForItemAtIndex:(NSInteger)index +{ + return ^{ + return [ASTItemNode new]; + }; +} + +@end +@implementation ASTItemNode + +@end diff --git a/SubspecWorkspaces/ASDKDiffing/ASDKDiffingTests/ASDKDiffingTests.m b/SubspecWorkspaces/ASDKDiffing/ASDKDiffingTests/ASDKDiffingTests.m new file mode 100644 index 00000000..2a9fd978 --- /dev/null +++ b/SubspecWorkspaces/ASDKDiffing/ASDKDiffingTests/ASDKDiffingTests.m @@ -0,0 +1,106 @@ +// +// ASDKDiffingTests.m +// ASDKDiffingTests +// +// Created by Adlai Holler on 6/20/17. +// +// + +#import +#import "ASTestCase.h" +#import "ASDKDiffingFixtures.h" +#import +#import + +@interface ASDKDiffingTests : ASTestCase + +@end + +@implementation ASDKDiffingTests { + ASCollectionNode *collectionNode; + UIWindow *window; + id mockDataSource; + NSMutableArray *sections; +} + +- (void)setUp { + [super setUp]; + [ASTViewModel reset]; + sections = [NSMutableArray array]; + + collectionNode = [[ASCollectionNode alloc] initWithCollectionViewLayout:[UICollectionViewFlowLayout new]]; + mockDataSource = OCMStrictProtocolMock(@protocol(ASCollectionModernDataSource)); + collectionNode.modernDataSource = mockDataSource; + window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; + UIViewController *vc = [[UIViewController alloc] init]; + collectionNode.view.frame = vc.view.bounds; + collectionNode.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + [vc.view addSubnode:collectionNode]; + window.rootViewController = vc; + [window makeKeyAndVisible]; +} + +- (void)testThatFixturesWork +{ + ASTSection *s1 = [ASTSection new]; + ASTSection *s1_2 = [s1 viewModelByUpdating]; + s1.debugName = @"Hello"; + ASTSection *s2 = [ASTSection new]; + ASTItem *i1 = [ASTItem new]; + + // -setDebugName works + XCTAssertEqualObjects(s1.debugName, @"Hello"); + // debugName shared between versions even if set after + XCTAssertEqualObjects(s1_2.debugName, s1.debugName); + // identifier starts at 0 + XCTAssertEqual(s1.identifier, 0); + // identifier incs each new object + XCTAssertEqual(s2.identifier, 1); + // identifier global between classes + XCTAssertEqual(i1.identifier, 2); + // identifier shared between versions + XCTAssertEqual(s1_2.identifier, s1.identifier); + // contents inc each new object + XCTAssertEqual(s1_2.contents, s1.contents + 1); + // contents global between classes + XCTAssertEqual(i1.contents, 3); +} + +- (void)testInitialDataLoad +{ + NSMapTable *sectionToCtrl = [NSMapTable weakToWeakObjectsMapTable]; + + // It gathers section view models. + OCMExpect([mockDataSource sectionViewModelsForCollectionNode:collectionNode]) + .andReturn(sections); + + // It gathers section controllers for each model. + __auto_type sectionControllers = [NSMutableArray array]; + for (ASTSection *sectionModel in sections) { + ASTSectionCtrl *ctrl = OCMPartialMock([ASTSectionCtrl new]); + [sectionControllers addObject:ctrl]; + + [sectionToCtrl setObject:ctrl forKey:sectionModel]; + OCMExpect([mockDataSource collectionNode:collectionNode controllerForSection:sectionModel]) + .andReturn(ctrl); + } + + // For each section model + for (ASTSection *sectionModel in sectionToCtrl) { + id mockCtrl = [sectionToCtrl objectForKey:sectionModel]; + + // It sets the new view model to the section controller + OCMExpect([mockCtrl setViewModel:sectionModel]) + .andForwardToRealObject(); + + // It fetches a new array of item view models + OCMExpect([mockCtrl generateItemViewModels]) + .andForwardToRealObject(); + } + + [window layoutIfNeeded]; +} + + +@end + diff --git a/SubspecWorkspaces/ASDKDiffing/ASDKDiffingTests/Info.plist b/SubspecWorkspaces/ASDKDiffing/ASDKDiffingTests/Info.plist new file mode 100644 index 00000000..6c6c23c4 --- /dev/null +++ b/SubspecWorkspaces/ASDKDiffing/ASDKDiffingTests/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/SubspecWorkspaces/ASDKDiffing/DiffingTestHost/AppDelegate.h b/SubspecWorkspaces/ASDKDiffing/DiffingTestHost/AppDelegate.h new file mode 100644 index 00000000..a0e5117d --- /dev/null +++ b/SubspecWorkspaces/ASDKDiffing/DiffingTestHost/AppDelegate.h @@ -0,0 +1,17 @@ +// +// AppDelegate.h +// DiffingTestHost +// +// Created by Adlai Holler on 6/20/17. +// +// + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + + +@end + diff --git a/SubspecWorkspaces/ASDKDiffing/DiffingTestHost/AppDelegate.m b/SubspecWorkspaces/ASDKDiffing/DiffingTestHost/AppDelegate.m new file mode 100644 index 00000000..3a832ae1 --- /dev/null +++ b/SubspecWorkspaces/ASDKDiffing/DiffingTestHost/AppDelegate.m @@ -0,0 +1,51 @@ +// +// AppDelegate.m +// DiffingTestHost +// +// Created by Adlai Holler on 6/20/17. +// +// + +#import "AppDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // Override point for customization after application launch. + return YES; +} + + +- (void)applicationWillResignActive:(UIApplication *)application { + // 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. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. +} + + +- (void)applicationDidEnterBackground:(UIApplication *)application { + // 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. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +} + + +- (void)applicationWillEnterForeground:(UIApplication *)application { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. +} + + +- (void)applicationDidBecomeActive:(UIApplication *)application { + // 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. +} + + +- (void)applicationWillTerminate:(UIApplication *)application { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. +} + + +@end diff --git a/SubspecWorkspaces/ASDKDiffing/DiffingTestHost/Info.plist b/SubspecWorkspaces/ASDKDiffing/DiffingTestHost/Info.plist new file mode 100644 index 00000000..02096782 --- /dev/null +++ b/SubspecWorkspaces/ASDKDiffing/DiffingTestHost/Info.plist @@ -0,0 +1,34 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + + + diff --git a/SubspecWorkspaces/ASDKDiffing/DiffingTestHost/main.m b/SubspecWorkspaces/ASDKDiffing/DiffingTestHost/main.m new file mode 100644 index 00000000..9c9cfc93 --- /dev/null +++ b/SubspecWorkspaces/ASDKDiffing/DiffingTestHost/main.m @@ -0,0 +1,16 @@ +// +// main.m +// DiffingTestHost +// +// Created by Adlai Holler on 6/20/17. +// +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/SubspecWorkspaces/ASDKDiffing/Podfile b/SubspecWorkspaces/ASDKDiffing/Podfile new file mode 100644 index 00000000..d6964fa1 --- /dev/null +++ b/SubspecWorkspaces/ASDKDiffing/Podfile @@ -0,0 +1,8 @@ +source 'https://github.com/CocoaPods/Specs.git' + +platform :ios, '8.0' +target 'ASDKDiffingTests' do + pod 'Texture/Diffing', :path => '../..' + pod 'OCMock', '~> 3.4' +end + diff --git a/Tests/Common/ASTestCase.m b/Tests/Common/ASTestCase.m index bc17a564..f113f629 100644 --- a/Tests/Common/ASTestCase.m +++ b/Tests/Common/ASTestCase.m @@ -73,9 +73,9 @@ static __weak ASTestCase *currentTestCase; [invocations removeAllObjects]; } - // Go ahead and spin the run loop before finishing, so the system + // Go ahead and spin the run loop (without waiting), so the system // unregisters/cleans up whatever possible. - [NSRunLoop.mainRunLoop runMode:NSDefaultRunLoopMode beforeDate:NSDate.distantFuture]; + [NSRunLoop.mainRunLoop runMode:NSDefaultRunLoopMode beforeDate:NSDate.distantPast]; [super tearDown]; } diff --git a/Texture.podspec b/Texture.podspec index 7371a209..039109f6 100644 --- a/Texture.podspec +++ b/Texture.podspec @@ -55,6 +55,11 @@ Pod::Spec.new do |spec| igl.dependency 'Texture/Core' end + spec.subspec 'Diffing' do |dif| + dif.dependency 'IGListKit/Diffing', '3.0.0' + dif.dependency 'Texture/Core' + end + spec.subspec 'Yoga' do |yoga| yoga.xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) YOGA=1' } yoga.dependency 'Yoga', '1.5.0'