From ad8f3960ae133a0612e09d1c5c0acafee18db109 Mon Sep 17 00:00:00 2001 From: Daniel Huri Date: Sat, 1 Dec 2018 19:20:05 +0200 Subject: [PATCH] Rename of test files. README update. --- .../CrownControl.xcodeproj/project.pbxproj | 24 ++-- ...sTests.swift => CrownAttributesSpec.swift} | 42 ++++--- .../CrownControlTests/CrownControlTests.swift | 5 +- ...Tests.swift => CrownInteractionSpec.swift} | 113 +++++++++--------- ...ift => HapticFeedbackGenerationSpec.swift} | 4 +- Example/Pods/Pods.xcodeproj/project.pbxproj | 61 ++++------ README.md | 16 +-- 7 files changed, 132 insertions(+), 133 deletions(-) rename Example/CrownControlTests/{CrownAttributesTests.swift => CrownAttributesSpec.swift} (83%) rename Example/CrownControlTests/{CrownViewControllerTests.swift => CrownInteractionSpec.swift} (63%) rename Example/CrownControlTests/{HapticFeedbackGenerationTests.swift => HapticFeedbackGenerationSpec.swift} (93%) diff --git a/Example/CrownControl.xcodeproj/project.pbxproj b/Example/CrownControl.xcodeproj/project.pbxproj index 587d3b1..df528fc 100644 --- a/Example/CrownControl.xcodeproj/project.pbxproj +++ b/Example/CrownControl.xcodeproj/project.pbxproj @@ -9,7 +9,7 @@ /* Begin PBXBuildFile section */ 14096EB921B27F4B00464A24 /* CrownControlTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14096EB821B27F4B00464A24 /* CrownControlTests.swift */; }; 14096EBB21B282B800464A24 /* CrownControlTestAccessors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14096EBA21B282B800464A24 /* CrownControlTestAccessors.swift */; }; - 14096EBD21B2B41600464A24 /* HapticFeedbackGenerationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14096EBC21B2B41600464A24 /* HapticFeedbackGenerationTests.swift */; }; + 14096EBD21B2B41600464A24 /* HapticFeedbackGenerationSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14096EBC21B2B41600464A24 /* HapticFeedbackGenerationSpec.swift */; }; 141B762821A1FBD600583E0C /* SamplesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 141B761521A1FBD600583E0C /* SamplesViewController.swift */; }; 141B762921A1FBD600583E0C /* ContactTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 141B761721A1FBD600583E0C /* ContactTableViewCell.xib */; }; 141B762A21A1FBD600583E0C /* ContactsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 141B761821A1FBD600583E0C /* ContactsViewController.swift */; }; @@ -41,7 +41,7 @@ 141B765621A1FC1F00583E0C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 141B765421A1FC1F00583E0C /* Main.storyboard */; }; 141B765821A1FC7A00583E0C /* UIColor+Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 141B765721A1FC7A00583E0C /* UIColor+Utils.swift */; }; 141B765A21A1FC9E00583E0C /* Object+ClassName.swift in Sources */ = {isa = PBXBuildFile; fileRef = 141B765921A1FC9E00583E0C /* Object+ClassName.swift */; }; - 14322ECB21AF29BC00EDF7D6 /* CrownViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14322ECA21AF29BC00EDF7D6 /* CrownViewControllerTests.swift */; }; + 14322ECB21AF29BC00EDF7D6 /* CrownInteractionSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14322ECA21AF29BC00EDF7D6 /* CrownInteractionSpec.swift */; }; 144ED30321A98DFE0062DD74 /* CHANGELOG.md in Resources */ = {isa = PBXBuildFile; fileRef = 144ED30221A98DFE0062DD74 /* CHANGELOG.md */; }; 14B7514921A2B3C400536272 /* SampleData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14B7514821A2B3C400536272 /* SampleData.swift */; }; 14B7514C21A2B69E00536272 /* UIStoryboard+Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14B7514B21A2B69E00536272 /* UIStoryboard+Utils.swift */; }; @@ -49,7 +49,7 @@ 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; }; 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; }; 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; }; - 607FACEC1AFB9204008FA782 /* CrownAttributesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* CrownAttributesTests.swift */; }; + 607FACEC1AFB9204008FA782 /* CrownAttributesSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* CrownAttributesSpec.swift */; }; 87112A1E45B4BF791A1D41EF /* Pods_CrownControlDemo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DB0497C094391FD38797E479 /* Pods_CrownControlDemo.framework */; }; D6B5BED3938F7AB3CA6B6005 /* Pods_CrownControlTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E490B07CECD5E8AB030A0154 /* Pods_CrownControlTests.framework */; }; /* End PBXBuildFile section */ @@ -67,7 +67,7 @@ /* Begin PBXFileReference section */ 14096EB821B27F4B00464A24 /* CrownControlTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CrownControlTests.swift; sourceTree = ""; }; 14096EBA21B282B800464A24 /* CrownControlTestAccessors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CrownControlTestAccessors.swift; sourceTree = ""; }; - 14096EBC21B2B41600464A24 /* HapticFeedbackGenerationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HapticFeedbackGenerationTests.swift; sourceTree = ""; }; + 14096EBC21B2B41600464A24 /* HapticFeedbackGenerationSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HapticFeedbackGenerationSpec.swift; sourceTree = ""; }; 141B761521A1FBD600583E0C /* SamplesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SamplesViewController.swift; sourceTree = ""; }; 141B761721A1FBD600583E0C /* ContactTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ContactTableViewCell.xib; sourceTree = ""; }; 141B761821A1FBD600583E0C /* ContactsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContactsViewController.swift; sourceTree = ""; }; @@ -99,7 +99,7 @@ 141B765521A1FC1F00583E0C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 141B765721A1FC7A00583E0C /* UIColor+Utils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Utils.swift"; sourceTree = ""; }; 141B765921A1FC9E00583E0C /* Object+ClassName.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Object+ClassName.swift"; sourceTree = ""; }; - 14322ECA21AF29BC00EDF7D6 /* CrownViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CrownViewControllerTests.swift; sourceTree = ""; }; + 14322ECA21AF29BC00EDF7D6 /* CrownInteractionSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CrownInteractionSpec.swift; sourceTree = ""; }; 144ED30221A98DFE0062DD74 /* CHANGELOG.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; name = CHANGELOG.md; path = ../CHANGELOG.md; sourceTree = ""; }; 14B7514821A2B3C400536272 /* SampleData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SampleData.swift; sourceTree = ""; }; 14B7514B21A2B69E00536272 /* UIStoryboard+Utils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIStoryboard+Utils.swift"; sourceTree = ""; }; @@ -113,7 +113,7 @@ 607FACDF1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 607FACE51AFB9204008FA782 /* CrownControlTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CrownControlTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 607FACEB1AFB9204008FA782 /* CrownAttributesTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CrownAttributesTests.swift; sourceTree = ""; }; + 607FACEB1AFB9204008FA782 /* CrownAttributesSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CrownAttributesSpec.swift; sourceTree = ""; }; 714E021AD8A830A0DD45B94E /* Pods-CrownControlTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CrownControlTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-CrownControlTests/Pods-CrownControlTests.debug.xcconfig"; sourceTree = ""; }; A35773A4EB53D93CB3CCD530 /* CrownControl.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = CrownControl.podspec; path = ../CrownControl.podspec; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; D73230BDE1CB6A516421FEF6 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; @@ -288,10 +288,10 @@ 607FACE81AFB9204008FA782 /* CrownControlTests */ = { isa = PBXGroup; children = ( - 607FACEB1AFB9204008FA782 /* CrownAttributesTests.swift */, - 14322ECA21AF29BC00EDF7D6 /* CrownViewControllerTests.swift */, 14096EB821B27F4B00464A24 /* CrownControlTests.swift */, - 14096EBC21B2B41600464A24 /* HapticFeedbackGenerationTests.swift */, + 607FACEB1AFB9204008FA782 /* CrownAttributesSpec.swift */, + 14322ECA21AF29BC00EDF7D6 /* CrownInteractionSpec.swift */, + 14096EBC21B2B41600464A24 /* HapticFeedbackGenerationSpec.swift */, 14096EBA21B282B800464A24 /* CrownControlTestAccessors.swift */, 607FACE91AFB9204008FA782 /* Supporting Files */, ); @@ -600,10 +600,10 @@ buildActionMask = 2147483647; files = ( 14096EB921B27F4B00464A24 /* CrownControlTests.swift in Sources */, - 14096EBD21B2B41600464A24 /* HapticFeedbackGenerationTests.swift in Sources */, - 14322ECB21AF29BC00EDF7D6 /* CrownViewControllerTests.swift in Sources */, + 14096EBD21B2B41600464A24 /* HapticFeedbackGenerationSpec.swift in Sources */, + 14322ECB21AF29BC00EDF7D6 /* CrownInteractionSpec.swift in Sources */, 14096EBB21B282B800464A24 /* CrownControlTestAccessors.swift in Sources */, - 607FACEC1AFB9204008FA782 /* CrownAttributesTests.swift in Sources */, + 607FACEC1AFB9204008FA782 /* CrownAttributesSpec.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Example/CrownControlTests/CrownAttributesTests.swift b/Example/CrownControlTests/CrownAttributesSpec.swift similarity index 83% rename from Example/CrownControlTests/CrownAttributesTests.swift rename to Example/CrownControlTests/CrownAttributesSpec.swift index 90c4e72..5d26c5b 100644 --- a/Example/CrownControlTests/CrownAttributesTests.swift +++ b/Example/CrownControlTests/CrownAttributesSpec.swift @@ -1,4 +1,10 @@ -// https://github.com/Quick/Quick +// +// CrownAttributesSpec.swift +// CrownControlTests +// +// Created by Daniel Huri on 11/28/18. +// Copyright © 2018 Daniel Huri. All rights reserved. +// import Quick import Nimble @@ -6,33 +12,32 @@ import Nimble class CrownAttributesSpec: QuickSpec { override func spec() { - describe("testing of crown attributes internal behavior") { + describe("tests of the crown attributes internal behavior") { var scrollView: UIScrollView! var attributes: CrownAttributes! beforeEach { - // INstantiate the scroll-view scrollView = UIScrollView(frame: UIScreen.main.bounds) attributes = CrownAttributes(scrollView: scrollView, scrollAxis: .vertical) } context("anchor position") { - it("right value is 0 in radians") { + it("has value of 0 in radians, when the position is *right*") { attributes.anchorPosition = .right expect(attributes.anchorPosition.radians).to(equal(0)) } - it("bottom value is pi/2 in radians") { + it("has value of pi/2 in radians, when the position is *bottom*") { attributes.anchorPosition = .bottom expect(attributes.anchorPosition.radians).to(equal(.pi / 2)) } - it("left value is .pi in radians") { + it("has value of pi in radians, when the position is *left*") { attributes.anchorPosition = .left expect(attributes.anchorPosition.radians).to(equal(.pi)) } - it("top value is .pi*1.5 in radians") { + it("has value of pi * 1.5 in radians, when the position is *top*") { attributes.anchorPosition = .top expect(attributes.anchorPosition.radians).to(equal(.pi * 1.5)) } @@ -51,7 +56,7 @@ class CrownAttributesSpec: QuickSpec { } context("scroll view") { - it("has a scroll view upon initialization") { + it("has a valid scroll view after initialization") { expect(attributes.scrollView).toNot(beNil()) } } @@ -88,17 +93,20 @@ class CrownAttributesSpec: QuickSpec { } context("user interaction") { - it("is interactable if needed") { - attributes.userInteraction.doubleTap = .scrollsToTrailingEdge(animated: false) - expect(attributes.userInteraction.doubleTap.isInteractable).to(beTrue()) - } - it("is not interactable if needed") { - attributes.userInteraction.doubleTap = .none - expect(attributes.userInteraction.doubleTap.isInteractable).to(beFalse()) + describe("double tap interaction") { + it("is interactable if needed") { + attributes.userInteraction.doubleTap = .scrollsToTrailingEdge(animated: false) + expect(attributes.userInteraction.doubleTap.isInteractable).to(beTrue()) + } + + it("is not interactable if needed") { + attributes.userInteraction.doubleTap = .none + expect(attributes.userInteraction.doubleTap.isInteractable).to(beFalse()) + } } - describe("long press") { + describe("long press interaction") { beforeEach { var longPressAttributes = CrownAttributes.UserInteraction.RepositionGesture.Attributes.LongPress() longPressAttributes.minimalDuration = 1 @@ -118,7 +126,7 @@ class CrownAttributesSpec: QuickSpec { } } - describe("force touch") { + describe("force touch interaction") { beforeEach { attributes.userInteraction.repositionGesture = .prefersForceTouch(attributes: .init()) } diff --git a/Example/CrownControlTests/CrownControlTests.swift b/Example/CrownControlTests/CrownControlTests.swift index 73166eb..5bee65d 100644 --- a/Example/CrownControlTests/CrownControlTests.swift +++ b/Example/CrownControlTests/CrownControlTests.swift @@ -1,5 +1,5 @@ // -// CrownControlTests.swift +// CrownControlSpec.swift // CrownControlTests // // Created by Daniel Huri on 12/1/18. @@ -10,7 +10,8 @@ import Quick import Nimble @testable import CrownControl -class CrownControlTests: QuickSpec, CrownControlDefaultSetup { +// Tests the public / open APIs +class CrownControlSpec: QuickSpec, CrownControlDefaultSetup { override func spec() { describe("test crown control external api") { diff --git a/Example/CrownControlTests/CrownViewControllerTests.swift b/Example/CrownControlTests/CrownInteractionSpec.swift similarity index 63% rename from Example/CrownControlTests/CrownViewControllerTests.swift rename to Example/CrownControlTests/CrownInteractionSpec.swift index e583a4d..97e7823 100644 --- a/Example/CrownControlTests/CrownViewControllerTests.swift +++ b/Example/CrownControlTests/CrownInteractionSpec.swift @@ -1,5 +1,5 @@ // -// CrownViewControllerTests.swift +// CrownInteractionSpec.swift // CrownControlTests // // Created by Daniel Huri on 11/28/18. @@ -10,18 +10,18 @@ import Quick import Nimble @testable import CrownControl -class CrownControlViewModelTests: QuickSpec, CrownControlDefaultSetup { +// Describes tests that are made through the crown controller +class CrownInteractionSpec: QuickSpec, CrownControlDefaultSetup { override func spec() { - describe("test crown control view model") { + describe("tests on the crown controller") { - var attributes: CrownAttributes! var scrollView: UIScrollView! var contentHeightRatio: CGFloat! - var crownViewController: CrownSurfaceView! - var viewModel: CrownSurfaceController! + var attributes: CrownAttributes! + var controller: CrownSurfaceController! - // Before each test case perform a whole app initialization + // Before each test case perform an app initialization beforeEach { let rootViewController = self.setupRootViewController() @@ -44,14 +44,14 @@ class CrownControlViewModelTests: QuickSpec, CrownControlDefaultSetup { // Cling the bottom of the crown to the bottom of its superview with -50 offset let horizontalConstraint = CrownAttributes.AxisConstraint(crownEdge: .trailing, anchorView: rootViewController.view, anchorViewEdge: .trailing, offset: -50) - viewModel = CrownSurfaceController(attributes: attributes) - crownViewController = viewModel.view - crownViewController.layout(in: rootViewController.view, horizontalConstaint: horizontalConstraint, verticalConstraint: verticalConstraint) + controller = CrownSurfaceController(attributes: attributes) + controller.view.layout(in: rootViewController.view, horizontalConstaint: horizontalConstraint, verticalConstraint: verticalConstraint) } describe("tests of how user interaction affects the scroll-view content-offset") { + it("scrolls to the trailing edge") { - viewModel.performTapActionIfNeeded(.scrollsToTrailingEdge(animated: false)) + controller.performTapActionIfNeeded(.scrollsToTrailingEdge(animated: false)) let maxOffsetY = scrollView.maxContentOffset(for: attributes.scrollAxis).y let maxExpectedOffsetY = scrollView.contentSize.height - scrollView.bounds.height expect(maxOffsetY).to(equal(maxExpectedOffsetY)) @@ -62,14 +62,14 @@ class CrownControlViewModelTests: QuickSpec, CrownControlDefaultSetup { scrollView.setContentOffset(CGPoint(x: 0, y: 100), animated: false) // Perform the action - scroll to leading edge so *contentOffset.y* would be 0 - viewModel.performTapActionIfNeeded(.scrollsToLeadingEdge(animated: false)) + controller.performTapActionIfNeeded(.scrollsToLeadingEdge(animated: false)) expect(scrollView.contentOffset.y).to(equal(0)) } it("scrolls a page forward") { let pageHeight = UIScreen.main.bounds.height - viewModel.performTapActionIfNeeded(.scrollsToTrailingPage(animated: false)) + controller.performTapActionIfNeeded(.scrollsToTrailingPage(animated: false)) expect(scrollView.contentOffset.y).to(equal(pageHeight)) } @@ -78,12 +78,12 @@ class CrownControlViewModelTests: QuickSpec, CrownControlDefaultSetup { let initialOffsetY = scrollView.maxContentOffset(for: attributes.scrollAxis).y let expectedOffsetAfterAssertion = initialOffsetY - pageHeight scrollView.setContentOffset(CGPoint(x: 0, y: initialOffsetY), animated: false) - viewModel.performTapActionIfNeeded(.scrollsToLeadingPage(animated: false)) + controller.performTapActionIfNeeded(.scrollsToLeadingPage(animated: false)) expect(scrollView.contentOffset.y).to(equal(expectedOffsetAfterAssertion)) } it("scrolls forward by a constant offset") { - viewModel.performTapActionIfNeeded(.scrollsForwardWithOffset(value: 10, animated: false)) + controller.performTapActionIfNeeded(.scrollsForwardWithOffset(value: 10, animated: false)) expect(scrollView.contentOffset.y).to(equal(10)) } @@ -91,7 +91,7 @@ class CrownControlViewModelTests: QuickSpec, CrownControlDefaultSetup { let initialOffsetY: CGFloat = 50 let subtractedOffsetY: CGFloat = 10 scrollView.setContentOffset(CGPoint(x: 0, y: initialOffsetY), animated: false) - viewModel.performTapActionIfNeeded(.scrollsBackwardWithOffset(value: subtractedOffsetY, animated: false)) + controller.performTapActionIfNeeded(.scrollsBackwardWithOffset(value: subtractedOffsetY, animated: false)) let expectedOffsetAfterSubtraction = initialOffsetY - subtractedOffsetY @@ -100,7 +100,7 @@ class CrownControlViewModelTests: QuickSpec, CrownControlDefaultSetup { it("performs a custom action") { var isActionPerformed = false - viewModel.performTapActionIfNeeded(.custom(action: { + controller.performTapActionIfNeeded(.custom(action: { isActionPerformed = true })) expect(isActionPerformed).to(equal(true)) @@ -108,82 +108,81 @@ class CrownControlViewModelTests: QuickSpec, CrownControlDefaultSetup { } describe("tests of the crown foreground ability to spin") { - it("is able to spin") { - expect(viewModel.isAbleToSpin).to(beTrue()) + expect(controller.isAbleToSpin).to(beTrue()) } } it("superview bounds equal to the root view controller's view bounds") { - expect(viewModel.superviewBounds).to(equal(crownViewController.superview!.bounds)) + expect(controller.superviewBounds).to(equal(controller.view.superview!.bounds)) } - describe("tests of the crown surface location change directly") { + describe("tests of the surface location change") { var superviewBounds: CGRect! var newCenter: CGPoint! beforeEach { - superviewBounds = viewModel.superviewBounds + superviewBounds = controller.superviewBounds newCenter = CGPoint(x: superviewBounds.midX, y: superviewBounds.midY) - viewModel.changeCrownLocation(to: newCenter) + controller.changeCrownLocation(to: newCenter) } it("changes location if the location is legit") { - expect(crownViewController.center).to(equal(newCenter)) + expect(controller.view.center).to(equal(newCenter)) } it("update its frame after location change") { - expect(crownViewController.frame).to(equal(viewModel.crownFrame)) + expect(controller.view.frame).to(equal(controller.crownFrame)) } it("is within superview horizontal bounds") { - let isCrownWithinHorizontalBounds = viewModel.isCrownWithinHorizontalBounds(after: 10, velocity: 1) + let isCrownWithinHorizontalBounds = controller.isCrownWithinHorizontalBounds(after: 10, velocity: 1) expect(isCrownWithinHorizontalBounds).to(beTrue()) } it("is isn't within superview horizontal bounds") { - let isCrownWithinHorizontalBounds = viewModel.isCrownWithinHorizontalBounds(after: UIScreen.main.bounds.width, velocity: 1) + let isCrownWithinHorizontalBounds = controller.isCrownWithinHorizontalBounds(after: UIScreen.main.bounds.width, velocity: 1) expect(isCrownWithinHorizontalBounds).to(beFalse()) } it("is within superview vertical bounds") { - let isCrownWithinHorizontalBounds = viewModel.isCrownWithinVerticalBounds(after: 10, velocity: 1) + let isCrownWithinHorizontalBounds = controller.isCrownWithinVerticalBounds(after: 10, velocity: 1) expect(isCrownWithinHorizontalBounds).to(beTrue()) } it("is isn't within superview vertical bounds") { - let isCrownWithinHorizontalBounds = viewModel.isCrownWithinVerticalBounds(after: UIScreen.main.bounds.height, velocity: 1) + let isCrownWithinHorizontalBounds = controller.isCrownWithinVerticalBounds(after: UIScreen.main.bounds.height, velocity: 1) expect(isCrownWithinHorizontalBounds).to(beFalse()) } } - describe("simulation of the crown surface location change using the long press view model logic") { - + describe("simulation of the surface location change using the long press controller logic") { it("changes pan subject when long press begins") { - viewModel.longPress(with: .began) - expect(viewModel.panSubject).to(equal(.crown)) + controller.longPress(with: .began) + expect(controller.panSubject).to(equal(.crown)) } it("changes pan subject when long press begins") { - viewModel.longPress(with: .began) - viewModel.longPress(with: .ended) - expect(viewModel.panSubject).to(equal(.indicator)) + controller.longPress(with: .began) + controller.longPress(with: .ended) + expect(controller.panSubject).to(equal(.indicator)) } it("changes crown surface center when long press *changed* state is received") { - let superviewBounds = viewModel.superviewBounds + let superviewBounds = controller.superviewBounds let newCenter = CGPoint(x: superviewBounds.midX, y: superviewBounds.midY) - viewModel.longPress(with: .changed, location: newCenter) - expect(crownViewController.center).to(equal(newCenter)) + controller.longPress(with: .changed, location: newCenter) + expect(controller.view.center).to(equal(newCenter)) } - } describe("simulation of force touch upon the crown surface") { + var maxForce: CGFloat! var inflationForce: CGFloat! var deflationForce: CGFloat! + beforeEach { maxForce = 10 deflationForce = 0 @@ -195,45 +194,45 @@ class CrownControlViewModelTests: QuickSpec, CrownControlDefaultSetup { } it("changes pan subject when force touch is applied") { - viewModel.force(force: inflationForce, max: maxForce, animateIfNeeded: false) - expect(viewModel.panSubject).to(equal(.crown)) + controller.force(force: inflationForce, max: maxForce, animateIfNeeded: false) + expect(controller.panSubject).to(equal(.crown)) } it("changes pan subject when force touch is removed") { - viewModel.force(force: inflationForce, max: maxForce, animateIfNeeded: false) - viewModel.force(force: deflationForce, max: maxForce, animateIfNeeded: false) - expect(viewModel.panSubject).to(equal(.indicator)) + controller.force(force: inflationForce, max: maxForce, animateIfNeeded: false) + controller.force(force: deflationForce, max: maxForce, animateIfNeeded: false) + expect(controller.panSubject).to(equal(.indicator)) } } - describe("simulation of the crown foreground location change using the pan view model logic") { + describe("simulation of the crown foreground location change using the controller logic") { var foregroundView: UIView! beforeEach { - foregroundView = crownViewController.indicatorView + foregroundView = controller.view.indicatorView } it("responds to pan in *began* state") { - let crownFrameBeforeAction = viewModel.crownFrame - viewModel.pan(foregroundView: foregroundView, with: .began) - expect(crownFrameBeforeAction).to(equal(viewModel.crownFrame)) + let crownFrameBeforeAction = controller.crownFrame + controller.pan(foregroundView: foregroundView, with: .began) + expect(crownFrameBeforeAction).to(equal(controller.crownFrame)) } it("responds to pan in *ended* state") { - let crownFrameBeforeAction = viewModel.crownFrame - viewModel.pan(foregroundView: foregroundView, with: .ended) - expect(crownFrameBeforeAction).to(equal(viewModel.crownFrame)) + let crownFrameBeforeAction = controller.crownFrame + controller.pan(foregroundView: foregroundView, with: .ended) + expect(crownFrameBeforeAction).to(equal(controller.crownFrame)) } it("responds to pan in *changed* state - pan left") { let translation = CGPoint(x: .min, y: 0) - viewModel.pan(foregroundView: foregroundView, with: .changed, translation: translation, enforceEdgeNormalization: false) - expect(viewModel.currentForegroundAngle).to(equal(.pi)) + controller.pan(foregroundView: foregroundView, with: .changed, translation: translation, enforceEdgeNormalization: false) + expect(controller.currentForegroundAngle).to(equal(.pi)) } it("responds to pan in *changed* state - pan downward") { let translation = CGPoint(x: 0, y: .max) - viewModel.pan(foregroundView: foregroundView, with: .changed, translation: translation, enforceEdgeNormalization: false) - expect(viewModel.currentForegroundAngle).to(equal(.pi * 0.5)) + controller.pan(foregroundView: foregroundView, with: .changed, translation: translation, enforceEdgeNormalization: false) + expect(controller.currentForegroundAngle).to(equal(.pi * 0.5)) } } } diff --git a/Example/CrownControlTests/HapticFeedbackGenerationTests.swift b/Example/CrownControlTests/HapticFeedbackGenerationSpec.swift similarity index 93% rename from Example/CrownControlTests/HapticFeedbackGenerationTests.swift rename to Example/CrownControlTests/HapticFeedbackGenerationSpec.swift index 7b06659..493831b 100644 --- a/Example/CrownControlTests/HapticFeedbackGenerationTests.swift +++ b/Example/CrownControlTests/HapticFeedbackGenerationSpec.swift @@ -1,5 +1,5 @@ // -// HapticFeedbackGenerationTests.swift +// HapticFeedbackGenerationSpec.swift // CrownControlTests // // Created by Daniel Huri on 12/1/18. @@ -10,7 +10,7 @@ import Quick import Nimble @testable import CrownControl -class HapticFeedbackGenerationTests: QuickSpec { +class HapticFeedbackGenerationSpec: QuickSpec { override func spec() { describe("simulation of haptic feedback test logic") { diff --git a/Example/Pods/Pods.xcodeproj/project.pbxproj b/Example/Pods/Pods.xcodeproj/project.pbxproj index fc310e3..20d53aa 100644 --- a/Example/Pods/Pods.xcodeproj/project.pbxproj +++ b/Example/Pods/Pods.xcodeproj/project.pbxproj @@ -284,7 +284,7 @@ 09EF44806EE1096553BE102278FD83B7 /* Pods-CrownControlTests.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = "Pods-CrownControlTests.modulemap"; sourceTree = ""; }; 0C1D53642F22E7FF636881863D716730 /* XCTestObservationCenter+CurrentTestCaseTracker.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "XCTestObservationCenter+CurrentTestCaseTracker.h"; sourceTree = ""; }; 0DC8A795DF9D647AD04E0E887F7A8F05 /* UIView+PositionUtils.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = "UIView+PositionUtils.swift"; sourceTree = ""; }; - 0E86D80A66726CB9145BB34D1F15B3DC /* Quick.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = Quick.framework; path = Quick.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 0E86D80A66726CB9145BB34D1F15B3DC /* Quick.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Quick.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 0E9FF43C4F486CDC950E8BA46396F5DB /* UIScrollView+Utils.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = "UIScrollView+Utils.swift"; sourceTree = ""; }; 0EE9005BD9BA6D082CA6B6A53CDE5C1C /* URL+FileName.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "URL+FileName.swift"; path = "Sources/Quick/URL+FileName.swift"; sourceTree = ""; }; 105DD163D606CFAFF6ED6E13B73C4F50 /* BeLessThanOrEqual.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = BeLessThanOrEqual.swift; path = Sources/Nimble/Matchers/BeLessThanOrEqual.swift; sourceTree = ""; }; @@ -307,7 +307,7 @@ 2260D22B7AA167A2196519DD4FA92BC9 /* UIView+QLContentWrap.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "UIView+QLContentWrap.swift"; path = "QuickLayout/UIView+QLContentWrap.swift"; sourceTree = ""; }; 22F1007B10366686910E6963BFAA50C1 /* Equal.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Equal.swift; path = Sources/Nimble/Matchers/Equal.swift; sourceTree = ""; }; 24C5120298E3D6F3855024475A465546 /* ExampleHooks.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ExampleHooks.swift; path = Sources/Quick/Hooks/ExampleHooks.swift; sourceTree = ""; }; - 26080F032C0183130F6D84BC17756AEA /* Nimble.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = Nimble.framework; path = Nimble.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 26080F032C0183130F6D84BC17756AEA /* Nimble.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Nimble.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 26431C992B75D2079A9ED198DD1A48F0 /* MatchError.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = MatchError.swift; path = Sources/Nimble/Matchers/MatchError.swift; sourceTree = ""; }; 26802A75E68B5AB0CF26A62F58FEEC87 /* Pods-CrownControlDemo-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-CrownControlDemo-frameworks.sh"; sourceTree = ""; }; 28FE75BB8C7BE0B41F328A491C1FE5F1 /* iOSSnapshotTestCase-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "iOSSnapshotTestCase-prefix.pch"; sourceTree = ""; }; @@ -327,7 +327,7 @@ 359A1CF1208955C45A80545CC0EC5F06 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 363B9BA05B7DA02C04DAF9D6D1170865 /* ExpectationMessage.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ExpectationMessage.swift; path = Sources/Nimble/ExpectationMessage.swift; sourceTree = ""; }; 364893FFEBE70AC02550977326336F05 /* HaveCount.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = HaveCount.swift; path = Sources/Nimble/Matchers/HaveCount.swift; sourceTree = ""; }; - 365C37B832E07E3E0FD7986D8EEB57FB /* Nimble_Snapshots.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = Nimble_Snapshots.framework; path = "Nimble-Snapshots.framework"; sourceTree = BUILT_PRODUCTS_DIR; }; + 365C37B832E07E3E0FD7986D8EEB57FB /* Nimble_Snapshots.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Nimble_Snapshots.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 377F282C9DA5332BF965FC38DC068DCE /* NSBundle+CurrentTestBundle.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "NSBundle+CurrentTestBundle.swift"; path = "Sources/Quick/NSBundle+CurrentTestBundle.swift"; sourceTree = ""; }; 385026C6EEEB034FB226E1A65C5D6CE0 /* CrownAttributes+Feedback.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = "CrownAttributes+Feedback.swift"; sourceTree = ""; }; 3B41581824F2881B00DAB1844D205EB3 /* CrownControl-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "CrownControl-prefix.pch"; sourceTree = ""; }; @@ -351,7 +351,7 @@ 5336989677D611345BE9E4EEDE60D455 /* CwlMachBadInstructionHandler.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = CwlMachBadInstructionHandler.h; path = Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/include/CwlMachBadInstructionHandler.h; sourceTree = ""; }; 53765E422EC578714796722C969568E7 /* ContainElementSatisfying.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ContainElementSatisfying.swift; path = Sources/Nimble/Matchers/ContainElementSatisfying.swift; sourceTree = ""; }; 55AB383A5BB1D5D924B5568A6D461E29 /* Nimble-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Nimble-umbrella.h"; sourceTree = ""; }; - 56F2CCDEE3665EFB9520AB9DB60B173E /* QuickLayout.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = QuickLayout.framework; path = QuickLayout.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 56F2CCDEE3665EFB9520AB9DB60B173E /* QuickLayout.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = QuickLayout.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 57EBCACF2EE6DF6D10809F24465A3D45 /* CrownAttributes.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = CrownAttributes.swift; sourceTree = ""; }; 58514DE1F7EFC7FD075B49F0E058C60D /* NimbleXCTestHandler.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = NimbleXCTestHandler.swift; path = Sources/Nimble/Adapters/NimbleXCTestHandler.swift; sourceTree = ""; }; 58FEE7FFC27CC38A9D99C60D3ACA4B50 /* BeAKindOf.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = BeAKindOf.swift; path = Sources/Nimble/Matchers/BeAKindOf.swift; sourceTree = ""; }; @@ -372,7 +372,7 @@ 69B388FC9BBC66A42E7B35AC16EA86B8 /* MatcherProtocols.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = MatcherProtocols.swift; path = Sources/Nimble/Matchers/MatcherProtocols.swift; sourceTree = ""; }; 6C22DBF7C72ACA217D0BE8E30EEC13E6 /* HaveValidDynamicTypeSnapshot.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = HaveValidDynamicTypeSnapshot.swift; path = DynamicType/HaveValidDynamicTypeSnapshot.swift; sourceTree = ""; }; 6C36F5A6F604C5D328D2358D4CB04B73 /* Errors.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Errors.swift; path = Sources/Nimble/Utils/Errors.swift; sourceTree = ""; }; - 6CA654DE268F7B2F35A4A8534EB06A57 /* Pods_CrownControlDemo.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = Pods_CrownControlDemo.framework; path = "Pods-CrownControlDemo.framework"; sourceTree = BUILT_PRODUCTS_DIR; }; + 6CA654DE268F7B2F35A4A8534EB06A57 /* Pods_CrownControlDemo.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_CrownControlDemo.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 6DC849CBA37A0590F72BC1F7027BA8E1 /* Pods-CrownControlTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-CrownControlTests.debug.xcconfig"; sourceTree = ""; }; 6EBE57346FCE6725EFEB559B3B551DE0 /* Functional.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Functional.swift; path = Sources/Nimble/Utils/Functional.swift; sourceTree = ""; }; 700630D246702A310563F88B0E7CD846 /* mach_excServer.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = mach_excServer.h; path = Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/mach_excServer.h; sourceTree = ""; }; @@ -401,7 +401,7 @@ 84601592B032A6FDA4D7D93302655FFF /* World+DSL.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "World+DSL.swift"; path = "Sources/Quick/DSL/World+DSL.swift"; sourceTree = ""; }; 8464991065606A241F6132F0A085D7AA /* Nimble.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Nimble.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 8552D1964D4B35B1EF10FBEFECEE2C22 /* CrownSurfaceController.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = CrownSurfaceController.swift; sourceTree = ""; }; - 8B93921B37BDBF57265B5B890479A541 /* CrownControl.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = CrownControl.framework; path = CrownControl.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 8B93921B37BDBF57265B5B890479A541 /* CrownControl.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CrownControl.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 8BFB5223A735E41FCAEDAEE07878227B /* BeEmpty.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = BeEmpty.swift; path = Sources/Nimble/Matchers/BeEmpty.swift; sourceTree = ""; }; 8C276D8BB42BDB5102C083EAAA27FBF3 /* Quick.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = Quick.h; path = Sources/QuickObjectiveC/Quick.h; sourceTree = ""; }; 8C7ED01723907E9A0FF3C0FDF88F4113 /* Nimble-Snapshots-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Nimble-Snapshots-prefix.pch"; sourceTree = ""; }; @@ -409,11 +409,11 @@ 8DBFC4BD51E5C25CAE58F334033FDC2B /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 90A7501D8876E93A879A93032B73A8A6 /* RaisesException.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = RaisesException.swift; path = Sources/Nimble/Matchers/RaisesException.swift; sourceTree = ""; }; 91C3B4AD1C859124F9F6B743B2D84F54 /* ExampleMetadata.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ExampleMetadata.swift; path = Sources/Quick/ExampleMetadata.swift; sourceTree = ""; }; - 93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; lastKnownFileType = text; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; + 93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; 93C54886A09E760B61D19B239F292F4E /* Nimble.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = Nimble.modulemap; sourceTree = ""; }; 93F4ABD34C216A39C6C9B0A4FFA9E4CC /* AllPass.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = AllPass.swift; path = Sources/Nimble/Matchers/AllPass.swift; sourceTree = ""; }; 94B0D82C857F6E29A490F413268BBB51 /* CrownIndicatorView.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = CrownIndicatorView.swift; sourceTree = ""; }; - 957A14B6A75F4F08E313D8C93F189397 /* CrownControl.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; lastKnownFileType = text; path = CrownControl.podspec; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; + 957A14B6A75F4F08E313D8C93F189397 /* CrownControl.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; path = CrownControl.podspec; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; 96C45026F8AEEB6A554C4685C265BCB4 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.3.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; 974EC0359700E3E41EE9029C961CC54C /* CrownAttributes+AxisConstraint.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = "CrownAttributes+AxisConstraint.swift"; sourceTree = ""; }; 98CD36596BED77F1393E2416F011CD9E /* Pods-CrownControlTests-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-CrownControlTests-acknowledgements.plist"; sourceTree = ""; }; @@ -443,18 +443,18 @@ AF7AC1BE521A6A98B069BB97EE994490 /* QCKDSL.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = QCKDSL.m; path = Sources/QuickObjectiveC/DSL/QCKDSL.m; sourceTree = ""; }; B0A762CBF270CBCD515A55A039D527E4 /* FBSnapshotTestCasePlatform.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = FBSnapshotTestCasePlatform.m; path = FBSnapshotTestCase/FBSnapshotTestCasePlatform.m; sourceTree = ""; }; B10822B83F4367000042CF1394E8F537 /* Nimble.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Nimble.xcconfig; sourceTree = ""; }; - B13E571CD10529994DAF27BE963B406C /* mach_excServer.c */ = {isa = PBXFileReference; includeInIndex = 1; name = mach_excServer.c; path = Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/mach_excServer.c; sourceTree = ""; }; + B13E571CD10529994DAF27BE963B406C /* mach_excServer.c */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.c; name = mach_excServer.c; path = Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/mach_excServer.c; sourceTree = ""; }; B21440A6B2863CEE2637DCC601CA80FE /* Quick-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Quick-prefix.pch"; sourceTree = ""; }; B21635DB4CF234959356CEC1E28DD10F /* iOSSnapshotTestCase.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = iOSSnapshotTestCase.xcconfig; sourceTree = ""; }; B2D4BB795677098E588EF542CC7C0F0A /* CrownAttributes+AnchorPosition.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = "CrownAttributes+AnchorPosition.swift"; sourceTree = ""; }; B513159D609AA2C7AB431A38B68D8407 /* QuickLayout.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = QuickLayout.xcconfig; sourceTree = ""; }; - B6095AC96223FBE5F2EC8ABF2E91925B /* FBSnapshotTestCase.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = FBSnapshotTestCase.framework; path = iOSSnapshotTestCase.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + B6095AC96223FBE5F2EC8ABF2E91925B /* FBSnapshotTestCase.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = FBSnapshotTestCase.framework; sourceTree = BUILT_PRODUCTS_DIR; }; B7AC73249BCABA0B4667C25767BDFB4A /* CrownControl.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = CrownControl.xcconfig; sourceTree = ""; }; BAE9C258B5F9BBA625E3F0D92842E7D8 /* NBSMockedApplication.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = NBSMockedApplication.m; path = DynamicType/NBSMockedApplication.m; sourceTree = ""; }; BE42D4E0722742997963EFD95E43AFE8 /* AssertionRecorder.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = AssertionRecorder.swift; path = Sources/Nimble/Adapters/AssertionRecorder.swift; sourceTree = ""; }; BE5560A1F80F42CE8B37A7B9B5FA04AB /* FBSnapshotTestCase.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = FBSnapshotTestCase.framework; sourceTree = BUILT_PRODUCTS_DIR; }; BEEC99941B18D62F5124BC2E5A9903F0 /* BackgroundView.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = BackgroundView.swift; sourceTree = ""; }; - BF26BF92988204EBF7F2CFDC7AD36562 /* Pods_CrownControlTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = Pods_CrownControlTests.framework; path = "Pods-CrownControlTests.framework"; sourceTree = BUILT_PRODUCTS_DIR; }; + BF26BF92988204EBF7F2CFDC7AD36562 /* Pods_CrownControlTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_CrownControlTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; BF2CD0E13044E16C9B1E3A57FCA7E78F /* Expression.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Expression.swift; path = Sources/Nimble/Expression.swift; sourceTree = ""; }; C5F39FE8AE5655239A092039D0250557 /* Pods-CrownControlDemo-resources.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-CrownControlDemo-resources.sh"; sourceTree = ""; }; C708AE89E96BA3DC2F38BEDEC76FCDB4 /* Nimble-Snapshots.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = "Nimble-Snapshots.modulemap"; sourceTree = ""; }; @@ -470,7 +470,7 @@ DAC18EF19CB066BCB862CFDFCDEB07CE /* FBSnapshotTestCase.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = FBSnapshotTestCase.m; path = FBSnapshotTestCase/FBSnapshotTestCase.m; sourceTree = ""; }; DC3051E8772978B83FCBDDAD63D8A532 /* FBSnapshotTestCase.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = FBSnapshotTestCase.h; path = FBSnapshotTestCase/FBSnapshotTestCase.h; sourceTree = ""; }; DD8CB3483A1840AC1DE9FB350012DF5E /* NMBObjCMatcher.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = NMBObjCMatcher.swift; path = Sources/Nimble/Adapters/NMBObjCMatcher.swift; sourceTree = ""; }; - DD8DFAAAAEEAA854E4EFC994832E8F0A /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; path = LICENSE; sourceTree = ""; }; + DD8DFAAAAEEAA854E4EFC994832E8F0A /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = LICENSE; sourceTree = ""; }; DE01505D07C0E0BB87AE06F17A27F813 /* QuickSpecBase.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = QuickSpecBase.m; path = Sources/QuickSpecBase/QuickSpecBase.m; sourceTree = ""; }; DE858AF651D8CAD0867E8E51D3877D29 /* Example.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Example.swift; path = Sources/Quick/Example.swift; sourceTree = ""; }; DF0FCEBF336F5D54514FEBAD59D35D67 /* QLUtils.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = QLUtils.swift; path = QuickLayout/QLUtils.swift; sourceTree = ""; }; @@ -489,7 +489,7 @@ EB61B7C5871B534EEF6A01404D1B0710 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.3.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; EB6D3D547A6FAA7D28C5AA21664C2AA6 /* QuickConfiguration.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = QuickConfiguration.m; path = Sources/QuickObjectiveC/Configuration/QuickConfiguration.m; sourceTree = ""; }; EBA75B14A539F33092EF93CF03E51D31 /* Contain.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Contain.swift; path = Sources/Nimble/Matchers/Contain.swift; sourceTree = ""; }; - F1D7857EC0ED888612B5DC32044DF5A4 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; path = README.md; sourceTree = ""; }; + F1D7857EC0ED888612B5DC32044DF5A4 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; F387CFA505390EA2AE8DE38DDDDE9121 /* CwlPreconditionTesting.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = CwlPreconditionTesting.h; path = Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/Mach/CwlPreconditionTesting.h; sourceTree = ""; }; F473B6499F274F58A30E6A1771DC95EE /* HaveValidSnapshot.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = HaveValidSnapshot.swift; sourceTree = ""; }; F5A6C60F1401637B513ECA40790B8EFF /* PostNotification.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = PostNotification.swift; path = Sources/Nimble/Matchers/PostNotification.swift; sourceTree = ""; }; @@ -639,7 +639,6 @@ 44CCA7F0E21BBA9A8B5D3425D22C806D /* Support Files */, 4C298702A0514F023761189EA31958A4 /* SwiftSupport */, ); - name = iOSSnapshotTestCase; path = iOSSnapshotTestCase; sourceTree = ""; }; @@ -735,7 +734,6 @@ 33AFD62D50DAB2EC9C991FA177B3C1EB /* XCTestObservationCenter+Register.m */, C33A69A7FF0CD126B394E16483CC262F /* Support Files */, ); - name = Nimble; path = Nimble; sourceTree = ""; }; @@ -868,7 +866,6 @@ 67EA47B738E5C9A26CFABA8639890F6D /* UIViewArray+QuickLayout.swift */, DA16E8DCBA3A3C21FDB73A6F588AD12B /* Support Files */, ); - name = QuickLayout; path = QuickLayout; sourceTree = ""; }; @@ -921,7 +918,6 @@ 4B692B283C33F40899C772135A81C1CC /* XCTestSuite+QuickTestSuiteBuilder.m */, 7B35DAB8CFEF6469596DD6F5B060DBE5 /* Support Files */, ); - name = Quick; path = Quick; sourceTree = ""; }; @@ -958,7 +954,6 @@ 0E9FF43C4F486CDC950E8BA46396F5DB /* UIScrollView+Utils.swift */, 0DC8A795DF9D647AD04E0E887F7A8F05 /* UIView+PositionUtils.swift */, ); - name = Extensions; path = Extensions; sourceTree = ""; }; @@ -990,7 +985,6 @@ 0ED3AEDE42E39FED8AB883FE5D12E0CE /* Core */, 2A948D67E53F38F24F8DD19FA3AE9CB9 /* Support Files */, ); - name = "Nimble-Snapshots"; path = "Nimble-Snapshots"; sourceTree = ""; }; @@ -1309,6 +1303,11 @@ attributes = { LastSwiftUpdateCheck = 0930; LastUpgradeCheck = 0930; + TargetAttributes = { + CCB670195D5BD218E1661BC4890D70E2 = { + LastSwiftMigration = 1010; + }; + }; }; buildConfigurationList = 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */; compatibilityVersion = "Xcode 3.2"; @@ -1684,8 +1683,7 @@ SDKROOT = iphoneos; SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; @@ -1750,8 +1748,7 @@ SDKROOT = iphoneos; SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; @@ -1787,8 +1784,7 @@ PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SDKROOT = iphoneos; SKIP_INSTALL = YES; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -2015,8 +2011,7 @@ SDKROOT = iphoneos; SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; @@ -2172,8 +2167,7 @@ SDKROOT = iphoneos; SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; @@ -2206,8 +2200,7 @@ SDKROOT = iphoneos; SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; @@ -2240,8 +2233,7 @@ SDKROOT = iphoneos; SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; @@ -2277,8 +2269,7 @@ PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SDKROOT = iphoneos; SKIP_INSTALL = YES; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; diff --git a/README.md b/README.md index 089b475..cc6daea 100644 --- a/README.md +++ b/README.md @@ -96,29 +96,29 @@ In your view controller: ```Swift -var crownViewController: CrownIndicatorViewController! +var crownControl: CrownControl! var scrollView: UIScrollView! private func setupCrownViewController() { - var attributes = CrownAttributes(scrollView: scrollView, scrollAxis: .vertical) - crownViewController = CrownIndicatorViewController(with: attributes) + let attributes = CrownAttributes(scrollView: scrollView, scrollAxis: .vertical) // Cling the bottom of the crown to the bottom of a view with -50 offset let verticalConstraint = CrownAttributes.AxisConstraint(crownEdge: .bottom, anchorView: view, anchorViewEdge: .bottom, offset: -50) // Cling the trailing edge of the crown to the trailing edge of a view with -50 offset let horizontalConstraint = CrownAttributes.AxisConstraint(crownEdge: .trailing, anchorView: tableView, anchorViewEdge: .trailing, offset: -50) - - crownViewController.layout(in: self, horizontalConstaint: horizontalConstraint, verticalConstraint: verticalConstraint) + + // Setup the crown control within *self* + crownControl = CrownControl(attributes: attributes, delegate: self) + crownControl.layout(in: view, horizontalConstaint: horizontalConstraint, verticalConstraint: verticalConstraint) } ``` -To make the crown respond to scrolling events that emanates from any other invoker but the crown, add to `scrollViewDidScroll(_:)` the following (depending on the scroll axis, replace `y` with `x`, and `height` with `width`): +To make the crown respond to scrolling events that emanates from any other invoker but the crown, add to `scrollViewDidScroll(_:)` the following: ```Swift func scrollViewDidScroll(_ scrollView: UIScrollView) { - let xOffset = collectionView.contentOffset.y / (collectionView.contentSize.height - collectionView.bounds.height) - crownViewController?.spin(to: xOffset) + crownControl?.spinToMatchScrollViewOffset() } ```