diff --git a/Sources/MapboxMaps/Gestures/GestureHandlers/RotateGestureHandler.swift b/Sources/MapboxMaps/Gestures/GestureHandlers/RotateGestureHandler.swift index 5761934168a..85173a7562c 100644 --- a/Sources/MapboxMaps/Gestures/GestureHandlers/RotateGestureHandler.swift +++ b/Sources/MapboxMaps/Gestures/GestureHandlers/RotateGestureHandler.swift @@ -3,7 +3,6 @@ import CoreLocation internal protocol RotateGestureHandlerProtocol: FocusableGestureHandlerProtocol { var simultaneousRotateAndPinchZoomEnabled: Bool { get set } - func scheduleRotationUpdateIfNeeded() } /// `RotateGestureHandler` updates the map camera in response to 2-touch rotate gestures @@ -57,31 +56,11 @@ internal protocol RotateGestureHandlerProtocol: FocusableGestureHandlerProtocol } } - private var rotationUpdateNeeded = false - - /// Appends bearing update to the end of the main queue. - /// The update will be performed only if no other bearing update precedes it. - func scheduleRotationUpdateIfNeeded() { - guard isMapRotating else { - return - } - rotationUpdateNeeded = true - DispatchQueue.main.async { - guard self.rotationUpdateNeeded else { - return - } - - self.updateBearing() - } - } - private func updateBearing() { guard let view = gestureRecognizer.view else { return } - rotationUpdateNeeded = false - // flip the sign since the UIKit coordinate system is flipped // relative to the coordinate system used for bearing. let rotationInDegrees = -CLLocationDirection(rotateGestureRecognizer.rotation.toDegrees()) diff --git a/Tests/MapboxMapsTests/Gestures/GestureHandlers/RotateGestureHandlerTests.swift b/Tests/MapboxMapsTests/Gestures/GestureHandlers/RotateGestureHandlerTests.swift index 5e569c453fe..c142abd9660 100644 --- a/Tests/MapboxMapsTests/Gestures/GestureHandlers/RotateGestureHandlerTests.swift +++ b/Tests/MapboxMapsTests/Gestures/GestureHandlers/RotateGestureHandlerTests.swift @@ -217,66 +217,6 @@ final class RotateGestureHandlerTests: XCTestCase { XCTAssertFalse(shouldRecognizeSimultaneously) } - - func testSheduleRotationUpdateIsIgnoredWhenNotRotating() { - let expectation = expectation(description: "Scheduled rotation update ignored") - expectation.isInverted = true - rotateGestureHandler.scheduleRotationUpdateIfNeeded() - DispatchQueue.main.async { - if !self.mapboxMap.setCameraStub.invocations.isEmpty { - expectation.fulfill() - } - } - - wait(for: [expectation], timeout: 0.1) - } - - func testScheduledRotationUpdateIsPerformed() { - let expectation = expectation(description: "Scheduled rotation update performed") - - gestureRecognizer.getStateStub.defaultReturnValue = .began - gestureRecognizer.sendActions() - - gestureRecognizer.getStateStub.defaultReturnValue = .changed - gestureRecognizer.getVelocityStub.defaultReturnValue = 1.radiansPerSecond - gestureRecognizer.getRotationStub.defaultReturnValue = 30.toRadians() - gestureRecognizer.sendActions() - mapboxMap.setCameraStub.reset() - - rotateGestureHandler.scheduleRotationUpdateIfNeeded() - DispatchQueue.main.async { - if !self.mapboxMap.setCameraStub.invocations.isEmpty { - expectation.fulfill() - } - } - wait(for: [expectation], timeout: 0.1) - } - - func testScheduledRotationUpdateIsIgnoredAfterGestureUpdate() { - let expectation = expectation(description: "Scheduled rotation update performed") - expectation.isInverted = true - - gestureRecognizer.getStateStub.defaultReturnValue = .began - gestureRecognizer.sendActions() - - gestureRecognizer.getStateStub.defaultReturnValue = .changed - gestureRecognizer.getVelocityStub.defaultReturnValue = 1.radiansPerSecond - gestureRecognizer.getRotationStub.defaultReturnValue = 30.toRadians() - gestureRecognizer.sendActions() - - mapboxMap.setCameraStub.reset() - - rotateGestureHandler.scheduleRotationUpdateIfNeeded() - DispatchQueue.main.async { - // camera should be set only once after gesture recognizer sends its update, - // the scheduled bearing update should be ignored after that - if self.mapboxMap.setCameraStub.invocations.count > 1 { - expectation.fulfill() - } - } - gestureRecognizer.sendActions() - wait(for: [expectation], timeout: 0.1) - } } fileprivate extension Double {