diff --git a/SWRefresh.xcodeproj/project.pbxproj b/SWRefresh.xcodeproj/project.pbxproj index e5e7b01..84e9421 100644 --- a/SWRefresh.xcodeproj/project.pbxproj +++ b/SWRefresh.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 216D45041CAE068900492F40 /* SWRefreshExampleUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 216D45031CAE068900492F40 /* SWRefreshExampleUITests.m */; }; + 216D45211CAE25E800492F40 /* SWRefreshExampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 216D45201CAE25E800492F40 /* SWRefreshExampleTests.m */; }; 217499351C34D6EF00399768 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 217499341C34D6EF00399768 /* main.m */; }; 217499381C34D6EF00399768 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 217499371C34D6EF00399768 /* AppDelegate.m */; }; 2174993B1C34D6EF00399768 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2174993A1C34D6EF00399768 /* ViewController.m */; }; @@ -28,6 +30,20 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ + 216D45061CAE068900492F40 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 217499191C34D6D500399768 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 217499301C34D6EF00399768; + remoteInfo = SWRefreshExample; + }; + 216D45231CAE25E800492F40 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 217499191C34D6D500399768 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 217499301C34D6EF00399768; + remoteInfo = SWRefreshExample; + }; 217499481C34D6FD00399768 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 217499191C34D6D500399768 /* Project object */; @@ -50,6 +66,12 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 216D45011CAE068900492F40 /* SWRefreshExampleUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SWRefreshExampleUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 216D45031CAE068900492F40 /* SWRefreshExampleUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SWRefreshExampleUITests.m; sourceTree = ""; }; + 216D45051CAE068900492F40 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 216D451E1CAE25E800492F40 /* SWRefreshExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SWRefreshExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 216D45201CAE25E800492F40 /* SWRefreshExampleTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SWRefreshExampleTests.m; sourceTree = ""; }; + 216D45221CAE25E800492F40 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 217499211C34D6D500399768 /* libSWRefresh.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSWRefresh.a; sourceTree = BUILT_PRODUCTS_DIR; }; 217499311C34D6EF00399768 /* SWRefreshExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SWRefreshExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 217499341C34D6EF00399768 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; @@ -86,6 +108,20 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 216D44FE1CAE068900492F40 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 216D451B1CAE25E800492F40 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 2174991E1C34D6D500399768 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -104,11 +140,31 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 216D45021CAE068900492F40 /* SWRefreshExampleUITests */ = { + isa = PBXGroup; + children = ( + 216D45031CAE068900492F40 /* SWRefreshExampleUITests.m */, + 216D45051CAE068900492F40 /* Info.plist */, + ); + path = SWRefreshExampleUITests; + sourceTree = ""; + }; + 216D451F1CAE25E800492F40 /* SWRefreshExampleTests */ = { + isa = PBXGroup; + children = ( + 216D45201CAE25E800492F40 /* SWRefreshExampleTests.m */, + 216D45221CAE25E800492F40 /* Info.plist */, + ); + path = SWRefreshExampleTests; + sourceTree = ""; + }; 217499181C34D6D500399768 = { isa = PBXGroup; children = ( 217499231C34D6D500399768 /* SWRefresh */, 217499321C34D6EF00399768 /* SWRefreshExample */, + 216D45021CAE068900492F40 /* SWRefreshExampleUITests */, + 216D451F1CAE25E800492F40 /* SWRefreshExampleTests */, 217499221C34D6D500399768 /* Products */, ); sourceTree = ""; @@ -118,6 +174,8 @@ children = ( 217499211C34D6D500399768 /* libSWRefresh.a */, 217499311C34D6EF00399768 /* SWRefreshExample.app */, + 216D45011CAE068900492F40 /* SWRefreshExampleUITests.xctest */, + 216D451E1CAE25E800492F40 /* SWRefreshExampleTests.xctest */, ); name = Products; sourceTree = ""; @@ -218,6 +276,42 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ + 216D45001CAE068900492F40 /* SWRefreshExampleUITests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 216D450A1CAE068900492F40 /* Build configuration list for PBXNativeTarget "SWRefreshExampleUITests" */; + buildPhases = ( + 216D44FD1CAE068900492F40 /* Sources */, + 216D44FE1CAE068900492F40 /* Frameworks */, + 216D44FF1CAE068900492F40 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 216D45071CAE068900492F40 /* PBXTargetDependency */, + ); + name = SWRefreshExampleUITests; + productName = SWRefreshExampleUITests; + productReference = 216D45011CAE068900492F40 /* SWRefreshExampleUITests.xctest */; + productType = "com.apple.product-type.bundle.ui-testing"; + }; + 216D451D1CAE25E800492F40 /* SWRefreshExampleTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 216D45251CAE25E800492F40 /* Build configuration list for PBXNativeTarget "SWRefreshExampleTests" */; + buildPhases = ( + 216D451A1CAE25E800492F40 /* Sources */, + 216D451B1CAE25E800492F40 /* Frameworks */, + 216D451C1CAE25E800492F40 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 216D45241CAE25E800492F40 /* PBXTargetDependency */, + ); + name = SWRefreshExampleTests; + productName = SWRefreshExampleTests; + productReference = 216D451E1CAE25E800492F40 /* SWRefreshExampleTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; 217499201C34D6D500399768 /* SWRefresh */ = { isa = PBXNativeTarget; buildConfigurationList = 2174992A1C34D6D500399768 /* Build configuration list for PBXNativeTarget "SWRefresh" */; @@ -262,6 +356,14 @@ LastUpgradeCheck = 0710; ORGANIZATIONNAME = SW; TargetAttributes = { + 216D45001CAE068900492F40 = { + CreatedOnToolsVersion = 7.2; + TestTargetID = 217499301C34D6EF00399768; + }; + 216D451D1CAE25E800492F40 = { + CreatedOnToolsVersion = 7.2; + TestTargetID = 217499301C34D6EF00399768; + }; 217499201C34D6D500399768 = { CreatedOnToolsVersion = 7.1.1; }; @@ -286,11 +388,27 @@ targets = ( 217499201C34D6D500399768 /* SWRefresh */, 217499301C34D6EF00399768 /* SWRefreshExample */, + 216D45001CAE068900492F40 /* SWRefreshExampleUITests */, + 216D451D1CAE25E800492F40 /* SWRefreshExampleTests */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + 216D44FF1CAE068900492F40 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 216D451C1CAE25E800492F40 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 2174992F1C34D6EF00399768 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -304,6 +422,22 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + 216D44FD1CAE068900492F40 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 216D45041CAE068900492F40 /* SWRefreshExampleUITests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 216D451A1CAE25E800492F40 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 216D45211CAE25E800492F40 /* SWRefreshExampleTests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 2174991D1C34D6D500399768 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -335,6 +469,16 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ + 216D45071CAE068900492F40 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 217499301C34D6EF00399768 /* SWRefreshExample */; + targetProxy = 216D45061CAE068900492F40 /* PBXContainerItemProxy */; + }; + 216D45241CAE25E800492F40 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 217499301C34D6EF00399768 /* SWRefreshExample */; + targetProxy = 216D45231CAE25E800492F40 /* PBXContainerItemProxy */; + }; 217499491C34D6FD00399768 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 217499201C34D6D500399768 /* SWRefresh */; @@ -362,6 +506,58 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ + 216D45081CAE068900492F40 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + INFOPLIST_FILE = SWRefreshExampleUITests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = SW.SWRefreshExampleUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_TARGET_NAME = SWRefreshExample; + USES_XCTRUNNER = YES; + }; + name = Debug; + }; + 216D45091CAE068900492F40 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + INFOPLIST_FILE = SWRefreshExampleUITests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = SW.SWRefreshExampleUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_TARGET_NAME = SWRefreshExample; + USES_XCTRUNNER = YES; + }; + name = Release; + }; + 216D45261CAE25E800492F40 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + INFOPLIST_FILE = SWRefreshExampleTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = SW.SWRefreshExampleTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SWRefreshExample.app/SWRefreshExample"; + }; + name = Debug; + }; + 216D45271CAE25E800492F40 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + INFOPLIST_FILE = SWRefreshExampleTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = SW.SWRefreshExampleTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SWRefreshExample.app/SWRefreshExample"; + }; + name = Release; + }; 217499281C34D6D500399768 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -487,6 +683,22 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 216D450A1CAE068900492F40 /* Build configuration list for PBXNativeTarget "SWRefreshExampleUITests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 216D45081CAE068900492F40 /* Debug */, + 216D45091CAE068900492F40 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; + 216D45251CAE25E800492F40 /* Build configuration list for PBXNativeTarget "SWRefreshExampleTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 216D45261CAE25E800492F40 /* Debug */, + 216D45271CAE25E800492F40 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; 2174991C1C34D6D500399768 /* Build configuration list for PBXProject "SWRefresh" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/SWRefreshExample/TableViewController.m b/SWRefreshExample/TableViewController.m index 699eda8..50303b3 100644 --- a/SWRefreshExample/TableViewController.m +++ b/SWRefreshExample/TableViewController.m @@ -63,6 +63,15 @@ - (void)viewDidLoad { tableView.refreshFooter = [SWRefreshFooterView footerWithRefreshingBlock:block]; tableView.contentInset = UIEdgeInsetsMake(50, 0, 0, 0); + CGRect frame = tableView.bounds; + frame.origin.y = -50; + frame.size.height = 50; + UILabel* insetTopLabel = [[UILabel alloc] initWithFrame:frame]; + insetTopLabel.backgroundColor = [UIColor greenColor]; + insetTopLabel.text = @"this is inset top placeholder!"; + insetTopLabel.textAlignment = NSTextAlignmentCenter; + [tableView addSubview:insetTopLabel]; + tableView.refreshHeader.headerOffset = 50; } diff --git a/SWRefreshExampleTests/Info.plist b/SWRefreshExampleTests/Info.plist new file mode 100644 index 0000000..ba72822 --- /dev/null +++ b/SWRefreshExampleTests/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/SWRefreshExampleTests/SWRefreshExampleTests.m b/SWRefreshExampleTests/SWRefreshExampleTests.m new file mode 100644 index 0000000..7416b15 --- /dev/null +++ b/SWRefreshExampleTests/SWRefreshExampleTests.m @@ -0,0 +1,40 @@ +// +// SWRefreshExampleTests.m +// SWRefreshExampleTests +// +// Created by SolaWing on 16/4/1. +// Copyright © 2016年 SW. All rights reserved. +// + +#import + +@interface SWRefreshExampleTests : XCTestCase + +@end + +@implementation SWRefreshExampleTests + +- (void)setUp { + [super setUp]; + + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; +} + +- (void)testExample { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. +} + +- (void)testPerformanceExample { + // This is an example of a performance test case. + [self measureBlock:^{ + // Put the code you want to measure the time of here. + }]; +} + +@end diff --git a/SWRefreshExampleUITests/Info.plist b/SWRefreshExampleUITests/Info.plist new file mode 100644 index 0000000..ba72822 --- /dev/null +++ b/SWRefreshExampleUITests/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/SWRefreshExampleUITests/SWRefreshExampleUITests.m b/SWRefreshExampleUITests/SWRefreshExampleUITests.m new file mode 100644 index 0000000..740c336 --- /dev/null +++ b/SWRefreshExampleUITests/SWRefreshExampleUITests.m @@ -0,0 +1,67 @@ +// +// SWRefreshExampleUITests.m +// SWRefreshExampleUITests +// +// Created by SolaWing on 16/4/1. +// Copyright © 2016年 SW. All rights reserved. +// + +#import + +@interface SWRefreshExampleUITests : XCTestCase + +@end + +@implementation SWRefreshExampleUITests + +- (void)setUp { + [super setUp]; + + // Put setup code here. This method is called before the invocation of each test method in the class. + + // In UI tests it is usually best to stop immediately when a failure occurs. + self.continueAfterFailure = NO; + // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. + [[[XCUIApplication alloc] init] launch]; + + // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; +} + +- (void)testExample { + XCUIApplication* app = [XCUIApplication new]; + XCUIElementQuery *tablesQuery = app.tables; + [tablesQuery.staticTexts[@"TableView"] tap]; + + // new page + XCTAssert(tablesQuery.staticTexts[@"this is inset top placeholder!"].exists); + + XCTAssertEqual(tablesQuery.count, 1); + XCUIElement *table = [tablesQuery elementBoundByIndex:0]; + NSUInteger count = [table cells].count; + + XCUICoordinate* start = [table coordinateWithNormalizedOffset:CGVectorMake(0.5, 0.5)]; + [start pressForDuration:0.2 thenDragToCoordinate:[start coordinateWithOffset:CGVectorMake(0, 200)]]; + [self expectationForPredicate:[NSPredicate predicateWithFormat:@"count > %d", count] evaluatedWithObject:table.cells handler:nil]; + [self waitForExpectationsWithTimeout:3 handler:nil]; + + count = [table cells].count; + [table swipeDown]; + [self expectationForPredicate:[NSPredicate predicateWithFormat:@"count > %d", count] evaluatedWithObject:table.cells handler:nil]; + [self waitForExpectationsWithTimeout:3 handler:nil]; + + count = [table cells].count; + [table swipeUp]; + [self expectationForPredicate:[NSPredicate predicateWithFormat:@"count > %d", count] evaluatedWithObject:table.cells handler:nil]; + [self waitForExpectationsWithTimeout:3 handler:nil]; + + [[app.navigationBars.buttons elementBoundByIndex:0] tap]; + // Use recording to get started writing UI tests. + // Use XCTAssert and related functions to verify your tests produce the correct results. +} + +@end