Make AnalyticsService mockable via `AnalyticsServiceProtocol (#5599)

* Create AnalyticsServiceProtocol and conform AnalyticsService

* Replace AnalyticsService properties and arguments with AnalyticsServiceProtocol

* Inline AnalyticsServiceMock replacing old mock

* handle more complex AnalyticsServiceMock callsites

* move documentation from AnalyticsService to AnalyticsServiceProtocol
This commit is contained in:
Michael
2026-05-20 00:23:58 -05:00
committed by GitHub
parent 946cb53559
commit 5a07c98afc
118 changed files with 1218 additions and 505 deletions
@@ -16,7 +16,7 @@ struct CallScreenCoordinatorParameters {
let allowPictureInPicture: Bool
let appSettings: AppSettings
let appHooks: AppHooks
let analytics: AnalyticsService
let analytics: AnalyticsServiceProtocol
}
enum CallScreenCoordinatorAction {
@@ -18,7 +18,7 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
private let configuration: ElementCallConfiguration
private let isPictureInPictureAllowed: Bool
private let appSettings: AppSettings
private let analyticsService: AnalyticsService
private let analyticsService: AnalyticsServiceProtocol
private let widgetDriver: ElementCallWidgetDriverProtocol
@@ -41,7 +41,7 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
allowPictureInPicture: Bool,
appHooks: AppHooks,
appSettings: AppSettings,
analyticsService: AnalyticsService) {
analyticsService: AnalyticsServiceProtocol) {
self.elementCallService = elementCallService
self.configuration = configuration
self.appSettings = appSettings
@@ -364,9 +364,6 @@ struct CallScreen_Previews: PreviewProvider {
roomProxy.elementCallWidgetDriverDeviceIDReturnValue = widgetDriver
let appSettings = AppSettings()
let analytics = AnalyticsService.mock(settings: appSettings)
return CallScreenViewModel(elementCallService: ElementCallServiceMock(.init()),
configuration: .init(roomProxy: roomProxy,
clientProxy: clientProxy,
@@ -377,8 +374,8 @@ struct CallScreen_Previews: PreviewProvider {
colorScheme: .light),
allowPictureInPicture: false,
appHooks: AppHooks(),
appSettings: appSettings,
analyticsService: analytics)
appSettings: AppSettings(),
analyticsService: AnalyticsServiceMock.default())
}()
static var previews: some View {