UIDeviceProviderMock

public class UIDeviceProviderMock : UIDeviceProviderType

A mock implementation of the UIDeviceProviderType protocol which can be used in UnitTests to have full control of the returned values and thus being independent on the device currently used in the test. This mock makes UnitTests more reliable.

  • Declaration

    Swift

    @MainActor
    public var userInterfaceIdiom: UIUserInterfaceIdiom { get set }
  • Declaration

    Swift

    public var isSimulator: Bool { get set }
  • Declaration

    Swift

    @MainActor
    public var deviceOrientation: UIDeviceOrientation { get set }
  • Creates a mock instance.

    Declaration

    Swift

    public init(interface: UIUserInterfaceIdiom = .phone, simulator: Bool = false, orientation: UIDeviceOrientation = .portrait)

    Parameters

    interface

    The given interface (defaults to phone).

    orientation

    The device’s orientation (defaults to portrait).

    simulator

    Whether the device is the simulator (default) or a physical device.