From 96c5dc7b749d4329f9e9531ea3bfe8d13ae620e1 Mon Sep 17 00:00:00 2001 From: Shin Yamamoto Date: Wed, 3 Jul 2019 11:06:08 +0900 Subject: [PATCH 1/7] Add FloatingPanelLayoutTests --- Framework/Sources/FloatingPanelController.swift | 2 +- Framework/Tests/FloatingPanelTests.swift | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Framework/Sources/FloatingPanelController.swift b/Framework/Sources/FloatingPanelController.swift index 5154cbb..139503f 100644 --- a/Framework/Sources/FloatingPanelController.swift +++ b/Framework/Sources/FloatingPanelController.swift @@ -145,7 +145,7 @@ open class FloatingPanelController: UIViewController, UIScrollViewDelegate, UIGe } private var _contentViewController: UIViewController? - private var floatingPanel: FloatingPanel! + private(set) var floatingPanel: FloatingPanel! private var preSafeAreaInsets: UIEdgeInsets = .zero // Capture the latest one private var safeAreaInsetsObservation: NSKeyValueObservation? private let modalTransition = FloatingPanelModalTransition() diff --git a/Framework/Tests/FloatingPanelTests.swift b/Framework/Tests/FloatingPanelTests.swift index e9530b6..fcf5178 100644 --- a/Framework/Tests/FloatingPanelTests.swift +++ b/Framework/Tests/FloatingPanelTests.swift @@ -63,3 +63,16 @@ class FloatingPanelTests: XCTestCase { XCTAssertEqual(contentVC2.tableView.bounces, false) } } + +class FloatingPanelLayoutTests: XCTestCase { + override func setUp() {} + + override func tearDown() {} + + func test_mostStates() { + let fpc = FloatingPanelController(delegate: nil) + fpc.loadViewIfNeeded() + fpc.view.frame = CGRect(x: 0, y: 0, width: 375, height: 667) + XCTAssertEqual(fpc.floatingPanel.layoutAdapter.topMostState, .full) + } +} From f6da876fdffe912de6d7b1920175e6199fdd4620 Mon Sep 17 00:00:00 2001 From: Shin Yamamoto Date: Wed, 3 Jul 2019 11:14:13 +0900 Subject: [PATCH 2/7] Add botomMostState prop --- .../Sources/FloatingPanelController.swift | 4 +++ Framework/Sources/FloatingPanelLayout.swift | 12 +++---- Framework/Tests/FloatingPanelTests.swift | 34 +++++++++++++++++++ 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/Framework/Sources/FloatingPanelController.swift b/Framework/Sources/FloatingPanelController.swift index 139503f..9c2ba07 100644 --- a/Framework/Sources/FloatingPanelController.swift +++ b/Framework/Sources/FloatingPanelController.swift @@ -68,6 +68,10 @@ public enum FloatingPanelPosition: Int { case half case tip case hidden + + static var allCases: [FloatingPanelPosition] { + return [.full, .half, .tip, .hidden] + } } /// diff --git a/Framework/Sources/FloatingPanelLayout.swift b/Framework/Sources/FloatingPanelLayout.swift index 4fa6fd2..c0b0755 100644 --- a/Framework/Sources/FloatingPanelLayout.swift +++ b/Framework/Sources/FloatingPanelLayout.swift @@ -181,13 +181,11 @@ class FloatingPanelLayoutAdapter { } var topMostState: FloatingPanelPosition { - if supportedPositions.contains(.full) { - return .full - } - if supportedPositions.contains(.half) { - return .half - } - return .tip + return supportedPositions.sorted(by: { $0.rawValue < $1.rawValue }).first ?? .hidden + } + + var bottomMostState: FloatingPanelPosition { + return supportedPositions.sorted(by: { $0.rawValue < $1.rawValue }).last ?? .hidden } var topY: CGFloat { diff --git a/Framework/Tests/FloatingPanelTests.swift b/Framework/Tests/FloatingPanelTests.swift index fcf5178..9cd7be3 100644 --- a/Framework/Tests/FloatingPanelTests.swift +++ b/Framework/Tests/FloatingPanelTests.swift @@ -62,6 +62,34 @@ class FloatingPanelTests: XCTestCase { XCTAssertEqual(contentVC2.tableView.showsVerticalScrollIndicator, false) XCTAssertEqual(contentVC2.tableView.bounces, false) } + +} + +class FloatingPanelTestDelegate: FloatingPanelControllerDelegate { + func floatingPanel(_ vc: FloatingPanelController, layoutFor newCollection: UITraitCollection) -> FloatingPanelLayout? { + return FloatingPanel2PositionsLayout() + } + func floatingPanel(_ vc: FloatingPanelController, behaviorFor newCollection: UITraitCollection) -> FloatingPanelBehavior? { + return nil + } +} + +class FloatingPanel2PositionsLayout: FloatingPanelLayout { + func insetFor(position: FloatingPanelPosition) -> CGFloat? { + switch position { + case .full: return 44.0 + case .half: return 216.0 + default: return nil + } + } + + var initialPosition: FloatingPanelPosition { + return .hidden + } + + var supportedPositions: Set { + return [.hidden, .half, .full] + } } class FloatingPanelLayoutTests: XCTestCase { @@ -74,5 +102,11 @@ class FloatingPanelLayoutTests: XCTestCase { fpc.loadViewIfNeeded() fpc.view.frame = CGRect(x: 0, y: 0, width: 375, height: 667) XCTAssertEqual(fpc.floatingPanel.layoutAdapter.topMostState, .full) + XCTAssertEqual(fpc.floatingPanel.layoutAdapter.bottomMostState, .tip) + + let delegate = FloatingPanelTestDelegate() + fpc.delegate = delegate + XCTAssertEqual(fpc.floatingPanel.layoutAdapter.topMostState, .full) + XCTAssertEqual(fpc.floatingPanel.layoutAdapter.bottomMostState, .hidden) } } From 33f8cf380216da2e672b24695aea5b130e5f3e9a Mon Sep 17 00:00:00 2001 From: Shin Yamamoto Date: Mon, 24 Jun 2019 19:23:02 +0900 Subject: [PATCH 3/7] Modify FloatingPanel.distance(to:) --- Framework/Sources/FloatingPanel.swift | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/Framework/Sources/FloatingPanel.swift b/Framework/Sources/FloatingPanel.swift index 53b005d..d675867 100644 --- a/Framework/Sources/FloatingPanel.swift +++ b/Framework/Sources/FloatingPanel.swift @@ -662,21 +662,9 @@ class FloatingPanel: NSObject, UIGestureRecognizerDelegate { } private func distance(to targetPosition: FloatingPanelPosition) -> CGFloat { - let topY = layoutAdapter.topY - let middleY = layoutAdapter.middleY - let bottomY = layoutAdapter.bottomY let currentY = surfaceView.frame.minY - - switch targetPosition { - case .full: - return CGFloat(abs(currentY - topY)) - case .half: - return CGFloat(abs(currentY - middleY)) - case .tip: - return CGFloat(abs(currentY - bottomY)) - case .hidden: - fatalError("Now .hidden must not be used for a user interaction") - } + let targetY = layoutAdapter.positionY(for: targetPosition) + return CGFloat(abs(currentY - targetY)) } private func directionalPosition(at currentY: CGFloat, with translation: CGPoint) -> FloatingPanelPosition { From 36d7ea5100683b69e4543758fdca809bc585883e Mon Sep 17 00:00:00 2001 From: Shin Yamamoto Date: Thu, 27 Jun 2019 15:55:48 +0900 Subject: [PATCH 4/7] Improve testing speed --- .../xcshareddata/xcschemes/FloatingPanel.xcscheme | 4 +++- Framework/Tests/FloatingPanelControllerTests.swift | 6 +----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Framework/FloatingPanel.xcodeproj/xcshareddata/xcschemes/FloatingPanel.xcscheme b/Framework/FloatingPanel.xcodeproj/xcshareddata/xcschemes/FloatingPanel.xcscheme index fbc7569..0270258 100644 --- a/Framework/FloatingPanel.xcodeproj/xcshareddata/xcschemes/FloatingPanel.xcscheme +++ b/Framework/FloatingPanel.xcodeproj/xcshareddata/xcschemes/FloatingPanel.xcscheme @@ -29,7 +29,9 @@ shouldUseLaunchSchemeArgsEnv = "YES"> + skipped = "NO" + parallelizable = "YES" + testExecutionOrdering = "random"> Date: Wed, 3 Jul 2019 11:21:19 +0900 Subject: [PATCH 5/7] Add FloatingPanelLayoutTests & Utils --- .../FloatingPanel.xcodeproj/project.pbxproj | 8 ++++ .../Tests/FloatingPanelControllerTests.swift | 6 +-- .../Tests/FloatingPanelLayoutTests.swift | 41 +++++++++++++++++ Framework/Tests/FloatingPanelTests.swift | 44 +++---------------- Framework/Tests/Utils.swift | 18 ++++++++ 5 files changed, 73 insertions(+), 44 deletions(-) create mode 100644 Framework/Tests/FloatingPanelLayoutTests.swift create mode 100644 Framework/Tests/Utils.swift diff --git a/Framework/FloatingPanel.xcodeproj/project.pbxproj b/Framework/FloatingPanel.xcodeproj/project.pbxproj index 10e685e..45a5ea3 100644 --- a/Framework/FloatingPanel.xcodeproj/project.pbxproj +++ b/Framework/FloatingPanel.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 542753C622C49A6E00D17955 /* FloatingPanelLayoutTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 542753C522C49A6E00D17955 /* FloatingPanelLayoutTests.swift */; }; + 542753C822C49A8F00D17955 /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 542753C722C49A8F00D17955 /* Utils.swift */; }; 54352E9621A51A2500CBCA08 /* FloatingPanelTransitioning.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54352E9521A51A2500CBCA08 /* FloatingPanelTransitioning.swift */; }; 54352E9821A521CA00CBCA08 /* FloatingPanelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54352E9721A521CA00CBCA08 /* FloatingPanelView.swift */; }; 5450EEE421646DF500135936 /* FloatingPanelBehavior.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5450EEE321646DF500135936 /* FloatingPanelBehavior.swift */; }; @@ -45,6 +47,8 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 542753C522C49A6E00D17955 /* FloatingPanelLayoutTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FloatingPanelLayoutTests.swift; sourceTree = ""; }; + 542753C722C49A8F00D17955 /* Utils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utils.swift; sourceTree = ""; }; 54352E9521A51A2500CBCA08 /* FloatingPanelTransitioning.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FloatingPanelTransitioning.swift; sourceTree = ""; }; 54352E9721A521CA00CBCA08 /* FloatingPanelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FloatingPanelView.swift; sourceTree = ""; }; 5450EEE321646DF500135936 /* FloatingPanelBehavior.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FloatingPanelBehavior.swift; sourceTree = ""; }; @@ -140,8 +144,10 @@ isa = PBXGroup; children = ( 54A6B6B022968B530077F348 /* FloatingPanelTests.swift */, + 542753C522C49A6E00D17955 /* FloatingPanelLayoutTests.swift */, 54A6B6B72296A8520077F348 /* FloatingPanelViewTests.swift */, 545DB9CF2151169500CA77B8 /* FloatingPanelControllerTests.swift */, + 542753C722C49A8F00D17955 /* Utils.swift */, 545DB9D12151169500CA77B8 /* Info.plist */, ); path = Tests; @@ -309,6 +315,7 @@ 545DBA2B2152383100CA77B8 /* GrabberHandleView.swift in Sources */, 54352E9621A51A2500CBCA08 /* FloatingPanelTransitioning.swift in Sources */, 545DB9DE215118C800CA77B8 /* UIExtensions.swift in Sources */, + 542753C822C49A8F00D17955 /* Utils.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -318,6 +325,7 @@ files = ( 54A6B6B122968B530077F348 /* FloatingPanelTests.swift in Sources */, 545DB9D02151169500CA77B8 /* FloatingPanelControllerTests.swift in Sources */, + 542753C622C49A6E00D17955 /* FloatingPanelLayoutTests.swift in Sources */, 54A6B6B82296A8520077F348 /* FloatingPanelViewTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Framework/Tests/FloatingPanelControllerTests.swift b/Framework/Tests/FloatingPanelControllerTests.swift index 210c4ad..4e4b665 100644 --- a/Framework/Tests/FloatingPanelControllerTests.swift +++ b/Framework/Tests/FloatingPanelControllerTests.swift @@ -54,11 +54,7 @@ class FloatingPanelControllerTests: XCTestCase { } } -func waitRunLoop(secs: TimeInterval = 0) { - RunLoop.main.run(until: Date(timeIntervalSinceNow: secs)) -} - -class MyZombieViewController: UIViewController, FloatingPanelLayout, FloatingPanelBehavior, FloatingPanelControllerDelegate { +private class MyZombieViewController: UIViewController, FloatingPanelLayout, FloatingPanelBehavior, FloatingPanelControllerDelegate { var fpc: FloatingPanelController? override func viewDidLoad() { fpc = FloatingPanelController(delegate: self) diff --git a/Framework/Tests/FloatingPanelLayoutTests.swift b/Framework/Tests/FloatingPanelLayoutTests.swift new file mode 100644 index 0000000..a5985e9 --- /dev/null +++ b/Framework/Tests/FloatingPanelLayoutTests.swift @@ -0,0 +1,41 @@ +// +// Created by Shin Yamamoto on 2019/06/27. +// Copyright © 2019 scenee. All rights reserved. +// + +import XCTest +@testable import FloatingPanel + +class FloatingPanelLayoutTests: XCTestCase { + override func setUp() {} + override func tearDown() {} + + func test_layoutAdapter_topAndBottomMostState() { + let fpc = FloatingPanelController(delegate: nil) + fpc.loadViewIfNeeded() + fpc.view.frame = CGRect(x: 0, y: 0, width: 375, height: 667) + XCTAssertEqual(fpc.floatingPanel.layoutAdapter.topMostState, .full) + XCTAssertEqual(fpc.floatingPanel.layoutAdapter.bottomMostState, .tip) + + class FloatingPanelLayoutWithHidden: FloatingPanelLayout { + func insetFor(position: FloatingPanelPosition) -> CGFloat? { return nil } + let initialPosition: FloatingPanelPosition = .hidden + let supportedPositions: Set = [.hidden, .half, .full] + } + class FloatingPanelLayout2Positions: FloatingPanelLayout { + func insetFor(position: FloatingPanelPosition) -> CGFloat? { return nil } + let initialPosition: FloatingPanelPosition = .tip + let supportedPositions: Set = [.tip, .half] + } + let delegate = FloatingPanelTestDelegate() + delegate.layout = FloatingPanelLayoutWithHidden() + fpc.delegate = delegate + XCTAssertEqual(fpc.floatingPanel.layoutAdapter.topMostState, .full) + XCTAssertEqual(fpc.floatingPanel.layoutAdapter.bottomMostState, .half) // Will fixed on fix-hidden-position branch + + delegate.layout = FloatingPanelLayout2Positions() + fpc.delegate = delegate + XCTAssertEqual(fpc.floatingPanel.layoutAdapter.topMostState, .half) + XCTAssertEqual(fpc.floatingPanel.layoutAdapter.bottomMostState, .tip) + } +} diff --git a/Framework/Tests/FloatingPanelTests.swift b/Framework/Tests/FloatingPanelTests.swift index 9cd7be3..992127e 100644 --- a/Framework/Tests/FloatingPanelTests.swift +++ b/Framework/Tests/FloatingPanelTests.swift @@ -65,48 +65,14 @@ class FloatingPanelTests: XCTestCase { } -class FloatingPanelTestDelegate: FloatingPanelControllerDelegate { - func floatingPanel(_ vc: FloatingPanelController, layoutFor newCollection: UITraitCollection) -> FloatingPanelLayout? { - return FloatingPanel2PositionsLayout() - } - func floatingPanel(_ vc: FloatingPanelController, behaviorFor newCollection: UITraitCollection) -> FloatingPanelBehavior? { - return nil - } -} - -class FloatingPanel2PositionsLayout: FloatingPanelLayout { +private protocol FloatingPanelTestLayout: FloatingPanelLayout {} +private extension FloatingPanelTestLayout { func insetFor(position: FloatingPanelPosition) -> CGFloat? { switch position { - case .full: return 44.0 - case .half: return 216.0 + case .full: return 18.0 + case .half: return 262.0 + case .tip: return 69.0 default: return nil } } - - var initialPosition: FloatingPanelPosition { - return .hidden - } - - var supportedPositions: Set { - return [.hidden, .half, .full] - } -} - -class FloatingPanelLayoutTests: XCTestCase { - override func setUp() {} - - override func tearDown() {} - - func test_mostStates() { - let fpc = FloatingPanelController(delegate: nil) - fpc.loadViewIfNeeded() - fpc.view.frame = CGRect(x: 0, y: 0, width: 375, height: 667) - XCTAssertEqual(fpc.floatingPanel.layoutAdapter.topMostState, .full) - XCTAssertEqual(fpc.floatingPanel.layoutAdapter.bottomMostState, .tip) - - let delegate = FloatingPanelTestDelegate() - fpc.delegate = delegate - XCTAssertEqual(fpc.floatingPanel.layoutAdapter.topMostState, .full) - XCTAssertEqual(fpc.floatingPanel.layoutAdapter.bottomMostState, .hidden) - } } diff --git a/Framework/Tests/Utils.swift b/Framework/Tests/Utils.swift new file mode 100644 index 0000000..4485aed --- /dev/null +++ b/Framework/Tests/Utils.swift @@ -0,0 +1,18 @@ +// +// Created by Shin Yamamoto on 2019/06/27. +// Copyright © 2019 scenee. All rights reserved. +// + +import Foundation +@testable import FloatingPanel + +func waitRunLoop(secs: TimeInterval = 0) { + RunLoop.main.run(until: Date(timeIntervalSinceNow: secs)) +} + +class FloatingPanelTestDelegate: FloatingPanelControllerDelegate { + var layout: FloatingPanelLayout? + func floatingPanel(_ vc: FloatingPanelController, layoutFor newCollection: UITraitCollection) -> FloatingPanelLayout? { + return layout + } +} From de7ab0e0cb8f2827f8dc6e59349f19ec84a7b300 Mon Sep 17 00:00:00 2001 From: Shin Yamamoto Date: Fri, 28 Jun 2019 17:00:28 +0900 Subject: [PATCH 6/7] Rename FloatingPanelViewTests to FloatingPanelSurfaceViewTests --- Framework/FloatingPanel.xcodeproj/project.pbxproj | 8 ++++---- ...iewTests.swift => FloatingPanelSurfaceViewTests.swift} | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) rename Framework/Tests/{FloatingPanelViewTests.swift => FloatingPanelSurfaceViewTests.swift} (98%) diff --git a/Framework/FloatingPanel.xcodeproj/project.pbxproj b/Framework/FloatingPanel.xcodeproj/project.pbxproj index 45a5ea3..2521373 100644 --- a/Framework/FloatingPanel.xcodeproj/project.pbxproj +++ b/Framework/FloatingPanel.xcodeproj/project.pbxproj @@ -20,7 +20,7 @@ 545DBA2B2152383100CA77B8 /* GrabberHandleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 545DBA2A2152383100CA77B8 /* GrabberHandleView.swift */; }; 54A6B6B122968B530077F348 /* FloatingPanelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54A6B6B022968B530077F348 /* FloatingPanelTests.swift */; }; 54A6B6B622968F710077F348 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 54A6B6B522968F710077F348 /* LaunchScreen.storyboard */; }; - 54A6B6B82296A8520077F348 /* FloatingPanelViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54A6B6B72296A8520077F348 /* FloatingPanelViewTests.swift */; }; + 54A6B6B82296A8520077F348 /* FloatingPanelSurfaceViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54A6B6B72296A8520077F348 /* FloatingPanelSurfaceViewTests.swift */; }; 54ABD7AF216CCFF7002E6C13 /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54ABD7AE216CCFF7002E6C13 /* Logger.swift */; }; 54CDC5D3215B6D5A007D205C /* FloatingPanelSurfaceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54CDC5D2215B6D5A007D205C /* FloatingPanelSurfaceView.swift */; }; 54CDC5D5215B6D8D007D205C /* FloatingPanelBackdropView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54CDC5D4215B6D8D007D205C /* FloatingPanelBackdropView.swift */; }; @@ -63,7 +63,7 @@ 545DBA2A2152383100CA77B8 /* GrabberHandleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GrabberHandleView.swift; sourceTree = ""; }; 54A6B6B022968B530077F348 /* FloatingPanelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FloatingPanelTests.swift; sourceTree = ""; }; 54A6B6B522968F710077F348 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = ""; }; - 54A6B6B72296A8520077F348 /* FloatingPanelViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FloatingPanelViewTests.swift; sourceTree = ""; }; + 54A6B6B72296A8520077F348 /* FloatingPanelSurfaceViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FloatingPanelSurfaceViewTests.swift; sourceTree = ""; }; 54ABD7AE216CCFF7002E6C13 /* Logger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Logger.swift; sourceTree = ""; }; 54CDC5D2215B6D5A007D205C /* FloatingPanelSurfaceView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FloatingPanelSurfaceView.swift; sourceTree = ""; }; 54CDC5D4215B6D8D007D205C /* FloatingPanelBackdropView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FloatingPanelBackdropView.swift; sourceTree = ""; }; @@ -145,7 +145,7 @@ children = ( 54A6B6B022968B530077F348 /* FloatingPanelTests.swift */, 542753C522C49A6E00D17955 /* FloatingPanelLayoutTests.swift */, - 54A6B6B72296A8520077F348 /* FloatingPanelViewTests.swift */, + 54A6B6B72296A8520077F348 /* FloatingPanelSurfaceViewTests.swift */, 545DB9CF2151169500CA77B8 /* FloatingPanelControllerTests.swift */, 542753C722C49A8F00D17955 /* Utils.swift */, 545DB9D12151169500CA77B8 /* Info.plist */, @@ -326,7 +326,7 @@ 54A6B6B122968B530077F348 /* FloatingPanelTests.swift in Sources */, 545DB9D02151169500CA77B8 /* FloatingPanelControllerTests.swift in Sources */, 542753C622C49A6E00D17955 /* FloatingPanelLayoutTests.swift in Sources */, - 54A6B6B82296A8520077F348 /* FloatingPanelViewTests.swift in Sources */, + 54A6B6B82296A8520077F348 /* FloatingPanelSurfaceViewTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Framework/Tests/FloatingPanelViewTests.swift b/Framework/Tests/FloatingPanelSurfaceViewTests.swift similarity index 98% rename from Framework/Tests/FloatingPanelViewTests.swift rename to Framework/Tests/FloatingPanelSurfaceViewTests.swift index 55b316b..327bb49 100644 --- a/Framework/Tests/FloatingPanelViewTests.swift +++ b/Framework/Tests/FloatingPanelSurfaceViewTests.swift @@ -6,8 +6,7 @@ import XCTest @testable import FloatingPanel -class FloatingPanelViewTests: XCTestCase { - +class FloatingPanelSurfaceViewTests: XCTestCase { override func setUp() {} override func tearDown() {} From a4a68e5b397503e67a9e10231ad43d43438d67d5 Mon Sep 17 00:00:00 2001 From: Shin Yamamoto Date: Mon, 3 Jun 2019 18:03:29 +0900 Subject: [PATCH 7/7] Add test_surfaceView_constraintsUpdate() --- .../Tests/FloatingPanelSurfaceViewTests.swift | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Framework/Tests/FloatingPanelSurfaceViewTests.swift b/Framework/Tests/FloatingPanelSurfaceViewTests.swift index 327bb49..2048824 100644 --- a/Framework/Tests/FloatingPanelSurfaceViewTests.swift +++ b/Framework/Tests/FloatingPanelSurfaceViewTests.swift @@ -23,6 +23,26 @@ class FloatingPanelSurfaceViewTests: XCTestCase { XCTAssert(surface.backgroundColor == surface.containerView.backgroundColor) } + func test_surfaceView_constraintsUpdate() { + let window = UIWindow() + let surface = FloatingPanelSurfaceView(frame: CGRect(x: 0.0, y: 0.0, width: 320.0, height: 480.0)) + window.addSubview(surface) + window.makeKeyAndVisible() + XCTAssert(surface.contentView == nil) + surface.layoutIfNeeded() + XCTAssert(surface.grabberHandle.frame.minY == 6.0) + XCTAssert(surface.grabberHandle.frame.width == surface.grabberHandleWidth) + XCTAssert(surface.grabberHandle.frame.height == surface.grabberHandleHeight) + + surface.grabberHandleWidth = 44.0 + surface.grabberHandleHeight = 12.0 + surface.layoutIfNeeded() + waitRunLoop(secs: 0.000_001) + XCTAssert(surface.grabberHandle.frame.width == surface.grabberHandleWidth, "\(surface.grabberHandle.frame.width) == \(surface.grabberHandleWidth)") + XCTAssert(surface.grabberHandle.frame.height == surface.grabberHandleHeight, "\(surface.grabberHandle.frame.height) == \(surface.grabberHandleHeight)") + window.resignKey() + } + func test_surfaceView_cornderRaduis() { let surface = FloatingPanelSurfaceView(frame: CGRect(x: 0.0, y: 0.0, width: 320.0, height: 480.0)) XCTAssert(surface.cornerRadius == 0.0)